[Xfce4-commits] <squeeze:stephan/ui> Improve white-space, introduce xfconf dependency and add some callbacks.
Stephan Arts
noreply at xfce.org
Sat Jan 7 10:28:03 CET 2012
Updating branch refs/heads/stephan/ui
to 560d43fe38b4d90c11330e65654662411f9a90b6 (commit)
from d65dcac78aed25d62473c617062834a01659f00d (commit)
commit 560d43fe38b4d90c11330e65654662411f9a90b6
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Jan 7 10:25:26 2012 +0100
Improve white-space, introduce xfconf dependency and add some callbacks.
src/Makefile.am | 3 +-
src/application.c | 295 -------
src/application.h | 71 --
src/archive_store.c | 2148 +++++++++++++++++++++++-----------------------
src/archive_store.h | 76 +-
src/button_drag_box.c | 418 +++++-----
src/button_drag_box.h | 50 +-
src/extract_dialog.c | 158 ++--
src/extract_dialog.h | 40 +-
src/main.c | 116 +---
src/main_window.c | 316 ++++++--
src/main_window.h | 2 +-
src/main_window_ui.xml | 6 +-
src/message_dialog.c | 174 ++--
src/message_dialog.h | 36 +-
src/navigation_bar.c | 146 ++--
src/navigation_bar.h | 40 +-
src/new_dialog.c | 176 ++--
src/new_dialog.h | 34 +-
src/path_bar.c | 1070 ++++++++++++------------
src/path_bar.h | 50 +-
src/preferences_dialog.c | 432 +++++-----
src/preferences_dialog.h | 64 +-
src/properties_dialog.c | 136 ++--
src/properties_dialog.h | 38 +-
src/settings.c | 484 ++++++++---
src/settings.h | 102 ++-
src/throbber-fallback.h | 4 +-
src/throbber.c | 410 +++++-----
src/throbber.h | 8 +-
src/tool_bar.c | 416 +++++-----
src/tool_bar.h | 46 +-
32 files changed, 3794 insertions(+), 3771 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 077969b..e6d54d9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,7 +4,6 @@ squeeze_SOURCES = \
main.c main.h \
path_bar.c path_bar.h \
tool_bar.c tool_bar.h \
- application.c application.h \
main_window.c main_window.h \
navigation_bar.c navigation_bar.h \
settings.c settings.h \
@@ -23,6 +22,7 @@ squeeze_CFLAGS = \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS) \
$(GIO_CFLAGS) \
+ $(XFCONF_CFLAGS) \
$(LIBXFCE4UTIL_CFLAGS)
squeeze_LDADD = \
@@ -31,6 +31,7 @@ squeeze_LDADD = \
squeeze_LDFLAGS = \
$(GTK_LIBS) \
$(GLIB_LIBS) \
+ $(DBUS_CFLAGS) \
$(GIO_LIBS) \
$(XFCONF_LIBS) \
$(LIBXFCE4UTIL_LIBS)
diff --git a/src/application.c b/src/application.c
deleted file mode 100644
index 2b2e8d5..0000000
--- a/src/application.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include <string.h>
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <gio/gio.h>
-
-#include <libxfce4util/libxfce4util.h>
-#include <libsqueeze/libsqueeze.h>
-
-#include "new_dialog.h"
-#include "message_dialog.h"
-#include "extract_dialog.h"
-
-#include "settings.h"
-#include "archive_store.h"
-#include "navigation_bar.h"
-#include "application.h"
-#include "main_window.h"
-
-static void
-sq_application_class_init(SQApplicationClass *archive_class);
-
-static void
-sq_application_init(SQApplication *);
-static void
-sq_application_finalize(GObject *);
-static void
-sq_application_dispose(GObject *object);
-
-enum
-{
- SQ_APPLICATION_SIGNAL_DESTROY = 0,
- SQ_APPLICATION_SIGNAL_COUNT
-};
-
-static gint sq_application_signals[SQ_APPLICATION_SIGNAL_COUNT];
-
-GType
-sq_application_get_type (void)
-{
- static GType sq_application_type = 0;
-
- if (!sq_application_type)
- {
- static const GTypeInfo sq_application_info =
- {
- sizeof (SQApplicationClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) sq_application_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (SQApplication),
- 0,
- (GInstanceInitFunc) sq_application_init,
- NULL
- };
-
- sq_application_type = g_type_register_static (G_TYPE_OBJECT, "SQApplication", &sq_application_info, 0);
- }
- return sq_application_type;
-}
-
-static void
-sq_application_class_init(SQApplicationClass *application_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (application_class);
- object_class->finalize = sq_application_finalize;
- object_class->dispose = sq_application_dispose;
-
- sq_application_signals[SQ_APPLICATION_SIGNAL_DESTROY] = g_signal_new("destroy",
- G_TYPE_FROM_CLASS(application_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- 0,
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-}
-
-static void
-sq_application_init(SQApplication *application)
-{
- application->settings = sq_settings_new();
- sq_settings_set_group(application->settings, "Global");
-
- application->props._tabs = sq_settings_read_bool_entry(application->settings, "UseTabs", FALSE);
-
-}
-
-static void
-sq_application_dispose(GObject *object)
-{
- g_signal_emit(object, sq_application_signals[SQ_APPLICATION_SIGNAL_DESTROY], 0, object);
-}
-
-static void
-sq_application_finalize(GObject *object )
-{
- SQApplication *application = SQ_APPLICATION(object);
-
- sq_settings_set_group(application->settings, "Global");
-
- sq_settings_write_bool_entry(application->settings, "UseTabs", application->props._tabs);
-
- sq_settings_save(application->settings);
-
- g_object_unref(G_OBJECT(application->settings));
-}
-
-SQApplication *
-sq_application_new(GtkIconTheme *icon_theme)
-{
- SQApplication *app;
-
- app = g_object_new(SQ_TYPE_APPLICATION, NULL);
-
- app->icon_theme = icon_theme;
-
- return app;
-}
-
-GtkWidget *
-sq_application_new_window(SQApplication *app)
-{
- GtkWidget *window = sq_main_window_new ( app );
- return window;
-}
-
-gint
-sq_application_extract_archive(SQApplication *app, GFile *file, gchar *dest_path)
-{
- GtkWidget *dialog = NULL;
- LSQArchive *lp_archive = NULL;
- GtkWidget *message_dialog;
- if(lsq_open_archive(file, &lp_archive))
- {
- /*
- * Could not open archive (mime type not supported or file did not exist)
- * Should be a more specific error message.
- */
- dialog = gtk_message_dialog_new (NULL,GTK_DIALOG_DESTROY_WITH_PARENT,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Could not open archive, MIME-type unsupported or file did not exist"));
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
- gtk_dialog_run (GTK_DIALOG (dialog) );
- gtk_widget_destroy (GTK_WIDGET (dialog) );
- return 1;
- }
- if(!dest_path)
- {
- GtkWidget *extr_dialog = sq_extract_archive_dialog_new(lp_archive, 0);
- gint result = gtk_dialog_run (GTK_DIALOG (extr_dialog) );
- if(result == GTK_RESPONSE_OK)
- {
- gtk_widget_hide(extr_dialog);
- dest_path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(extr_dialog));
- }
- gtk_widget_destroy(extr_dialog);
- }
- if(!dest_path)
- {
- lsq_close_archive(lp_archive);
- return 1;
- }
- message_dialog = sq_message_dialog_new(GTK_WINDOW_TOPLEVEL, lp_archive);
- gtk_widget_show(message_dialog);
- if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_EXTRACT, NULL, dest_path))
- {
- GtkWidget *warning_dialog = gtk_message_dialog_new(NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_CLOSE,
- _("Squeeze cannot extract this archive type,\nthe application to support this is missing."));
- if(warning_dialog)
- {
- gtk_dialog_run (GTK_DIALOG (warning_dialog) );
- gtk_widget_destroy(warning_dialog);
- }
-
- }
- g_object_ref(app);
- return 0;
-}
-
-gint
-sq_application_new_archive(SQApplication *app, GFile *file, GSList *files)
-{
- GtkWidget *dialog = NULL;
- gint result = 0;
- LSQArchive *lp_archive = NULL;
- GtkWidget *message_dialog;
-
- if(!file)
- {
- gchar **filename_components;
- dialog = sq_new_archive_dialog_new();
- /* FIXME, does not work correctly when there are more dots in a filename then the one identifying the extention */
- filename_components = g_strsplit(files->data, ".", 2);
- gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename_components[0]);
- g_strfreev(filename_components);
- result = gtk_dialog_run (GTK_DIALOG (dialog) );
- if(result == GTK_RESPONSE_CANCEL || result == GTK_RESPONSE_DELETE_EVENT)
- {
- gtk_widget_destroy (GTK_WIDGET (dialog) );
- return 2;
- }
- if(result == GTK_RESPONSE_OK)
- {
- file = sq_new_archive_dialog_get_file(SQ_NEW_ARCHIVE_DIALOG(dialog));
- gtk_widget_destroy (GTK_WIDGET (dialog) );
- }
- if(lsq_new_archive(file, TRUE, &lp_archive))
- {
- /*
- * Could not create archive (mime type unsupported)
- */
- dialog = gtk_message_dialog_new (NULL,GTK_DIALOG_DESTROY_WITH_PARENT,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Could not create archive, MIME-type unsupported"));
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
- gtk_dialog_run (GTK_DIALOG (dialog) );
- gtk_widget_destroy (GTK_WIDGET (dialog) );
- return 1;
- }
- g_object_unref(file);
- file = NULL;
- }
- else
- {
- if(lsq_open_archive(file, &lp_archive))
- {
- /*
- * Could not open archive (mime type not supported or file did not exist)
- * Should be a more specific error message.
- */
- dialog = gtk_message_dialog_new (NULL,GTK_DIALOG_DESTROY_WITH_PARENT,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Could not open archive, MIME-type unsupported or file did not exist"));
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
- gtk_dialog_run (GTK_DIALOG (dialog) );
- gtk_widget_destroy (GTK_WIDGET (dialog) );
- return 1;
- }
- }
- message_dialog = sq_message_dialog_new(GTK_WINDOW_TOPLEVEL, lp_archive);
- gtk_widget_show(message_dialog);
-
- if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_ADD, NULL, NULL))
- {
- /* FIXME: show warning dialog */
- GtkWidget *warning_dialog = gtk_message_dialog_new(
- NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_CLOSE,
- _("Squeeze cannot add files to this archive type,\nthe application to support this is missing."));
- gtk_dialog_run (GTK_DIALOG (warning_dialog) );
- gtk_widget_destroy(warning_dialog);
- }
- g_object_ref(app);
- return 0;
-}
-
-gint
-sq_application_open_archive(SQApplication *app, GtkWidget *window, GFile *file)
-{
- gint retval = 0;
-
- if(!window)
- {
- window = sq_application_new_window(app);
- }
- if(app->props._tabs)
- {
- //retval = sq_main_window_open_archive(SQ_MAIN_WINDOW(window), file, -1);
- }
- else
- {
- //retval = sq_main_window_open_archive(SQ_MAIN_WINDOW(window), file, 0);
- }
- gtk_widget_show_all(window);
- return retval;
-}
diff --git a/src/application.h b/src/application.h
deleted file mode 100644
index 5b79074..0000000
--- a/src/application.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __SQRCHIVER_APPLICATION_H__
-#define __SQRCHIVER_APPLICATION_H__
-G_BEGIN_DECLS
-
-#define SQ_TYPE_APPLICATION sq_application_get_type()
-
-#define SQ_APPLICATION(obj)( \
- G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- SQ_TYPE_APPLICATION, \
- SQApplication))
-
-#define SQ_IS_APPLICATION(obj) ( \
- G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- SQ_TYPE_APPLICATION))
-
-#define SQ_APPLICATION_CLASS(klass) ( \
- G_TYPE_CHECK_CLASS_CAST ((klass), \
- SQ_TYPE_APPLICATION, \
- SQApplicationClass))
-
-#define SQ_IS_APPLICATION_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_TYPE ((class), \
- SQ_TYPE_APPLICATION()))
-
-typedef struct _SQApplication SQApplication;
-
-struct _SQApplication
-{
- GObject parent;
- GtkIconTheme *icon_theme;
- SQSettings *settings;
- struct {
- gboolean _tabs;
- } props;
-};
-
-typedef struct _SQApplicationClass SQApplicationClass;
-
-struct _SQApplicationClass
-{
- GObjectClass parent_class;
-};
-
-GType sq_application_get_type();
-SQApplication *sq_application_new(GtkIconTheme *icon_theme);
-
-GtkWidget *sq_application_new_window(SQApplication *);
-
-gint sq_application_extract_archive(SQApplication *, GFile *, gchar *);
-gint sq_application_new_archive(SQApplication *, GFile *, GSList *);
-
-gint sq_application_open_archive(SQApplication *, GtkWidget *, GFile *);
-
-G_END_DECLS
-#endif /* __SQRCHIVER_APPLICATION_H__*/
diff --git a/src/archive_store.c b/src/archive_store.c
index 8faed2e..9a25182 100644
--- a/src/archive_store.c
+++ b/src/archive_store.c
@@ -47,19 +47,19 @@ sq_archive_store_dispose(GObject *object);
/* properties */
enum {
- SQ_ARCHIVE_STORE_SHOW_FULL_PATH = 1,
- SQ_ARCHIVE_STORE_SHOW_ICONS,
- SQ_ARCHIVE_STORE_SHOW_UP_DIR,
- SQ_ARCHIVE_STORE_SORT_FOLDERS_FIRST,
- SQ_ARCHIVE_STORE_SORT_CASE_SENSITIVE
+ SQ_ARCHIVE_STORE_SHOW_FULL_PATH = 1,
+ SQ_ARCHIVE_STORE_SHOW_ICONS,
+ SQ_ARCHIVE_STORE_SHOW_UP_DIR,
+ SQ_ARCHIVE_STORE_SORT_FOLDERS_FIRST,
+ SQ_ARCHIVE_STORE_SORT_CASE_SENSITIVE
};
/* signals */
enum {
- SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED = 0,
- SQ_ARCHIVE_STORE_SIGNAL_NEW_ARCHIVE,
- SQ_ARCHIVE_STORE_SIGNAL_FILE_ACTIVATED,
- SQ_ARCHIVE_STORE_SIGNAL_COUNT
+ SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED = 0,
+ SQ_ARCHIVE_STORE_SIGNAL_NEW_ARCHIVE,
+ SQ_ARCHIVE_STORE_SIGNAL_FILE_ACTIVATED,
+ SQ_ARCHIVE_STORE_SIGNAL_COUNT
};
static gint sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_COUNT];
@@ -138,1533 +138,1533 @@ sq_archive_store_refresh(SQArchiveStore *store);
static void
cb_sq_archive_store_archive_refreshed(LSQArchive *archive, gpointer user_data);
-/* static void */
+/* static void */
/* cb_sq_archive_store_archive_path_changed(LSQArchive *archive, const gchar *path, gpointer user_data); */
GType
sq_archive_store_get_type(void)
{
- static const GInterfaceInfo tree_model_info =
- {
- (GInterfaceInitFunc) sq_archive_tree_model_init,
- NULL,
- NULL
- };
- static const GInterfaceInfo tree_sort_info =
- {
- (GInterfaceInitFunc) sq_archive_tree_sortable_init,
- NULL,
- NULL
- };
- static GType sq_archive_store_type= 0;
-
- if(sq_archive_store_type)
- return sq_archive_store_type;
-
- if (!sq_archive_store_type)
- {
- static const GTypeInfo sq_archive_store_info =
- {
- sizeof (SQArchiveStoreClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) sq_archive_store_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (SQArchiveStore),
- 0,
- (GInstanceInitFunc) sq_archive_store_init,
- NULL
- };
-
- sq_archive_store_type = g_type_register_static (G_TYPE_OBJECT, "SQArchiveStore", &sq_archive_store_info, 0);
- }
-
- g_type_add_interface_static (sq_archive_store_type, GTK_TYPE_TREE_MODEL, &tree_model_info);
-
- g_type_add_interface_static (sq_archive_store_type, GTK_TYPE_TREE_SORTABLE, &tree_sort_info);
-
- return sq_archive_store_type;
+ static const GInterfaceInfo tree_model_info =
+ {
+ (GInterfaceInitFunc) sq_archive_tree_model_init,
+ NULL,
+ NULL
+ };
+ static const GInterfaceInfo tree_sort_info =
+ {
+ (GInterfaceInitFunc) sq_archive_tree_sortable_init,
+ NULL,
+ NULL
+ };
+ static GType sq_archive_store_type= 0;
+
+ if(sq_archive_store_type)
+ return sq_archive_store_type;
+
+ if (!sq_archive_store_type)
+ {
+ static const GTypeInfo sq_archive_store_info =
+ {
+ sizeof (SQArchiveStoreClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) sq_archive_store_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (SQArchiveStore),
+ 0,
+ (GInstanceInitFunc) sq_archive_store_init,
+ NULL
+ };
+
+ sq_archive_store_type = g_type_register_static (G_TYPE_OBJECT, "SQArchiveStore", &sq_archive_store_info, 0);
+ }
+
+ g_type_add_interface_static (sq_archive_store_type, GTK_TYPE_TREE_MODEL, &tree_model_info);
+
+ g_type_add_interface_static (sq_archive_store_type, GTK_TYPE_TREE_SORTABLE, &tree_sort_info);
+
+ return sq_archive_store_type;
}
static void
sq_archive_tree_model_init(GtkTreeModelIface *iface)
{
- iface->get_flags = sq_archive_store_get_flags;
- iface->get_n_columns = sq_archive_store_get_n_columns;
- iface->get_column_type = sq_archive_store_get_column_type;
- iface->get_iter = sq_archive_store_get_iter;
- iface->get_path = sq_archive_store_get_path;
- iface->get_value = sq_archive_store_get_value;
- iface->iter_next = sq_archive_store_iter_next;
- iface->iter_children = sq_archive_store_iter_children;
- iface->iter_has_child = sq_archive_store_iter_has_child;
- iface->iter_n_children = sq_archive_store_iter_n_children;
- iface->iter_nth_child = sq_archive_store_iter_nth_child;
- iface->iter_parent = sq_archive_store_iter_parent;
+ iface->get_flags = sq_archive_store_get_flags;
+ iface->get_n_columns = sq_archive_store_get_n_columns;
+ iface->get_column_type = sq_archive_store_get_column_type;
+ iface->get_iter = sq_archive_store_get_iter;
+ iface->get_path = sq_archive_store_get_path;
+ iface->get_value = sq_archive_store_get_value;
+ iface->iter_next = sq_archive_store_iter_next;
+ iface->iter_children = sq_archive_store_iter_children;
+ iface->iter_has_child = sq_archive_store_iter_has_child;
+ iface->iter_n_children = sq_archive_store_iter_n_children;
+ iface->iter_nth_child = sq_archive_store_iter_nth_child;
+ iface->iter_parent = sq_archive_store_iter_parent;
}
static void
sq_archive_tree_sortable_init(GtkTreeSortableIface *iface)
{
- iface->get_sort_column_id = sq_archive_store_get_sort_column_id;
- iface->set_sort_column_id = sq_archive_store_set_sort_column_id;
- iface->set_sort_func = sq_archive_store_set_sort_func; /*NOT SUPPORTED*/
- iface->set_default_sort_func = sq_archive_store_set_default_sort_func; /*NOT SUPPORTED*/
- iface->has_default_sort_func = sq_archive_store_has_default_sort_func;
+ iface->get_sort_column_id = sq_archive_store_get_sort_column_id;
+ iface->set_sort_column_id = sq_archive_store_set_sort_column_id;
+ iface->set_sort_func = sq_archive_store_set_sort_func; /*NOT SUPPORTED*/
+ iface->set_default_sort_func = sq_archive_store_set_default_sort_func; /*NOT SUPPORTED*/
+ iface->has_default_sort_func = sq_archive_store_has_default_sort_func;
}
static void
sq_archive_store_init(SQArchiveStore *as)
{
- as->stamp = g_random_int();
- as->archive = NULL;
- as->sort_column = GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID;
- as->sort_order = GTK_SORT_ASCENDING;
- as->sort_list = NULL;
- as->icon_theme = NULL;
- as->props._show_full_path = 0;
- as->props._show_icons = 0;
- as->props._show_up_dir = 1;
- as->props._sort_folders_first = 1;
- as->props._sort_case_sensitive = 1;
- as->navigation.history = NULL;
- as->navigation.present = NULL;
- as->navigation.maxhistory = SQ_ARCHIVE_STORE_MAX_HISTORY;
- as->navigation.trailing = NULL;
+ as->stamp = g_random_int();
+ as->archive = NULL;
+ as->sort_column = GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID;
+ as->sort_order = GTK_SORT_ASCENDING;
+ as->sort_list = NULL;
+ as->icon_theme = NULL;
+ as->props._show_full_path = 0;
+ as->props._show_icons = 0;
+ as->props._show_up_dir = 1;
+ as->props._sort_folders_first = 1;
+ as->props._sort_case_sensitive = 1;
+ as->navigation.history = NULL;
+ as->navigation.present = NULL;
+ as->navigation.maxhistory = SQ_ARCHIVE_STORE_MAX_HISTORY;
+ as->navigation.trailing = NULL;
}
static void
sq_archive_store_class_init(SQArchiveStoreClass *as_class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (as_class);
- GParamSpec *pspec = NULL;
-
- object_class->set_property = sq_archive_store_set_property;
- object_class->get_property = sq_archive_store_get_property;
- object_class->dispose = sq_archive_store_dispose;
-
- parent_class = gtk_type_class (G_TYPE_OBJECT);
-
- pspec = g_param_spec_boolean("show-full-path",
- _("Show full path"),
- _("Show the full path strings for each entry"),
- FALSE,
- G_PARAM_READWRITE);
- g_object_class_install_property(object_class, SQ_ARCHIVE_STORE_SHOW_ICONS, pspec);
-
- pspec = g_param_spec_boolean("show-icons",
- _("Show mime icons"),
- _("Show the mime type icons for each entry"),
- FALSE,
- G_PARAM_READWRITE);
- g_object_class_install_property(object_class, SQ_ARCHIVE_STORE_SHOW_ICONS, pspec);
-
- pspec = g_param_spec_boolean("show-up-dir",
- _("Show up dir entry"),
- _("Show \'..\' to go to the parent directory"),
- TRUE,
- G_PARAM_READWRITE);
- g_object_class_install_property(object_class, SQ_ARCHIVE_STORE_SHOW_UP_DIR, pspec);
-
- pspec = g_param_spec_boolean("sort-folders-first",
- _("Sort folders before files"),
- _("The folders will be put at the top of the list"),
- TRUE,
- G_PARAM_READWRITE);
- g_object_class_install_property(object_class, SQ_ARCHIVE_STORE_SORT_FOLDERS_FIRST, pspec);
-
- pspec = g_param_spec_boolean("sort-case-sensitive",
- _("Sort text case sensitive"),
- _("Sort text case sensitive"),
- TRUE,
- G_PARAM_READWRITE);
- g_object_class_install_property(object_class, SQ_ARCHIVE_STORE_SORT_CASE_SENSITIVE, pspec);
-
- sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED] = g_signal_new("sq-pwd-changed",
- G_TYPE_FROM_CLASS(as_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- 0,
- NULL,
- NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER,
- NULL);
-
- sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_NEW_ARCHIVE] = g_signal_new("sq-new-archive",
- G_TYPE_FROM_CLASS(as_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- 0,
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0,
- NULL);
-
- sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_FILE_ACTIVATED] = g_signal_new("file-activated",
- G_TYPE_FROM_CLASS(as_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- 0,
- NULL,
- NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER,
- NULL);
+ GObjectClass *object_class = G_OBJECT_CLASS (as_class);
+ GParamSpec *pspec = NULL;
+
+ object_class->set_property = sq_archive_store_set_property;
+ object_class->get_property = sq_archive_store_get_property;
+ object_class->dispose = sq_archive_store_dispose;
+
+ parent_class = gtk_type_class (G_TYPE_OBJECT);
+
+ pspec = g_param_spec_boolean("show-full-path",
+ _("Show full path"),
+ _("Show the full path strings for each entry"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, SQ_ARCHIVE_STORE_SHOW_ICONS, pspec);
+
+ pspec = g_param_spec_boolean("show-icons",
+ _("Show mime icons"),
+ _("Show the mime type icons for each entry"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, SQ_ARCHIVE_STORE_SHOW_ICONS, pspec);
+
+ pspec = g_param_spec_boolean("show-up-dir",
+ _("Show up dir entry"),
+ _("Show \'..\' to go to the parent directory"),
+ TRUE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, SQ_ARCHIVE_STORE_SHOW_UP_DIR, pspec);
+
+ pspec = g_param_spec_boolean("sort-folders-first",
+ _("Sort folders before files"),
+ _("The folders will be put at the top of the list"),
+ TRUE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, SQ_ARCHIVE_STORE_SORT_FOLDERS_FIRST, pspec);
+
+ pspec = g_param_spec_boolean("sort-case-sensitive",
+ _("Sort text case sensitive"),
+ _("Sort text case sensitive"),
+ TRUE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, SQ_ARCHIVE_STORE_SORT_CASE_SENSITIVE, pspec);
+
+ sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED] = g_signal_new("sq-pwd-changed",
+ G_TYPE_FROM_CLASS(as_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER,
+ NULL);
+
+ sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_NEW_ARCHIVE] = g_signal_new("sq-new-archive",
+ G_TYPE_FROM_CLASS(as_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0,
+ NULL);
+
+ sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_FILE_ACTIVATED] = g_signal_new("file-activated",
+ G_TYPE_FROM_CLASS(as_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER,
+ NULL);
}
static void
sq_archive_store_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
- SQArchiveStore *store = SQ_ARCHIVE_STORE(object);
- switch(prop_id)
- {
- case SQ_ARCHIVE_STORE_SHOW_FULL_PATH:
- sq_archive_store_set_show_full_path(store, g_value_get_boolean(value));
- break;
- case SQ_ARCHIVE_STORE_SHOW_ICONS:
- sq_archive_store_set_show_icons(store, g_value_get_boolean(value));
- break;
- case SQ_ARCHIVE_STORE_SHOW_UP_DIR:
- if(store->props._show_up_dir != g_value_get_boolean(value)?1:0)
- {
- store->props._show_up_dir = g_value_get_boolean(value)?1:0;
- sq_archive_store_refresh(store);
- }
- break;
- case SQ_ARCHIVE_STORE_SORT_FOLDERS_FIRST:
- sq_archive_store_set_sort_folders_first(store, g_value_get_boolean(value));
- break;
- case SQ_ARCHIVE_STORE_SORT_CASE_SENSITIVE:
- sq_archive_store_set_sort_case_sensitive(store, g_value_get_boolean(value));
- break;
- }
+ SQArchiveStore *store = SQ_ARCHIVE_STORE(object);
+ switch(prop_id)
+ {
+ case SQ_ARCHIVE_STORE_SHOW_FULL_PATH:
+ sq_archive_store_set_show_full_path(store, g_value_get_boolean(value));
+ break;
+ case SQ_ARCHIVE_STORE_SHOW_ICONS:
+ sq_archive_store_set_show_icons(store, g_value_get_boolean(value));
+ break;
+ case SQ_ARCHIVE_STORE_SHOW_UP_DIR:
+ if(store->props._show_up_dir != g_value_get_boolean(value)?1:0)
+ {
+ store->props._show_up_dir = g_value_get_boolean(value)?1:0;
+ sq_archive_store_refresh(store);
+ }
+ break;
+ case SQ_ARCHIVE_STORE_SORT_FOLDERS_FIRST:
+ sq_archive_store_set_sort_folders_first(store, g_value_get_boolean(value));
+ break;
+ case SQ_ARCHIVE_STORE_SORT_CASE_SENSITIVE:
+ sq_archive_store_set_sort_case_sensitive(store, g_value_get_boolean(value));
+ break;
+ }
}
static void
sq_archive_store_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
- switch(prop_id)
- {
- case SQ_ARCHIVE_STORE_SHOW_FULL_PATH:
- g_value_set_boolean(value, SQ_ARCHIVE_STORE(object)->props._show_full_path?TRUE:FALSE);
- break;
- case SQ_ARCHIVE_STORE_SHOW_ICONS:
- g_value_set_boolean(value, SQ_ARCHIVE_STORE(object)->props._show_icons?TRUE:FALSE);
- break;
- case SQ_ARCHIVE_STORE_SHOW_UP_DIR:
- g_value_set_boolean(value, SQ_ARCHIVE_STORE(object)->props._show_up_dir?TRUE:FALSE);
- break;
- case SQ_ARCHIVE_STORE_SORT_FOLDERS_FIRST:
- g_value_set_boolean(value, SQ_ARCHIVE_STORE(object)->props._sort_folders_first?TRUE:FALSE);
- break;
- case SQ_ARCHIVE_STORE_SORT_CASE_SENSITIVE:
- g_value_set_boolean(value, SQ_ARCHIVE_STORE(object)->props._sort_case_sensitive?TRUE:FALSE);
- break;
- }
+ switch(prop_id)
+ {
+ case SQ_ARCHIVE_STORE_SHOW_FULL_PATH:
+ g_value_set_boolean(value, SQ_ARCHIVE_STORE(object)->props._show_full_path?TRUE:FALSE);
+ break;
+ case SQ_ARCHIVE_STORE_SHOW_ICONS:
+ g_value_set_boolean(value, SQ_ARCHIVE_STORE(object)->props._show_icons?TRUE:FALSE);
+ break;
+ case SQ_ARCHIVE_STORE_SHOW_UP_DIR:
+ g_value_set_boolean(value, SQ_ARCHIVE_STORE(object)->props._show_up_dir?TRUE:FALSE);
+ break;
+ case SQ_ARCHIVE_STORE_SORT_FOLDERS_FIRST:
+ g_value_set_boolean(value, SQ_ARCHIVE_STORE(object)->props._sort_folders_first?TRUE:FALSE);
+ break;
+ case SQ_ARCHIVE_STORE_SORT_CASE_SENSITIVE:
+ g_value_set_boolean(value, SQ_ARCHIVE_STORE(object)->props._sort_case_sensitive?TRUE:FALSE);
+ break;
+ }
}
static GtkTreeModelFlags
sq_archive_store_get_flags(GtkTreeModel *tree_model)
{
- g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), (GtkTreeModelFlags)0);
+ g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), (GtkTreeModelFlags)0);
- return (GTK_TREE_MODEL_LIST_ONLY | GTK_TREE_MODEL_ITERS_PERSIST);
+ return (GTK_TREE_MODEL_LIST_ONLY | GTK_TREE_MODEL_ITERS_PERSIST);
}
static gint
sq_archive_store_get_n_columns(GtkTreeModel *tree_model)
{
- SQArchiveStore *store;
- LSQArchive *archive;
+ SQArchiveStore *store;
+ LSQArchive *archive;
- g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), 0);
+ g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), 0);
- store = SQ_ARCHIVE_STORE(tree_model);
- archive = store->archive;
+ store = SQ_ARCHIVE_STORE(tree_model);
+ archive = store->archive;
- if(!archive)
- return 0;
-
- return lsq_archive_n_entry_properties(archive) + SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT;
+ if(!archive)
+ return 0;
+
+ return lsq_archive_n_entry_properties(archive) + SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT;
}
static GType
sq_archive_store_get_column_type(GtkTreeModel *tree_model, gint index_)
{
- SQArchiveStore *store;
- LSQArchive *archive;
-
- g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), G_TYPE_INVALID);
-
- store = SQ_ARCHIVE_STORE(tree_model);
- archive = store->archive;
- g_return_val_if_fail(index_ < (gint)lsq_archive_n_entry_properties(archive), G_TYPE_INVALID);
-
- if(!archive)
- return G_TYPE_INVALID;
-
- switch(index_)
- {
- case SQ_ARCHIVE_STORE_EXTRA_PROP_PATH:
- return G_TYPE_STRING;
- case SQ_ARCHIVE_STORE_EXTRA_PROP_ICON:
- return G_TYPE_ICON;
- default:
- return lsq_archive_get_entry_property_type(archive, index_ - SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT);
- }
+ SQArchiveStore *store;
+ LSQArchive *archive;
+
+ g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), G_TYPE_INVALID);
+
+ store = SQ_ARCHIVE_STORE(tree_model);
+ archive = store->archive;
+ g_return_val_if_fail(index_ < (gint)lsq_archive_n_entry_properties(archive), G_TYPE_INVALID);
+
+ if(!archive)
+ return G_TYPE_INVALID;
+
+ switch(index_)
+ {
+ case SQ_ARCHIVE_STORE_EXTRA_PROP_PATH:
+ return G_TYPE_STRING;
+ case SQ_ARCHIVE_STORE_EXTRA_PROP_ICON:
+ return G_TYPE_ICON;
+ default:
+ return lsq_archive_get_entry_property_type(archive, index_ - SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT);
+ }
}
static gboolean
sq_archive_store_get_iter(GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreePath *path)
{
- SQArchiveStore *store;
- LSQArchiveIter *entry;
- gint *indices;
- gint depth;
- gint index_;
+ SQArchiveStore *store;
+ LSQArchiveIter *entry;
+ gint *indices;
+ gint depth;
+ gint index_;
#ifdef DEBUG
- g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), FALSE);
+ g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), FALSE);
#endif
- store = SQ_ARCHIVE_STORE(tree_model);
+ store = SQ_ARCHIVE_STORE(tree_model);
- if(!store->navigation.present)
- return FALSE;
+ if(!store->navigation.present)
+ return FALSE;
#ifdef DEBUG
- g_return_val_if_fail(store->navigation.present->data, FALSE);
+ g_return_val_if_fail(store->navigation.present->data, FALSE);
#endif
- /* get the present history */
- entry = store->navigation.present->data;
+ /* get the present history */
+ entry = store->navigation.present->data;
- indices = gtk_tree_path_get_indices(path);
- depth = gtk_tree_path_get_depth(path) - 1;
+ indices = gtk_tree_path_get_indices(path);
+ depth = gtk_tree_path_get_depth(path) - 1;
- /* only support list: depth is always 0 */
- g_return_val_if_fail(depth == 0, FALSE);
+ /* only support list: depth is always 0 */
+ g_return_val_if_fail(depth == 0, FALSE);
- index_ = indices[depth];
+ index_ = indices[depth];
- /* if this is the root entry we don't need the ".." */
- if(store->props._show_up_dir && lsq_archive_iter_has_parent(entry))
- index_--;
+ /* if this is the root entry we don't need the ".." */
+ if(store->props._show_up_dir && lsq_archive_iter_has_parent(entry))
+ index_--;
- if(index_ == -1)
- {
- /* it is the ".." */
- entry = NULL;
- }
- else
- {
- /* as long as it is a list depth is 0 other wise current_entry should be synced ? */
- if(store->sort_list)
- entry = store->sort_list[index_];
- else
- entry = NULL;
+ if(index_ == -1)
+ {
+ /* it is the ".." */
+ entry = NULL;
+ }
+ else
+ {
+ /* as long as it is a list depth is 0 other wise current_entry should be synced ? */
+ if(store->sort_list)
+ entry = store->sort_list[index_];
+ else
+ entry = NULL;
- if(!entry)
- return FALSE;
- }
+ if(!entry)
+ return FALSE;
+ }
- iter->stamp = store->stamp;
- iter->user_data = entry;
- /* the index_ in the child list */
- iter->user_data3 = GINT_TO_POINTER(index_);
+ iter->stamp = store->stamp;
+ iter->user_data = entry;
+ /* the index_ in the child list */
+ iter->user_data3 = GINT_TO_POINTER(index_);
- return TRUE;
+ return TRUE;
}
static GtkTreePath *
sq_archive_store_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter)
{
- SQArchiveStore *store;
- LSQArchive *archive;
- LSQArchiveIter *entry;
- gint pos;
- GtkTreePath *path;
+ SQArchiveStore *store;
+ LSQArchive *archive;
+ LSQArchiveIter *entry;
+ gint pos;
+ GtkTreePath *path;
- g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), NULL);
+ g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), NULL);
- store = SQ_ARCHIVE_STORE(tree_model);
- archive = store->archive;
+ store = SQ_ARCHIVE_STORE(tree_model);
+ archive = store->archive;
- g_return_val_if_fail(archive, NULL);
+ g_return_val_if_fail(archive, NULL);
- entry = (LSQArchiveIter*)iter->user_data;
- pos = GPOINTER_TO_INT(iter->user_data3);
+ entry = (LSQArchiveIter*)iter->user_data;
+ pos = GPOINTER_TO_INT(iter->user_data3);
- if(store->props._show_up_dir && lsq_archive_iter_has_parent(entry))
- pos++;
+ if(store->props._show_up_dir && lsq_archive_iter_has_parent(entry))
+ pos++;
- path = gtk_tree_path_new();
- gtk_tree_path_append_index(path, pos);
+ path = gtk_tree_path_new();
+ gtk_tree_path_append_index(path, pos);
- return path;
+ return path;
}
static void
sq_archive_store_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, gint column, GValue *value)
{
- SQArchiveStore *store;
- LSQArchive *archive;
- LSQArchiveIter *parent, *entry;
-
- g_return_if_fail (SQ_IS_ARCHIVE_STORE (tree_model));
-
- store = SQ_ARCHIVE_STORE(tree_model);
- archive = store->archive;
- entry = iter->user_data;
-
- g_return_if_fail(archive);
-
- if(entry)
- {
- switch(column)
- {
- case SQ_ARCHIVE_STORE_EXTRA_PROP_PATH:
- g_value_init(value, G_TYPE_STRING);
-
- parent = lsq_archive_iter_get_parent(entry);
- g_value_take_string(value, lsq_archive_iter_get_path(parent));
- lsq_archive_iter_unref(parent);
- break;
- case SQ_ARCHIVE_STORE_EXTRA_PROP_ICON:
- g_value_init(value, G_TYPE_ICON);
-
- if(store->props._show_icons)
- g_value_take_object(value, sq_archive_store_get_icon_name_for_iter(store, entry));
- break;
- case LSQ_ARCHIVE_PROP_FILENAME + SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT:
- if(store->props._show_full_path)
- {
- g_value_init(value, G_TYPE_STRING);
- g_value_take_string(value, lsq_archive_iter_get_path(entry));
- if(!g_utf8_validate(g_value_get_string(value), -1, NULL))
- g_value_take_string(value, g_convert(g_value_get_string(value), -1, "UTF-8", "WINDOWS-1252", NULL, NULL, NULL));
- break;
- }
- default:
- column -= SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT;
- if(column < (gint)lsq_archive_n_entry_properties(archive))
- lsq_archive_iter_get_prop_value(entry, column, value);
- /* what if it isn't utf-8 */
- if(G_VALUE_HOLDS_STRING(value) && g_value_get_string(value) && !g_utf8_validate(g_value_get_string(value), -1, NULL))
- g_value_take_string(value, g_convert(g_value_get_string(value), -1, "UTF-8", "WINDOWS-1252", NULL, NULL, NULL));
- break;
- }
- }
- else
- {
- switch(column)
- {
- case SQ_ARCHIVE_STORE_EXTRA_PROP_ICON:
- g_value_init(value, G_TYPE_ICON);
- if(store->props._show_icons)
- g_value_take_object(value, g_themed_icon_new(GTK_STOCK_GO_UP));
- break;
- case LSQ_ARCHIVE_PROP_FILENAME + SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT:
- g_value_init(value, G_TYPE_STRING);
- g_value_set_string(value, "..");
- break;
- default:
- g_value_init(value, lsq_archive_get_entry_property_type(archive, column - SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT));
- break;
- }
- }
+ SQArchiveStore *store;
+ LSQArchive *archive;
+ LSQArchiveIter *parent, *entry;
+
+ g_return_if_fail (SQ_IS_ARCHIVE_STORE (tree_model));
+
+ store = SQ_ARCHIVE_STORE(tree_model);
+ archive = store->archive;
+ entry = iter->user_data;
+
+ g_return_if_fail(archive);
+
+ if(entry)
+ {
+ switch(column)
+ {
+ case SQ_ARCHIVE_STORE_EXTRA_PROP_PATH:
+ g_value_init(value, G_TYPE_STRING);
+
+ parent = lsq_archive_iter_get_parent(entry);
+ g_value_take_string(value, lsq_archive_iter_get_path(parent));
+ lsq_archive_iter_unref(parent);
+ break;
+ case SQ_ARCHIVE_STORE_EXTRA_PROP_ICON:
+ g_value_init(value, G_TYPE_ICON);
+
+ if(store->props._show_icons)
+ g_value_take_object(value, sq_archive_store_get_icon_name_for_iter(store, entry));
+ break;
+ case LSQ_ARCHIVE_PROP_FILENAME + SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT:
+ if(store->props._show_full_path)
+ {
+ g_value_init(value, G_TYPE_STRING);
+ g_value_take_string(value, lsq_archive_iter_get_path(entry));
+ if(!g_utf8_validate(g_value_get_string(value), -1, NULL))
+ g_value_take_string(value, g_convert(g_value_get_string(value), -1, "UTF-8", "WINDOWS-1252", NULL, NULL, NULL));
+ break;
+ }
+ default:
+ column -= SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT;
+ if(column < (gint)lsq_archive_n_entry_properties(archive))
+ lsq_archive_iter_get_prop_value(entry, column, value);
+ /* what if it isn't utf-8 */
+ if(G_VALUE_HOLDS_STRING(value) && g_value_get_string(value) && !g_utf8_validate(g_value_get_string(value), -1, NULL))
+ g_value_take_string(value, g_convert(g_value_get_string(value), -1, "UTF-8", "WINDOWS-1252", NULL, NULL, NULL));
+ break;
+ }
+ }
+ else
+ {
+ switch(column)
+ {
+ case SQ_ARCHIVE_STORE_EXTRA_PROP_ICON:
+ g_value_init(value, G_TYPE_ICON);
+ if(store->props._show_icons)
+ g_value_take_object(value, g_themed_icon_new(GTK_STOCK_GO_UP));
+ break;
+ case LSQ_ARCHIVE_PROP_FILENAME + SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT:
+ g_value_init(value, G_TYPE_STRING);
+ g_value_set_string(value, "..");
+ break;
+ default:
+ g_value_init(value, lsq_archive_get_entry_property_type(archive, column - SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT));
+ break;
+ }
+ }
}
static gboolean
sq_archive_store_iter_next (GtkTreeModel *tree_model, GtkTreeIter *iter)
{
- SQArchiveStore *store;
- LSQArchiveIter *entry;
- gint pos;
+ SQArchiveStore *store;
+ LSQArchiveIter *entry;
+ gint pos;
- g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), FALSE);
-
- store = SQ_ARCHIVE_STORE(tree_model);
- if(iter->stamp != store->stamp)
- return FALSE;
+ g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), FALSE);
+
+ store = SQ_ARCHIVE_STORE(tree_model);
+ if(iter->stamp != store->stamp)
+ return FALSE;
- entry = iter->user_data;
- pos = GPOINTER_TO_INT(iter->user_data3);
- pos++;
+ entry = iter->user_data;
+ pos = GPOINTER_TO_INT(iter->user_data3);
+ pos++;
- if(store->sort_list)
- entry = store->sort_list[pos];
- else
- entry = NULL;
+ if(store->sort_list)
+ entry = store->sort_list[pos];
+ else
+ entry = NULL;
- if(!entry)
- return FALSE;
+ if(!entry)
+ return FALSE;
- iter->stamp = store->stamp;
- iter->user_data = entry;
- iter->user_data3 = GINT_TO_POINTER(pos);
+ iter->stamp = store->stamp;
+ iter->user_data = entry;
+ iter->user_data3 = GINT_TO_POINTER(pos);
- return TRUE;
+ return TRUE;
}
static gboolean
sq_archive_store_iter_children (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent)
{
- SQArchiveStore *store;
- LSQArchive *archive;
- LSQArchiveIter *entry;
+ SQArchiveStore *store;
+ LSQArchive *archive;
+ LSQArchiveIter *entry;
#ifdef DEBUG
- g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), FALSE);
+ g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), FALSE);
#endif
- store = SQ_ARCHIVE_STORE(tree_model);
- archive = store->archive;
+ store = SQ_ARCHIVE_STORE(tree_model);
+ archive = store->archive;
#ifdef DEBUG
- g_return_val_if_fail(store->navigation.present, FALSE);
- g_return_val_if_fail(store->navigation.present->data, FALSE);
+ g_return_val_if_fail(store->navigation.present, FALSE);
+ g_return_val_if_fail(store->navigation.present->data, FALSE);
#endif
- entry = store->navigation.present->data;
+ entry = store->navigation.present->data;
#ifdef DEBUG
- g_return_val_if_fail(archive, FALSE);
- g_return_val_if_fail(entry, FALSE);
+ g_return_val_if_fail(archive, FALSE);
+ g_return_val_if_fail(entry, FALSE);
#endif
- /* only support lists: parent is always NULL */
- g_return_val_if_fail(parent == NULL, FALSE);
-
- if(store->props._show_up_dir && lsq_archive_iter_has_parent(entry))
- {
- entry = NULL;
- iter->user_data3 = GINT_TO_POINTER(-1);
- }
- else
- {
- if(store->sort_list)
- entry = store->sort_list[0];
- else
- entry = NULL;
-
- g_return_val_if_fail(entry, FALSE);
-
- iter->user_data3 = GINT_TO_POINTER(0);
- }
-
- iter->stamp = store->stamp;
- iter->user_data = entry;
-
- return TRUE;
+ /* only support lists: parent is always NULL */
+ g_return_val_if_fail(parent == NULL, FALSE);
+
+ if(store->props._show_up_dir && lsq_archive_iter_has_parent(entry))
+ {
+ entry = NULL;
+ iter->user_data3 = GINT_TO_POINTER(-1);
+ }
+ else
+ {
+ if(store->sort_list)
+ entry = store->sort_list[0];
+ else
+ entry = NULL;
+
+ g_return_val_if_fail(entry, FALSE);
+
+ iter->user_data3 = GINT_TO_POINTER(0);
+ }
+
+ iter->stamp = store->stamp;
+ iter->user_data = entry;
+
+ return TRUE;
}
static gboolean
sq_archive_store_iter_has_child (GtkTreeModel *tree_model, GtkTreeIter *iter)
{
- return FALSE;
+ return FALSE;
}
static gint
sq_archive_store_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter)
{
- SQArchiveStore *store;
- LSQArchive *archive;
- LSQArchiveIter *entry;
+ SQArchiveStore *store;
+ LSQArchive *archive;
+ LSQArchiveIter *entry;
#ifdef DEBUG
- g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), 0);
+ g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), 0);
#endif
- store = SQ_ARCHIVE_STORE(tree_model);
- archive = store->archive;
+ store = SQ_ARCHIVE_STORE(tree_model);
+ archive = store->archive;
#ifdef DEBUG
- g_return_val_if_fail(store->navigation.present, 0);
- g_return_val_if_fail(store->navigation.present->data, 0);
+ g_return_val_if_fail(store->navigation.present, 0);
+ g_return_val_if_fail(store->navigation.present->data, 0);
#endif
- entry = store->navigation.present->data;
+ entry = store->navigation.present->data;
#ifdef DEBUG
- g_return_val_if_fail(archive, 0);
- g_return_val_if_fail(entry, 0);
+ g_return_val_if_fail(archive, 0);
+ g_return_val_if_fail(entry, 0);
#endif
- /* only support lists: iter is always NULL */
- g_return_val_if_fail(iter == NULL, FALSE);
+ /* only support lists: iter is always NULL */
+ g_return_val_if_fail(iter == NULL, FALSE);
- return store->list_size + (lsq_archive_iter_has_parent(entry)?1:0);
+ return store->list_size + (lsq_archive_iter_has_parent(entry)?1:0);
}
static gboolean
sq_archive_store_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent, gint n)
{
- SQArchiveStore *store;
- LSQArchive *archive;
- LSQArchiveIter *entry;
+ SQArchiveStore *store;
+ LSQArchive *archive;
+ LSQArchiveIter *entry;
#ifdef DEBUG
- g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), FALSE);
+ g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), FALSE);
#endif
- store = SQ_ARCHIVE_STORE(tree_model);
- archive = store->archive;
+ store = SQ_ARCHIVE_STORE(tree_model);
+ archive = store->archive;
#ifdef DEBUG
- g_return_val_if_fail(store->navigation.present, FALSE);
- g_return_val_if_fail(store->navigation.present->data, FALSE);
+ g_return_val_if_fail(store->navigation.present, FALSE);
+ g_return_val_if_fail(store->navigation.present->data, FALSE);
#endif
- entry = store->navigation.present->data;
+ entry = store->navigation.present->data;
#ifdef DEBUG
- g_return_val_if_fail(archive, FALSE);
- g_return_val_if_fail(entry, FALSE);
- g_return_val_if_fail(iter, FALSE);
+ g_return_val_if_fail(archive, FALSE);
+ g_return_val_if_fail(entry, FALSE);
+ g_return_val_if_fail(iter, FALSE);
#endif
- /* only support lists: parent is always NULL */
- g_return_val_if_fail(parent == NULL, FALSE);
-
- if(store->props._show_up_dir && lsq_archive_iter_has_parent(entry))
- n--;
-
- if(n == -1)
- {
- entry = NULL;
- }
- else
- {
- if(store->sort_list)
- entry = store->sort_list[n];
- else
- entry = NULL;
-
- if(!entry)
- return FALSE;
- }
-
- iter->stamp = store->stamp;
- iter->user_data = entry;
- iter->user_data3 = GINT_TO_POINTER(n);
-
- return TRUE;
+ /* only support lists: parent is always NULL */
+ g_return_val_if_fail(parent == NULL, FALSE);
+
+ if(store->props._show_up_dir && lsq_archive_iter_has_parent(entry))
+ n--;
+
+ if(n == -1)
+ {
+ entry = NULL;
+ }
+ else
+ {
+ if(store->sort_list)
+ entry = store->sort_list[n];
+ else
+ entry = NULL;
+
+ if(!entry)
+ return FALSE;
+ }
+
+ iter->stamp = store->stamp;
+ iter->user_data = entry;
+ iter->user_data3 = GINT_TO_POINTER(n);
+
+ return TRUE;
}
static gboolean
sq_archive_store_iter_parent (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child)
{
- return FALSE;
+ return FALSE;
}
static gboolean
sq_archive_store_get_sort_column_id(GtkTreeSortable *sortable, gint *sort_col_id, GtkSortType *order)
{
- SQArchiveStore *store;
+ SQArchiveStore *store;
- g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(sortable), FALSE);
+ g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(sortable), FALSE);
- store = SQ_ARCHIVE_STORE(sortable);
+ store = SQ_ARCHIVE_STORE(sortable);
- if(sort_col_id)
- *sort_col_id = store->sort_column;
+ if(sort_col_id)
+ *sort_col_id = store->sort_column;
- if(order)
- *order = store->sort_order;
+ if(order)
+ *order = store->sort_order;
- return TRUE; /*store->sort_order >= 0;*/
+ return TRUE; /*store->sort_order >= 0;*/
}
static void
sq_archive_store_set_sort_column_id(GtkTreeSortable *sortable, gint sort_col_id, GtkSortType order)
{
- SQArchiveStore *store;
+ SQArchiveStore *store;
- g_return_if_fail(SQ_IS_ARCHIVE_STORE(sortable));
+ g_return_if_fail(SQ_IS_ARCHIVE_STORE(sortable));
- store = SQ_ARCHIVE_STORE(sortable);
+ store = SQ_ARCHIVE_STORE(sortable);
- if(store->sort_column == sort_col_id && store->sort_order == order)
- return;
+ if(store->sort_column == sort_col_id && store->sort_order == order)
+ return;
- if(sort_col_id == SQ_ARCHIVE_STORE_EXTRA_PROP_PATH || sort_col_id == SQ_ARCHIVE_STORE_EXTRA_PROP_ICON)
- return;
+ if(sort_col_id == SQ_ARCHIVE_STORE_EXTRA_PROP_PATH || sort_col_id == SQ_ARCHIVE_STORE_EXTRA_PROP_ICON)
+ return;
- store->sort_column = sort_col_id;
- store->sort_order = order;
+ store->sort_column = sort_col_id;
+ store->sort_order = order;
- sq_archive_store_sort(store);
- sq_archive_store_refresh(store);
+ sq_archive_store_sort(store);
+ sq_archive_store_refresh(store);
- gtk_tree_sortable_sort_column_changed(sortable);
+ gtk_tree_sortable_sort_column_changed(sortable);
}
static void
sq_archive_store_set_sort_func(GtkTreeSortable *s, gint i, GtkTreeIterCompareFunc f, gpointer p, GtkDestroyNotify d)
{
- g_warning("%s is not supported by the SQArchiveStore model", __FUNCTION__);
+ g_warning("%s is not supported by the SQArchiveStore model", __FUNCTION__);
}
static void
sq_archive_store_set_default_sort_func(GtkTreeSortable *s, GtkTreeIterCompareFunc f, gpointer p, GtkDestroyNotify d)
{
- g_warning("%s is not supported by the SQArchiveStore model", __FUNCTION__);
+ g_warning("%s is not supported by the SQArchiveStore model", __FUNCTION__);
}
static gboolean
sq_archive_store_has_default_sort_func(GtkTreeSortable *s)
{
- return SQ_ARCHIVE_STORE(s)->props._sort_folders_first||!SQ_ARCHIVE_STORE(s)->props._sort_case_sensitive?FALSE:TRUE;
+ return SQ_ARCHIVE_STORE(s)->props._sort_folders_first||!SQ_ARCHIVE_STORE(s)->props._sort_case_sensitive?FALSE:TRUE;
}
static gint
sq_archive_entry_compare(SQArchiveStore *store, LSQArchiveIter *a, LSQArchiveIter *b)
{
- gint retval = 0;
- gint column = 0;
- gboolean cmp_a = 0;
- gboolean cmp_b = 0;
- GValue prop_a;
- GValue prop_b;
- LSQArchiveIter *swap;
- LSQArchive *archive;
- memset(&prop_a, 0, sizeof(GValue));
- memset(&prop_b, 0, sizeof(GValue));
- if(store->props._sort_folders_first)
- {
- cmp_a = lsq_archive_iter_is_directory(a);
- cmp_b = lsq_archive_iter_is_directory(b);
-
- if(cmp_a && !cmp_b)
- return -1;
- if(cmp_b && !cmp_a)
- return 1;
- }
-
- swap = b;
- if(store->sort_order == GTK_SORT_DESCENDING)
- {
- b = a;
- a = swap;
- }
-
- archive = store->archive;
- column = store->sort_column - SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT;
-
- lsq_archive_iter_get_prop_value(a, column, &prop_a);
- lsq_archive_iter_get_prop_value(b, column, &prop_b);
-
- switch(lsq_archive_get_entry_property_type(archive, column))
- {
- case G_TYPE_STRING:
- if(g_value_get_string(&prop_a) == NULL)
- {
- retval = -1;
- break;
- }
- if(g_value_get_string(&prop_b) == NULL)
- {
- retval = 1;
- break;
- }
- switch(store->props._sort_case_sensitive)
- {
- case 0: /* case insensitive */
- retval = g_ascii_strcasecmp(g_value_get_string(&prop_a), g_value_get_string(&prop_b));
- break;
- case 1: /* case sensitive */
- retval = strcmp(g_value_get_string(&prop_a), g_value_get_string(&prop_b));
- break;
- }
- break;
- case G_TYPE_UINT64:
- retval = g_value_get_uint64(&prop_a) - g_value_get_uint64(&prop_b);
- break;
- case G_TYPE_UINT:
- retval = g_value_get_uint(&prop_a) - g_value_get_uint(&prop_b);
- break;
- }
- g_value_unset(&prop_a);
- g_value_unset(&prop_b);
- return retval;
+ gint retval = 0;
+ gint column = 0;
+ gboolean cmp_a = 0;
+ gboolean cmp_b = 0;
+ GValue prop_a;
+ GValue prop_b;
+ LSQArchiveIter *swap;
+ LSQArchive *archive;
+ memset(&prop_a, 0, sizeof(GValue));
+ memset(&prop_b, 0, sizeof(GValue));
+ if(store->props._sort_folders_first)
+ {
+ cmp_a = lsq_archive_iter_is_directory(a);
+ cmp_b = lsq_archive_iter_is_directory(b);
+
+ if(cmp_a && !cmp_b)
+ return -1;
+ if(cmp_b && !cmp_a)
+ return 1;
+ }
+
+ swap = b;
+ if(store->sort_order == GTK_SORT_DESCENDING)
+ {
+ b = a;
+ a = swap;
+ }
+
+ archive = store->archive;
+ column = store->sort_column - SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT;
+
+ lsq_archive_iter_get_prop_value(a, column, &prop_a);
+ lsq_archive_iter_get_prop_value(b, column, &prop_b);
+
+ switch(lsq_archive_get_entry_property_type(archive, column))
+ {
+ case G_TYPE_STRING:
+ if(g_value_get_string(&prop_a) == NULL)
+ {
+ retval = -1;
+ break;
+ }
+ if(g_value_get_string(&prop_b) == NULL)
+ {
+ retval = 1;
+ break;
+ }
+ switch(store->props._sort_case_sensitive)
+ {
+ case 0: /* case insensitive */
+ retval = g_ascii_strcasecmp(g_value_get_string(&prop_a), g_value_get_string(&prop_b));
+ break;
+ case 1: /* case sensitive */
+ retval = strcmp(g_value_get_string(&prop_a), g_value_get_string(&prop_b));
+ break;
+ }
+ break;
+ case G_TYPE_UINT64:
+ retval = g_value_get_uint64(&prop_a) - g_value_get_uint64(&prop_b);
+ break;
+ case G_TYPE_UINT:
+ retval = g_value_get_uint(&prop_a) - g_value_get_uint(&prop_b);
+ break;
+ }
+ g_value_unset(&prop_a);
+ g_value_unset(&prop_b);
+ return retval;
}
static void
sq_archive_store_sort(SQArchiveStore *store)
{
- LSQArchiveIter *pentry;
- guint psize;
- guint i = 0;
-
- if(store->sort_list)
- {
- LSQArchiveIter **iter;
- for(iter = store->sort_list; *iter; iter++)
- {
- lsq_archive_iter_unref(*iter);
- }
- g_free(store->sort_list);
- store->sort_list = NULL;
- }
+ LSQArchiveIter *pentry;
+ guint psize;
+ guint i = 0;
+
+ if(store->sort_list)
+ {
+ LSQArchiveIter **iter;
+ for(iter = store->sort_list; *iter; iter++)
+ {
+ lsq_archive_iter_unref(*iter);
+ }
+ g_free(store->sort_list);
+ store->sort_list = NULL;
+ }
#ifdef DEBUG
- g_return_if_fail(store->navigation.present);
- g_return_if_fail(store->navigation.present->data);
+ g_return_if_fail(store->navigation.present);
+ g_return_if_fail(store->navigation.present->data);
#endif
- pentry = store->navigation.present->data;
- psize = lsq_archive_iter_n_children(pentry);
-
- store->sort_list = g_new(LSQArchiveIter*, psize+1);
-
- for(i = 0; i < psize; ++i)
- {
- store->sort_list[i] = lsq_archive_iter_nth_child(pentry, i);
- }
- if(psize && store->sort_column >= SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT)
- {
- sq_archive_quicksort(store, 0, psize-1);
- sq_archive_insertionsort(store, 0, psize-1);
- }
- store->sort_list[psize] = NULL;
+ pentry = store->navigation.present->data;
+ psize = lsq_archive_iter_n_children(pentry);
+
+ store->sort_list = g_new(LSQArchiveIter*, psize+1);
+
+ for(i = 0; i < psize; ++i)
+ {
+ store->sort_list[i] = lsq_archive_iter_nth_child(pentry, i);
+ }
+ if(psize && store->sort_column >= SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT)
+ {
+ sq_archive_quicksort(store, 0, psize-1);
+ sq_archive_insertionsort(store, 0, psize-1);
+ }
+ store->sort_list[psize] = NULL;
}
static inline void
swap(LSQArchiveIter **left, LSQArchiveIter **right)
{
- LSQArchiveIter *tmp = *right;
- *right = *left;
- *left = tmp;
+ LSQArchiveIter *tmp = *right;
+ *right = *left;
+ *left = tmp;
}
static void
sq_archive_quicksort(SQArchiveStore *store, gint left, gint right)
{
- gint i;
- gint j;
- LSQArchiveIter *value = NULL;
- LSQArchiveIter **list;
-
- if(right-left < 30) return;
-
- i = (left+right)/2;
- j = right-1;
- list = store->sort_list;
-
- if(sq_archive_entry_compare(store, list[left], list[i]) > 0)
- swap(list+left, list+i);
- if(sq_archive_entry_compare(store, list[left], list[right]) > 0)
- swap(list+left, list+right);
- if(sq_archive_entry_compare(store, list[i], list[right]) > 0)
- swap(list+i, list+right);
-
- swap(list+i, list+j);
- i = left;
- value = list[j];
-
- for(;;)
- {
- while(sq_archive_entry_compare(store, list[++i], value) < 0);
- while(sq_archive_entry_compare(store, list[--j], value) > 0);
- if(j<i) break;
-
- swap(list+i, list+j);
- }
- swap(list+i, list+right-1);
- sq_archive_quicksort(store, left, j);
- sq_archive_quicksort(store, i+1, right);
+ gint i;
+ gint j;
+ LSQArchiveIter *value = NULL;
+ LSQArchiveIter **list;
+
+ if(right-left < 30) return;
+
+ i = (left+right)/2;
+ j = right-1;
+ list = store->sort_list;
+
+ if(sq_archive_entry_compare(store, list[left], list[i]) > 0)
+ swap(list+left, list+i);
+ if(sq_archive_entry_compare(store, list[left], list[right]) > 0)
+ swap(list+left, list+right);
+ if(sq_archive_entry_compare(store, list[i], list[right]) > 0)
+ swap(list+i, list+right);
+
+ swap(list+i, list+j);
+ i = left;
+ value = list[j];
+
+ for(;;)
+ {
+ while(sq_archive_entry_compare(store, list[++i], value) < 0);
+ while(sq_archive_entry_compare(store, list[--j], value) > 0);
+ if(j<i) break;
+
+ swap(list+i, list+j);
+ }
+ swap(list+i, list+right-1);
+ sq_archive_quicksort(store, left, j);
+ sq_archive_quicksort(store, i+1, right);
}
static void
sq_archive_insertionsort(SQArchiveStore *store, gint left, gint right)
{
- gint i = 0;
- gint j = 0;
- LSQArchiveIter *value = NULL;
- LSQArchiveIter **list = store->sort_list;
-
- for(i = left+1; i <= right; ++i)
- {
- j = i;
- value = list[i];
- while(j > left && sq_archive_entry_compare(store, list[j-1], value) > 0)
- {
- list[j] = list[j-1];
- j--;
- }
- list[j] = value;
- }
+ gint i = 0;
+ gint j = 0;
+ LSQArchiveIter *value = NULL;
+ LSQArchiveIter **list = store->sort_list;
+
+ for(i = left+1; i <= right; ++i)
+ {
+ j = i;
+ value = list[i];
+ while(j > left && sq_archive_entry_compare(store, list[j-1], value) > 0)
+ {
+ list[j] = list[j-1];
+ j--;
+ }
+ list[j] = value;
+ }
}
static GIcon *
sq_archive_store_get_icon_name_for_iter(SQArchiveStore *store, LSQArchiveIter *iter)
{
- return g_content_type_get_icon(lsq_archive_iter_get_contenttype(iter));
+ return g_content_type_get_icon(lsq_archive_iter_get_contenttype(iter));
}
GtkTreeModel *
sq_archive_store_new(LSQArchive *archive, gboolean show_icons, gboolean show_up_dir, GtkIconTheme *icon_theme)
{
- SQArchiveStore *tree_model;
+ SQArchiveStore *tree_model;
- tree_model = g_object_new(SQ_TYPE_ARCHIVE_STORE, NULL);
+ tree_model = g_object_new(SQ_TYPE_ARCHIVE_STORE, NULL);
- tree_model->props._show_icons = show_icons?1:0;
- tree_model->props._show_up_dir = show_up_dir?1:0;
- tree_model->icon_theme = icon_theme;
+ tree_model->props._show_icons = show_icons?1:0;
+ tree_model->props._show_up_dir = show_up_dir?1:0;
+ tree_model->icon_theme = icon_theme;
- if(tree_model->props._sort_folders_first)
- tree_model->sort_column = SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT + LSQ_ARCHIVE_PROP_FILENAME;
+ if(tree_model->props._sort_folders_first)
+ tree_model->sort_column = SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT + LSQ_ARCHIVE_PROP_FILENAME;
- sq_archive_store_set_archive(tree_model, archive);
+ sq_archive_store_set_archive(tree_model, archive);
- return GTK_TREE_MODEL(tree_model);
+ return GTK_TREE_MODEL(tree_model);
}
void
sq_archive_store_connect_treeview(SQArchiveStore *store, GtkTreeView *treeview)
{
- store->treeview = treeview;
- g_signal_connect(G_OBJECT(treeview), "row-activated", G_CALLBACK(cb_sq_archive_store_row_activated), store);
+ store->treeview = treeview;
+ g_signal_connect(G_OBJECT(treeview), "row-activated", G_CALLBACK(cb_sq_archive_store_row_activated), store);
}
static void
sq_archive_store_refresh(SQArchiveStore *store)
{
- LSQArchive *archive = store->archive;
- LSQArchiveIter *entry;
- guint prev_size;
- guint new_size;
- guint i = 0;
- GtkTreePath *path_ = NULL;
- GtkTreeIter iter;
-
- if(!store->navigation.present)
- return;
+ LSQArchive *archive = store->archive;
+ LSQArchiveIter *entry;
+ guint prev_size;
+ guint new_size;
+ guint i = 0;
+ GtkTreePath *path_ = NULL;
+ GtkTreeIter iter;
+
+ if(!store->navigation.present)
+ return;
#ifdef DEBUG
- g_return_if_fail(store->navigation.present->data);
+ g_return_if_fail(store->navigation.present->data);
#endif
- entry = store->navigation.present->data;
-
- g_return_if_fail(archive);
- g_return_if_fail(entry);
-
- prev_size = store->list_size;
- new_size = lsq_archive_iter_n_children(entry);
-
- /* if(store->treeview) */
- {
- /* we need to add up dir .. */
- if(store->props._show_up_dir && lsq_archive_iter_has_parent(entry))
- {
- /* use a hack like in thunar-list-model to prevent re-allocating */
- path_ = gtk_tree_path_new();
- gtk_tree_path_append_index(path_, 0);
-
- iter.stamp = store->stamp;
- iter.user_data = NULL;
- iter.user_data3 = GINT_TO_POINTER(-1);
-
- if(0 < prev_size)
- gtk_tree_model_row_changed(GTK_TREE_MODEL(store), path_, &iter);
- else
- gtk_tree_model_row_inserted(GTK_TREE_MODEL(store), path_, &iter);
-
- gtk_tree_path_free(path_);
- i=1;
- new_size++;
- }
-
- if(store->sort_list)
- {
- /* notify the tree view that we have rows */
- for(; i < new_size; ++i)
- {
- /* use a hack like in thunar-list-model to prevent re-allocating */
- path_ = gtk_tree_path_new();
- gtk_tree_path_append_index(path_, i);
-
- iter.stamp = store->stamp;
- iter.user_data = store->sort_list[i];
- iter.user_data3 = GINT_TO_POINTER(i);
-
- if(i < prev_size)
- gtk_tree_model_row_changed(GTK_TREE_MODEL(store), path_, &iter);
- else
- gtk_tree_model_row_inserted(GTK_TREE_MODEL(store), path_, &iter);
-
- gtk_tree_path_free(path_);
- }
- }
+ entry = store->navigation.present->data;
+
+ g_return_if_fail(archive);
+ g_return_if_fail(entry);
+
+ prev_size = store->list_size;
+ new_size = lsq_archive_iter_n_children(entry);
+
+ /* if(store->treeview) */
+ {
+ /* we need to add up dir .. */
+ if(store->props._show_up_dir && lsq_archive_iter_has_parent(entry))
+ {
+ /* use a hack like in thunar-list-model to prevent re-allocating */
+ path_ = gtk_tree_path_new();
+ gtk_tree_path_append_index(path_, 0);
+
+ iter.stamp = store->stamp;
+ iter.user_data = NULL;
+ iter.user_data3 = GINT_TO_POINTER(-1);
+
+ if(0 < prev_size)
+ gtk_tree_model_row_changed(GTK_TREE_MODEL(store), path_, &iter);
+ else
+ gtk_tree_model_row_inserted(GTK_TREE_MODEL(store), path_, &iter);
+
+ gtk_tree_path_free(path_);
+ i=1;
+ new_size++;
+ }
+
+ if(store->sort_list)
+ {
+ /* notify the tree view that we have rows */
+ for(; i < new_size; ++i)
+ {
+ /* use a hack like in thunar-list-model to prevent re-allocating */
+ path_ = gtk_tree_path_new();
+ gtk_tree_path_append_index(path_, i);
+
+ iter.stamp = store->stamp;
+ iter.user_data = store->sort_list[i];
+ iter.user_data3 = GINT_TO_POINTER(i);
+
+ if(i < prev_size)
+ gtk_tree_model_row_changed(GTK_TREE_MODEL(store), path_, &iter);
+ else
+ gtk_tree_model_row_inserted(GTK_TREE_MODEL(store), path_, &iter);
+
+ gtk_tree_path_free(path_);
+ }
+ }
- /* notify tree view we romeved all the remaining rows */
- i = prev_size;
- while(i > new_size)
- {
- --i;
- /* use a hack like in thunar-list-model to prevent re-allocating */
- path_ = gtk_tree_path_new();
- gtk_tree_path_append_index(path_, i);
-
- gtk_tree_model_row_deleted(GTK_TREE_MODEL(store), path_);
-
- gtk_tree_path_free(path_);
- }
- }
-
- store->list_size = new_size;
+ /* notify tree view we romeved all the remaining rows */
+ i = prev_size;
+ while(i > new_size)
+ {
+ --i;
+ /* use a hack like in thunar-list-model to prevent re-allocating */
+ path_ = gtk_tree_path_new();
+ gtk_tree_path_append_index(path_, i);
+
+ gtk_tree_model_row_deleted(GTK_TREE_MODEL(store), path_);
+
+ gtk_tree_path_free(path_);
+ }
+ }
+
+ store->list_size = new_size;
}
static void
cb_sq_archive_store_row_activated(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
{
- sq_archive_store_file_activated(SQ_ARCHIVE_STORE(user_data), path);
+ sq_archive_store_file_activated(SQ_ARCHIVE_STORE(user_data), path);
}
static void
sq_archive_store_file_activated(SQArchiveStore *store, GtkTreePath *path)
{
- LSQArchive *archive;
- LSQArchiveIter *entry;
- gint *indices;
- gint depth;
- gint index_;
+ LSQArchive *archive;
+ LSQArchiveIter *entry;
+ gint *indices;
+ gint depth;
+ gint index_;
- g_return_if_fail(store->navigation.present);
- g_return_if_fail(store->navigation.present->data);
+ g_return_if_fail(store->navigation.present);
+ g_return_if_fail(store->navigation.present->data);
- archive = store->archive;
- entry = store->navigation.present->data;
+ archive = store->archive;
+ entry = store->navigation.present->data;
- g_return_if_fail(archive);
- g_return_if_fail(entry);
+ g_return_if_fail(archive);
+ g_return_if_fail(entry);
- indices = gtk_tree_path_get_indices(path);
- depth = gtk_tree_path_get_depth(path) - 1;
+ indices = gtk_tree_path_get_indices(path);
+ depth = gtk_tree_path_get_depth(path) - 1;
- /* only support list: depth is always 0 */
- g_return_if_fail(depth == 0);
+ /* only support list: depth is always 0 */
+ g_return_if_fail(depth == 0);
- index_ = indices[depth];
+ index_ = indices[depth];
- if(store->props._show_up_dir && lsq_archive_iter_has_parent(entry))
- index_--;
+ if(store->props._show_up_dir && lsq_archive_iter_has_parent(entry))
+ index_--;
- if(index_ == -1)
- {
- entry = lsq_archive_iter_get_parent(entry);
- sq_archive_store_append_history(store, entry);
- }
- else
- {
- if(store->sort_list)
- entry = store->sort_list[index_];
- else
- entry = NULL;
+ if(index_ == -1)
+ {
+ entry = lsq_archive_iter_get_parent(entry);
+ sq_archive_store_append_history(store, entry);
+ }
+ else
+ {
+ if(store->sort_list)
+ entry = store->sort_list[index_];
+ else
+ entry = NULL;
- g_return_if_fail(entry);
+ g_return_if_fail(entry);
- /* Signal file-activated */
- if(!lsq_archive_iter_is_directory(entry))
- {
+ /* Signal file-activated */
+ if(!lsq_archive_iter_is_directory(entry))
+ {
#ifdef DEBUG
- g_debug("file clicked");
+ g_debug("file clicked");
#endif
- g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_FILE_ACTIVATED], 0, entry, NULL);
- return;
- }
+ g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_FILE_ACTIVATED], 0, entry, NULL);
+ return;
+ }
- sq_archive_store_append_history(store, lsq_archive_iter_ref(entry));
- }
+ sq_archive_store_append_history(store, lsq_archive_iter_ref(entry));
+ }
- sq_archive_store_sort(store);
- sq_archive_store_refresh(store);
- g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, entry, NULL);
+ sq_archive_store_sort(store);
+ sq_archive_store_refresh(store);
+ g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, entry, NULL);
}
void
sq_archive_store_go_up(SQArchiveStore *store)
{
- LSQArchive *archive = store->archive;
- LSQArchiveIter *entry;
+ LSQArchive *archive = store->archive;
+ LSQArchiveIter *entry;
#ifdef DEBUG
- g_return_if_fail(store->navigation.present);
- g_return_if_fail(store->navigation.present->data);
+ g_return_if_fail(store->navigation.present);
+ g_return_if_fail(store->navigation.present->data);
#endif
- entry = store->navigation.present->data;
+ entry = store->navigation.present->data;
- g_return_if_fail(archive);
- g_return_if_fail(entry);
+ g_return_if_fail(archive);
+ g_return_if_fail(entry);
- g_return_if_fail((entry = lsq_archive_iter_get_parent(entry)));
+ g_return_if_fail((entry = lsq_archive_iter_get_parent(entry)));
- sq_archive_store_append_history(store, entry);
+ sq_archive_store_append_history(store, entry);
- sq_archive_store_sort(store);
- sq_archive_store_refresh(store);
- g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, entry, NULL);
+ sq_archive_store_sort(store);
+ sq_archive_store_refresh(store);
+ g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, entry, NULL);
}
void
sq_archive_store_set_archive(SQArchiveStore *store, LSQArchive *archive)
{
- guint i = 0;
- GtkTreePath *path_ = NULL;
- GtkTreeIter iter;
- GList *list_iter;
- LSQArchiveIter *root_entry;
-
- g_return_if_fail(store);
-
- if(store->archive == archive)
- return;
-
- /* free the sort data */
- if(store->sort_list)
- {
- LSQArchiveIter **_iter;
- for(_iter = store->sort_list; *_iter; _iter++)
- {
- lsq_archive_iter_unref(*_iter);
- }
- g_free(store->sort_list);
- store->sort_list = NULL;
- }
+ guint i = 0;
+ GtkTreePath *path_ = NULL;
+ GtkTreeIter iter;
+ GList *list_iter;
+ LSQArchiveIter *root_entry;
+
+ g_return_if_fail(store);
+
+ if(store->archive == archive)
+ return;
+
+ /* free the sort data */
+ if(store->sort_list)
+ {
+ LSQArchiveIter **_iter;
+ for(_iter = store->sort_list; *_iter; _iter++)
+ {
+ lsq_archive_iter_unref(*_iter);
+ }
+ g_free(store->sort_list);
+ store->sort_list = NULL;
+ }
/* notify the tree view, all rows are gone */
- i = store->list_size;
- while(i)
- {
- --i;
- /* use a hack like in thunar-list-model to prevent re-allocating */
- path_ = gtk_tree_path_new();
- gtk_tree_path_append_index(path_, i);
-
- gtk_tree_model_row_deleted(GTK_TREE_MODEL(store), path_);
-
- gtk_tree_path_free(path_);
- }
-
- store->list_size = 0;
-
- /* clear the history */
- for(list_iter = store->navigation.history; list_iter; list_iter = list_iter->next)
- lsq_archive_iter_unref(list_iter->data);
-
- g_list_free(store->navigation.history);
- if(store->navigation.trailing)
- lsq_archive_iter_unref(store->navigation.trailing);
-
- store->navigation.history = NULL;
- store->navigation.present = NULL;
- store->navigation.trailing = NULL;
-
- /* disconnect from the archive */
- if(store->archive)
- {
- g_signal_handlers_disconnect_by_func(store->archive, cb_sq_archive_store_archive_refreshed, store);
- /* g_signal_handlers_disconnect_by_func(store->archive, cb_sq_archive_store_archive_path_changed, store); */
- g_object_unref(store->archive);
- store->archive = NULL;
- }
-
- /* notify all that we have a new NULL archive */
- if(!archive)
- {
- g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_NEW_ARCHIVE], 0, NULL);
- return;
- }
-
- /* take a ownership of the archive */
- g_object_ref(archive);
- store->archive = archive;
-
- /* only update if we are not busy */
- /* if(lsq_archive_get_status(archive) == NULL) */
- {
- root_entry = lsq_archive_get_iter(archive, NULL);
-
- sq_archive_store_append_history(store, root_entry);
-
- sq_archive_store_sort(store);
-
- /* lets notify the tree view we have new rows */
- store->list_size = lsq_archive_iter_n_children(root_entry);
-
- if(store->sort_list)
- {
- for(i = 0; i < store->list_size; ++i)
- {
- /* use a hack like in thunar-list-model to prevent re-allocating */
- path_ = gtk_tree_path_new();
- gtk_tree_path_append_index(path_, i);
-
- iter.stamp = store->stamp;
- iter.user_data = store->sort_list[i];
- iter.user_data3 = GINT_TO_POINTER(i);
-
- gtk_tree_model_row_inserted(GTK_TREE_MODEL(store), path_, &iter);
-
- gtk_tree_path_free(path_);
- }
- }
- }
-
- /* notify all we have a new archive and connect with the archive */
- g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_NEW_ARCHIVE], 0, NULL);
- g_signal_connect(store->archive, "refreshed", G_CALLBACK(cb_sq_archive_store_archive_refreshed), store);
+ i = store->list_size;
+ while(i)
+ {
+ --i;
+ /* use a hack like in thunar-list-model to prevent re-allocating */
+ path_ = gtk_tree_path_new();
+ gtk_tree_path_append_index(path_, i);
+
+ gtk_tree_model_row_deleted(GTK_TREE_MODEL(store), path_);
+
+ gtk_tree_path_free(path_);
+ }
+
+ store->list_size = 0;
+
+ /* clear the history */
+ for(list_iter = store->navigation.history; list_iter; list_iter = list_iter->next)
+ lsq_archive_iter_unref(list_iter->data);
+
+ g_list_free(store->navigation.history);
+ if(store->navigation.trailing)
+ lsq_archive_iter_unref(store->navigation.trailing);
+
+ store->navigation.history = NULL;
+ store->navigation.present = NULL;
+ store->navigation.trailing = NULL;
+
+ /* disconnect from the archive */
+ if(store->archive)
+ {
+ g_signal_handlers_disconnect_by_func(store->archive, cb_sq_archive_store_archive_refreshed, store);
+ /* g_signal_handlers_disconnect_by_func(store->archive, cb_sq_archive_store_archive_path_changed, store); */
+ g_object_unref(store->archive);
+ store->archive = NULL;
+ }
+
+ /* notify all that we have a new NULL archive */
+ if(!archive)
+ {
+ g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_NEW_ARCHIVE], 0, NULL);
+ return;
+ }
+
+ /* take a ownership of the archive */
+ g_object_ref(archive);
+ store->archive = archive;
+
+ /* only update if we are not busy */
+ /* if(lsq_archive_get_status(archive) == NULL) */
+ {
+ root_entry = lsq_archive_get_iter(archive, NULL);
+
+ sq_archive_store_append_history(store, root_entry);
+
+ sq_archive_store_sort(store);
+
+ /* lets notify the tree view we have new rows */
+ store->list_size = lsq_archive_iter_n_children(root_entry);
+
+ if(store->sort_list)
+ {
+ for(i = 0; i < store->list_size; ++i)
+ {
+ /* use a hack like in thunar-list-model to prevent re-allocating */
+ path_ = gtk_tree_path_new();
+ gtk_tree_path_append_index(path_, i);
+
+ iter.stamp = store->stamp;
+ iter.user_data = store->sort_list[i];
+ iter.user_data3 = GINT_TO_POINTER(i);
+
+ gtk_tree_model_row_inserted(GTK_TREE_MODEL(store), path_, &iter);
+
+ gtk_tree_path_free(path_);
+ }
+ }
+ }
+
+ /* notify all we have a new archive and connect with the archive */
+ g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_NEW_ARCHIVE], 0, NULL);
+ g_signal_connect(store->archive, "refreshed", G_CALLBACK(cb_sq_archive_store_archive_refreshed), store);
}
LSQArchiveIter *
sq_archive_store_get_pwd(SQArchiveStore *store)
{
- LSQArchiveIter *iter;
+ LSQArchiveIter *iter;
#ifdef DEBUG
- g_return_val_if_fail(store, NULL);
- g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(store), NULL);
+ g_return_val_if_fail(store, NULL);
+ g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(store), NULL);
#endif
- if(!store->navigation.present)
- return NULL;
+ if(!store->navigation.present)
+ return NULL;
- iter = store->navigation.present->data;
+ iter = store->navigation.present->data;
- return lsq_archive_iter_ref(iter);
+ return lsq_archive_iter_ref(iter);
}
gboolean
sq_archive_store_set_pwd(SQArchiveStore *store, LSQArchiveIter *path)
{
- /* should check if the iter is of the current archive */
+ /* should check if the iter is of the current archive */
- g_return_val_if_fail(store, FALSE);
+ g_return_val_if_fail(store, FALSE);
- if(!store->archive)
- return FALSE;
+ if(!store->archive)
+ return FALSE;
#ifdef DEBUG
- g_return_val_if_fail(store->navigation.present, FALSE);
- g_return_val_if_fail(store->navigation.present->data, FALSE);
+ g_return_val_if_fail(store->navigation.present, FALSE);
+ g_return_val_if_fail(store->navigation.present->data, FALSE);
#endif
- if(lsq_archive_iter_is_directory(path))
- {
- sq_archive_store_append_history(store, lsq_archive_iter_ref(path));
+ if(lsq_archive_iter_is_directory(path))
+ {
+ sq_archive_store_append_history(store, lsq_archive_iter_ref(path));
- sq_archive_store_sort(store);
- sq_archive_store_refresh(store);
+ sq_archive_store_sort(store);
+ sq_archive_store_refresh(store);
- g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, path, NULL);
- return TRUE;
- }
- else
- {
+ g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, path, NULL);
+ return TRUE;
+ }
+ else
+ {
#ifdef DEBUG
- g_debug("file activated");
+ g_debug("file activated");
#endif
- g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_FILE_ACTIVATED], 0, lsq_archive_iter_get_filename(path), NULL);
- }
+ g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_FILE_ACTIVATED], 0, lsq_archive_iter_get_filename(path), NULL);
+ }
- return FALSE;
+ return FALSE;
}
void
sq_archive_store_set_icon_theme(SQArchiveStore *store, GtkIconTheme *icon_theme)
{
- if(store)
- store->icon_theme = icon_theme;
+ if(store)
+ store->icon_theme = icon_theme;
}
gboolean
sq_archive_store_get_show_full_path(SQArchiveStore *store)
{
- return store->props._show_full_path;
+ return store->props._show_full_path;
}
gboolean
sq_archive_store_get_show_icons(SQArchiveStore *store)
{
- return store->props._show_icons;
+ return store->props._show_icons;
}
gboolean
sq_archive_store_get_sort_case_sensitive(SQArchiveStore *store)
{
- return store->props._sort_case_sensitive;
+ return store->props._sort_case_sensitive;
}
gboolean
sq_archive_store_get_sort_folders_first(SQArchiveStore *store)
{
- return store->props._sort_folders_first;
+ return store->props._sort_folders_first;
}
void
sq_archive_store_set_show_full_path(SQArchiveStore *store, gboolean show)
{
- show = show?1:0;
-
- if(store->props._show_full_path != show)
- {
- store->props._show_full_path = show;
- if(store->archive)
- sq_archive_store_refresh(store);
- g_object_notify(G_OBJECT(store), "show-full-path");
- }
+ show = show?1:0;
+
+ if(store->props._show_full_path != show)
+ {
+ store->props._show_full_path = show;
+ if(store->archive)
+ sq_archive_store_refresh(store);
+ g_object_notify(G_OBJECT(store), "show-full-path");
+ }
}
void
sq_archive_store_set_show_icons(SQArchiveStore *store, gboolean show)
{
- show = show?1:0;
-
- if(store->props._show_icons != show)
- {
- store->props._show_icons = show;
- if(store->archive)
- sq_archive_store_refresh(store);
- g_object_notify(G_OBJECT(store), "show-icons");
- }
+ show = show?1:0;
+
+ if(store->props._show_icons != show)
+ {
+ store->props._show_icons = show;
+ if(store->archive)
+ sq_archive_store_refresh(store);
+ g_object_notify(G_OBJECT(store), "show-icons");
+ }
}
void
sq_archive_store_set_sort_case_sensitive(SQArchiveStore *store, gboolean sort)
{
- sort = sort?1:0;
-
- if(store->props._sort_case_sensitive != sort)
- {
- store->props._sort_case_sensitive = sort;
- if(!sort && store->sort_column < SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT)
- store->sort_column = SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT + LSQ_ARCHIVE_PROP_FILENAME;
-
- if(store->archive)
- {
- sq_archive_store_sort(store);
- sq_archive_store_refresh(store);
- }
- g_object_notify(G_OBJECT(store), "sort-case-sensitive");
- }
+ sort = sort?1:0;
+
+ if(store->props._sort_case_sensitive != sort)
+ {
+ store->props._sort_case_sensitive = sort;
+ if(!sort && store->sort_column < SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT)
+ store->sort_column = SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT + LSQ_ARCHIVE_PROP_FILENAME;
+
+ if(store->archive)
+ {
+ sq_archive_store_sort(store);
+ sq_archive_store_refresh(store);
+ }
+ g_object_notify(G_OBJECT(store), "sort-case-sensitive");
+ }
}
void
sq_archive_store_set_sort_folders_first(SQArchiveStore *store, gboolean sort)
{
- sort = sort?1:0;
-
- if(store->props._sort_folders_first != sort)
- {
- store->props._sort_folders_first = sort;
- if(sort && store->sort_column < SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT)
- store->sort_column = SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT + LSQ_ARCHIVE_PROP_FILENAME;
-
- if(store->archive)
- {
- sq_archive_store_sort(store);
- sq_archive_store_refresh(store);
- }
- g_object_notify(G_OBJECT(store), "sort-folders-first");
- }
+ sort = sort?1:0;
+
+ if(store->props._sort_folders_first != sort)
+ {
+ store->props._sort_folders_first = sort;
+ if(sort && store->sort_column < SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT)
+ store->sort_column = SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT + LSQ_ARCHIVE_PROP_FILENAME;
+
+ if(store->archive)
+ {
+ sq_archive_store_sort(store);
+ sq_archive_store_refresh(store);
+ }
+ g_object_notify(G_OBJECT(store), "sort-folders-first");
+ }
}
gboolean
sq_archive_store_has_history(SQArchiveStore *store)
{
- if(!store->navigation.present)
- return FALSE;
- return store->navigation.present->prev?TRUE:FALSE;
+ if(!store->navigation.present)
+ return FALSE;
+ return store->navigation.present->prev?TRUE:FALSE;
}
gboolean
sq_archive_store_has_future(SQArchiveStore *store)
{
- if(!store->navigation.present)
- return FALSE;
- return store->navigation.present->next?TRUE:FALSE;
+ if(!store->navigation.present)
+ return FALSE;
+ return store->navigation.present->next?TRUE:FALSE;
}
void
sq_archive_store_go_back(SQArchiveStore *store)
{
- LSQArchive *archive = store->archive;
+ LSQArchive *archive = store->archive;
#ifdef DEBUG
- g_return_if_fail(store->navigation.present);
- g_return_if_fail(store->navigation.present->data);
+ g_return_if_fail(store->navigation.present);
+ g_return_if_fail(store->navigation.present->data);
#endif
- g_return_if_fail(archive);
+ g_return_if_fail(archive);
- if(sq_archive_store_has_history(store))
- store->navigation.present = store->navigation.present->prev;
+ if(sq_archive_store_has_history(store))
+ store->navigation.present = store->navigation.present->prev;
- sq_archive_store_sort(store);
- sq_archive_store_refresh(store);
+ sq_archive_store_sort(store);
+ sq_archive_store_refresh(store);
- sq_archive_store_check_trailing(store);
+ sq_archive_store_check_trailing(store);
- g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, store->navigation.present->data, NULL);
+ g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, store->navigation.present->data, NULL);
}
void
sq_archive_store_go_forward(SQArchiveStore *store)
{
- LSQArchive *archive = store->archive;
+ LSQArchive *archive = store->archive;
#ifdef DEBUG
- g_return_if_fail(store->navigation.present);
- g_return_if_fail(store->navigation.present->data);
+ g_return_if_fail(store->navigation.present);
+ g_return_if_fail(store->navigation.present->data);
#endif
- g_return_if_fail(archive);
+ g_return_if_fail(archive);
- if(sq_archive_store_has_future(store))
- store->navigation.present = store->navigation.present->next;
+ if(sq_archive_store_has_future(store))
+ store->navigation.present = store->navigation.present->next;
- sq_archive_store_sort(store);
- sq_archive_store_refresh(store);
+ sq_archive_store_sort(store);
+ sq_archive_store_refresh(store);
- sq_archive_store_check_trailing(store);
+ sq_archive_store_check_trailing(store);
- g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, store->navigation.present->data, NULL);
+ g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, store->navigation.present->data, NULL);
}
static void
sq_archive_store_append_history(SQArchiveStore *store, LSQArchiveIter *entry)
{
- /*
- if(lsq_archive_get_status(store->archive) != NULL)
- return;
- */
+ /*
+ if(lsq_archive_get_status(store->archive) != NULL)
+ return;
+ */
- GList *iter = store->navigation.present;
+ GList *iter = store->navigation.present;
- if(store->navigation.present)
- {
- if(store->navigation.present->next)
- store->navigation.present->next->prev = NULL;
+ if(store->navigation.present)
+ {
+ if(store->navigation.present->next)
+ store->navigation.present->next->prev = NULL;
- while((iter = iter->next))
- lsq_archive_iter_unref(iter->data);
+ while((iter = iter->next))
+ lsq_archive_iter_unref(iter->data);
- g_list_free(store->navigation.present->next);
+ g_list_free(store->navigation.present->next);
- store->navigation.present->next = NULL;
- }
+ store->navigation.present->next = NULL;
+ }
- store->navigation.history = g_list_append(store->navigation.history, entry);
- store->navigation.present = g_list_last(store->navigation.history);
+ store->navigation.history = g_list_append(store->navigation.history, entry);
+ store->navigation.present = g_list_last(store->navigation.history);
- while(g_list_length(store->navigation.history) > store->navigation.maxhistory)
- {
- lsq_archive_iter_unref(g_list_first(store->navigation.history)->data);
- store->navigation.history = g_list_delete_link(store->navigation.history, g_list_first(store->navigation.history));
- }
+ while(g_list_length(store->navigation.history) > store->navigation.maxhistory)
+ {
+ lsq_archive_iter_unref(g_list_first(store->navigation.history)->data);
+ store->navigation.history = g_list_delete_link(store->navigation.history, g_list_first(store->navigation.history));
+ }
- sq_archive_store_check_trailing(store);
+ sq_archive_store_check_trailing(store);
}
static void
sq_archive_store_check_trailing(SQArchiveStore *store)
{
- LSQArchiveIter *piter = store->navigation.present->data;
- LSQArchiveIter *titer = store->navigation.trailing;
- LSQArchiveIter *child = NULL;
-
- if(titer)
- {
- while(titer)
- {
- if(titer == piter)
- {
- if(child)
- lsq_archive_iter_unref(child);
- return;
- }
-
- titer = lsq_archive_iter_get_parent(titer);
- if(child)
- lsq_archive_iter_unref(child);
- child = titer;
- }
- if(child)
- lsq_archive_iter_unref(child);
-
- lsq_archive_iter_unref(store->navigation.trailing);
- }
- store->navigation.trailing = lsq_archive_iter_ref(piter);
+ LSQArchiveIter *piter = store->navigation.present->data;
+ LSQArchiveIter *titer = store->navigation.trailing;
+ LSQArchiveIter *child = NULL;
+
+ if(titer)
+ {
+ while(titer)
+ {
+ if(titer == piter)
+ {
+ if(child)
+ lsq_archive_iter_unref(child);
+ return;
+ }
+
+ titer = lsq_archive_iter_get_parent(titer);
+ if(child)
+ lsq_archive_iter_unref(child);
+ child = titer;
+ }
+ if(child)
+ lsq_archive_iter_unref(child);
+
+ lsq_archive_iter_unref(store->navigation.trailing);
+ }
+ store->navigation.trailing = lsq_archive_iter_ref(piter);
}
LSQArchiveIter *
sq_archive_store_get_trailing(SQArchiveStore *store)
{
- LSQArchiveIter *iter;
+ LSQArchiveIter *iter;
#ifdef DEBUG
- g_return_val_if_fail(store, NULL);
- g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(store), NULL);
+ g_return_val_if_fail(store, NULL);
+ g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(store), NULL);
#endif
- iter = store->navigation.trailing;
+ iter = store->navigation.trailing;
- return lsq_archive_iter_ref(iter);
+ return lsq_archive_iter_ref(iter);
}
LSQArchive *
sq_archive_store_get_archive(SQArchiveStore *archive_store)
{
- return archive_store->archive;
+ return archive_store->archive;
}
static void
sq_archive_store_dispose(GObject *object)
{
- SQArchiveStore *store = SQ_ARCHIVE_STORE(object);
- if(store->archive)
- {
- g_signal_handlers_disconnect_by_func(store->archive, cb_sq_archive_store_archive_refreshed, store);
-
- g_object_unref(store->archive);
- store->archive = NULL;
- }
- parent_class->dispose(object);
+ SQArchiveStore *store = SQ_ARCHIVE_STORE(object);
+ if(store->archive)
+ {
+ g_signal_handlers_disconnect_by_func(store->archive, cb_sq_archive_store_archive_refreshed, store);
+
+ g_object_unref(store->archive);
+ store->archive = NULL;
+ }
+ parent_class->dispose(object);
}
static void
cb_sq_archive_store_archive_refreshed(LSQArchive *archive, gpointer user_data)
{
- SQArchiveStore *store = SQ_ARCHIVE_STORE(user_data);
- GList *iter;
- LSQArchiveIter *aIter;
-
- for(iter = store->navigation.history; iter; iter = g_list_next(iter))
- {
- aIter = lsq_archive_iter_get_real_parent(iter->data);
- lsq_archive_iter_unref(iter->data);
- iter->data = aIter;
- }
-
- sq_archive_store_sort(store);
- sq_archive_store_refresh(store);
- g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, store->navigation.present->data, NULL);
+ SQArchiveStore *store = SQ_ARCHIVE_STORE(user_data);
+ GList *iter;
+ LSQArchiveIter *aIter;
+
+ for(iter = store->navigation.history; iter; iter = g_list_next(iter))
+ {
+ aIter = lsq_archive_iter_get_real_parent(iter->data);
+ lsq_archive_iter_unref(iter->data);
+ iter->data = aIter;
+ }
+
+ sq_archive_store_sort(store);
+ sq_archive_store_refresh(store);
+ g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, store->navigation.present->data, NULL);
}
LSQArchiveIter *
sq_archive_store_get_archive_iter(SQArchiveStore *store, GtkTreeIter *iter)
{
- LSQArchiveIter *entry = iter->user_data;
- return entry;
+ LSQArchiveIter *entry = iter->user_data;
+ return entry;
}
diff --git a/src/archive_store.h b/src/archive_store.h
index 5fc9b11..7cc5f72 100644
--- a/src/archive_store.h
+++ b/src/archive_store.h
@@ -18,64 +18,64 @@
#define SQ_TYPE_ARCHIVE_STORE sq_archive_store_get_type()
-#define SQ_ARCHIVE_STORE(obj) ( \
- G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- SQ_TYPE_ARCHIVE_STORE, \
- SQArchiveStore))
+#define SQ_ARCHIVE_STORE(obj) ( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ SQ_TYPE_ARCHIVE_STORE, \
+ SQArchiveStore))
-#define SQ_IS_ARCHIVE_STORE(obj) ( \
- G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- SQ_TYPE_ARCHIVE_STORE))
+#define SQ_IS_ARCHIVE_STORE(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ SQ_TYPE_ARCHIVE_STORE))
#define SQ_ARCHIVE_STORE_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_CAST ((class), \
- SQ_TYPE_ARCHIVE_STORE, \
- SQArchiveStoreClass))
+ G_TYPE_CHECK_CLASS_CAST ((class), \
+ SQ_TYPE_ARCHIVE_STORE, \
+ SQArchiveStoreClass))
#define SQ_IS_ARCHIVE_STORE_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_TYPE ((class), \
- SQ_TYPE_ARCHIVE_STORE))
+ G_TYPE_CHECK_CLASS_TYPE ((class), \
+ SQ_TYPE_ARCHIVE_STORE))
typedef struct _SQArchiveStore SQArchiveStore;
struct _SQArchiveStore
{
- GObject parent;
- gint stamp;
- LSQArchive *archive;
- gint sort_column;
- GtkSortType sort_order;
- LSQArchiveIter **sort_list;
- guint list_size;
- GtkIconTheme *icon_theme;
- GtkTreeView *treeview;
- struct {
- guint _show_full_path :1;
- guint _show_icons : 1;
- guint _show_up_dir : 1;
- guint _sort_folders_first : 1;
- guint _sort_case_sensitive : 1;
- } props;
- struct {
- GList *history;
- GList *present;
- guint maxhistory;
- LSQArchiveIter *trailing;
- } navigation;
+ GObject parent;
+ gint stamp;
+ LSQArchive *archive;
+ gint sort_column;
+ GtkSortType sort_order;
+ LSQArchiveIter **sort_list;
+ guint list_size;
+ GtkIconTheme *icon_theme;
+ GtkTreeView *treeview;
+ struct {
+ guint _show_full_path :1;
+ guint _show_icons : 1;
+ guint _show_up_dir : 1;
+ guint _sort_folders_first : 1;
+ guint _sort_case_sensitive : 1;
+ } props;
+ struct {
+ GList *history;
+ GList *present;
+ guint maxhistory;
+ LSQArchiveIter *trailing;
+ } navigation;
};
typedef struct _SQArchiveStoreClass SQArchiveStoreClass;
struct _SQArchiveStoreClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
};
/* archive iter extra props columns */
enum {
- SQ_ARCHIVE_STORE_EXTRA_PROP_PATH = 0,
- SQ_ARCHIVE_STORE_EXTRA_PROP_ICON,
- SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT
+ SQ_ARCHIVE_STORE_EXTRA_PROP_PATH = 0,
+ SQ_ARCHIVE_STORE_EXTRA_PROP_ICON,
+ SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT
};
GType sq_archive_store_get_type();
diff --git a/src/button_drag_box.c b/src/button_drag_box.c
index 6f3ca93..cda9d3c 100644
--- a/src/button_drag_box.c
+++ b/src/button_drag_box.c
@@ -71,335 +71,335 @@ sq_button_drag_box_class_init(SQButtonDragBoxClass *button_drag_box_class)
static void
sq_button_drag_box_init(SQButtonDragBox *box)
{
- GtkWidget *frame;
+ GtkWidget *frame;
- box->locked_buttons = 0;
+ box->locked_buttons = 0;
- box->visible_box = gtk_hbox_new(FALSE, 0);
- box->hidden_box = gtk_hbox_new(FALSE, 0);
+ box->visible_box = gtk_hbox_new(FALSE, 0);
+ box->hidden_box = gtk_hbox_new(FALSE, 0);
- box->entry.target = SQ_DRAG_TARGET_ID;
- box->entry.flags = GTK_TARGET_SAME_APP;
- box->entry.info = 2;
+ box->entry.target = SQ_DRAG_TARGET_ID;
+ box->entry.flags = GTK_TARGET_SAME_APP;
+ box->entry.info = 2;
- frame = gtk_frame_new(_("Visible:"));
+ frame = gtk_frame_new(_("Visible:"));
- gtk_drag_dest_set(frame, GTK_DEST_DEFAULT_ALL, &box->entry, 1, GDK_ACTION_MOVE);
- g_signal_connect(frame, "drag_data_received", G_CALLBACK(cb_sq_visible_data_received), box);
- g_signal_connect(frame, "drag_motion", G_CALLBACK(cb_sq_visible_drag_motion), box);
- g_signal_connect(frame, "drag_leave", G_CALLBACK(cb_sq_visible_drag_leave), box);
+ gtk_drag_dest_set(frame, GTK_DEST_DEFAULT_ALL, &box->entry, 1, GDK_ACTION_MOVE);
+ g_signal_connect(frame, "drag_data_received", G_CALLBACK(cb_sq_visible_data_received), box);
+ g_signal_connect(frame, "drag_motion", G_CALLBACK(cb_sq_visible_drag_motion), box);
+ g_signal_connect(frame, "drag_leave", G_CALLBACK(cb_sq_visible_drag_leave), box);
- gtk_container_set_border_width(GTK_CONTAINER(box->visible_box), 5);
- gtk_container_add(GTK_CONTAINER(frame), box->visible_box);
- gtk_box_pack_start(GTK_BOX(box), frame, FALSE, TRUE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(box->visible_box), 5);
+ gtk_container_add(GTK_CONTAINER(frame), box->visible_box);
+ gtk_box_pack_start(GTK_BOX(box), frame, FALSE, TRUE, 0);
- frame = gtk_frame_new(_("Available:"));
+ frame = gtk_frame_new(_("Available:"));
- gtk_drag_dest_set(frame, GTK_DEST_DEFAULT_ALL, &box->entry, 1, GDK_ACTION_MOVE);
- g_signal_connect(frame, "drag_data_received", G_CALLBACK(cb_sq_hidden_data_received), box);
+ gtk_drag_dest_set(frame, GTK_DEST_DEFAULT_ALL, &box->entry, 1, GDK_ACTION_MOVE);
+ g_signal_connect(frame, "drag_data_received", G_CALLBACK(cb_sq_hidden_data_received), box);
- gtk_container_set_border_width(GTK_CONTAINER(box->hidden_box), 5);
- gtk_container_add(GTK_CONTAINER(frame), box->hidden_box);
- gtk_box_pack_start(GTK_BOX(box), frame, FALSE, TRUE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(box->hidden_box), 5);
+ gtk_container_add(GTK_CONTAINER(frame), box->hidden_box);
+ gtk_box_pack_start(GTK_BOX(box), frame, FALSE, TRUE, 0);
- gtk_box_set_homogeneous(GTK_BOX(box), TRUE);
+ gtk_box_set_homogeneous(GTK_BOX(box), TRUE);
}
GtkWidget *
sq_button_drag_box_new(void)
{
- GtkWidget *box;
+ GtkWidget *box;
- box = g_object_new(SQ_TYPE_BUTTON_DRAG_BOX, NULL);
+ box = g_object_new(SQ_TYPE_BUTTON_DRAG_BOX, NULL);
- return box;
+ return box;
}
void
sq_button_drag_box_add_fixed_button(SQButtonDragBox *box, const gchar *label, gpointer user_data)
{
- GtkWidget *button = gtk_button_new_with_label(label);
+ GtkWidget *button = gtk_button_new_with_label(label);
- g_object_set_data(G_OBJECT(button), SQ_BUTTON_USER_DATA, user_data);
+ g_object_set_data(G_OBJECT(button), SQ_BUTTON_USER_DATA, user_data);
- gtk_box_pack_start(GTK_BOX(box->visible_box), button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(box->visible_box), button, FALSE, FALSE, 0);
- g_signal_connect(G_OBJECT(button), "button_press_event", G_CALLBACK(cb_signal_blocker), NULL);
- g_signal_connect(G_OBJECT(button), "enter_notify_event", G_CALLBACK(cb_signal_blocker), NULL);
- g_signal_connect(G_OBJECT(button), "focus", G_CALLBACK(cb_signal_blocker), NULL);
+ g_signal_connect(G_OBJECT(button), "button_press_event", G_CALLBACK(cb_signal_blocker), NULL);
+ g_signal_connect(G_OBJECT(button), "enter_notify_event", G_CALLBACK(cb_signal_blocker), NULL);
+ g_signal_connect(G_OBJECT(button), "focus", G_CALLBACK(cb_signal_blocker), NULL);
}
void
sq_button_drag_box_add_button(SQButtonDragBox *box, const gchar *label, gboolean visible, gpointer user_data)
{
- GtkWidget *button = gtk_button_new_with_label(label);
+ GtkWidget *button = gtk_button_new_with_label(label);
- g_object_set_data(G_OBJECT(button), SQ_BUTTON_USER_DATA, user_data);
+ g_object_set_data(G_OBJECT(button), SQ_BUTTON_USER_DATA, user_data);
- gtk_box_pack_start(visible?GTK_BOX(box->visible_box):GTK_BOX(box->hidden_box), button, FALSE, FALSE, 0);
+ gtk_box_pack_start(visible?GTK_BOX(box->visible_box):GTK_BOX(box->hidden_box), button, FALSE, FALSE, 0);
- gtk_drag_source_set(button, GDK_BUTTON1_MASK, &box->entry, 1, GDK_ACTION_MOVE);
- g_signal_connect(G_OBJECT(button), "drag_data_get", G_CALLBACK(cb_sq_button_data_get), NULL);
- g_signal_connect(G_OBJECT(button), "drag_begin", G_CALLBACK(cb_sq_button_drag_begin), NULL);
- g_signal_connect(G_OBJECT(button), "drag_end", G_CALLBACK(cb_sq_button_drag_end), NULL);
- g_signal_connect(G_OBJECT(button), "button_press_event", G_CALLBACK(cb_signal_blocker), NULL);
- g_signal_connect(G_OBJECT(button), "enter_notify_event", G_CALLBACK(cb_signal_blocker), NULL);
- g_signal_connect(G_OBJECT(button), "focus", G_CALLBACK(cb_signal_blocker), NULL);
+ gtk_drag_source_set(button, GDK_BUTTON1_MASK, &box->entry, 1, GDK_ACTION_MOVE);
+ g_signal_connect(G_OBJECT(button), "drag_data_get", G_CALLBACK(cb_sq_button_data_get), NULL);
+ g_signal_connect(G_OBJECT(button), "drag_begin", G_CALLBACK(cb_sq_button_drag_begin), NULL);
+ g_signal_connect(G_OBJECT(button), "drag_end", G_CALLBACK(cb_sq_button_drag_end), NULL);
+ g_signal_connect(G_OBJECT(button), "button_press_event", G_CALLBACK(cb_signal_blocker), NULL);
+ g_signal_connect(G_OBJECT(button), "enter_notify_event", G_CALLBACK(cb_signal_blocker), NULL);
+ g_signal_connect(G_OBJECT(button), "focus", G_CALLBACK(cb_signal_blocker), NULL);
}
void
sq_button_drag_box_lock_buttons(SQButtonDragBox *box, guint buttons)
{
- box->locked_buttons = buttons;
+ box->locked_buttons = buttons;
}
GSList *
sq_button_drag_box_get_visible(SQButtonDragBox *box)
{
- GList *iter, *children = iter = gtk_container_get_children(GTK_CONTAINER(box->visible_box));
- GSList *list = NULL;
+ GList *iter, *children = iter = gtk_container_get_children(GTK_CONTAINER(box->visible_box));
+ GSList *list = NULL;
- while(iter)
- {
- if(GTK_WIDGET_VISIBLE(iter->data))
- {
- list = g_slist_append(list, g_object_get_data(G_OBJECT(iter->data), SQ_BUTTON_USER_DATA));
- }
+ while(iter)
+ {
+ if(GTK_WIDGET_VISIBLE(iter->data))
+ {
+ list = g_slist_append(list, g_object_get_data(G_OBJECT(iter->data), SQ_BUTTON_USER_DATA));
+ }
- iter = g_list_next(iter);
- }
+ iter = g_list_next(iter);
+ }
- g_list_free(children);
+ g_list_free(children);
- return list;
+ return list;
}
GSList *
sq_button_drag_box_get_hidden(SQButtonDragBox *box)
{
- GList *iter, *children = iter = gtk_container_get_children(GTK_CONTAINER(box->hidden_box));
- GSList *list = NULL;
+ GList *iter, *children = iter = gtk_container_get_children(GTK_CONTAINER(box->hidden_box));
+ GSList *list = NULL;
- while(iter)
- {
- if(GTK_WIDGET_VISIBLE(iter->data))
- {
- list = g_slist_append(list, g_object_get_data(G_OBJECT(iter->data), SQ_BUTTON_USER_DATA));
- }
+ while(iter)
+ {
+ if(GTK_WIDGET_VISIBLE(iter->data))
+ {
+ list = g_slist_append(list, g_object_get_data(G_OBJECT(iter->data), SQ_BUTTON_USER_DATA));
+ }
- iter = g_list_next(iter);
- }
+ iter = g_list_next(iter);
+ }
- g_list_free(children);
+ g_list_free(children);
- return list;
+ return list;
}
static GdkPixbuf*
sq_create_icon_from_widget(GtkWidget *widget)
{
- GdkWindow *drawable = GDK_DRAWABLE(gtk_widget_get_parent_window(widget));
- return gdk_pixbuf_get_from_drawable(NULL, drawable, NULL, widget->allocation.x, widget->allocation.y, 0, 0, widget->allocation.width, widget->allocation.height);
+ GdkWindow *drawable = GDK_DRAWABLE(gtk_widget_get_parent_window(widget));
+ return gdk_pixbuf_get_from_drawable(NULL, drawable, NULL, widget->allocation.x, widget->allocation.y, 0, 0, widget->allocation.width, widget->allocation.height);
}
static void
sq_create_indicator(SQButtonDragBox *box, gint x, gint y, gint width, gint height)
{
- gint attr_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_COLORMAP | GDK_WA_VISUAL;
- GdkWindowAttr attributes = {
- NULL,
- 0,
- x, y,
- width, height,
- GDK_INPUT_OUTPUT,
- gtk_widget_get_visual(box->visible_box),
- gtk_widget_get_colormap(box->visible_box),
- GDK_WINDOW_CHILD,
- NULL, NULL, NULL, FALSE
- };
-
- sq_delete_indicator(box);
-
- box->indicator = gdk_window_new(gtk_widget_get_parent_window(box->visible_box), &attributes, attr_mask);
- gdk_window_set_user_data(box->indicator, box->visible_box);
-
- GdkPoint points[9];
- points[0].x = 0;
- points[0].y = 0;
- points[1].x = width;
- points[1].y = 0;
- points[2].x = width/2+1;
- points[2].y = width/2;
- points[3].x = width/2+1;
- points[3].y = height-1-width/2;
- points[4].x = width;
- points[4].y = height;
- points[5].x = 0;
- points[5].y = height-1;
- points[6].x = width/2;
- points[6].y = height-1-width/2;
- points[7].x = width/2;
- points[7].y = width/2;
- points[8].x = 0;
- points[8].y = 0;
- GdkRegion *shape = gdk_region_polygon(points, 9, GDK_WINDING_RULE);
-
- gdk_window_shape_combine_region(box->indicator, shape, 0, 0);
-
- gdk_window_show(box->indicator);
- gdk_window_raise(box->indicator);
+ gint attr_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_COLORMAP | GDK_WA_VISUAL;
+ GdkWindowAttr attributes = {
+ NULL,
+ 0,
+ x, y,
+ width, height,
+ GDK_INPUT_OUTPUT,
+ gtk_widget_get_visual(box->visible_box),
+ gtk_widget_get_colormap(box->visible_box),
+ GDK_WINDOW_CHILD,
+ NULL, NULL, NULL, FALSE
+ };
+
+ sq_delete_indicator(box);
+
+ box->indicator = gdk_window_new(gtk_widget_get_parent_window(box->visible_box), &attributes, attr_mask);
+ gdk_window_set_user_data(box->indicator, box->visible_box);
+
+ GdkPoint points[9];
+ points[0].x = 0;
+ points[0].y = 0;
+ points[1].x = width;
+ points[1].y = 0;
+ points[2].x = width/2+1;
+ points[2].y = width/2;
+ points[3].x = width/2+1;
+ points[3].y = height-1-width/2;
+ points[4].x = width;
+ points[4].y = height;
+ points[5].x = 0;
+ points[5].y = height-1;
+ points[6].x = width/2;
+ points[6].y = height-1-width/2;
+ points[7].x = width/2;
+ points[7].y = width/2;
+ points[8].x = 0;
+ points[8].y = 0;
+ GdkRegion *shape = gdk_region_polygon(points, 9, GDK_WINDING_RULE);
+
+ gdk_window_shape_combine_region(box->indicator, shape, 0, 0);
+
+ gdk_window_show(box->indicator);
+ gdk_window_raise(box->indicator);
}
static void
sq_delete_indicator(SQButtonDragBox *box)
{
- if(box->indicator)
- {
- gdk_window_destroy(box->indicator);
- box->indicator = NULL;
- }
+ if(box->indicator)
+ {
+ gdk_window_destroy(box->indicator);
+ box->indicator = NULL;
+ }
}
static gboolean
cb_signal_blocker(GtkWidget *widget, gpointer user_data)
{
- return TRUE;
+ return TRUE;
}
static void
cb_sq_button_data_get(GtkWidget *widget, GdkDragContext *context, GtkSelectionData *data, guint info, guint time, gpointer user_data)
{
- gtk_widget_hide(widget);
- gtk_selection_data_set(data, gdk_atom_intern(SQ_DRAG_TARGET_ID, FALSE), 8, NULL, 0);
+ gtk_widget_hide(widget);
+ gtk_selection_data_set(data, gdk_atom_intern(SQ_DRAG_TARGET_ID, FALSE), 8, NULL, 0);
}
static void
cb_sq_button_drag_begin(GtkWidget *widget, GdkDragContext *context, gpointer user_data)
{
- GdkPixbuf *pixbuf = sq_create_icon_from_widget(widget);
+ GdkPixbuf *pixbuf = sq_create_icon_from_widget(widget);
- gtk_drag_source_set_icon_pixbuf(widget, pixbuf);
- g_object_unref(G_OBJECT(pixbuf));
- gtk_widget_hide(widget);
+ gtk_drag_source_set_icon_pixbuf(widget, pixbuf);
+ g_object_unref(G_OBJECT(pixbuf));
+ gtk_widget_hide(widget);
}
static void
cb_sq_button_drag_end(GtkWidget *widget, GdkDragContext *context, gpointer user_data)
{
- gtk_widget_show(widget);
+ gtk_widget_show(widget);
}
static void
cb_sq_visible_data_received(GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint infom, guint time, gpointer user_data)
{
- SQButtonDragBox *box = SQ_BUTTON_DRAG_BOX(user_data);
+ SQButtonDragBox *box = SQ_BUTTON_DRAG_BOX(user_data);
- GtkWidget *source = gtk_drag_get_source_widget(context);
- GtkWidget *parent = gtk_widget_get_parent(source);
+ GtkWidget *source = gtk_drag_get_source_widget(context);
+ GtkWidget *parent = gtk_widget_get_parent(source);
- gtk_widget_ref(source);
- gtk_container_remove(GTK_CONTAINER(parent), source);
- gtk_box_pack_start(GTK_BOX(box->visible_box), source, FALSE, FALSE, 0);
- gtk_widget_unref(source);
+ gtk_widget_ref(source);
+ gtk_container_remove(GTK_CONTAINER(parent), source);
+ gtk_box_pack_start(GTK_BOX(box->visible_box), source, FALSE, FALSE, 0);
+ gtk_widget_unref(source);
- guint button = 0;
- gint xoffset = box->visible_box->allocation.x;
- GtkWidget *item;
+ guint button = 0;
+ gint xoffset = box->visible_box->allocation.x;
+ GtkWidget *item;
- GList *iter, *children = iter = gtk_container_get_children(GTK_CONTAINER(box->visible_box));
+ GList *iter, *children = iter = gtk_container_get_children(GTK_CONTAINER(box->visible_box));
- gint i = 0;
+ gint i = 0;
- while(iter)
- {
- item = GTK_WIDGET(iter->data);
+ while(iter)
+ {
+ item = GTK_WIDGET(iter->data);
- if(GTK_WIDGET_VISIBLE(item))
- {
- button++;
- if((box->locked_buttons < button) && (x < (item->allocation.width/2 + item->allocation.x - xoffset)))
- {
- break;
- }
- }
- i++;
- iter = g_list_next(iter);
- }
+ if(GTK_WIDGET_VISIBLE(item))
+ {
+ button++;
+ if((box->locked_buttons < button) && (x < (item->allocation.width/2 + item->allocation.x - xoffset)))
+ {
+ break;
+ }
+ }
+ i++;
+ iter = g_list_next(iter);
+ }
- g_list_free(children);
+ g_list_free(children);
- gtk_box_reorder_child(GTK_BOX(box->visible_box), source, i);
+ gtk_box_reorder_child(GTK_BOX(box->visible_box), source, i);
}
static gboolean
cb_sq_visible_drag_motion(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data)
{
- SQButtonDragBox *box = SQ_BUTTON_DRAG_BOX(user_data);
-
- guint button = 0;
- gint ix, iy;
- gint xoffset = box->visible_box->allocation.x;
- GtkWidget *item;
-
- GList *iter, *children = iter = gtk_container_get_children(GTK_CONTAINER(box->visible_box));
-
- ix = xoffset + gtk_container_get_border_width(GTK_CONTAINER(box->visible_box));
-
- while(iter)
- {
- item = GTK_WIDGET(iter->data);
-
- if(GTK_WIDGET_VISIBLE(item))
- {
- button++;
- if((box->locked_buttons < button) && (x < (item->allocation.width/2 + item->allocation.x - xoffset)))
- {
- ix = item->allocation.x;
- break;
- }
- ix = item->allocation.x + item->allocation.width;
- }
- iter = g_list_next(iter);
- }
-
- g_list_free(children);
-
- ix -= SQ_INDICATOR_SIZE/2 + 1;
- iy = box->visible_box->allocation.y - SQ_INDICATOR_SIZE/2 + gtk_container_get_border_width(GTK_CONTAINER(box->visible_box));
-
- if(!box->indicator)
- {
- sq_create_indicator(box, ix, iy, SQ_INDICATOR_SIZE, box->visible_box->allocation.height + SQ_INDICATOR_SIZE - gtk_container_get_border_width(GTK_CONTAINER(box->visible_box))*2);
- }
- else
- {
- gdk_window_move(box->indicator, ix, iy);
- }
-
- return FALSE;
+ SQButtonDragBox *box = SQ_BUTTON_DRAG_BOX(user_data);
+
+ guint button = 0;
+ gint ix, iy;
+ gint xoffset = box->visible_box->allocation.x;
+ GtkWidget *item;
+
+ GList *iter, *children = iter = gtk_container_get_children(GTK_CONTAINER(box->visible_box));
+
+ ix = xoffset + gtk_container_get_border_width(GTK_CONTAINER(box->visible_box));
+
+ while(iter)
+ {
+ item = GTK_WIDGET(iter->data);
+
+ if(GTK_WIDGET_VISIBLE(item))
+ {
+ button++;
+ if((box->locked_buttons < button) && (x < (item->allocation.width/2 + item->allocation.x - xoffset)))
+ {
+ ix = item->allocation.x;
+ break;
+ }
+ ix = item->allocation.x + item->allocation.width;
+ }
+ iter = g_list_next(iter);
+ }
+
+ g_list_free(children);
+
+ ix -= SQ_INDICATOR_SIZE/2 + 1;
+ iy = box->visible_box->allocation.y - SQ_INDICATOR_SIZE/2 + gtk_container_get_border_width(GTK_CONTAINER(box->visible_box));
+
+ if(!box->indicator)
+ {
+ sq_create_indicator(box, ix, iy, SQ_INDICATOR_SIZE, box->visible_box->allocation.height + SQ_INDICATOR_SIZE - gtk_container_get_border_width(GTK_CONTAINER(box->visible_box))*2);
+ }
+ else
+ {
+ gdk_window_move(box->indicator, ix, iy);
+ }
+
+ return FALSE;
}
static void
cb_sq_visible_drag_leave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer user_data)
{
- sq_delete_indicator(SQ_BUTTON_DRAG_BOX(user_data));
+ sq_delete_indicator(SQ_BUTTON_DRAG_BOX(user_data));
}
static void
cb_sq_hidden_data_received(GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint infom, guint time, gpointer user_data)
{
- GtkWidget *source = gtk_drag_get_source_widget(context);
- GtkWidget *parent = gtk_widget_get_parent(source);
-
- /* if the item was dragged back to the location it already was */
- if(parent == SQ_BUTTON_DRAG_BOX(user_data)->hidden_box)
- {
- return;
- }
-
- gtk_widget_ref(source);
- gtk_container_remove(GTK_CONTAINER(parent), source);
- gtk_box_pack_start(GTK_BOX(SQ_BUTTON_DRAG_BOX(user_data)->hidden_box), source, FALSE, FALSE, 0);
- gtk_widget_unref(source);
+ GtkWidget *source = gtk_drag_get_source_widget(context);
+ GtkWidget *parent = gtk_widget_get_parent(source);
+
+ /* if the item was dragged back to the location it already was */
+ if(parent == SQ_BUTTON_DRAG_BOX(user_data)->hidden_box)
+ {
+ return;
+ }
+
+ gtk_widget_ref(source);
+ gtk_container_remove(GTK_CONTAINER(parent), source);
+ gtk_box_pack_start(GTK_BOX(SQ_BUTTON_DRAG_BOX(user_data)->hidden_box), source, FALSE, FALSE, 0);
+ gtk_widget_unref(source);
}
diff --git a/src/button_drag_box.h b/src/button_drag_box.h
index c6dd02d..c697ff5 100644
--- a/src/button_drag_box.h
+++ b/src/button_drag_box.h
@@ -22,52 +22,52 @@ G_BEGIN_DECLS
#define SQ_TYPE_BUTTON_DRAG_BOX sq_button_drag_box_get_type()
-#define SQ_BUTTON_DRAG_BOX(obj)( \
- G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- SQ_TYPE_BUTTON_DRAG_BOX, \
- SQButtonDragBox))
+#define SQ_BUTTON_DRAG_BOX(obj)( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ SQ_TYPE_BUTTON_DRAG_BOX, \
+ SQButtonDragBox))
-#define SQ_IS_BUTTON_DRAG_BOX(obj) ( \
- G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- SQ_TYPE_BUTTON_DRAG_BOX))
+#define SQ_IS_BUTTON_DRAG_BOX(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ SQ_TYPE_BUTTON_DRAG_BOX))
#define SQ_BUTTON_DRAG_BOX_CLASS(klass) ( \
- G_TYPE_CHECK_CLASS_CAST ((klass), \
- SQ_TYPE_BUTTON_DRAG_BOX, \
- SQButtonDragBoxClass))
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ SQ_TYPE_BUTTON_DRAG_BOX, \
+ SQButtonDragBoxClass))
#define SQ_IS_BUTTON_DRAG_BOX_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_TYPE ((class), \
- SQ_TYPE_BUTTON_DRAG_BOX()))
+ G_TYPE_CHECK_CLASS_TYPE ((class), \
+ SQ_TYPE_BUTTON_DRAG_BOX()))
typedef struct _SQButtonDragBox SQButtonDragBox;
struct _SQButtonDragBox
{
- GtkVBox parent;
- GtkWidget *visible_box;
- GtkWidget *hidden_box;
- GtkTargetEntry entry;
- GdkWindow *indicator;
- guint locked_buttons;
+ GtkVBox parent;
+ GtkWidget *visible_box;
+ GtkWidget *hidden_box;
+ GtkTargetEntry entry;
+ GdkWindow *indicator;
+ guint locked_buttons;
};
typedef struct _SQButtonDragBoxClass SQButtonDragBoxClass;
struct _SQButtonDragBoxClass
{
- GtkVBoxClass parent_class;
+ GtkVBoxClass parent_class;
};
-GType sq_button_drag_box_get_type();
+GType sq_button_drag_box_get_type();
GtkWidget *sq_button_drag_box_new();
-void sq_button_drag_box_lock_buttons(SQButtonDragBox *box, guint buttons);
-void sq_button_drag_box_add_fixed_button(SQButtonDragBox *box, const gchar *label, gpointer user_data);
-void sq_button_drag_box_add_button(SQButtonDragBox *box, const gchar *label, gboolean visible, gpointer user_data);
+void sq_button_drag_box_lock_buttons(SQButtonDragBox *box, guint buttons);
+void sq_button_drag_box_add_fixed_button(SQButtonDragBox *box, const gchar *label, gpointer user_data);
+void sq_button_drag_box_add_button(SQButtonDragBox *box, const gchar *label, gboolean visible, gpointer user_data);
-GSList *sq_button_drag_box_get_visible(SQButtonDragBox *box);
-GSList *sq_button_drag_box_get_hidden(SQButtonDragBox *box);
+GSList *sq_button_drag_box_get_visible(SQButtonDragBox *box);
+GSList *sq_button_drag_box_get_hidden(SQButtonDragBox *box);
G_END_DECLS
#endif /* __SQRCHIVER_BUTTON_DRAG_BOX_H__*/
diff --git a/src/extract_dialog.c b/src/extract_dialog.c
index c511252..19e9c0e 100644
--- a/src/extract_dialog.c
+++ b/src/extract_dialog.c
@@ -14,7 +14,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
- TODO: Fix props
+ TODO: Fix props
*/
#include <config.h>
@@ -40,27 +40,27 @@ sq_extract_dialog_option_child_notify(GtkWidget *widget, GParamSpec *, gpointer
GType
sq_extract_archive_dialog_get_type (void)
{
- static GType sq_extract_archive_dialog_type = 0;
-
- if (!sq_extract_archive_dialog_type)
- {
- static const GTypeInfo sq_extract_archive_dialog_info =
- {
- sizeof (SQExtractArchiveDialogClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) sq_extract_archive_dialog_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (SQExtractArchiveDialog),
- 0,
- (GInstanceInitFunc) sq_extract_archive_dialog_init,
- NULL
- };
-
- sq_extract_archive_dialog_type = g_type_register_static (GTK_TYPE_FILE_CHOOSER_DIALOG, "SQExtractArchiveDialog", &sq_extract_archive_dialog_info, 0);
- }
- return sq_extract_archive_dialog_type;
+ static GType sq_extract_archive_dialog_type = 0;
+
+ if (!sq_extract_archive_dialog_type)
+ {
+ static const GTypeInfo sq_extract_archive_dialog_info =
+ {
+ sizeof (SQExtractArchiveDialogClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) sq_extract_archive_dialog_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (SQExtractArchiveDialog),
+ 0,
+ (GInstanceInitFunc) sq_extract_archive_dialog_init,
+ NULL
+ };
+
+ sq_extract_archive_dialog_type = g_type_register_static (GTK_TYPE_FILE_CHOOSER_DIALOG, "SQExtractArchiveDialog", &sq_extract_archive_dialog_info, 0);
+ }
+ return sq_extract_archive_dialog_type;
}
static void
@@ -71,52 +71,52 @@ sq_extract_archive_dialog_class_init(SQExtractArchiveDialogClass *dialog_class)
static void
sq_extract_archive_dialog_init(SQExtractArchiveDialog *dialog)
{
- GtkWidget *hbox = gtk_hbox_new(TRUE, 5);
- GtkWidget *l_label = gtk_label_new(_("<b>Extract files:</b>"));
- GtkWidget *r_label = gtk_label_new(_("<b>Options:</b>"));
- GtkWidget *l_vbox;
- gtk_label_set_use_markup(GTK_LABEL(l_label), TRUE);
- gtk_label_set_use_markup(GTK_LABEL(r_label), TRUE);
-
- l_vbox = gtk_vbox_new(FALSE, 0);
-
- dialog->l_frame = gtk_frame_new( NULL );
- gtk_frame_set_label_widget(GTK_FRAME(dialog->l_frame), l_label);
- gtk_box_pack_start(GTK_BOX(hbox), dialog->l_frame, TRUE, TRUE, 0);
- gtk_container_add(GTK_CONTAINER(dialog->l_frame), l_vbox);
- dialog->all_files_radio = gtk_radio_button_new_with_mnemonic (NULL, _("All files"));
- dialog->sel_files_radio = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON(dialog->all_files_radio), _("Selected files"));
-
- gtk_box_pack_start(GTK_BOX(l_vbox), dialog->all_files_radio, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(l_vbox), dialog->sel_files_radio, FALSE, FALSE, 0);
-
- dialog->r_frame = gtk_frame_new( NULL );
- gtk_frame_set_label_widget(GTK_FRAME(dialog->r_frame), r_label);
- gtk_box_pack_start(GTK_BOX(hbox), dialog->r_frame, TRUE, TRUE, 0);
-
- gtk_box_pack_end(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0);
- gtk_dialog_add_buttons(GTK_DIALOG(dialog),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- _("Extract"), GTK_RESPONSE_OK,
- NULL);
- gtk_widget_show_all(hbox);
+ GtkWidget *hbox = gtk_hbox_new(TRUE, 5);
+ GtkWidget *l_label = gtk_label_new(_("<b>Extract files:</b>"));
+ GtkWidget *r_label = gtk_label_new(_("<b>Options:</b>"));
+ GtkWidget *l_vbox;
+ gtk_label_set_use_markup(GTK_LABEL(l_label), TRUE);
+ gtk_label_set_use_markup(GTK_LABEL(r_label), TRUE);
+
+ l_vbox = gtk_vbox_new(FALSE, 0);
+
+ dialog->l_frame = gtk_frame_new( NULL );
+ gtk_frame_set_label_widget(GTK_FRAME(dialog->l_frame), l_label);
+ gtk_box_pack_start(GTK_BOX(hbox), dialog->l_frame, TRUE, TRUE, 0);
+ gtk_container_add(GTK_CONTAINER(dialog->l_frame), l_vbox);
+ dialog->all_files_radio = gtk_radio_button_new_with_mnemonic (NULL, _("All files"));
+ dialog->sel_files_radio = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON(dialog->all_files_radio), _("Selected files"));
+
+ gtk_box_pack_start(GTK_BOX(l_vbox), dialog->all_files_radio, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(l_vbox), dialog->sel_files_radio, FALSE, FALSE, 0);
+
+ dialog->r_frame = gtk_frame_new( NULL );
+ gtk_frame_set_label_widget(GTK_FRAME(dialog->r_frame), r_label);
+ gtk_box_pack_start(GTK_BOX(hbox), dialog->r_frame, TRUE, TRUE, 0);
+
+ gtk_box_pack_end(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0);
+ gtk_dialog_add_buttons(GTK_DIALOG(dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ _("Extract"), GTK_RESPONSE_OK,
+ NULL);
+ gtk_widget_show_all(hbox);
}
GtkWidget *
sq_extract_archive_dialog_new(LSQArchive *archive, gboolean sel_option)
{
- SQExtractArchiveDialog *dialog;
- GtkWidget *r_vbox;
- gchar *filename;
- gchar **filename_components;
+ SQExtractArchiveDialog *dialog;
+ GtkWidget *r_vbox;
+ gchar *filename;
+ gchar **filename_components;
- dialog = g_object_new(sq_extract_archive_dialog_get_type(), "title", _("Extract archive"), "action", GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER, "do-overwrite-confirmation", TRUE, NULL);
+ dialog = g_object_new(sq_extract_archive_dialog_get_type(), "title", _("Extract archive"), "action", GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER, "do-overwrite-confirmation", TRUE, NULL);
/* Handle 'extract selected files' option */
- gtk_widget_set_sensitive(dialog->sel_files_radio, sel_option);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->sel_files_radio), sel_option);
+ gtk_widget_set_sensitive(dialog->sel_files_radio, sel_option);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->sel_files_radio), sel_option);
- r_vbox = gtk_vbox_new(FALSE, 0);
- gtk_container_add(GTK_CONTAINER(dialog->r_frame), r_vbox);
+ r_vbox = gtk_vbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(dialog->r_frame), r_vbox);
if((dialog->command_options = lsq_archive_get_command_options(archive, LSQ_COMMAND_TYPE_EXTRACT)))
{
@@ -129,37 +129,37 @@ sq_extract_archive_dialog_new(LSQArchive *archive, gboolean sel_option)
}
}
- /* FIXME, does not work correctly when there are more dots in a filename then the one identifying the extention */
- filename = lsq_archive_get_filename(archive);
- filename_components = g_strsplit(filename, ".", 2);
- g_free(filename);
- gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename_components[0]);
- g_strfreev(filename_components);
+ /* FIXME, does not work correctly when there are more dots in a filename then the one identifying the extention */
+ filename = lsq_archive_get_filename(archive);
+ filename_components = g_strsplit(filename, ".", 2);
+ g_free(filename);
+ gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename_components[0]);
+ g_strfreev(filename_components);
- gtk_widget_show_all(r_vbox);
- return GTK_WIDGET(dialog);
+ gtk_widget_show_all(r_vbox);
+ return GTK_WIDGET(dialog);
}
void
sq_extract_dialog_option_toggled (GtkWidget *widget, gpointer data)
{
- GValue *val = g_new0(GValue, 1);
+ GValue *val = g_new0(GValue, 1);
- val = g_value_init(val, G_TYPE_BOOLEAN);
+ val = g_value_init(val, G_TYPE_BOOLEAN);
- g_value_set_boolean(val, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
+ g_value_set_boolean(val, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
- g_free(val);
+ g_free(val);
}
void
sq_extract_dialog_option_child_notify (GtkWidget *widget, GParamSpec *pspec, gpointer data)
{
- GValue *val = g_new0(GValue, 1);
- if(strcmp(g_param_spec_get_name(pspec), "text"))
- {
- val = g_value_init(val, G_TYPE_STRING);
- g_object_get_property(G_OBJECT(widget), "text", val);
- }
- g_free(val);
+ GValue *val = g_new0(GValue, 1);
+ if(strcmp(g_param_spec_get_name(pspec), "text"))
+ {
+ val = g_value_init(val, G_TYPE_STRING);
+ g_object_get_property(G_OBJECT(widget), "text", val);
+ }
+ g_free(val);
}
diff --git a/src/extract_dialog.h b/src/extract_dialog.h
index eb99311..c3d58fc 100644
--- a/src/extract_dialog.h
+++ b/src/extract_dialog.h
@@ -18,34 +18,34 @@
#define __SQRCHIVER_EXTRACT_ARCHIVE_DIALOG_H__
G_BEGIN_DECLS
-#define SQ_EXTRACT_ARCHIVE_DIALOG(obj) ( \
- G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- sq_extract_archive_dialog_get_type(), \
- SQExtractArchiveDialog))
+#define SQ_EXTRACT_ARCHIVE_DIALOG(obj) ( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ sq_extract_archive_dialog_get_type(), \
+ SQExtractArchiveDialog))
-#define SQ_IS_EXTRACT_ARCHIVE_DIALOG(obj) ( \
- G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- sq_extract_archive_dialog_get_type()))
+#define SQ_IS_EXTRACT_ARCHIVE_DIALOG(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ sq_extract_archive_dialog_get_type()))
#define SQ_EXTRACT_ARCHIVE_DIALOG_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_CAST ((class), \
- sq_extract_archive_dialog_get_type(), \
- SQExtractArchiveDialogClass))
+ G_TYPE_CHECK_CLASS_CAST ((class), \
+ sq_extract_archive_dialog_get_type(), \
+ SQExtractArchiveDialogClass))
#define SQ_IS_EXTRACT_ARCHIVE_DIALOG_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_TYPE ((class), \
- sq_extract_archive_dialog_get_type()))
+ G_TYPE_CHECK_CLASS_TYPE ((class), \
+ sq_extract_archive_dialog_get_type()))
typedef struct _SQExtractArchiveDialog SQExtractArchiveDialog;
struct _SQExtractArchiveDialog
{
- GtkFileChooserDialog parent;
- GtkWidget *l_frame;
- GtkWidget *r_frame;
- GtkWidget *all_files_radio;
- GtkWidget *sel_files_radio;
- LSQArchive *archive;
+ GtkFileChooserDialog parent;
+ GtkWidget *l_frame;
+ GtkWidget *r_frame;
+ GtkWidget *all_files_radio;
+ GtkWidget *sel_files_radio;
+ LSQArchive *archive;
LSQCommandOptionPair **command_options;
};
@@ -53,10 +53,10 @@ typedef struct _SQExtractArchiveDialogClass SQExtractArchiveDialogClass;
struct _SQExtractArchiveDialogClass
{
- GtkFileChooserDialogClass parent_class;
+ GtkFileChooserDialogClass parent_class;
};
-GType sq_extract_archive_dialog_get_type();
+GType sq_extract_archive_dialog_get_type();
GtkWidget *sq_extract_archive_dialog_new(LSQArchive *, gboolean);
G_END_DECLS
diff --git a/src/main.c b/src/main.c
index 6c44f84..ad0da7f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -20,6 +20,7 @@
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
+#include <xfconf/xfconf.h>
#include <libxfce4util/libxfce4util.h>
#include <libsqueeze/libsqueeze.h>
@@ -27,7 +28,6 @@
#include "settings.h"
#include "archive_store.h"
#include "navigation_bar.h"
-#include "application.h"
#include "main_window.h"
#include "main.h"
@@ -44,6 +44,7 @@ gpointer command;
gint opened_archives = 0;
+
static GOptionEntry entries[] =
{
{ "extract-to", 'x', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &extract_archive_path,
@@ -69,23 +70,19 @@ static GOptionEntry entries[] =
{ NULL }
};
-#if 0
-void
-cb_main_window_destroy(SQMainWindow *window, gpointer data)
+static void
+cb_main_window_destroy ( SQMainWindow *window, gpointer data)
{
gtk_main_quit();
}
-#endif
int main(int argc, char **argv)
{
- GtkWidget *main_window = NULL;
GtkIconTheme *sq_icon_theme;
- SQApplication *sq_app = NULL;
+ GtkWidget *main_window = NULL;
GError *cli_error = NULL;
gint i = 0;
GFile *file = NULL;
- gchar *current_dir;
#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
@@ -102,16 +99,17 @@ int main(int argc, char **argv)
return 1;
}
}
- current_dir = g_get_current_dir();
+ xfconf_init(NULL);
lsq_init();
sq_icon_theme = gtk_icon_theme_get_default();
- sq_app = sq_application_new(sq_icon_theme);
+ main_window = sq_main_window_new ();
gtk_window_set_default_icon_name("squeeze");
- g_signal_connect(G_OBJECT(sq_app), "destroy", G_CALLBACK(gtk_main_quit), NULL);
+ g_signal_connect(
+ G_OBJECT(main_window), "destroy", G_CALLBACK(cb_main_window_destroy), NULL);
if(version)
{
@@ -119,102 +117,12 @@ int main(int argc, char **argv)
return 0;
}
+ gtk_widget_show_all (GTK_WIDGET(main_window));
- if(extract_archive_path || extract_archive)
- {
- gint err = 0;
- if(argc == 1)
- {
- return 1;
- }
- for(i = 1; i < argc; i++)
- {
- file = g_file_new_for_path(argv[i]);
- if (file)
- {
- if(sq_application_extract_archive(sq_app, file, extract_archive_path))
- err++;
- g_object_unref(file);
- }
- }
- if(err)
- return 1;
- }
- if(new_archive || add_archive_path)
- {
- GSList *files = NULL;
-
- /*
- * Remove prefix if it is the pwd
- */
- for(i = 1; i < argc; i++)
- {
- gchar *filename;
- if(g_str_has_prefix(argv[i], current_dir))
- {
- filename = g_strdup(&(argv[i][strlen(current_dir)+1]));
- }
- else
- {
- filename = g_strdup(argv[i]);
- }
- files = g_slist_prepend(files, filename);
- }
-
- /*
- * Remove prefix if it is the pwd
- */
- if(new_archive)
- {
- gchar *filename;
- if(g_str_has_prefix(new_archive, current_dir))
- {
- filename = g_strdup(&(new_archive[strlen(current_dir)+1]));
- }
- else
- {
- filename = g_strdup(new_archive);
- }
- files = g_slist_prepend(files, filename);
- }
-
- if(sq_application_new_archive(sq_app, file, files))
- return 1;
- }
-
- if(!new_archive && !add_archive_path && !extract_archive && !extract_archive_path)
- {
- if(argc > 1)
- {
- if(sq_app->props._tabs)
- main_window = sq_application_new_window(sq_app);
- for(i = 1; i < argc; i++)
- {
- file = g_file_new_for_path (argv[i]);
- if (file)
- {
- sq_application_open_archive(sq_app, main_window, file);
- }
- }
- }
- else
- {
- main_window = sq_application_new_window(sq_app);
- gtk_widget_show_all (GTK_WIDGET(main_window));
- }
- }
-
-
- g_signal_connect (
- G_OBJECT(main_window),
- "destroy",
- G_CALLBACK ( gtk_main_quit ),
- NULL);
-
-
- g_object_unref(sq_app);
gtk_main();
lsq_shutdown();
+ xfconf_shutdown();
+
return 0;
}
diff --git a/src/main_window.c b/src/main_window.c
index f3eac3e..601b585 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -24,11 +24,11 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <gio/gio.h>
+#include <dbus/dbus-glib.h>
#include <libxfce4util/libxfce4util.h>
#include <libsqueeze/libsqueeze.h>
#include "settings.h"
-#include "application.h"
#include "main_window.h"
#include "main_window_ui.h"
@@ -36,11 +36,14 @@
struct _SQMainWindowPriv {
SQSettings *settings;
- SQApplication *app;
+ LSQArchive *archive;
+
+ DBusGConnection *connection;
+ DBusGProxy *filemanager_proxy;
- GtkIconTheme *icon_theme;
GtkUIManager *ui_manager;
GtkActionGroup *action_group;
+ GtkIconTheme *icon_theme;
GtkWidget *menubar;
GtkWidget *toolbar;
@@ -50,6 +53,8 @@ struct _SQMainWindowPriv {
GtkWidget *statusbar;
guint statusbar_context_id;
+
+ gint save_geometry_timer_id;
};
static void
@@ -73,15 +78,41 @@ sq_main_window_get_property (
static void
sq_main_window_dispose ( GObject *object );
-static void
-cb_archive_refreshed (
- LSQArchive *archive,
- gpointer user_data);
+static gboolean
+sq_main_window_configure_event (
+ GtkWidget *widget,
+ GdkEventConfigure *event );
+
+static gboolean
+sq_save_geometry_timer ( gpointer user_data );
static void
-cb_window_quit (
+cb_archive_new (
+ GtkWidget *widget,
+ gpointer user_data );
+static void
+cb_archive_open (
+ GtkWidget *widget,
+ gpointer user_data );
+static void
+cb_archive_properties (
+ GtkWidget *widget,
+ gpointer user_data );
+static void
+cb_archive_close (
GtkWidget *widget,
+ gpointer user_data );
+static void
+cb_squeeze_quit (
+ GtkWidget *widget,
+ gpointer user_data );
+
+#if 0
+static void
+cb_archive_refreshed (
+ LSQArchive *archive,
gpointer user_data);
+#endif
static void
sq_treeview_reset_columns (
@@ -98,40 +129,40 @@ static GtkActionEntry action_entries[] =
N_("_File"),
NULL,
},
- {"new", /* Name */
- "document-new", /* Icon-name */
- N_("_New"), /* Label */
- "<control>N", /* Accelerator */
- N_( "New Archive"), /* Tooltip */
- G_CALLBACK ( NULL), /* Callback function */
+ {"new", /* Name */
+ "document-new", /* Icon-name */
+ N_("_New"), /* Label */
+ "<control>N", /* Accelerator */
+ N_( "New Archive"), /* Tooltip */
+ G_CALLBACK ( cb_archive_new ), /* Callback function */
},
- {"open", /* Name */
- "document-open", /* Icon-name */
- N_("_Open"), /* Label */
- "<control>O", /* Accelerator */
- N_( "Open Archive"), /* Tooltip */
- G_CALLBACK ( NULL), /* Callback function */
+ {"open", /* Name */
+ "document-open", /* Icon-name */
+ N_("_Open"), /* Label */
+ "<control>O", /* Accelerator */
+ N_( "Open Archive"), /* Tooltip */
+ G_CALLBACK ( cb_archive_open ), /* Callback function */
},
- {"properties", /* Name */
- GTK_STOCK_PROPERTIES, /* Icon-name */
- N_("_Properties"), /* Label */
- NULL, /* Accelerator */
- N_( "Show file Properties"), /* Tooltip */
- G_CALLBACK ( NULL), /* Callback function */
+ {"properties", /* Name */
+ GTK_STOCK_PROPERTIES, /* Icon-name */
+ N_("_Properties"), /* Label */
+ NULL, /* Accelerator */
+ N_( "Show file Properties"), /* Tooltip */
+ G_CALLBACK ( cb_archive_properties ), /* Callback function */
},
- {"close", /* Name */
- GTK_STOCK_CLOSE, /* Icon-name */
- N_("_Close"), /* Label */
- "<control>W", /* Accelerator */
- N_( "Close Archive"), /* Tooltip */
- G_CALLBACK ( NULL), /* Callback function */
+ {"close", /* Name */
+ GTK_STOCK_CLOSE, /* Icon-name */
+ N_("_Close"), /* Label */
+ "<control>W", /* Accelerator */
+ N_( "Close Archive"), /* Tooltip */
+ G_CALLBACK ( cb_archive_close ), /* Callback function */
},
- {"quit", /* Name */
- GTK_STOCK_QUIT, /* Icon-name */
- N_("_Quit"), /* Label */
- "<control>Q", /* Accelerator */
- N_( "Quit Squeeze"), /* Tooltip */
- G_CALLBACK ( cb_window_quit ), /* Callback function */
+ {"quit", /* Name */
+ GTK_STOCK_QUIT, /* Icon-name */
+ N_("_Quit"), /* Label */
+ "<control>Q", /* Accelerator */
+ N_( "Quit Squeeze"), /* Tooltip */
+ G_CALLBACK ( cb_squeeze_quit ), /* Callback function */
},
/* Edit menu */
{"edit-menu",
@@ -177,11 +208,11 @@ static GtkActionEntry action_entries[] =
N_("Extract archive"), /* Tooltip */
G_CALLBACK ( NULL), /* Callback function */
},
- {"add-file", /* Name */
+ {"add", /* Name */
NULL, /* Icon-name */
- N_("_Add File"), /* Label */
+ N_("_Add"), /* Label */
NULL, /* Accelerator */
- N_("Add files"), /* Tooltip */
+ N_("Add files/folders"),/* Tooltip */
G_CALLBACK ( NULL), /* Callback function */
},
{"add-folder", /* Name */
@@ -264,46 +295,125 @@ sq_main_window_get_type (void)
static void
sq_main_window_class_init ( GObjectClass *object_class )
{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (object_class);
+
parent_class = gtk_type_class (GTK_TYPE_WINDOW);
- object_class->set_property = sq_main_window_set_property;
- object_class->get_property = sq_main_window_get_property;
- object_class->dispose = sq_main_window_dispose;
+ object_class->set_property = sq_main_window_set_property;
+ object_class->get_property = sq_main_window_get_property;
+ object_class->dispose = sq_main_window_dispose;
+
+ widget_class->configure_event = sq_main_window_configure_event;
}
static void
sq_main_window_dispose(GObject *object)
{
+ SQMainWindow *window = SQ_MAIN_WINDOW (object);
+ if (window->priv->settings)
+ {
+ g_object_unref (window->priv->settings);
+ window->priv->settings = NULL;
+ }
parent_class->dispose(object);
}
+static gboolean
+sq_main_window_configure_event (
+ GtkWidget *widget,
+ GdkEventConfigure *event )
+{
+ SQMainWindow *window = SQ_MAIN_WINDOW (widget);
+
+ if ( ( widget->allocation.width != event->width ) ||
+ ( widget->allocation.height != event->height ) )
+ {
+ if ( window->priv->save_geometry_timer_id > 0 )
+ {
+ g_source_remove ( window->priv->save_geometry_timer_id );
+ }
+ window->priv->save_geometry_timer_id = 0;
+
+ if ( GTK_WIDGET_VISIBLE (widget) )
+ {
+ window->priv->save_geometry_timer_id = g_timeout_add (
+ 1000,
+ sq_save_geometry_timer,
+ widget );
+ }
+ }
+
+ GTK_WIDGET_CLASS(parent_class)->configure_event(widget, event);
+
+ return FALSE;
+}
+
+static gboolean
+sq_save_geometry_timer ( gpointer user_data )
+{
+ GtkWindow *window = GTK_WINDOW ( user_data );
+ GtkWidget *widget = GTK_WIDGET ( user_data );
+
+ gint state = 0;
+ gint width = 0;
+ gint height = 0;
+
+ if ( GTK_WIDGET_VISIBLE (widget) )
+ {
+ state = gdk_window_get_state (widget->window);
+
+ if ( 0 == (state &
+ (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN) ) )
+ {
+ gtk_window_get_size (
+ window,
+ &width,
+ &height);
+
+ g_object_set (
+ G_OBJECT (SQ_MAIN_WINDOW (window)->priv->settings),
+ "window-width",
+ width,
+ "window-height",
+ height,
+ NULL);
+ }
+ }
+ return FALSE;
+}
+
static void
sq_main_window_init ( GObject *object )
{
SQMainWindow *window = SQ_MAIN_WINDOW (object);
+ guint window_width = 0;
+ guint window_height = 0;
GtkAccelGroup *accel_group;
GtkWidget *scrolled_window;
- GClosure *quit_closure = g_cclosure_new (
- (GCallback)cb_window_quit,
- window,
- NULL);
-
GtkWidget *main_vbox = gtk_vbox_new (FALSE, 0);
-
window->priv = g_new0 (SQMainWindowPriv, 1);
window->priv->icon_theme = gtk_icon_theme_get_default();
window->priv->ui_manager = gtk_ui_manager_new();
window->priv->action_group = gtk_action_group_new ("SQWindow");
+ window->priv->settings = sq_settings_new();
+
+ window_width = sq_settings_get_uint_property (
+ window->priv->settings,
+ "window-width" );
+ window_height = sq_settings_get_uint_property (
+ window->priv->settings,
+ "window-height" );
+
+ gtk_window_set_default_size (
+ GTK_WINDOW (window),
+ window_width,
+ window_height );
accel_group = gtk_ui_manager_get_accel_group ( window->priv->ui_manager);
gtk_window_add_accel_group (GTK_WINDOW ( window ), accel_group);
-
- gtk_accel_group_connect_by_path (accel_group, "<Window>/quit", quit_closure);
-
- gtk_accel_map_change_entry ("<Window>/quit", GDK_q, 0, FALSE);
gtk_ui_manager_insert_action_group (
window->priv->ui_manager,
@@ -319,7 +429,6 @@ sq_main_window_init ( GObject *object )
G_N_ELEMENTS (action_entries),
GTK_WIDGET (window) );
-
gtk_ui_manager_add_ui_from_string (
window->priv->ui_manager,
main_window_ui,
@@ -398,7 +507,7 @@ sq_main_window_init ( GObject *object )
}
GtkWidget *
-sq_main_window_new ( SQApplication *app )
+sq_main_window_new ( )
{
SQMainWindow *window;
@@ -406,9 +515,6 @@ sq_main_window_new ( SQApplication *app )
"title", _("Archive Manager"),
NULL);
- g_object_ref(app);
- window->priv->app = app;
-
return GTK_WIDGET(window);
}
@@ -440,7 +546,7 @@ sq_main_window_set_property (
}
}
-
+#if 0
static void
sq_treeview_reset_columns (
GtkTreeView *treeview,
@@ -567,7 +673,9 @@ sq_treeview_reset_columns (
treeview,
LSQ_ARCHIVE_PROP_FILENAME + SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT);
}
+#endif
+#if 0
static void
cb_archive_refreshed (
LSQArchive *archive,
@@ -579,21 +687,91 @@ cb_archive_refreshed (
GTK_TREE_VIEW (window->priv->tree_view),
archive );
}
+#endif
-/**
- * cb_window_quit:
- * @widget:
- * @window:
- *
+static void
+cb_archive_new (
+ GtkWidget *widget,
+ gpointer user_data )
+{
+
+ return;
+}
+
+static void
+cb_archive_open (
+ GtkWidget *widget,
+ gpointer user_data )
+{
+
+ return;
+}
+
+/*
+ * cb_archive_properties:
+ * widget:
+ * user_data: Main Window object
*
+ * Launch a file-properties dialog, use thunar's if it's available,
+ * otherwise show the built-in dialog.
*/
static void
-cb_window_quit (
+cb_archive_properties (
GtkWidget *widget,
- gpointer user_data)
+ gpointer user_data )
{
- GtkWindow *window = GTK_WINDOW (user_data);
+ GFile *file = NULL;
+ GError *error = NULL;
+ const gchar *uri = NULL;
- gtk_widget_destroy (GTK_WIDGET (window));
+ /* The display object is owned by gdk, do not unref it */
+ GdkDisplay *display = gdk_display_get_default();
+ SQMainWindow *window = SQ_MAIN_WINDOW (user_data);
+
+ gboolean use_thunar_properties = sq_settings_get_boolean_property (
+ window->priv->settings,
+ "use-thunar-properties");
+
+ if (window->priv->archive)
+ {
+ file = lsq_archive_get_file (window->priv->archive);
+ if ( TRUE == use_thunar_properties && NULL != file )
+ {
+ uri = g_file_get_uri(file);
+ if(dbus_g_proxy_call(window->priv->filemanager_proxy,
+ "DisplayFileProperties",
+ &error,
+ G_TYPE_STRING, uri,
+ G_TYPE_STRING, gdk_display_get_name(display),
+ G_TYPE_STRING, "",
+ G_TYPE_INVALID,
+ G_TYPE_INVALID) == FALSE)
+ {
+ g_warning("DBUS CALL FAILED: '%s'", error->message);
+ }
+
+ }
+ }
+
+ return;
+}
+
+static void
+cb_archive_close (
+ GtkWidget *widget,
+ gpointer user_data )
+{
+
+ return;
}
+static void
+cb_squeeze_quit (
+ GtkWidget *widget,
+ gpointer user_data )
+{
+ GtkWidget *window = GTK_WIDGET (user_data);
+
+ gtk_widget_destroy (window);
+ return;
+}
diff --git a/src/main_window.h b/src/main_window.h
index e30d4a4..2466417 100644
--- a/src/main_window.h
+++ b/src/main_window.h
@@ -76,7 +76,7 @@ GType
sq_main_window_get_type ();
GtkWidget *
-sq_main_window_new ( SQApplication * );
+sq_main_window_new ( );
G_END_DECLS
diff --git a/src/main_window_ui.xml b/src/main_window_ui.xml
index e5daa17..500bc11 100644
--- a/src/main_window_ui.xml
+++ b/src/main_window_ui.xml
@@ -24,8 +24,7 @@
<menu action="view-menu">
</menu>
<menu action="go-menu">
- <menuitem action="add-file"/>
- <menuitem action="add-folder"/>
+ <menuitem action="add"/>
<menuitem action="extract"/>
<menuitem action="remove"/>
<separator/>
@@ -51,8 +50,7 @@
<toolitem action="new"/>
<toolitem action="open"/>
<separator />
- <toolitem action="add-file"/>
- <toolitem action="add-folder"/>
+ <toolitem action="add"/>
<toolitem action="extract"/>
<toolitem action="remove"/>
<separator />
diff --git a/src/message_dialog.c b/src/message_dialog.c
index b486734..7c42b5f 100644
--- a/src/message_dialog.c
+++ b/src/message_dialog.c
@@ -42,139 +42,139 @@ static GObjectClass *parent_class = NULL;
GType
sq_message_dialog_get_type (void)
{
- static GType sq_message_dialog_type = 0;
-
- if (!sq_message_dialog_type)
- {
- static const GTypeInfo sq_message_dialog_info =
- {
- sizeof (SQMessageDialogClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) sq_message_dialog_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (SQMessageDialog),
- 0,
- (GInstanceInitFunc) sq_message_dialog_init,
- NULL
- };
-
- sq_message_dialog_type = g_type_register_static (GTK_TYPE_WINDOW, "SQMessageDialog", &sq_message_dialog_info, 0);
- }
- return sq_message_dialog_type;
+ static GType sq_message_dialog_type = 0;
+
+ if (!sq_message_dialog_type)
+ {
+ static const GTypeInfo sq_message_dialog_info =
+ {
+ sizeof (SQMessageDialogClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) sq_message_dialog_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (SQMessageDialog),
+ 0,
+ (GInstanceInitFunc) sq_message_dialog_init,
+ NULL
+ };
+
+ sq_message_dialog_type = g_type_register_static (GTK_TYPE_WINDOW, "SQMessageDialog", &sq_message_dialog_info, 0);
+ }
+ return sq_message_dialog_type;
}
static void
sq_message_dialog_class_init(SQMessageDialogClass *dialog_class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (dialog_class);
+ GObjectClass *object_class = G_OBJECT_CLASS (dialog_class);
- parent_class = gtk_type_class (GTK_TYPE_WINDOW);
+ parent_class = gtk_type_class (GTK_TYPE_WINDOW);
- object_class->dispose = sq_message_dialog_dispose;
+ object_class->dispose = sq_message_dialog_dispose;
}
static void
sq_message_dialog_init(SQMessageDialog *dialog)
{
- GtkWidget *vbox = gtk_vbox_new(FALSE, 3);
- GtkWidget *separator;
- GtkWidget *button_box;
- GtkWidget *cancel_button;
- dialog->message_label = gtk_label_new("being silly here");
- dialog->progress_bar = gtk_progress_bar_new();
+ GtkWidget *vbox = gtk_vbox_new(FALSE, 3);
+ GtkWidget *separator;
+ GtkWidget *button_box;
+ GtkWidget *cancel_button;
+ dialog->message_label = gtk_label_new("being silly here");
+ dialog->progress_bar = gtk_progress_bar_new();
- gtk_label_set_ellipsize(GTK_LABEL(dialog->message_label), PANGO_ELLIPSIZE_MIDDLE);
+ gtk_label_set_ellipsize(GTK_LABEL(dialog->message_label), PANGO_ELLIPSIZE_MIDDLE);
- separator = gtk_hseparator_new();
- button_box = gtk_hbutton_box_new();
+ separator = gtk_hseparator_new();
+ button_box = gtk_hbutton_box_new();
- gtk_box_pack_end(GTK_BOX(vbox), button_box, FALSE, FALSE, 0);
- gtk_box_pack_end(GTK_BOX(vbox), separator, FALSE, FALSE, 0);
- gtk_box_pack_end(GTK_BOX(vbox), dialog->message_label, FALSE, FALSE, 0);
- gtk_box_pack_end(GTK_BOX(vbox), dialog->progress_bar, TRUE, FALSE, 5);
+ gtk_box_pack_end(GTK_BOX(vbox), button_box, FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(vbox), separator, FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(vbox), dialog->message_label, FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(vbox), dialog->progress_bar, TRUE, FALSE, 5);
- gtk_button_box_set_layout(GTK_BUTTON_BOX(button_box), GTK_BUTTONBOX_END);
+ gtk_button_box_set_layout(GTK_BUTTON_BOX(button_box), GTK_BUTTONBOX_END);
- cancel_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
+ cancel_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
- g_signal_connect(cancel_button, "clicked", G_CALLBACK(cb_sq_message_dialog_close), dialog);
+ g_signal_connect(cancel_button, "clicked", G_CALLBACK(cb_sq_message_dialog_close), dialog);
- gtk_container_add(GTK_CONTAINER(button_box), cancel_button);
+ gtk_container_add(GTK_CONTAINER(button_box), cancel_button);
- gtk_widget_show_all(vbox);
+ gtk_widget_show_all(vbox);
- gtk_container_add(GTK_CONTAINER(dialog), vbox);
+ gtk_container_add(GTK_CONTAINER(dialog), vbox);
}
static void
sq_message_dialog_dispose(GObject *dialog)
{
- if(SQ_MESSAGE_DIALOG(dialog)->archive)
- {
- GtkWidget *warning_dialog = gtk_message_dialog_new(GTK_WINDOW(dialog),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_YES_NO,
- "Are you sure you want to cancel this operation?");
- if(gtk_dialog_run(GTK_DIALOG(warning_dialog)) == GTK_RESPONSE_YES)
- {
- lsq_archive_stop(SQ_MESSAGE_DIALOG(dialog)->archive);
- SQ_MESSAGE_DIALOG(dialog)->archive = NULL;
-
- }
- gtk_widget_destroy(warning_dialog);
-
-
- g_timeout_add(200, (GSourceFunc)sq_message_dialog_progressbar_pulse, dialog);
- }
- else
- parent_class->dispose(dialog);
+ if(SQ_MESSAGE_DIALOG(dialog)->archive)
+ {
+ GtkWidget *warning_dialog = gtk_message_dialog_new(GTK_WINDOW(dialog),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_YES_NO,
+ "Are you sure you want to cancel this operation?");
+ if(gtk_dialog_run(GTK_DIALOG(warning_dialog)) == GTK_RESPONSE_YES)
+ {
+ lsq_archive_stop(SQ_MESSAGE_DIALOG(dialog)->archive);
+ SQ_MESSAGE_DIALOG(dialog)->archive = NULL;
+
+ }
+ gtk_widget_destroy(warning_dialog);
+
+
+ g_timeout_add(200, (GSourceFunc)sq_message_dialog_progressbar_pulse, dialog);
+ }
+ else
+ parent_class->dispose(dialog);
}
static gboolean
sq_message_dialog_progressbar_pulse(SQMessageDialog *dialog)
{
- if(dialog->archive)
- {
- gtk_progress_bar_pulse(GTK_PROGRESS_BAR(dialog->progress_bar));
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(dialog->progress_bar), lsq_archive_get_state_msg(dialog->archive));
- return TRUE;
- }
- return FALSE;
+ if(dialog->archive)
+ {
+ gtk_progress_bar_pulse(GTK_PROGRESS_BAR(dialog->progress_bar));
+ gtk_progress_bar_set_text(GTK_PROGRESS_BAR(dialog->progress_bar), lsq_archive_get_state_msg(dialog->archive));
+ return TRUE;
+ }
+ return FALSE;
}
static void
cb_sq_message_dialog_close(GtkButton *button, SQMessageDialog *dialog)
{
- gtk_widget_destroy(GTK_WIDGET(dialog));
+ gtk_widget_destroy(GTK_WIDGET(dialog));
}
GtkWidget *
sq_message_dialog_new(GtkWindowType type, LSQArchive *archive)
{
- SQMessageDialog *dialog;
- gchar *filename;
+ SQMessageDialog *dialog;
+ gchar *filename;
- dialog = g_object_new(sq_message_dialog_get_type(),
- "title", _("Archive manager"),
- "type", type,
- "resizable", FALSE,
- "deletable", FALSE,
- "modal", TRUE,
- NULL);
+ dialog = g_object_new(sq_message_dialog_get_type(),
+ "title", _("Archive manager"),
+ "type", type,
+ "resizable", FALSE,
+ "deletable", FALSE,
+ "modal", TRUE,
+ NULL);
- gtk_widget_set_size_request(GTK_WIDGET(dialog), 300,100);
+ gtk_widget_set_size_request(GTK_WIDGET(dialog), 300,100);
- SQ_MESSAGE_DIALOG(dialog)->archive = archive;
+ SQ_MESSAGE_DIALOG(dialog)->archive = archive;
- g_timeout_add(200, (GSourceFunc)sq_message_dialog_progressbar_pulse, dialog);
+ g_timeout_add(200, (GSourceFunc)sq_message_dialog_progressbar_pulse, dialog);
- filename = lsq_archive_get_filename(archive);
- gtk_label_set_text(GTK_LABEL(dialog->message_label), filename);
- g_free(filename);
+ filename = lsq_archive_get_filename(archive);
+ gtk_label_set_text(GTK_LABEL(dialog->message_label), filename);
+ g_free(filename);
- return (GtkWidget*)dialog;
+ return (GtkWidget*)dialog;
}
diff --git a/src/message_dialog.h b/src/message_dialog.h
index 442d4d6..6b2547e 100644
--- a/src/message_dialog.h
+++ b/src/message_dialog.h
@@ -18,42 +18,42 @@
#define __SQRCHIVER_MESSAGE_DIALOG_H__
G_BEGIN_DECLS
-#define SQ_MESSAGE_DIALOG(obj) ( \
- G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- sq_message_dialog_get_type(), \
- SQMessageDialog))
+#define SQ_MESSAGE_DIALOG(obj) ( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ sq_message_dialog_get_type(), \
+ SQMessageDialog))
-#define SQ_IS_MESSAGE_DIALOG(obj) ( \
- G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- sq_message_dialog_get_type()))
+#define SQ_IS_MESSAGE_DIALOG(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ sq_message_dialog_get_type()))
#define SQ_MESSAGE_DIALOG_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_CAST ((class), \
- sq_message_dialog_get_type(), \
- SQMessageDialogClass))
+ G_TYPE_CHECK_CLASS_CAST ((class), \
+ sq_message_dialog_get_type(), \
+ SQMessageDialogClass))
#define SQ_IS_MESSAGE_DIALOG_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_TYPE ((class), \
- sq_message_dialog_get_type()))
+ G_TYPE_CHECK_CLASS_TYPE ((class), \
+ sq_message_dialog_get_type()))
typedef struct _SQMessageDialog SQMessageDialog;
struct _SQMessageDialog
{
- GtkWindow parent;
- LSQArchive *archive;
- GtkWidget *message_label;
- GtkWidget *progress_bar;
+ GtkWindow parent;
+ LSQArchive *archive;
+ GtkWidget *message_label;
+ GtkWidget *progress_bar;
};
typedef struct _SQMessageDialogClass SQMessageDialogClass;
struct _SQMessageDialogClass
{
- GtkWindowClass parent;
+ GtkWindowClass parent;
};
-GType sq_message_dialog_get_type();
+GType sq_message_dialog_get_type();
GtkWidget *sq_message_dialog_new();
G_END_DECLS
diff --git a/src/navigation_bar.c b/src/navigation_bar.c
index 1b71d0b..0bfbeb7 100644
--- a/src/navigation_bar.c
+++ b/src/navigation_bar.c
@@ -41,7 +41,7 @@ cb_sq_navigation_bar_new_archive(SQArchiveStore *store, SQNavigationBar *bar);
/* properties */
enum {
- SQ_NAVIGATION_BAR_NAV_HISTORY = 1
+ SQ_NAVIGATION_BAR_NAV_HISTORY = 1
};
static GObjectClass *parent_class;
@@ -49,109 +49,109 @@ static GObjectClass *parent_class;
GType
sq_navigation_bar_get_type (void)
{
- static GType sq_navigation_bar_type = 0;
-
- if (!sq_navigation_bar_type)
- {
- static const GTypeInfo sq_navigation_bar_info =
- {
- sizeof (SQNavigationBarClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) sq_navigation_bar_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (SQNavigationBar),
- 0,
- (GInstanceInitFunc) sq_navigation_bar_init,
- NULL
- };
-
- sq_navigation_bar_type = g_type_register_static (GTK_TYPE_CONTAINER, "SQNavigationBar", &sq_navigation_bar_info, 0);
- }
- return sq_navigation_bar_type;
+ static GType sq_navigation_bar_type = 0;
+
+ if (!sq_navigation_bar_type)
+ {
+ static const GTypeInfo sq_navigation_bar_info =
+ {
+ sizeof (SQNavigationBarClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) sq_navigation_bar_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (SQNavigationBar),
+ 0,
+ (GInstanceInitFunc) sq_navigation_bar_init,
+ NULL
+ };
+
+ sq_navigation_bar_type = g_type_register_static (GTK_TYPE_CONTAINER, "SQNavigationBar", &sq_navigation_bar_info, 0);
+ }
+ return sq_navigation_bar_type;
}
static void
sq_navigation_bar_class_init(SQNavigationBarClass *navigation_bar_class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (navigation_bar_class);
+ GObjectClass *object_class = G_OBJECT_CLASS (navigation_bar_class);
- parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
+ parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
- object_class->dispose = sq_navigation_bar_dispose;
+ object_class->dispose = sq_navigation_bar_dispose;
}
static void
sq_navigation_bar_init(SQNavigationBar *navigation_bar)
{
- GTK_WIDGET_SET_FLAGS(navigation_bar, GTK_NO_WINDOW);
- gtk_widget_set_redraw_on_allocate(GTK_WIDGET(navigation_bar), FALSE);
+ GTK_WIDGET_SET_FLAGS(navigation_bar, GTK_NO_WINDOW);
+ gtk_widget_set_redraw_on_allocate(GTK_WIDGET(navigation_bar), FALSE);
- navigation_bar->_cb_pwd_changed = cb_sq_navigation_bar_pwd_changed;
- navigation_bar->_cb_new_archive = cb_sq_navigation_bar_new_archive;
+ navigation_bar->_cb_pwd_changed = cb_sq_navigation_bar_pwd_changed;
+ navigation_bar->_cb_new_archive = cb_sq_navigation_bar_new_archive;
}
static void
sq_navigation_bar_dispose(GObject *object)
{
- SQNavigationBar *navigation_bar = SQ_NAVIGATION_BAR(object);
- if(navigation_bar->store)
- {
- if(navigation_bar->_cb_pwd_changed)
- {
- g_signal_handlers_disconnect_by_func(navigation_bar->store, navigation_bar->_cb_pwd_changed, navigation_bar);
- navigation_bar->_cb_pwd_changed = NULL;
- }
- if(navigation_bar->_cb_new_archive)
- {
- g_signal_handlers_disconnect_by_func(navigation_bar->store, navigation_bar->_cb_new_archive, navigation_bar);
- navigation_bar->_cb_new_archive = NULL;
- }
- navigation_bar->store = NULL;
- }
- parent_class->dispose(object);
+ SQNavigationBar *navigation_bar = SQ_NAVIGATION_BAR(object);
+ if(navigation_bar->store)
+ {
+ if(navigation_bar->_cb_pwd_changed)
+ {
+ g_signal_handlers_disconnect_by_func(navigation_bar->store, navigation_bar->_cb_pwd_changed, navigation_bar);
+ navigation_bar->_cb_pwd_changed = NULL;
+ }
+ if(navigation_bar->_cb_new_archive)
+ {
+ g_signal_handlers_disconnect_by_func(navigation_bar->store, navigation_bar->_cb_new_archive, navigation_bar);
+ navigation_bar->_cb_new_archive = NULL;
+ }
+ navigation_bar->store = NULL;
+ }
+ parent_class->dispose(object);
}
void
sq_navigation_bar_set_store(SQNavigationBar *navigation_bar, SQArchiveStore *store)
{
- if(navigation_bar->store)
- {
- if(navigation_bar->_cb_pwd_changed)
- {
- g_signal_handlers_disconnect_by_func(navigation_bar->store, navigation_bar->_cb_pwd_changed, navigation_bar);
- }
- if(navigation_bar->_cb_new_archive)
- {
- g_signal_handlers_disconnect_by_func(navigation_bar->store, navigation_bar->_cb_new_archive, navigation_bar);
- }
- navigation_bar->store = NULL;
- }
-
- navigation_bar->store = store;
- if(store)
- {
- g_return_if_fail(SQ_IS_ARCHIVE_STORE(store));
- g_return_if_fail(SQ_IS_NAVIGATION_BAR(navigation_bar));
- g_signal_connect(G_OBJECT(store), "sq-pwd-changed", (GCallback)navigation_bar->_cb_pwd_changed, navigation_bar);
- g_signal_connect(G_OBJECT(store), "sq-new-archive", (GCallback)navigation_bar->_cb_new_archive, navigation_bar);
- }
-
- navigation_bar->_cb_store_set(navigation_bar);
+ if(navigation_bar->store)
+ {
+ if(navigation_bar->_cb_pwd_changed)
+ {
+ g_signal_handlers_disconnect_by_func(navigation_bar->store, navigation_bar->_cb_pwd_changed, navigation_bar);
+ }
+ if(navigation_bar->_cb_new_archive)
+ {
+ g_signal_handlers_disconnect_by_func(navigation_bar->store, navigation_bar->_cb_new_archive, navigation_bar);
+ }
+ navigation_bar->store = NULL;
+ }
+
+ navigation_bar->store = store;
+ if(store)
+ {
+ g_return_if_fail(SQ_IS_ARCHIVE_STORE(store));
+ g_return_if_fail(SQ_IS_NAVIGATION_BAR(navigation_bar));
+ g_signal_connect(G_OBJECT(store), "sq-pwd-changed", (GCallback)navigation_bar->_cb_pwd_changed, navigation_bar);
+ g_signal_connect(G_OBJECT(store), "sq-new-archive", (GCallback)navigation_bar->_cb_new_archive, navigation_bar);
+ }
+
+ navigation_bar->_cb_store_set(navigation_bar);
}
SQNavigationBar *
sq_navigation_bar_new(SQArchiveStore *store)
{
- SQNavigationBar *bar;
+ SQNavigationBar *bar;
- bar = g_object_new(SQ_TYPE_NAVIGATION_BAR, NULL);
+ bar = g_object_new(SQ_TYPE_NAVIGATION_BAR, NULL);
- if(store)
- sq_navigation_bar_set_store(bar, store);
+ if(store)
+ sq_navigation_bar_set_store(bar, store);
- return bar;
+ return bar;
}
static void
diff --git a/src/navigation_bar.h b/src/navigation_bar.h
index 37cd123..cb7dc9f 100644
--- a/src/navigation_bar.h
+++ b/src/navigation_bar.h
@@ -20,45 +20,45 @@ G_BEGIN_DECLS
#define SQ_TYPE_NAVIGATION_BAR sq_navigation_bar_get_type()
-#define SQ_NAVIGATION_BAR(obj)( \
- G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- SQ_TYPE_NAVIGATION_BAR, \
- SQNavigationBar))
+#define SQ_NAVIGATION_BAR(obj)( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ SQ_TYPE_NAVIGATION_BAR, \
+ SQNavigationBar))
-#define SQ_IS_NAVIGATION_BAR(obj) ( \
- G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- SQ_TYPE_NAVIGATION_BAR))
+#define SQ_IS_NAVIGATION_BAR(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ SQ_TYPE_NAVIGATION_BAR))
#define SQ_NAVIGATION_BAR_CLASS(klass) ( \
- G_TYPE_CHECK_CLASS_CAST ((klass), \
- SQ_TYPE_NAVIGATION_BAR, \
- SQNavigationBarClass))
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ SQ_TYPE_NAVIGATION_BAR, \
+ SQNavigationBarClass))
#define SQ_IS_NAVIGATION_BAR_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_TYPE ((class), \
- SQ_TYPE_NAVIGATION_BAR()))
+ G_TYPE_CHECK_CLASS_TYPE ((class), \
+ SQ_TYPE_NAVIGATION_BAR()))
typedef struct _SQNavigationBar SQNavigationBar;
struct _SQNavigationBar
{
- GtkContainer parent;
- SQArchiveStore *store;
- void (*_cb_pwd_changed)(SQArchiveStore *, LSQArchiveIter *, SQNavigationBar *);
- void (*_cb_new_archive)(SQArchiveStore *, SQNavigationBar *);
- void (*_cb_store_set)(SQNavigationBar *);
+ GtkContainer parent;
+ SQArchiveStore *store;
+ void (*_cb_pwd_changed)(SQArchiveStore *, LSQArchiveIter *, SQNavigationBar *);
+ void (*_cb_new_archive)(SQArchiveStore *, SQNavigationBar *);
+ void (*_cb_store_set)(SQNavigationBar *);
};
typedef struct _SQNavigationBarClass SQNavigationBarClass;
struct _SQNavigationBarClass
{
- GtkToolbarClass parent_class;
+ GtkToolbarClass parent_class;
};
-GType sq_navigation_bar_get_type();
+GType sq_navigation_bar_get_type();
SQNavigationBar *sq_navigation_bar_new();
-void sq_navigation_bar_set_store(SQNavigationBar *navigation_bar, SQArchiveStore *store);
+void sq_navigation_bar_set_store(SQNavigationBar *navigation_bar, SQArchiveStore *store);
G_END_DECLS
#endif /* __SQRCHIVER_NAVIGATION_BAR_H__*/
diff --git a/src/new_dialog.c b/src/new_dialog.c
index 13624bc..c91d629 100644
--- a/src/new_dialog.c
+++ b/src/new_dialog.c
@@ -35,27 +35,27 @@ sq_new_archive_dialog_init(SQNewArchiveDialog *archive);
GType
sq_new_archive_dialog_get_type (void)
{
- static GType sq_new_archive_dialog_type = 0;
-
- if (!sq_new_archive_dialog_type)
- {
- static const GTypeInfo sq_new_archive_dialog_info =
- {
- sizeof (SQNewArchiveDialogClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) sq_new_archive_dialog_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (SQNewArchiveDialog),
- 0,
- (GInstanceInitFunc) sq_new_archive_dialog_init,
- NULL
- };
-
- sq_new_archive_dialog_type = g_type_register_static (GTK_TYPE_FILE_CHOOSER_DIALOG, "SQNewArchiveDialog", &sq_new_archive_dialog_info, 0);
- }
- return sq_new_archive_dialog_type;
+ static GType sq_new_archive_dialog_type = 0;
+
+ if (!sq_new_archive_dialog_type)
+ {
+ static const GTypeInfo sq_new_archive_dialog_info =
+ {
+ sizeof (SQNewArchiveDialogClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) sq_new_archive_dialog_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (SQNewArchiveDialog),
+ 0,
+ (GInstanceInitFunc) sq_new_archive_dialog_init,
+ NULL
+ };
+
+ sq_new_archive_dialog_type = g_type_register_static (GTK_TYPE_FILE_CHOOSER_DIALOG, "SQNewArchiveDialog", &sq_new_archive_dialog_info, 0);
+ }
+ return sq_new_archive_dialog_type;
}
static void
@@ -66,86 +66,86 @@ sq_new_archive_dialog_class_init(SQNewArchiveDialogClass *dialog_class)
static void
sq_new_archive_dialog_init(SQNewArchiveDialog *dialog)
{
- GtkWidget *hbox = gtk_hbox_new(FALSE, 10);
- GSList *_supported_mime_types;
- gtk_box_pack_start (GTK_BOX (hbox),gtk_label_new (_("Archive type:")),FALSE, FALSE, 0);
-
- dialog->archive_types_combo = gtk_combo_box_new_text();
- gtk_box_pack_start (GTK_BOX (hbox),dialog->archive_types_combo,FALSE, FALSE, 0);
-
- gtk_widget_show_all(hbox);
-
- dialog->supported_mime_types = lsq_get_supported_mime_types(LSQ_COMMAND_TYPE_ADD);
- _supported_mime_types = dialog->supported_mime_types;
-
- dialog->file_filter = gtk_file_filter_new();
- gtk_file_filter_set_name(dialog->file_filter, _("Archives"));
- while(_supported_mime_types)
- {
- /*
- gtk_combo_box_append_text(GTK_COMBO_BOX(dialog->archive_types_combo),
- lsq_mime_support_get_comment((LSQMimeSupport *)(_supported_mime_types->data)));
-
- gtk_file_filter_add_mime_type(dialog->file_filter,
- lsq_mime_support_get_name((LSQMimeSupport *)(_supported_mime_types->data)));
-
- _supported_mime_types = g_slist_next(_supported_mime_types);
- */
- }
-
- gtk_box_pack_end(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, TRUE, 0);
- gtk_dialog_add_buttons(GTK_DIALOG(dialog),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_NEW, GTK_RESPONSE_OK,
- NULL);
- gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
+ GtkWidget *hbox = gtk_hbox_new(FALSE, 10);
+ GSList *_supported_mime_types;
+ gtk_box_pack_start (GTK_BOX (hbox),gtk_label_new (_("Archive type:")),FALSE, FALSE, 0);
+
+ dialog->archive_types_combo = gtk_combo_box_new_text();
+ gtk_box_pack_start (GTK_BOX (hbox),dialog->archive_types_combo,FALSE, FALSE, 0);
+
+ gtk_widget_show_all(hbox);
+
+ dialog->supported_mime_types = lsq_get_supported_mime_types(LSQ_COMMAND_TYPE_ADD);
+ _supported_mime_types = dialog->supported_mime_types;
+
+ dialog->file_filter = gtk_file_filter_new();
+ gtk_file_filter_set_name(dialog->file_filter, _("Archives"));
+ while(_supported_mime_types)
+ {
+ /*
+ gtk_combo_box_append_text(GTK_COMBO_BOX(dialog->archive_types_combo),
+ lsq_mime_support_get_comment((LSQMimeSupport *)(_supported_mime_types->data)));
+
+ gtk_file_filter_add_mime_type(dialog->file_filter,
+ lsq_mime_support_get_name((LSQMimeSupport *)(_supported_mime_types->data)));
+
+ _supported_mime_types = g_slist_next(_supported_mime_types);
+ */
+ }
+
+ gtk_box_pack_end(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, TRUE, 0);
+ gtk_dialog_add_buttons(GTK_DIALOG(dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_NEW, GTK_RESPONSE_OK,
+ NULL);
+ gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
}
GtkWidget *
sq_new_archive_dialog_new(void)
{
- GtkWidget *dialog;
+ GtkWidget *dialog;
- dialog = g_object_new(sq_new_archive_dialog_get_type(),
- "title", _("Create new archive"),
- "do-overwrite-confirmation", TRUE,
- "action", GTK_FILE_CHOOSER_ACTION_SAVE,
- NULL);
- gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), SQ_NEW_ARCHIVE_DIALOG(dialog)->file_filter);
+ dialog = g_object_new(sq_new_archive_dialog_get_type(),
+ "title", _("Create new archive"),
+ "do-overwrite-confirmation", TRUE,
+ "action", GTK_FILE_CHOOSER_ACTION_SAVE,
+ NULL);
+ gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), SQ_NEW_ARCHIVE_DIALOG(dialog)->file_filter);
- return dialog;
+ return dialog;
}
GFile *
sq_new_archive_dialog_get_file(SQNewArchiveDialog *dialog)
{
- GFile *file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER(dialog));
+ GFile *file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER(dialog));
if (file)
- {
- const gchar *mime_type = ""; //lsq_mime_support_get_name(((LSQMimeSupport *)_supported_mime_types->data));
- gchar *suffix = NULL;
- gint i;
- GSList *_supported_mime_types = dialog->supported_mime_types;
- for(i = 0; i < gtk_combo_box_get_active(GTK_COMBO_BOX(dialog->archive_types_combo)); i++)
- {
- _supported_mime_types = g_slist_next(_supported_mime_types);
- }
- if(!strcmp(mime_type, "application/x-tar")) suffix = ".tar";
- if(!strcmp(mime_type, "application/x-compressed-tar")) suffix = ".tar.gz";
- if(!strcmp(mime_type, "application/x-bzip-compressed-tar")) suffix = ".tar.bz2";
- if(!strcmp(mime_type, "application/x-tarz")) suffix = ".tar.Z";
- if(!strcmp(mime_type, "application/x-tzo")) suffix = ".tzo";
-
- if(!strcmp(mime_type, "application/zip")) suffix = ".zip";
-
- if(!strcmp(mime_type, "application/x-rar")) suffix = ".rar";
-
-
- if(!strcmp(mime_type, "application/x-gzip")) suffix = ".gz";
- if(!strcmp(mime_type, "application/x-bzip")) suffix = ".bz2";
- if(!strcmp(mime_type, "application/x-lzop")) suffix = ".lzo";
- if(!strcmp(mime_type, "application/x-compress")) suffix = ".Z";
- }
+ {
+ const gchar *mime_type = ""; //lsq_mime_support_get_name(((LSQMimeSupport *)_supported_mime_types->data));
+ gchar *suffix = NULL;
+ gint i;
+ GSList *_supported_mime_types = dialog->supported_mime_types;
+ for(i = 0; i < gtk_combo_box_get_active(GTK_COMBO_BOX(dialog->archive_types_combo)); i++)
+ {
+ _supported_mime_types = g_slist_next(_supported_mime_types);
+ }
+ if(!strcmp(mime_type, "application/x-tar")) suffix = ".tar";
+ if(!strcmp(mime_type, "application/x-compressed-tar")) suffix = ".tar.gz";
+ if(!strcmp(mime_type, "application/x-bzip-compressed-tar")) suffix = ".tar.bz2";
+ if(!strcmp(mime_type, "application/x-tarz")) suffix = ".tar.Z";
+ if(!strcmp(mime_type, "application/x-tzo")) suffix = ".tzo";
+
+ if(!strcmp(mime_type, "application/zip")) suffix = ".zip";
+
+ if(!strcmp(mime_type, "application/x-rar")) suffix = ".rar";
+
+
+ if(!strcmp(mime_type, "application/x-gzip")) suffix = ".gz";
+ if(!strcmp(mime_type, "application/x-bzip")) suffix = ".bz2";
+ if(!strcmp(mime_type, "application/x-lzop")) suffix = ".lzo";
+ if(!strcmp(mime_type, "application/x-compress")) suffix = ".Z";
+ }
return file;
}
diff --git a/src/new_dialog.h b/src/new_dialog.h
index 21668d5..9dc3994 100644
--- a/src/new_dialog.h
+++ b/src/new_dialog.h
@@ -20,39 +20,39 @@
#define __SQRCHIVER_NEW_ARCHIVE_DIALOG_H__
G_BEGIN_DECLS
-#define SQ_NEW_ARCHIVE_DIALOG(obj) ( \
- G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- sq_new_archive_dialog_get_type(), \
- SQNewArchiveDialog))
+#define SQ_NEW_ARCHIVE_DIALOG(obj) ( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ sq_new_archive_dialog_get_type(), \
+ SQNewArchiveDialog))
-#define SQ_IS_NEW_ARCHIVE_DIALOG(obj) ( \
- G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- sq_new_archive_dialog_get_type()))
+#define SQ_IS_NEW_ARCHIVE_DIALOG(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ sq_new_archive_dialog_get_type()))
#define SQ_NEW_ARCHIVE_DIALOG_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_CAST ((class), \
- sq_new_archive_dialog_get_type(), \
- SQNewArchiveDialogClass))
+ G_TYPE_CHECK_CLASS_CAST ((class), \
+ sq_new_archive_dialog_get_type(), \
+ SQNewArchiveDialogClass))
#define SQ_IS_NEW_ARCHIVE_DIALOG_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_TYPE ((class), \
- sq_new_archive_dialog_get_type()))
+ G_TYPE_CHECK_CLASS_TYPE ((class), \
+ sq_new_archive_dialog_get_type()))
typedef struct _SQNewArchiveDialog SQNewArchiveDialog;
struct _SQNewArchiveDialog
{
- GtkFileChooserDialog parent;
- GtkWidget *archive_types_combo;
- GtkFileFilter *file_filter; /* HACK -- should just be set inside the constructor */
- GSList *supported_mime_types;
+ GtkFileChooserDialog parent;
+ GtkWidget *archive_types_combo;
+ GtkFileFilter *file_filter; /* HACK -- should just be set inside the constructor */
+ GSList *supported_mime_types;
};
typedef struct _SQNewArchiveDialogClass SQNewArchiveDialogClass;
struct _SQNewArchiveDialogClass
{
- GtkFileChooserDialogClass parent_class;
+ GtkFileChooserDialogClass parent_class;
};
GType sq_new_archive_dialog_get_type();
diff --git a/src/path_bar.c b/src/path_bar.c
index cd41b6f..aa91316 100644
--- a/src/path_bar.c
+++ b/src/path_bar.c
@@ -97,671 +97,671 @@ cb_sq_path_bar_right_clicked(GtkWidget *widget, gpointer user_data);
GType
sq_path_bar_get_type (void)
{
- static GType sq_path_bar_type = 0;
-
- if (!sq_path_bar_type)
- {
- static const GTypeInfo sq_path_bar_info =
- {
- sizeof (SQPathBarClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) sq_path_bar_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (SQPathBar),
- 0,
- (GInstanceInitFunc) sq_path_bar_init,
- NULL
- };
-
- sq_path_bar_type = g_type_register_static (SQ_TYPE_NAVIGATION_BAR, "SQPathBar", &sq_path_bar_info, 0);
- }
- return sq_path_bar_type;
+ static GType sq_path_bar_type = 0;
+
+ if (!sq_path_bar_type)
+ {
+ static const GTypeInfo sq_path_bar_info =
+ {
+ sizeof (SQPathBarClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) sq_path_bar_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (SQPathBar),
+ 0,
+ (GInstanceInitFunc) sq_path_bar_init,
+ NULL
+ };
+
+ sq_path_bar_type = g_type_register_static (SQ_TYPE_NAVIGATION_BAR, "SQPathBar", &sq_path_bar_info, 0);
+ }
+ return sq_path_bar_type;
}
static void
sq_path_bar_class_init(SQPathBarClass *path_bar_class)
{
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- widget_class = (GtkWidgetClass*)path_bar_class;
- container_class = (GtkContainerClass*)path_bar_class;
-
- widget_class->size_request = sq_path_bar_size_request;
- widget_class->size_allocate = sq_path_bar_size_allocate;
-
- container_class->add = sq_path_bar_add;
- container_class->remove = sq_path_bar_remove;
- container_class->forall = sq_path_bar_forall;
- container_class->child_type = sq_path_bar_child_type;
-
- gtk_widget_class_install_style_property (widget_class,
- g_param_spec_int ("spacing",
- _("Spacing"),
- _("The amount of space between the path buttons"),
- 0, G_MAXINT, 3,
- G_PARAM_READABLE));
+ GtkWidgetClass *widget_class;
+ GtkContainerClass *container_class;
+
+ widget_class = (GtkWidgetClass*)path_bar_class;
+ container_class = (GtkContainerClass*)path_bar_class;
+
+ widget_class->size_request = sq_path_bar_size_request;
+ widget_class->size_allocate = sq_path_bar_size_allocate;
+
+ container_class->add = sq_path_bar_add;
+ container_class->remove = sq_path_bar_remove;
+ container_class->forall = sq_path_bar_forall;
+ container_class->child_type = sq_path_bar_child_type;
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("spacing",
+ _("Spacing"),
+ _("The amount of space between the path buttons"),
+ 0, G_MAXINT, 3,
+ G_PARAM_READABLE));
}
static void
sq_path_bar_init(SQPathBar *path_bar)
{
- GtkWidget *arrow;
- SQ_NAVIGATION_BAR(path_bar)->_cb_pwd_changed = cb_sq_path_bar_pwd_changed;
- SQ_NAVIGATION_BAR(path_bar)->_cb_new_archive = cb_sq_path_bar_new_archive;
- SQ_NAVIGATION_BAR(path_bar)->_cb_store_set = cb_sq_path_bar_store_set;
-
- GTK_WIDGET_SET_FLAGS(path_bar, GTK_NO_WINDOW);
- gtk_widget_set_redraw_on_allocate(GTK_WIDGET(path_bar), FALSE);
-
- path_bar->left_button = GTK_BUTTON(gtk_button_new());
- g_signal_connect(G_OBJECT(path_bar->left_button), "button-press-event", G_CALLBACK(cb_sq_path_bar_left_button_pressed), path_bar);
- g_signal_connect(G_OBJECT(path_bar->left_button), "button-release-event", G_CALLBACK(cb_sq_path_bar_scroll_button_released), path_bar);
- g_signal_connect(G_OBJECT(path_bar->left_button), "clicked", G_CALLBACK(cb_sq_path_bar_left_clicked), path_bar);
- gtk_container_add(GTK_CONTAINER(path_bar), GTK_WIDGET(path_bar->left_button));
- gtk_widget_show(GTK_WIDGET(path_bar->left_button));
- gtk_widget_ref(GTK_WIDGET(path_bar->left_button));
-
- arrow = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_OUT);
- gtk_container_add (GTK_CONTAINER (path_bar->left_button), arrow);
- gtk_widget_show (arrow);
-
- path_bar->right_button = GTK_BUTTON(gtk_button_new());
- g_signal_connect(G_OBJECT(path_bar->right_button), "button-press-event", G_CALLBACK(cb_sq_path_bar_right_button_pressed), path_bar);
- g_signal_connect(G_OBJECT(path_bar->right_button), "button-release-event", G_CALLBACK(cb_sq_path_bar_scroll_button_released), path_bar);
- g_signal_connect(G_OBJECT(path_bar->right_button), "clicked", G_CALLBACK(cb_sq_path_bar_right_clicked), path_bar);
- gtk_container_add(GTK_CONTAINER(path_bar), GTK_WIDGET(path_bar->right_button));
- gtk_widget_show(GTK_WIDGET(path_bar->right_button));
- gtk_widget_ref(GTK_WIDGET(path_bar->right_button));
-
- arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
- gtk_container_add (GTK_CONTAINER (path_bar->right_button), arrow);
- gtk_widget_show (arrow);
-
- path_bar->home_button = GTK_BUTTON(gtk_radio_button_new(NULL));
- gtk_container_add(GTK_CONTAINER(path_bar), GTK_WIDGET(path_bar->home_button));
- g_signal_connect(G_OBJECT(path_bar->home_button), "clicked", (GCallback)cb_sq_path_bar_path_button_clicked, path_bar);
- gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(path_bar->home_button), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(path_bar->home_button), FALSE);
- gtk_widget_show(GTK_WIDGET(path_bar->home_button));
- gtk_widget_ref(GTK_WIDGET(path_bar->home_button));
-
- arrow = gtk_image_new_from_stock(GTK_STOCK_HOME, GTK_ICON_SIZE_MENU);
- gtk_container_add (GTK_CONTAINER (path_bar->home_button), arrow);
- gtk_widget_show (arrow);
-
- path_bar->path_button = g_slist_prepend(NULL, path_bar->home_button);
- path_bar->first_button = NULL;
- path_bar->trailing = NULL;
- path_bar->scroll_timeout = 0;
- path_bar->scroll_dir = SQ_SCROLL_NONE;
- path_bar->scroll_click = TRUE;
- path_bar->updating = FALSE;
- gtk_container_set_border_width(GTK_CONTAINER(path_bar), 2);
-
- gtk_widget_ref(GTK_WIDGET(path_bar));
+ GtkWidget *arrow;
+ SQ_NAVIGATION_BAR(path_bar)->_cb_pwd_changed = cb_sq_path_bar_pwd_changed;
+ SQ_NAVIGATION_BAR(path_bar)->_cb_new_archive = cb_sq_path_bar_new_archive;
+ SQ_NAVIGATION_BAR(path_bar)->_cb_store_set = cb_sq_path_bar_store_set;
+
+ GTK_WIDGET_SET_FLAGS(path_bar, GTK_NO_WINDOW);
+ gtk_widget_set_redraw_on_allocate(GTK_WIDGET(path_bar), FALSE);
+
+ path_bar->left_button = GTK_BUTTON(gtk_button_new());
+ g_signal_connect(G_OBJECT(path_bar->left_button), "button-press-event", G_CALLBACK(cb_sq_path_bar_left_button_pressed), path_bar);
+ g_signal_connect(G_OBJECT(path_bar->left_button), "button-release-event", G_CALLBACK(cb_sq_path_bar_scroll_button_released), path_bar);
+ g_signal_connect(G_OBJECT(path_bar->left_button), "clicked", G_CALLBACK(cb_sq_path_bar_left_clicked), path_bar);
+ gtk_container_add(GTK_CONTAINER(path_bar), GTK_WIDGET(path_bar->left_button));
+ gtk_widget_show(GTK_WIDGET(path_bar->left_button));
+ gtk_widget_ref(GTK_WIDGET(path_bar->left_button));
+
+ arrow = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_OUT);
+ gtk_container_add (GTK_CONTAINER (path_bar->left_button), arrow);
+ gtk_widget_show (arrow);
+
+ path_bar->right_button = GTK_BUTTON(gtk_button_new());
+ g_signal_connect(G_OBJECT(path_bar->right_button), "button-press-event", G_CALLBACK(cb_sq_path_bar_right_button_pressed), path_bar);
+ g_signal_connect(G_OBJECT(path_bar->right_button), "button-release-event", G_CALLBACK(cb_sq_path_bar_scroll_button_released), path_bar);
+ g_signal_connect(G_OBJECT(path_bar->right_button), "clicked", G_CALLBACK(cb_sq_path_bar_right_clicked), path_bar);
+ gtk_container_add(GTK_CONTAINER(path_bar), GTK_WIDGET(path_bar->right_button));
+ gtk_widget_show(GTK_WIDGET(path_bar->right_button));
+ gtk_widget_ref(GTK_WIDGET(path_bar->right_button));
+
+ arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
+ gtk_container_add (GTK_CONTAINER (path_bar->right_button), arrow);
+ gtk_widget_show (arrow);
+
+ path_bar->home_button = GTK_BUTTON(gtk_radio_button_new(NULL));
+ gtk_container_add(GTK_CONTAINER(path_bar), GTK_WIDGET(path_bar->home_button));
+ g_signal_connect(G_OBJECT(path_bar->home_button), "clicked", (GCallback)cb_sq_path_bar_path_button_clicked, path_bar);
+ gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(path_bar->home_button), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(path_bar->home_button), FALSE);
+ gtk_widget_show(GTK_WIDGET(path_bar->home_button));
+ gtk_widget_ref(GTK_WIDGET(path_bar->home_button));
+
+ arrow = gtk_image_new_from_stock(GTK_STOCK_HOME, GTK_ICON_SIZE_MENU);
+ gtk_container_add (GTK_CONTAINER (path_bar->home_button), arrow);
+ gtk_widget_show (arrow);
+
+ path_bar->path_button = g_slist_prepend(NULL, path_bar->home_button);
+ path_bar->first_button = NULL;
+ path_bar->trailing = NULL;
+ path_bar->scroll_timeout = 0;
+ path_bar->scroll_dir = SQ_SCROLL_NONE;
+ path_bar->scroll_click = TRUE;
+ path_bar->updating = FALSE;
+ gtk_container_set_border_width(GTK_CONTAINER(path_bar), 2);
+
+ gtk_widget_ref(GTK_WIDGET(path_bar));
}
SQNavigationBar *
sq_path_bar_new(SQArchiveStore *store)
{
- SQNavigationBar *bar;
+ SQNavigationBar *bar;
- bar = g_object_new(SQ_TYPE_PATH_BAR, NULL);
+ bar = g_object_new(SQ_TYPE_PATH_BAR, NULL);
- if(store)
- sq_navigation_bar_set_store(SQ_NAVIGATION_BAR(bar), store);
+ if(store)
+ sq_navigation_bar_set_store(SQ_NAVIGATION_BAR(bar), store);
- return bar;
+ return bar;
}
static GType
sq_path_bar_child_type(GtkContainer *container)
{
- if(!SQ_PATH_BAR(container)->path_button)
- return GTK_TYPE_WIDGET;
- else
- return G_TYPE_NONE;
+ if(!SQ_PATH_BAR(container)->path_button)
+ return GTK_TYPE_WIDGET;
+ else
+ return G_TYPE_NONE;
}
static void
sq_path_bar_add(GtkContainer *container, GtkWidget *child)
{
- SQPathBar *path_bar = SQ_PATH_BAR(container);
+ SQPathBar *path_bar = SQ_PATH_BAR(container);
- g_return_if_fail(GTK_IS_WIDGET(child));
+ g_return_if_fail(GTK_IS_WIDGET(child));
- /* list is stored somewhere else */
- gtk_widget_set_parent(child, GTK_WIDGET(path_bar));
+ /* list is stored somewhere else */
+ gtk_widget_set_parent(child, GTK_WIDGET(path_bar));
}
static void
sq_path_bar_remove(GtkContainer *container, GtkWidget *child)
{
- gboolean widget_was_visible;
+ gboolean widget_was_visible;
- g_return_if_fail(GTK_IS_WIDGET(child));
+ g_return_if_fail(GTK_IS_WIDGET(child));
- widget_was_visible = GTK_WIDGET_VISIBLE(child);
+ widget_was_visible = GTK_WIDGET_VISIBLE(child);
- gtk_widget_unparent(child);
+ gtk_widget_unparent(child);
- /* remove from list is somewhere else */
- if(widget_was_visible)
- gtk_widget_queue_resize(GTK_WIDGET(container));
+ /* remove from list is somewhere else */
+ if(widget_was_visible)
+ gtk_widget_queue_resize(GTK_WIDGET(container));
}
static void
sq_path_bar_forall(GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data)
{
- SQPathBar *path_bar = SQ_PATH_BAR(container);
+ SQPathBar *path_bar = SQ_PATH_BAR(container);
- g_return_if_fail(callback != NULL);
+ g_return_if_fail(callback != NULL);
- g_slist_foreach(path_bar->path_button, (GFunc)callback, callback_data);
+ g_slist_foreach(path_bar->path_button, (GFunc)callback, callback_data);
- if(include_internals)
- {
- if(path_bar->left_button)
- (*callback)(GTK_WIDGET(path_bar->left_button), callback_data);
- if(path_bar->right_button)
- (*callback)(GTK_WIDGET(path_bar->right_button), callback_data);
- }
+ if(include_internals)
+ {
+ if(path_bar->left_button)
+ (*callback)(GTK_WIDGET(path_bar->left_button), callback_data);
+ if(path_bar->right_button)
+ (*callback)(GTK_WIDGET(path_bar->right_button), callback_data);
+ }
}
static void
sq_path_bar_size_request(GtkWidget *widget, GtkRequisition *requisition)
{
- SQPathBar *path_bar = SQ_PATH_BAR(widget);
- GSList *iter = NULL;
- GtkRequisition child_requisition;
- gint spacing = 0;
- gtk_widget_style_get(widget, "spacing", &spacing, NULL);
-
- requisition->width = 0;
- requisition->height = 0;
-
- /* get biggest button */
- for(iter = path_bar->path_button; iter; iter = iter->next)
- {
- gtk_widget_size_request(GTK_WIDGET(iter->data), &child_requisition);
- requisition->width = MAX(child_requisition.width, requisition->width);
- requisition->height = MAX(child_requisition.height, requisition->height);
- }
-
- gtk_widget_size_request(GTK_WIDGET(path_bar->left_button), &child_requisition);
- gtk_widget_size_request(GTK_WIDGET(path_bar->right_button), &child_requisition);
- /* add space for scroll buttons if more then 1 button */
- if(path_bar->path_button && path_bar->path_button->next)
- {
- gtk_widget_get_child_requisition(GTK_WIDGET(path_bar->left_button), &child_requisition);
- requisition->height = MAX(child_requisition.height, requisition->height);
- gtk_widget_get_child_requisition(GTK_WIDGET(path_bar->right_button), &child_requisition);
- requisition->height = MAX(child_requisition.height, requisition->height);
-
- requisition->width += (MIN(requisition->height *2/3+5, requisition->height) + spacing) * 2;
- }
-
- requisition->width += GTK_CONTAINER(path_bar)->border_width * 2;
- requisition->height += GTK_CONTAINER(path_bar)->border_width * 2;
-
- widget->requisition = *requisition;
+ SQPathBar *path_bar = SQ_PATH_BAR(widget);
+ GSList *iter = NULL;
+ GtkRequisition child_requisition;
+ gint spacing = 0;
+ gtk_widget_style_get(widget, "spacing", &spacing, NULL);
+
+ requisition->width = 0;
+ requisition->height = 0;
+
+ /* get biggest button */
+ for(iter = path_bar->path_button; iter; iter = iter->next)
+ {
+ gtk_widget_size_request(GTK_WIDGET(iter->data), &child_requisition);
+ requisition->width = MAX(child_requisition.width, requisition->width);
+ requisition->height = MAX(child_requisition.height, requisition->height);
+ }
+
+ gtk_widget_size_request(GTK_WIDGET(path_bar->left_button), &child_requisition);
+ gtk_widget_size_request(GTK_WIDGET(path_bar->right_button), &child_requisition);
+ /* add space for scroll buttons if more then 1 button */
+ if(path_bar->path_button && path_bar->path_button->next)
+ {
+ gtk_widget_get_child_requisition(GTK_WIDGET(path_bar->left_button), &child_requisition);
+ requisition->height = MAX(child_requisition.height, requisition->height);
+ gtk_widget_get_child_requisition(GTK_WIDGET(path_bar->right_button), &child_requisition);
+ requisition->height = MAX(child_requisition.height, requisition->height);
+
+ requisition->width += (MIN(requisition->height *2/3+5, requisition->height) + spacing) * 2;
+ }
+
+ requisition->width += GTK_CONTAINER(path_bar)->border_width * 2;
+ requisition->height += GTK_CONTAINER(path_bar)->border_width * 2;
+
+ widget->requisition = *requisition;
}
static void
sq_path_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
- SQPathBar *path_bar = SQ_PATH_BAR(widget);
- gint spacing = 0;
- gint width = 0;
- gint left_width = 0;
- gint right_width = 0;
- gint border_width = 0;
- GSList *iter = NULL;
- GSList *first_display = NULL;
- GtkRequisition child_requisition;
- GtkAllocation child_allocation;
+ SQPathBar *path_bar = SQ_PATH_BAR(widget);
+ gint spacing = 0;
+ gint width = 0;
+ gint left_width = 0;
+ gint right_width = 0;
+ gint border_width = 0;
+ GSList *iter = NULL;
+ GSList *first_display = NULL;
+ GtkRequisition child_requisition;
+ GtkAllocation child_allocation;
GtkTextDirection direction;
- widget->allocation = *allocation;
+ widget->allocation = *allocation;
- if(!path_bar->path_button)
- return;
-
+ if(!path_bar->path_button)
+ return;
+
direction = gtk_widget_get_direction (widget);
- gtk_widget_style_get(widget, "spacing", &spacing, NULL);
-
- border_width = GTK_CONTAINER(path_bar)->border_width;
- width = border_width * 2;
-
- iter = path_bar->path_button;
-
- /* are the scroll arrows needed? */
- while(iter)
- {
- gtk_widget_get_child_requisition(GTK_WIDGET(iter->data), &child_requisition);
- if(width)
- width += spacing;
- width += child_requisition.width;
- iter = iter->next;
- }
-
- first_display = g_slist_prepend(first_display, path_bar->path_button);
-
- /* scroll arrows are needed */
- if(width > allocation->width)
- {
- right_width = left_width = MIN((allocation->height-(border_width*2))*2/3+5, (allocation->height-(border_width*2)));
-
- width = border_width + left_width + spacing + right_width + border_width;
-
- if(path_bar->first_button)
- {
- iter = path_bar->path_button;
- while(iter != path_bar->first_button)
- {
- iter = iter->next;
- first_display = g_slist_prepend(first_display, iter);
- }
- }
-
- iter = (GSList*)first_display->data;
-
- /* are there parent maps visible? */
- while(iter)
- {
- gtk_widget_get_child_requisition(GTK_WIDGET(iter->data), &child_requisition);
- width += child_requisition.width + spacing;
- iter = iter->next;
- }
-
- iter = first_display->next;
-
- /* which parent map is visible? */
- while(iter)
- {
- gtk_widget_get_child_requisition(GTK_WIDGET(((GSList*)iter->data)->data), &child_requisition);
- width += child_requisition.width + spacing;
- if(width > allocation->width)
- break;
-
- first_display = g_slist_delete_link(first_display, first_display);
- iter = first_display->next;
- }
- /* first_display is the first entry from the list that fits */
- }
-
- child_allocation.y = allocation->y + border_width;
- child_allocation.height = allocation->height - (border_width * 2);
- if(direction == GTK_TEXT_DIR_RTL)
- {
- child_allocation.x = allocation->x + allocation->width - border_width;
- }
- else
- {
- child_allocation.x = allocation->x + border_width;
- }
-
- /* set visible and sensitive scroll buttons */
- if(left_width)
- {
- /* set visible */
- gtk_widget_set_child_visible(GTK_WIDGET(path_bar->left_button), TRUE);
-
- child_allocation.width = left_width;
- if(direction == GTK_TEXT_DIR_RTL)
- {
- child_allocation.x -= left_width;
- gtk_widget_size_allocate(GTK_WIDGET(path_bar->left_button), &child_allocation);
- child_allocation.x -= spacing;
- }
- else
- {
- gtk_widget_size_allocate(GTK_WIDGET(path_bar->left_button), &child_allocation);
- child_allocation.x += left_width + spacing;
- }
-
- gtk_widget_set_sensitive(GTK_WIDGET(path_bar->left_button), (first_display->data == (gpointer)path_bar->path_button)?FALSE:TRUE);
-
- if(path_bar->scroll_dir == SQ_SCROLL_LEFT && first_display->data == (gpointer)path_bar->path_button)
- {
- g_source_remove(path_bar->scroll_timeout);
- path_bar->scroll_dir = SQ_SCROLL_NONE;
- }
- }
- else
- {
- /* set invisible */
- gtk_widget_set_child_visible(GTK_WIDGET(path_bar->left_button), FALSE);
- }
-
- /* set visible for buttons */
- width = border_width * 2 - spacing;
- if(left_width)
- width += left_width + spacing;
- if(right_width)
- width += spacing + right_width;
- iter = (GSList*)first_display->data;
- while(iter)
- {
- gtk_widget_get_child_requisition(GTK_WIDGET(iter->data), &child_requisition);
- width += spacing + child_requisition.width;
- /* check to see if there is enough space */
- if(width > allocation->width)
- break;
- /* set visible */
- gtk_widget_set_child_visible(GTK_WIDGET(iter->data), TRUE);
- child_allocation.width = child_requisition.width;
- if(direction == GTK_TEXT_DIR_RTL)
- {
- child_allocation.x -= child_requisition.width;
- }
- gtk_widget_size_allocate(GTK_WIDGET(iter->data), &child_allocation);
-
- if(direction == GTK_TEXT_DIR_RTL)
- {
- child_allocation.x -= spacing;
- }
- else
- {
- child_allocation.x += child_requisition.width + spacing;
- }
- iter = iter->next;
- }
-
- /* set visible and sensitive scroll buttons */
- if(right_width)
- {
- /* set visible */
- gtk_widget_set_child_visible(GTK_WIDGET(path_bar->right_button), TRUE);
-
- child_allocation.width = right_width;
- if(direction == GTK_TEXT_DIR_RTL)
- {
- child_allocation.x = border_width + allocation->x;
- }
- else
- {
- child_allocation.x = allocation->width - right_width - border_width;
- }
- gtk_widget_size_allocate(GTK_WIDGET(path_bar->right_button), &child_allocation);
-
- gtk_widget_set_sensitive(GTK_WIDGET(path_bar->right_button), iter?TRUE:FALSE);
-
- if(path_bar->scroll_dir == SQ_SCROLL_RIGHT && !iter)
- {
- g_source_remove(path_bar->scroll_timeout);
- path_bar->scroll_dir = SQ_SCROLL_NONE;
- }
- }
- else
- {
- /* set invisible */
- gtk_widget_set_child_visible(GTK_WIDGET(path_bar->right_button), FALSE);
- }
-
- /* hide all buttons that don't fit */
- while(iter)
- {
- gtk_widget_set_child_visible(GTK_WIDGET(iter->data), FALSE);
- iter = iter->next;
- }
-
- iter = first_display->next;
-
- while(iter)
- {
- gtk_widget_set_child_visible(GTK_WIDGET(((GSList*)iter->data)->data), FALSE);
- iter = iter->next;
- }
-
- g_slist_free(first_display);
+ gtk_widget_style_get(widget, "spacing", &spacing, NULL);
+
+ border_width = GTK_CONTAINER(path_bar)->border_width;
+ width = border_width * 2;
+
+ iter = path_bar->path_button;
+
+ /* are the scroll arrows needed? */
+ while(iter)
+ {
+ gtk_widget_get_child_requisition(GTK_WIDGET(iter->data), &child_requisition);
+ if(width)
+ width += spacing;
+ width += child_requisition.width;
+ iter = iter->next;
+ }
+
+ first_display = g_slist_prepend(first_display, path_bar->path_button);
+
+ /* scroll arrows are needed */
+ if(width > allocation->width)
+ {
+ right_width = left_width = MIN((allocation->height-(border_width*2))*2/3+5, (allocation->height-(border_width*2)));
+
+ width = border_width + left_width + spacing + right_width + border_width;
+
+ if(path_bar->first_button)
+ {
+ iter = path_bar->path_button;
+ while(iter != path_bar->first_button)
+ {
+ iter = iter->next;
+ first_display = g_slist_prepend(first_display, iter);
+ }
+ }
+
+ iter = (GSList*)first_display->data;
+
+ /* are there parent maps visible? */
+ while(iter)
+ {
+ gtk_widget_get_child_requisition(GTK_WIDGET(iter->data), &child_requisition);
+ width += child_requisition.width + spacing;
+ iter = iter->next;
+ }
+
+ iter = first_display->next;
+
+ /* which parent map is visible? */
+ while(iter)
+ {
+ gtk_widget_get_child_requisition(GTK_WIDGET(((GSList*)iter->data)->data), &child_requisition);
+ width += child_requisition.width + spacing;
+ if(width > allocation->width)
+ break;
+
+ first_display = g_slist_delete_link(first_display, first_display);
+ iter = first_display->next;
+ }
+ /* first_display is the first entry from the list that fits */
+ }
+
+ child_allocation.y = allocation->y + border_width;
+ child_allocation.height = allocation->height - (border_width * 2);
+ if(direction == GTK_TEXT_DIR_RTL)
+ {
+ child_allocation.x = allocation->x + allocation->width - border_width;
+ }
+ else
+ {
+ child_allocation.x = allocation->x + border_width;
+ }
+
+ /* set visible and sensitive scroll buttons */
+ if(left_width)
+ {
+ /* set visible */
+ gtk_widget_set_child_visible(GTK_WIDGET(path_bar->left_button), TRUE);
+
+ child_allocation.width = left_width;
+ if(direction == GTK_TEXT_DIR_RTL)
+ {
+ child_allocation.x -= left_width;
+ gtk_widget_size_allocate(GTK_WIDGET(path_bar->left_button), &child_allocation);
+ child_allocation.x -= spacing;
+ }
+ else
+ {
+ gtk_widget_size_allocate(GTK_WIDGET(path_bar->left_button), &child_allocation);
+ child_allocation.x += left_width + spacing;
+ }
+
+ gtk_widget_set_sensitive(GTK_WIDGET(path_bar->left_button), (first_display->data == (gpointer)path_bar->path_button)?FALSE:TRUE);
+
+ if(path_bar->scroll_dir == SQ_SCROLL_LEFT && first_display->data == (gpointer)path_bar->path_button)
+ {
+ g_source_remove(path_bar->scroll_timeout);
+ path_bar->scroll_dir = SQ_SCROLL_NONE;
+ }
+ }
+ else
+ {
+ /* set invisible */
+ gtk_widget_set_child_visible(GTK_WIDGET(path_bar->left_button), FALSE);
+ }
+
+ /* set visible for buttons */
+ width = border_width * 2 - spacing;
+ if(left_width)
+ width += left_width + spacing;
+ if(right_width)
+ width += spacing + right_width;
+ iter = (GSList*)first_display->data;
+ while(iter)
+ {
+ gtk_widget_get_child_requisition(GTK_WIDGET(iter->data), &child_requisition);
+ width += spacing + child_requisition.width;
+ /* check to see if there is enough space */
+ if(width > allocation->width)
+ break;
+ /* set visible */
+ gtk_widget_set_child_visible(GTK_WIDGET(iter->data), TRUE);
+ child_allocation.width = child_requisition.width;
+ if(direction == GTK_TEXT_DIR_RTL)
+ {
+ child_allocation.x -= child_requisition.width;
+ }
+ gtk_widget_size_allocate(GTK_WIDGET(iter->data), &child_allocation);
+
+ if(direction == GTK_TEXT_DIR_RTL)
+ {
+ child_allocation.x -= spacing;
+ }
+ else
+ {
+ child_allocation.x += child_requisition.width + spacing;
+ }
+ iter = iter->next;
+ }
+
+ /* set visible and sensitive scroll buttons */
+ if(right_width)
+ {
+ /* set visible */
+ gtk_widget_set_child_visible(GTK_WIDGET(path_bar->right_button), TRUE);
+
+ child_allocation.width = right_width;
+ if(direction == GTK_TEXT_DIR_RTL)
+ {
+ child_allocation.x = border_width + allocation->x;
+ }
+ else
+ {
+ child_allocation.x = allocation->width - right_width - border_width;
+ }
+ gtk_widget_size_allocate(GTK_WIDGET(path_bar->right_button), &child_allocation);
+
+ gtk_widget_set_sensitive(GTK_WIDGET(path_bar->right_button), iter?TRUE:FALSE);
+
+ if(path_bar->scroll_dir == SQ_SCROLL_RIGHT && !iter)
+ {
+ g_source_remove(path_bar->scroll_timeout);
+ path_bar->scroll_dir = SQ_SCROLL_NONE;
+ }
+ }
+ else
+ {
+ /* set invisible */
+ gtk_widget_set_child_visible(GTK_WIDGET(path_bar->right_button), FALSE);
+ }
+
+ /* hide all buttons that don't fit */
+ while(iter)
+ {
+ gtk_widget_set_child_visible(GTK_WIDGET(iter->data), FALSE);
+ iter = iter->next;
+ }
+
+ iter = first_display->next;
+
+ while(iter)
+ {
+ gtk_widget_set_child_visible(GTK_WIDGET(((GSList*)iter->data)->data), FALSE);
+ iter = iter->next;
+ }
+
+ g_slist_free(first_display);
}
static void
cb_sq_path_bar_new_archive(SQArchiveStore *store, SQNavigationBar *bar)
{
- SQPathBar *path_bar = SQ_PATH_BAR(bar);
- GSList *buttons = path_bar->path_button->next;
- LSQArchiveIter *iter;
- GtkRadioButton *button;
-
- SQ_PATH_BAR(bar)->updating = TRUE;
-
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(path_bar->path_button->data), TRUE);
-
- while(buttons)
- {
- gtk_container_remove(GTK_CONTAINER(path_bar), GTK_WIDGET(buttons->data));
- lsq_archive_iter_unref(g_object_get_data(G_OBJECT(buttons->data), SQ_PATH_BAR_PATH_BUTTON_ITER));
- gtk_widget_unref(GTK_WIDGET(buttons->data));
- buttons = buttons->next;
- }
- g_slist_free(path_bar->path_button->next);
- path_bar->path_button->next = NULL;
-
- gtk_widget_set_sensitive(GTK_WIDGET(path_bar->home_button), (store&&store->archive));
- iter = g_object_get_data(G_OBJECT(path_bar->home_button), SQ_PATH_BAR_PATH_BUTTON_ITER);
- if(iter)
- lsq_archive_iter_unref(iter);
- iter = NULL;
- g_object_set_data(G_OBJECT(path_bar->home_button), SQ_PATH_BAR_PATH_BUTTON_ITER, NULL);
- if(path_bar->trailing)
- lsq_archive_iter_unref(path_bar->trailing);
-
- if(store)
- {
- path_bar->trailing = iter = lsq_archive_iter_ref(sq_archive_store_get_trailing(store));
- if(iter)
- {
- while(lsq_archive_iter_has_parent(iter))
- {
- button = GTK_RADIO_BUTTON(gtk_radio_button_new_with_label(path_bar->path_button, lsq_archive_iter_get_filename(iter)));
- gtk_widget_ref(GTK_WIDGET(button));
- gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button), FALSE);
- path_bar->path_button = g_slist_prepend(path_bar->path_button->next, button);
-
- g_object_set_data(G_OBJECT(button), SQ_PATH_BAR_PATH_BUTTON_ITER, iter);
- g_signal_connect(G_OBJECT(button), "clicked", (GCallback)cb_sq_path_bar_path_button_clicked, path_bar);
-
- gtk_container_add(GTK_CONTAINER(path_bar), GTK_WIDGET(button));
- gtk_widget_show(GTK_WIDGET(button));
-
- iter = lsq_archive_iter_get_parent(iter);
- }
-
- g_object_set_data(G_OBJECT(path_bar->home_button), SQ_PATH_BAR_PATH_BUTTON_ITER, iter);
- }
- }
-
- SQ_PATH_BAR(bar)->updating = FALSE;
+ SQPathBar *path_bar = SQ_PATH_BAR(bar);
+ GSList *buttons = path_bar->path_button->next;
+ LSQArchiveIter *iter;
+ GtkRadioButton *button;
+
+ SQ_PATH_BAR(bar)->updating = TRUE;
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(path_bar->path_button->data), TRUE);
+
+ while(buttons)
+ {
+ gtk_container_remove(GTK_CONTAINER(path_bar), GTK_WIDGET(buttons->data));
+ lsq_archive_iter_unref(g_object_get_data(G_OBJECT(buttons->data), SQ_PATH_BAR_PATH_BUTTON_ITER));
+ gtk_widget_unref(GTK_WIDGET(buttons->data));
+ buttons = buttons->next;
+ }
+ g_slist_free(path_bar->path_button->next);
+ path_bar->path_button->next = NULL;
+
+ gtk_widget_set_sensitive(GTK_WIDGET(path_bar->home_button), (store&&store->archive));
+ iter = g_object_get_data(G_OBJECT(path_bar->home_button), SQ_PATH_BAR_PATH_BUTTON_ITER);
+ if(iter)
+ lsq_archive_iter_unref(iter);
+ iter = NULL;
+ g_object_set_data(G_OBJECT(path_bar->home_button), SQ_PATH_BAR_PATH_BUTTON_ITER, NULL);
+ if(path_bar->trailing)
+ lsq_archive_iter_unref(path_bar->trailing);
+
+ if(store)
+ {
+ path_bar->trailing = iter = lsq_archive_iter_ref(sq_archive_store_get_trailing(store));
+ if(iter)
+ {
+ while(lsq_archive_iter_has_parent(iter))
+ {
+ button = GTK_RADIO_BUTTON(gtk_radio_button_new_with_label(path_bar->path_button, lsq_archive_iter_get_filename(iter)));
+ gtk_widget_ref(GTK_WIDGET(button));
+ gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button), FALSE);
+ path_bar->path_button = g_slist_prepend(path_bar->path_button->next, button);
+
+ g_object_set_data(G_OBJECT(button), SQ_PATH_BAR_PATH_BUTTON_ITER, iter);
+ g_signal_connect(G_OBJECT(button), "clicked", (GCallback)cb_sq_path_bar_path_button_clicked, path_bar);
+
+ gtk_container_add(GTK_CONTAINER(path_bar), GTK_WIDGET(button));
+ gtk_widget_show(GTK_WIDGET(button));
+
+ iter = lsq_archive_iter_get_parent(iter);
+ }
+
+ g_object_set_data(G_OBJECT(path_bar->home_button), SQ_PATH_BAR_PATH_BUTTON_ITER, iter);
+ }
+ }
+
+ SQ_PATH_BAR(bar)->updating = FALSE;
}
static void
cb_sq_path_bar_pwd_changed(SQArchiveStore *store, LSQArchiveIter *path, SQNavigationBar *bar)
{
- SQPathBar *path_bar = SQ_PATH_BAR(bar);
- LSQArchiveIter *iter = sq_archive_store_get_trailing(store);
- GSList *buttons = path_bar->path_button->next;
- GtkRadioButton *button;
-
- path_bar->updating = TRUE;
-
- /* TODO: check if the trailings match, save making new buttons */
-
- while(buttons)
- {
- gtk_container_remove(GTK_CONTAINER(path_bar), GTK_WIDGET(buttons->data));
- lsq_archive_iter_unref(g_object_get_data(G_OBJECT(buttons->data), SQ_PATH_BAR_PATH_BUTTON_ITER));
- gtk_widget_unref(GTK_WIDGET(buttons->data));
- buttons = buttons->next;
- }
- g_slist_free(path_bar->path_button->next);
- path_bar->path_button->next = NULL;
-
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(path_bar->home_button), TRUE);
- lsq_archive_iter_unref(g_object_get_data(G_OBJECT(path_bar->home_button), SQ_PATH_BAR_PATH_BUTTON_ITER));
- g_object_set_data(G_OBJECT(path_bar->home_button), SQ_PATH_BAR_PATH_BUTTON_ITER, NULL);
- if(path_bar->trailing)
- lsq_archive_iter_unref(path_bar->trailing);
- path_bar->trailing = lsq_archive_iter_ref(iter);
-
- if(iter)
- {
- while(lsq_archive_iter_has_parent(iter))
- {
- button = GTK_RADIO_BUTTON(gtk_radio_button_new_with_label(path_bar->path_button, lsq_archive_iter_get_filename(iter)));
- gtk_widget_ref(GTK_WIDGET(button));
- gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button), FALSE);
- path_bar->path_button->next = g_slist_prepend(path_bar->path_button->next, button);
-
- if(iter == path)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
-
- g_object_set_data(G_OBJECT(button), SQ_PATH_BAR_PATH_BUTTON_ITER, iter);
- g_signal_connect(G_OBJECT(button), "clicked", (GCallback)cb_sq_path_bar_path_button_clicked, path_bar);
-
- gtk_container_add(GTK_CONTAINER(path_bar), GTK_WIDGET(button));
- gtk_widget_show(GTK_WIDGET(button));
-
- iter = lsq_archive_iter_get_parent(iter);
- }
-
- g_object_set_data(G_OBJECT(path_bar->home_button), SQ_PATH_BAR_PATH_BUTTON_ITER, iter);
- }
-
- path_bar->first_button = g_slist_last(path_bar->path_button);
-
- path_bar->updating = FALSE;
+ SQPathBar *path_bar = SQ_PATH_BAR(bar);
+ LSQArchiveIter *iter = sq_archive_store_get_trailing(store);
+ GSList *buttons = path_bar->path_button->next;
+ GtkRadioButton *button;
+
+ path_bar->updating = TRUE;
+
+ /* TODO: check if the trailings match, save making new buttons */
+
+ while(buttons)
+ {
+ gtk_container_remove(GTK_CONTAINER(path_bar), GTK_WIDGET(buttons->data));
+ lsq_archive_iter_unref(g_object_get_data(G_OBJECT(buttons->data), SQ_PATH_BAR_PATH_BUTTON_ITER));
+ gtk_widget_unref(GTK_WIDGET(buttons->data));
+ buttons = buttons->next;
+ }
+ g_slist_free(path_bar->path_button->next);
+ path_bar->path_button->next = NULL;
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(path_bar->home_button), TRUE);
+ lsq_archive_iter_unref(g_object_get_data(G_OBJECT(path_bar->home_button), SQ_PATH_BAR_PATH_BUTTON_ITER));
+ g_object_set_data(G_OBJECT(path_bar->home_button), SQ_PATH_BAR_PATH_BUTTON_ITER, NULL);
+ if(path_bar->trailing)
+ lsq_archive_iter_unref(path_bar->trailing);
+ path_bar->trailing = lsq_archive_iter_ref(iter);
+
+ if(iter)
+ {
+ while(lsq_archive_iter_has_parent(iter))
+ {
+ button = GTK_RADIO_BUTTON(gtk_radio_button_new_with_label(path_bar->path_button, lsq_archive_iter_get_filename(iter)));
+ gtk_widget_ref(GTK_WIDGET(button));
+ gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button), FALSE);
+ path_bar->path_button->next = g_slist_prepend(path_bar->path_button->next, button);
+
+ if(iter == path)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+
+ g_object_set_data(G_OBJECT(button), SQ_PATH_BAR_PATH_BUTTON_ITER, iter);
+ g_signal_connect(G_OBJECT(button), "clicked", (GCallback)cb_sq_path_bar_path_button_clicked, path_bar);
+
+ gtk_container_add(GTK_CONTAINER(path_bar), GTK_WIDGET(button));
+ gtk_widget_show(GTK_WIDGET(button));
+
+ iter = lsq_archive_iter_get_parent(iter);
+ }
+
+ g_object_set_data(G_OBJECT(path_bar->home_button), SQ_PATH_BAR_PATH_BUTTON_ITER, iter);
+ }
+
+ path_bar->first_button = g_slist_last(path_bar->path_button);
+
+ path_bar->updating = FALSE;
}
static void
cb_sq_path_bar_path_button_clicked(GtkRadioButton *button, SQPathBar *path_bar)
{
- LSQArchiveIter *path;
+ LSQArchiveIter *path;
- if(path_bar->updating)
- return;
+ if(path_bar->updating)
+ return;
- path = g_object_get_data(G_OBJECT(button), SQ_PATH_BAR_PATH_BUTTON_ITER);
+ path = g_object_get_data(G_OBJECT(button), SQ_PATH_BAR_PATH_BUTTON_ITER);
- sq_archive_store_set_pwd(SQ_NAVIGATION_BAR(path_bar)->store, path);
+ sq_archive_store_set_pwd(SQ_NAVIGATION_BAR(path_bar)->store, path);
}
static void
sq_path_bar_scroll_left(SQPathBar *path_bar)
{
- GSList *iter = path_bar->path_button;
-
- while(iter->next)
- {
- if(gtk_widget_get_child_visible(GTK_WIDGET(iter->next->data)))
- break;
- iter = iter->next;
- }
- path_bar->first_button = iter;
+ GSList *iter = path_bar->path_button;
+
+ while(iter->next)
+ {
+ if(gtk_widget_get_child_visible(GTK_WIDGET(iter->next->data)))
+ break;
+ iter = iter->next;
+ }
+ path_bar->first_button = iter;
}
static void
sq_path_bar_scroll_right(SQPathBar *path_bar)
{
- if(path_bar->first_button->next)
- path_bar->first_button = path_bar->first_button->next;
+ if(path_bar->first_button->next)
+ path_bar->first_button = path_bar->first_button->next;
}
static gboolean
cb_sq_path_bar_init_timeout(gpointer user_data)
{
- if(cb_sq_path_bar_timeout(user_data))
- {
- SQ_PATH_BAR(user_data)->scroll_click = FALSE;
- SQ_PATH_BAR(user_data)->scroll_timeout = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, SQ_PATH_BAR_SCROLL_TIMEOUT, cb_sq_path_bar_timeout, user_data, NULL);
- }
+ if(cb_sq_path_bar_timeout(user_data))
+ {
+ SQ_PATH_BAR(user_data)->scroll_click = FALSE;
+ SQ_PATH_BAR(user_data)->scroll_timeout = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, SQ_PATH_BAR_SCROLL_TIMEOUT, cb_sq_path_bar_timeout, user_data, NULL);
+ }
- return FALSE;
+ return FALSE;
}
static gboolean
cb_sq_path_bar_timeout(gpointer user_data)
{
- switch(SQ_PATH_BAR(user_data)->scroll_dir)
- {
- case SQ_SCROLL_LEFT:
- sq_path_bar_scroll_left(SQ_PATH_BAR(user_data));
- break;
- case SQ_SCROLL_RIGHT:
- sq_path_bar_scroll_right(SQ_PATH_BAR(user_data));
- break;
- default:
- return FALSE;
- }
-
- gtk_widget_queue_resize(GTK_WIDGET(user_data));
-
- return TRUE;
+ switch(SQ_PATH_BAR(user_data)->scroll_dir)
+ {
+ case SQ_SCROLL_LEFT:
+ sq_path_bar_scroll_left(SQ_PATH_BAR(user_data));
+ break;
+ case SQ_SCROLL_RIGHT:
+ sq_path_bar_scroll_right(SQ_PATH_BAR(user_data));
+ break;
+ default:
+ return FALSE;
+ }
+
+ gtk_widget_queue_resize(GTK_WIDGET(user_data));
+
+ return TRUE;
}
static gboolean
cb_sq_path_bar_left_button_pressed(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
{
- if(event->type == GDK_BUTTON_PRESS && event->button == 1)
- {
- SQ_PATH_BAR(user_data)->scroll_click = TRUE;
- SQ_PATH_BAR(user_data)->scroll_dir = SQ_SCROLL_LEFT;
-
- SQ_PATH_BAR(user_data)->scroll_timeout = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, SQ_PATH_BAR_SCROLL_INIT_TIMEOUT, cb_sq_path_bar_init_timeout, user_data, NULL);
- }
- return FALSE;
+ if(event->type == GDK_BUTTON_PRESS && event->button == 1)
+ {
+ SQ_PATH_BAR(user_data)->scroll_click = TRUE;
+ SQ_PATH_BAR(user_data)->scroll_dir = SQ_SCROLL_LEFT;
+
+ SQ_PATH_BAR(user_data)->scroll_timeout = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, SQ_PATH_BAR_SCROLL_INIT_TIMEOUT, cb_sq_path_bar_init_timeout, user_data, NULL);
+ }
+ return FALSE;
}
static gboolean
cb_sq_path_bar_right_button_pressed(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
{
- if(event->type == GDK_BUTTON_PRESS && event->button == 1)
- {
- SQ_PATH_BAR(user_data)->scroll_click = TRUE;
- SQ_PATH_BAR(user_data)->scroll_dir = SQ_SCROLL_RIGHT;
-
- SQ_PATH_BAR(user_data)->scroll_timeout = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, SQ_PATH_BAR_SCROLL_INIT_TIMEOUT, cb_sq_path_bar_init_timeout, user_data, NULL);
- }
- return FALSE;
+ if(event->type == GDK_BUTTON_PRESS && event->button == 1)
+ {
+ SQ_PATH_BAR(user_data)->scroll_click = TRUE;
+ SQ_PATH_BAR(user_data)->scroll_dir = SQ_SCROLL_RIGHT;
+
+ SQ_PATH_BAR(user_data)->scroll_timeout = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, SQ_PATH_BAR_SCROLL_INIT_TIMEOUT, cb_sq_path_bar_init_timeout, user_data, NULL);
+ }
+ return FALSE;
}
static gboolean
cb_sq_path_bar_scroll_button_released(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
{
- if(event->type == GDK_BUTTON_RELEASE && event->button == 1)
- {
- if(SQ_PATH_BAR(user_data)->scroll_dir)
- g_source_remove(SQ_PATH_BAR(user_data)->scroll_timeout);
-
- SQ_PATH_BAR(user_data)->scroll_dir = SQ_SCROLL_NONE;
- }
- return FALSE;
+ if(event->type == GDK_BUTTON_RELEASE && event->button == 1)
+ {
+ if(SQ_PATH_BAR(user_data)->scroll_dir)
+ g_source_remove(SQ_PATH_BAR(user_data)->scroll_timeout);
+
+ SQ_PATH_BAR(user_data)->scroll_dir = SQ_SCROLL_NONE;
+ }
+ return FALSE;
}
static void
cb_sq_path_bar_left_clicked(GtkWidget *widget, gpointer user_data)
{
- if(SQ_PATH_BAR(user_data)->scroll_click)
- sq_path_bar_scroll_left(SQ_PATH_BAR(user_data));
+ if(SQ_PATH_BAR(user_data)->scroll_click)
+ sq_path_bar_scroll_left(SQ_PATH_BAR(user_data));
}
static void
cb_sq_path_bar_right_clicked(GtkWidget *widget, gpointer user_data)
{
- if(SQ_PATH_BAR(user_data)->scroll_click)
- sq_path_bar_scroll_right(SQ_PATH_BAR(user_data));
+ if(SQ_PATH_BAR(user_data)->scroll_click)
+ sq_path_bar_scroll_right(SQ_PATH_BAR(user_data));
}
static void
cb_sq_path_bar_store_set(SQNavigationBar *bar)
{
- cb_sq_path_bar_new_archive(bar->store, bar);
+ cb_sq_path_bar_new_archive(bar->store, bar);
- if(bar->store)
- cb_sq_path_bar_pwd_changed(bar->store, sq_archive_store_get_pwd(bar->store), bar);
+ if(bar->store)
+ cb_sq_path_bar_pwd_changed(bar->store, sq_archive_store_get_pwd(bar->store), bar);
}
diff --git a/src/path_bar.h b/src/path_bar.h
index 3c45e28..c37faee 100644
--- a/src/path_bar.h
+++ b/src/path_bar.h
@@ -20,49 +20,49 @@ G_BEGIN_DECLS
#define SQ_TYPE_PATH_BAR sq_path_bar_get_type()
-#define SQ_PATH_BAR(obj)( \
- G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- SQ_TYPE_PATH_BAR, \
- SQPathBar))
+#define SQ_PATH_BAR(obj)( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ SQ_TYPE_PATH_BAR, \
+ SQPathBar))
-#define SQ_IS_PATH_BAR(obj) ( \
- G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- SQ_TYPE_PATH_BAR))
+#define SQ_IS_PATH_BAR(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ SQ_TYPE_PATH_BAR))
#define SQ_PATH_BAR_CLASS(klass) ( \
- G_TYPE_CHECK_CLASS_CAST ((klass), \
- SQ_TYPE_PATH_BAR, \
- SQPathBarClass))
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ SQ_TYPE_PATH_BAR, \
+ SQPathBarClass))
#define SQ_IS_PATH_BAR_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_TYPE ((class), \
- SQ_TYPE_PATH_BAR()))
+ G_TYPE_CHECK_CLASS_TYPE ((class), \
+ SQ_TYPE_PATH_BAR()))
typedef struct _SQPathBar SQPathBar;
struct _SQPathBar
{
- SQNavigationBar parent;
- GtkButton *left_button;
- GtkButton *right_button;
- GtkButton *home_button;
- GSList *path_button;
- GSList *first_button;
- LSQArchiveIter *trailing;
- guint scroll_timeout;
- guint scroll_dir;
- gboolean scroll_click;
- gboolean updating;
+ SQNavigationBar parent;
+ GtkButton *left_button;
+ GtkButton *right_button;
+ GtkButton *home_button;
+ GSList *path_button;
+ GSList *first_button;
+ LSQArchiveIter *trailing;
+ guint scroll_timeout;
+ guint scroll_dir;
+ gboolean scroll_click;
+ gboolean updating;
};
typedef struct _SQPathBarClass SQPathBarClass;
struct _SQPathBarClass
{
- SQNavigationBarClass parent_class;
+ SQNavigationBarClass parent_class;
};
-GType sq_path_bar_get_type();
+GType sq_path_bar_get_type();
SQNavigationBar *sq_path_bar_new(SQArchiveStore *);
G_END_DECLS
diff --git a/src/preferences_dialog.c b/src/preferences_dialog.c
index 89515d0..b0a4120 100644
--- a/src/preferences_dialog.c
+++ b/src/preferences_dialog.c
@@ -45,27 +45,27 @@ sq_preferences_dialog_create_support_object_page(SQSupportTuple *tuple);
GType
sq_preferences_dialog_get_type (void)
{
- static GType sq_preferences_dialog_type = 0;
-
- if (!sq_preferences_dialog_type)
- {
- static const GTypeInfo sq_preferences_dialog_info =
- {
- sizeof (SQPreferencesDialogClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) sq_preferences_dialog_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (SQPreferencesDialog),
- 0,
- (GInstanceInitFunc) sq_preferences_dialog_init,
- NULL
- };
-
- sq_preferences_dialog_type = g_type_register_static (GTK_TYPE_DIALOG, "SQPreferencesDialog", &sq_preferences_dialog_info, 0);
- }
- return sq_preferences_dialog_type;
+ static GType sq_preferences_dialog_type = 0;
+
+ if (!sq_preferences_dialog_type)
+ {
+ static const GTypeInfo sq_preferences_dialog_info =
+ {
+ sizeof (SQPreferencesDialogClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) sq_preferences_dialog_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (SQPreferencesDialog),
+ 0,
+ (GInstanceInitFunc) sq_preferences_dialog_init,
+ NULL
+ };
+
+ sq_preferences_dialog_type = g_type_register_static (GTK_TYPE_DIALOG, "SQPreferencesDialog", &sq_preferences_dialog_info, 0);
+ }
+ return sq_preferences_dialog_type;
}
static void
@@ -76,121 +76,121 @@ sq_preferences_dialog_class_init(SQPreferencesDialogClass *dialog_class)
static void
sq_preferences_dialog_init(SQPreferencesDialog *dialog)
{
- GtkWidget *box;
- GtkWidget *label;
- GtkWidget *frame;
- dialog->notebook = gtk_notebook_new();
-
- box = gtk_vbox_new(FALSE, 0);
- label = gtk_label_new_with_mnemonic(_("_General"));
- gtk_notebook_append_page(GTK_NOTEBOOK(dialog->notebook), box, label);
-
- frame = gtk_frame_new(_("Archive viewer:"));
- gtk_box_pack_start(GTK_BOX(box), frame,FALSE, FALSE, 0);
- gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
- gtk_container_set_border_width(GTK_CONTAINER(frame), 0);
-
- GtkWidget *_vbox = gtk_vbox_new(FALSE, 0);
- gtk_container_add(GTK_CONTAINER(frame), _vbox);
- gtk_container_set_border_width(GTK_CONTAINER(_vbox), 0);
-
- dialog->general.viewer.show_icons = gtk_check_button_new_with_mnemonic(_("_Show Icons"));
- gtk_box_pack_start(GTK_BOX(_vbox), dialog->general.viewer.show_icons, FALSE, FALSE, 0);
-
- dialog->general.viewer.rules_hint = gtk_check_button_new_with_mnemonic(_("_Rules Hint"));
- gtk_box_pack_start(GTK_BOX(_vbox), dialog->general.viewer.rules_hint, FALSE, FALSE, 0);
-
- frame = gtk_frame_new(_("Sorting:"));
- gtk_box_pack_start(GTK_BOX(_vbox), frame,FALSE, FALSE, 0);
- gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
- gtk_container_set_border_width(GTK_CONTAINER(frame), 0);
-
- GtkWidget *sort_vbox = gtk_vbox_new(FALSE, 0);
- gtk_container_add(GTK_CONTAINER(frame), sort_vbox);
- gtk_container_set_border_width(GTK_CONTAINER(sort_vbox), 0);
-
- dialog->general.viewer.sorting.sort_case = gtk_check_button_new_with_mnemonic(_("Sort _Case Sensitive "));
- gtk_box_pack_start(GTK_BOX(sort_vbox), dialog->general.viewer.sorting.sort_case, FALSE, FALSE, 0);
-
- dialog->general.viewer.sorting.sort_folders = gtk_check_button_new_with_mnemonic(_("Sort _Folders First"));
- gtk_box_pack_start(GTK_BOX(sort_vbox), dialog->general.viewer.sorting.sort_folders, FALSE, FALSE, 0);
-
- frame = gtk_frame_new(_("Navigation bar:"));
- gtk_box_pack_start(GTK_BOX(box), frame,FALSE, FALSE, 0);
- gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
- gtk_container_set_border_width(GTK_CONTAINER(frame), 0);
-
- GtkWidget *nav_vbox = gtk_hbox_new(FALSE, 0);
- gtk_container_add(GTK_CONTAINER(frame), nav_vbox);
- gtk_container_set_border_width(GTK_CONTAINER(nav_vbox), 0);
-
- sq_preferences_dialog_create_support_page(dialog);
-
- box = gtk_hbox_new(FALSE, 0);
- label = gtk_label_new_with_mnemonic(_("_Behaviour"));
- gtk_notebook_append_page(GTK_NOTEBOOK(dialog->notebook), box, label);
-
- gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), dialog->notebook);
- gtk_widget_show_all(dialog->notebook);
- gtk_dialog_add_buttons(GTK_DIALOG(dialog),
- GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
- NULL);
- gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
+ GtkWidget *box;
+ GtkWidget *label;
+ GtkWidget *frame;
+ dialog->notebook = gtk_notebook_new();
+
+ box = gtk_vbox_new(FALSE, 0);
+ label = gtk_label_new_with_mnemonic(_("_General"));
+ gtk_notebook_append_page(GTK_NOTEBOOK(dialog->notebook), box, label);
+
+ frame = gtk_frame_new(_("Archive viewer:"));
+ gtk_box_pack_start(GTK_BOX(box), frame,FALSE, FALSE, 0);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 0);
+
+ GtkWidget *_vbox = gtk_vbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(frame), _vbox);
+ gtk_container_set_border_width(GTK_CONTAINER(_vbox), 0);
+
+ dialog->general.viewer.show_icons = gtk_check_button_new_with_mnemonic(_("_Show Icons"));
+ gtk_box_pack_start(GTK_BOX(_vbox), dialog->general.viewer.show_icons, FALSE, FALSE, 0);
+
+ dialog->general.viewer.rules_hint = gtk_check_button_new_with_mnemonic(_("_Rules Hint"));
+ gtk_box_pack_start(GTK_BOX(_vbox), dialog->general.viewer.rules_hint, FALSE, FALSE, 0);
+
+ frame = gtk_frame_new(_("Sorting:"));
+ gtk_box_pack_start(GTK_BOX(_vbox), frame,FALSE, FALSE, 0);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 0);
+
+ GtkWidget *sort_vbox = gtk_vbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(frame), sort_vbox);
+ gtk_container_set_border_width(GTK_CONTAINER(sort_vbox), 0);
+
+ dialog->general.viewer.sorting.sort_case = gtk_check_button_new_with_mnemonic(_("Sort _Case Sensitive "));
+ gtk_box_pack_start(GTK_BOX(sort_vbox), dialog->general.viewer.sorting.sort_case, FALSE, FALSE, 0);
+
+ dialog->general.viewer.sorting.sort_folders = gtk_check_button_new_with_mnemonic(_("Sort _Folders First"));
+ gtk_box_pack_start(GTK_BOX(sort_vbox), dialog->general.viewer.sorting.sort_folders, FALSE, FALSE, 0);
+
+ frame = gtk_frame_new(_("Navigation bar:"));
+ gtk_box_pack_start(GTK_BOX(box), frame,FALSE, FALSE, 0);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 0);
+
+ GtkWidget *nav_vbox = gtk_hbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(frame), nav_vbox);
+ gtk_container_set_border_width(GTK_CONTAINER(nav_vbox), 0);
+
+ sq_preferences_dialog_create_support_page(dialog);
+
+ box = gtk_hbox_new(FALSE, 0);
+ label = gtk_label_new_with_mnemonic(_("_Behaviour"));
+ gtk_notebook_append_page(GTK_NOTEBOOK(dialog->notebook), box, label);
+
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), dialog->notebook);
+ gtk_widget_show_all(dialog->notebook);
+ gtk_dialog_add_buttons(GTK_DIALOG(dialog),
+ GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
+ NULL);
+ gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
}
GtkWidget *
sq_preferences_dialog_new(void)
{
- GtkWidget *dialog;
+ GtkWidget *dialog;
- dialog = g_object_new(sq_preferences_dialog_get_type(),
- "title", _("Preferences"),
- NULL);
+ dialog = g_object_new(sq_preferences_dialog_get_type(),
+ "title", _("Preferences"),
+ NULL);
- return dialog;
+ return dialog;
}
/*
inline static void
sq_preferences_dialog_create_general_page(SQPreferencesDialog *dialog)
{
- box = gtk_vbox_new(FALSE, 0);
- label = gtk_label_new_with_mnemonic(_("_General"));
- gtk_notebook_append_page(GTK_NOTEBOOK(dialog->notebook), box, label);
+ box = gtk_vbox_new(FALSE, 0);
+ label = gtk_label_new_with_mnemonic(_("_General"));
+ gtk_notebook_append_page(GTK_NOTEBOOK(dialog->notebook), box, label);
- frame = gtk_frame_new(_("Archive viewer:"));
- gtk_box_pack_start(GTK_BOX(box), frame,FALSE, FALSE, 0);
- gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
- gtk_container_set_border_width(GTK_CONTAINER(frame), 0);
+ frame = gtk_frame_new(_("Archive viewer:"));
+ gtk_box_pack_start(GTK_BOX(box), frame,FALSE, FALSE, 0);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 0);
- GtkWidget *_vbox = gtk_vbox_new(FALSE, 0);
- gtk_container_add(GTK_CONTAINER(frame), _vbox);
- gtk_container_set_border_width(GTK_CONTAINER(_vbox), 0);
+ GtkWidget *_vbox = gtk_vbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(frame), _vbox);
+ gtk_container_set_border_width(GTK_CONTAINER(_vbox), 0);
- dialog->general.viewer.show_icons = gtk_check_button_new_with_mnemonic(_("_Show Icons"));
- gtk_box_pack_start(GTK_BOX(_vbox), dialog->general.viewer.show_icons, FALSE, FALSE, 0);
+ dialog->general.viewer.show_icons = gtk_check_button_new_with_mnemonic(_("_Show Icons"));
+ gtk_box_pack_start(GTK_BOX(_vbox), dialog->general.viewer.show_icons, FALSE, FALSE, 0);
- dialog->general.viewer.rules_hint = gtk_check_button_new_with_mnemonic(_("_Rules Hint"));
- gtk_box_pack_start(GTK_BOX(_vbox), dialog->general.viewer.rules_hint, FALSE, FALSE, 0);
+ dialog->general.viewer.rules_hint = gtk_check_button_new_with_mnemonic(_("_Rules Hint"));
+ gtk_box_pack_start(GTK_BOX(_vbox), dialog->general.viewer.rules_hint, FALSE, FALSE, 0);
- frame = gtk_frame_new(_("Sorting:"));
- gtk_box_pack_start(GTK_BOX(_vbox), frame,FALSE, FALSE, 0);
- gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
- gtk_container_set_border_width(GTK_CONTAINER(frame), 0);
+ frame = gtk_frame_new(_("Sorting:"));
+ gtk_box_pack_start(GTK_BOX(_vbox), frame,FALSE, FALSE, 0);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 0);
- GtkWidget *sort_vbox = gtk_vbox_new(FALSE, 0);
- gtk_container_add(GTK_CONTAINER(frame), sort_vbox);
- gtk_container_set_border_width(GTK_CONTAINER(sort_vbox), 0);
+ GtkWidget *sort_vbox = gtk_vbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(frame), sort_vbox);
+ gtk_container_set_border_width(GTK_CONTAINER(sort_vbox), 0);
- dialog->general.viewer.sorting.sort_case = gtk_check_button_new_with_mnemonic(_("Sort _Case Sensitive "));
- gtk_box_pack_start(GTK_BOX(sort_vbox), dialog->general.viewer.sorting.sort_case, FALSE, FALSE, 0);
+ dialog->general.viewer.sorting.sort_case = gtk_check_button_new_with_mnemonic(_("Sort _Case Sensitive "));
+ gtk_box_pack_start(GTK_BOX(sort_vbox), dialog->general.viewer.sorting.sort_case, FALSE, FALSE, 0);
- dialog->general.viewer.sorting.sort_folders = gtk_check_button_new_with_mnemonic(_("Sort _Folders First"));
- gtk_box_pack_start(GTK_BOX(sort_vbox), dialog->general.viewer.sorting.sort_folders, FALSE, FALSE, 0);
+ dialog->general.viewer.sorting.sort_folders = gtk_check_button_new_with_mnemonic(_("Sort _Folders First"));
+ gtk_box_pack_start(GTK_BOX(sort_vbox), dialog->general.viewer.sorting.sort_folders, FALSE, FALSE, 0);
#ifdef SQ_MAIN_ANY_BAR
frame = sq_widget_factory_create_property_widget(window->widget_factory, G_OBJECT(window), "navigation-style");
- gtk_box_pack_start(GTK_BOX(box), frame,FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(box), frame,FALSE, FALSE, 0);
#endif
}
*/
@@ -198,162 +198,162 @@ sq_preferences_dialog_create_general_page(SQPreferencesDialog *dialog)
inline static void
sq_preferences_dialog_create_support_page(SQPreferencesDialog *dialog)
{
- GtkWidget *iconview;
- GtkWidget *label;
- GtkWidget *box = gtk_hbox_new(FALSE, 0);
- label = gtk_label_new_with_mnemonic(_("_Archivers"));
- gtk_notebook_append_page(GTK_NOTEBOOK(dialog->notebook), box, label);
+ GtkWidget *iconview;
+ GtkWidget *label;
+ GtkWidget *box = gtk_hbox_new(FALSE, 0);
+ label = gtk_label_new_with_mnemonic(_("_Archivers"));
+ gtk_notebook_append_page(GTK_NOTEBOOK(dialog->notebook), box, label);
- GtkTreeModel *store = GTK_TREE_MODEL(gtk_list_store_new(2, GDK_TYPE_PIXBUF, G_TYPE_STRING));
- GtkCellRenderer *render = gtk_cell_renderer_pixbuf_new();
+ GtkTreeModel *store = GTK_TREE_MODEL(gtk_list_store_new(2, GDK_TYPE_PIXBUF, G_TYPE_STRING));
+ GtkCellRenderer *render = gtk_cell_renderer_pixbuf_new();
- iconview = gtk_icon_view_new_with_model(store);
- g_signal_connect(G_OBJECT(iconview), "selection-changed", (GCallback)cb_sq_preferences_dialog_item_changed, dialog);
+ iconview = gtk_icon_view_new_with_model(store);
+ g_signal_connect(G_OBJECT(iconview), "selection-changed", (GCallback)cb_sq_preferences_dialog_item_changed, dialog);
- GtkWidget *scroll = gtk_scrolled_window_new(NULL, NULL);
- gtk_widget_set_size_request(scroll, 84, 84);
+ GtkWidget *scroll = gtk_scrolled_window_new(NULL, NULL);
+ gtk_widget_set_size_request(scroll, 84, 84);
- gtk_container_add(GTK_CONTAINER(scroll), iconview);
- /* gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll), iconview); */
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
- gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scroll), GTK_CORNER_TOP_RIGHT);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll), GTK_SHADOW_IN);
+ gtk_container_add(GTK_CONTAINER(scroll), iconview);
+ /* gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll), iconview); */
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
+ gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scroll), GTK_CORNER_TOP_RIGHT);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll), GTK_SHADOW_IN);
- render = gtk_cell_renderer_text_new();
- g_object_set(G_OBJECT(render), "ellipsize", PANGO_ELLIPSIZE_END, "ellipsize-set", TRUE, NULL);
- gtk_icon_view_set_item_width(GTK_ICON_VIEW(iconview), 48);
- /* gtk_icon_view_set_orientation(GTK_ICON_VIEW(iconview), GTK_ORIENTATION_HORIZONTAL); */
- gtk_icon_view_set_columns(GTK_ICON_VIEW(iconview), 1);
- gtk_icon_view_set_pixbuf_column(GTK_ICON_VIEW(iconview), 0);
- gtk_icon_view_set_text_column(GTK_ICON_VIEW(iconview), 1);
+ render = gtk_cell_renderer_text_new();
+ g_object_set(G_OBJECT(render), "ellipsize", PANGO_ELLIPSIZE_END, "ellipsize-set", TRUE, NULL);
+ gtk_icon_view_set_item_width(GTK_ICON_VIEW(iconview), 48);
+ /* gtk_icon_view_set_orientation(GTK_ICON_VIEW(iconview), GTK_ORIENTATION_HORIZONTAL); */
+ gtk_icon_view_set_columns(GTK_ICON_VIEW(iconview), 1);
+ gtk_icon_view_set_pixbuf_column(GTK_ICON_VIEW(iconview), 0);
+ gtk_icon_view_set_text_column(GTK_ICON_VIEW(iconview), 1);
- dialog->support.notebook = gtk_notebook_new();
- gtk_notebook_set_show_tabs(GTK_NOTEBOOK(dialog->support.notebook), FALSE);
- gtk_notebook_set_show_border(GTK_NOTEBOOK(dialog->support.notebook), FALSE);
+ dialog->support.notebook = gtk_notebook_new();
+ gtk_notebook_set_show_tabs(GTK_NOTEBOOK(dialog->support.notebook), FALSE);
+ gtk_notebook_set_show_border(GTK_NOTEBOOK(dialog->support.notebook), FALSE);
- dialog->support.support_list = NULL;
+ dialog->support.support_list = NULL;
- GSList *sup_iter, *support_list = sup_iter = lsq_get_registered_support_list();
+ GSList *sup_iter, *support_list = sup_iter = lsq_get_registered_support_list();
- GtkTreeIter iter;
- LSQArchiveSupport *support;
- SQSupportTuple *tuple;
+ GtkTreeIter iter;
+ LSQArchiveSupport *support;
+ SQSupportTuple *tuple;
- while(sup_iter)
- {
- tuple = g_new(SQSupportTuple, 1);
- tuple->support = support = LSQ_ARCHIVE_SUPPORT(sup_iter->data);
- gtk_list_store_append(GTK_LIST_STORE(store), &iter);
- gtk_list_store_set(GTK_LIST_STORE(store), &iter, 1, lsq_archive_support_get_id(support), -1);
- sup_iter = g_slist_next(sup_iter);
+ while(sup_iter)
+ {
+ tuple = g_new(SQSupportTuple, 1);
+ tuple->support = support = LSQ_ARCHIVE_SUPPORT(sup_iter->data);
+ gtk_list_store_append(GTK_LIST_STORE(store), &iter);
+ gtk_list_store_set(GTK_LIST_STORE(store), &iter, 1, lsq_archive_support_get_id(support), -1);
+ sup_iter = g_slist_next(sup_iter);
- gtk_notebook_append_page(GTK_NOTEBOOK(dialog->support.notebook), sq_preferences_dialog_create_support_object_page(tuple), NULL);
+ gtk_notebook_append_page(GTK_NOTEBOOK(dialog->support.notebook), sq_preferences_dialog_create_support_object_page(tuple), NULL);
- dialog->support.support_list = g_slist_prepend(dialog->support.support_list, tuple);
- }
+ dialog->support.support_list = g_slist_prepend(dialog->support.support_list, tuple);
+ }
- g_slist_free(support_list);
+ g_slist_free(support_list);
- GtkTreePath *path = gtk_tree_path_new_from_indices(0, -1);
+ GtkTreePath *path = gtk_tree_path_new_from_indices(0, -1);
- gtk_icon_view_set_cursor(GTK_ICON_VIEW(iconview), path, NULL, FALSE);
- gtk_icon_view_select_path(GTK_ICON_VIEW(iconview), path);
+ gtk_icon_view_set_cursor(GTK_ICON_VIEW(iconview), path, NULL, FALSE);
+ gtk_icon_view_select_path(GTK_ICON_VIEW(iconview), path);
- gtk_tree_path_free(path);
+ gtk_tree_path_free(path);
- gtk_widget_show(iconview);
+ gtk_widget_show(iconview);
- gtk_box_pack_start(GTK_BOX(box), scroll, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(box), dialog->support.notebook, TRUE, TRUE, 0);
- gtk_widget_show_all(box);
+ gtk_box_pack_start(GTK_BOX(box), scroll, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(box), dialog->support.notebook, TRUE, TRUE, 0);
+ gtk_widget_show_all(box);
}
#if 1
static GtkWidget *
sq_preferences_dialog_create_support_object_page(SQSupportTuple *tuple)
{
- GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
+ GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
- tuple->box = sq_button_drag_box_new();
- SQButtonDragBox *button_box = SQ_BUTTON_DRAG_BOX(tuple->box);
+ tuple->box = sq_button_drag_box_new();
+ SQButtonDragBox *button_box = SQ_BUTTON_DRAG_BOX(tuple->box);
- gtk_box_pack_start(GTK_BOX(vbox), tuple->box, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), tuple->box, FALSE, FALSE, 0);
- sq_button_drag_box_add_fixed_button(button_box, _("Filename"), NULL);
- sq_button_drag_box_lock_buttons(button_box, 1);
+ sq_button_drag_box_add_fixed_button(button_box, _("Filename"), NULL);
+ sq_button_drag_box_lock_buttons(button_box, 1);
- GSList *iter, *view_props = iter = lsq_archive_support_list_properties(tuple->support, "view");
- GParamSpec *spec;
- gboolean visible;
+ GSList *iter, *view_props = iter = lsq_archive_support_list_properties(tuple->support, "view");
+ GParamSpec *spec;
+ gboolean visible;
- while(iter)
- {
- spec = G_PARAM_SPEC(iter->data);
- g_object_get(G_OBJECT(tuple->support), g_param_spec_get_name(spec), &visible, NULL);
- sq_button_drag_box_add_button(button_box, g_param_spec_get_nick(spec), visible, (gpointer)g_param_spec_get_name(spec));
- iter = g_slist_next(iter);
- }
+ while(iter)
+ {
+ spec = G_PARAM_SPEC(iter->data);
+ g_object_get(G_OBJECT(tuple->support), g_param_spec_get_name(spec), &visible, NULL);
+ sq_button_drag_box_add_button(button_box, g_param_spec_get_nick(spec), visible, (gpointer)g_param_spec_get_name(spec));
+ iter = g_slist_next(iter);
+ }
- g_slist_free(view_props);
+ g_slist_free(view_props);
- return vbox;
+ return vbox;
}
#else
static GtkWidget *
sq_preferences_dialog_create_support_object_page(SQSupportTuple *tuple)
{
- GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
+ GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
- GtkTreeModel *store = GTK_TREE_MODEL(gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING));
+ GtkTreeModel *store = GTK_TREE_MODEL(gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING));
- tuple->box = gtk_tree_view_new_with_model(store);
- GtkTreeView *tree_view = GTK_TREE_VIEW(tuple->box);
- gtk_tree_view_set_reorderable(tree_view, TRUE);
+ tuple->box = gtk_tree_view_new_with_model(store);
+ GtkTreeView *tree_view = GTK_TREE_VIEW(tuple->box);
+ gtk_tree_view_set_reorderable(tree_view, TRUE);
- GtkCellRenderer *render = gtk_cell_renderer_text_new();
- GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes("Column", render, "text", 0, NULL);
- gtk_tree_view_append_column(tree_view, column);
+ GtkCellRenderer *render = gtk_cell_renderer_text_new();
+ GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes("Column", render, "text", 0, NULL);
+ gtk_tree_view_append_column(tree_view, column);
- GtkWidget *scroll = gtk_scrolled_window_new(NULL, NULL);
- gtk_widget_set_size_request(scroll, 100, 100);
+ GtkWidget *scroll = gtk_scrolled_window_new(NULL, NULL);
+ gtk_widget_set_size_request(scroll, 100, 100);
- gtk_container_add(GTK_CONTAINER(scroll), tuple->box);
- /* gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll), iconview); */
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll), GTK_SHADOW_IN);
+ gtk_container_add(GTK_CONTAINER(scroll), tuple->box);
+ /* gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll), iconview); */
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll), GTK_SHADOW_IN);
- render = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("Discription", render, "text", 1, NULL);
- gtk_tree_view_append_column(tree_view, column);
+ render = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes("Discription", render, "text", 1, NULL);
+ gtk_tree_view_append_column(tree_view, column);
- gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0);
- GSList *iter, *view_props = iter = lsq_archive_support_list_properties(tuple->support, "view");
- GParamSpec *spec;
- gboolean visible;
- GtkTreeIter titer;
+ GSList *iter, *view_props = iter = lsq_archive_support_list_properties(tuple->support, "view");
+ GParamSpec *spec;
+ gboolean visible;
+ GtkTreeIter titer;
- while(iter)
- {
- spec = G_PARAM_SPEC(iter->data);
- g_object_get(G_OBJECT(tuple->support), g_param_spec_get_name(spec), &visible, NULL);
+ while(iter)
+ {
+ spec = G_PARAM_SPEC(iter->data);
+ g_object_get(G_OBJECT(tuple->support), g_param_spec_get_name(spec), &visible, NULL);
- gtk_list_store_append(GTK_LIST_STORE(store), &titer);
- gtk_list_store_set(GTK_LIST_STORE(store), &titer, 0, g_param_spec_get_nick(spec), 1, g_param_spec_get_blurb(spec), -1);
+ gtk_list_store_append(GTK_LIST_STORE(store), &titer);
+ gtk_list_store_set(GTK_LIST_STORE(store), &titer, 0, g_param_spec_get_nick(spec), 1, g_param_spec_get_blurb(spec), -1);
- iter = g_slist_next(iter);
- }
+ iter = g_slist_next(iter);
+ }
- g_slist_free(view_props);
+ g_slist_free(view_props);
- return vbox;
+ return vbox;
}
#endif
static void
cb_sq_preferences_dialog_item_changed(GtkWidget *widget, gpointer user_data)
{
- SQPreferencesDialog *dialog = SQ_PREFERENCES_DIALOG(user_data);
- GtkTreePath *path;
- gtk_icon_view_get_cursor(GTK_ICON_VIEW(widget), &path, NULL);
- gtk_notebook_set_current_page(GTK_NOTEBOOK(dialog->support.notebook), gtk_tree_path_get_indices(path)[0]);
- gtk_tree_path_free(path);
+ SQPreferencesDialog *dialog = SQ_PREFERENCES_DIALOG(user_data);
+ GtkTreePath *path;
+ gtk_icon_view_get_cursor(GTK_ICON_VIEW(widget), &path, NULL);
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(dialog->support.notebook), gtk_tree_path_get_indices(path)[0]);
+ gtk_tree_path_free(path);
}
diff --git a/src/preferences_dialog.h b/src/preferences_dialog.h
index a5bbedb..4faa847 100644
--- a/src/preferences_dialog.h
+++ b/src/preferences_dialog.h
@@ -18,60 +18,60 @@
#define __SQRCHIVER_PREFERENCES_DIALOG_H__
G_BEGIN_DECLS
-#define SQ_PREFERENCES_DIALOG(obj) ( \
- G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- sq_preferences_dialog_get_type(), \
- SQPreferencesDialog))
+#define SQ_PREFERENCES_DIALOG(obj) ( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ sq_preferences_dialog_get_type(), \
+ SQPreferencesDialog))
-#define SQ_IS_PREFERENCES_DIALOG(obj) ( \
- G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- sq_preferences_dialog_get_type()))
+#define SQ_IS_PREFERENCES_DIALOG(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ sq_preferences_dialog_get_type()))
#define SQ_PREFERENCES_DIALOG_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_CAST ((class), \
- sq_preferences_dialog_get_type(), \
- SQPreferencesDialogClass))
+ G_TYPE_CHECK_CLASS_CAST ((class), \
+ sq_preferences_dialog_get_type(), \
+ SQPreferencesDialogClass))
#define SQ_IS_PREFERENCES_DIALOG_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_TYPE ((class), \
- sq_preferences_dialog_get_type()))
+ G_TYPE_CHECK_CLASS_TYPE ((class), \
+ sq_preferences_dialog_get_type()))
typedef struct
{
- LSQArchiveSupport *support;
- GtkWidget *box;
+ LSQArchiveSupport *support;
+ GtkWidget *box;
} SQSupportTuple;
typedef struct _SQPreferencesDialog SQPreferencesDialog;
struct _SQPreferencesDialog
{
- GtkDialog parent;
- GtkWidget *notebook;
- struct {
- struct {
- GtkWidget *show_icons;
- GtkWidget *rules_hint;
- struct {
- GtkWidget *sort_case;
- GtkWidget *sort_folders;
- } sorting;
- } viewer;
- } general;
- struct {
- GtkWidget *notebook;
- GSList *support_list;
- } support;
+ GtkDialog parent;
+ GtkWidget *notebook;
+ struct {
+ struct {
+ GtkWidget *show_icons;
+ GtkWidget *rules_hint;
+ struct {
+ GtkWidget *sort_case;
+ GtkWidget *sort_folders;
+ } sorting;
+ } viewer;
+ } general;
+ struct {
+ GtkWidget *notebook;
+ GSList *support_list;
+ } support;
};
typedef struct _SQPreferencesDialogClass SQPreferencesDialogClass;
struct _SQPreferencesDialogClass
{
- GtkDialogClass parent;
+ GtkDialogClass parent;
};
-GType sq_preferences_dialog_get_type ();
+GType sq_preferences_dialog_get_type ();
GtkWidget *sq_preferences_dialog_new();
G_END_DECLS
diff --git a/src/properties_dialog.c b/src/properties_dialog.c
index 53a48a5..4daf8aa 100644
--- a/src/properties_dialog.c
+++ b/src/properties_dialog.c
@@ -33,27 +33,27 @@ sq_properties_dialog_init(SQPropertiesDialog *archive);
GType
sq_properties_dialog_get_type (void)
{
- static GType sq_properties_dialog_type = 0;
-
- if (!sq_properties_dialog_type)
- {
- static const GTypeInfo sq_properties_dialog_info =
- {
- sizeof (SQPropertiesDialogClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) sq_properties_dialog_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (SQPropertiesDialog),
- 0,
- (GInstanceInitFunc) sq_properties_dialog_init,
- NULL
- };
-
- sq_properties_dialog_type = g_type_register_static (GTK_TYPE_DIALOG, "SQPropertiesDialog", &sq_properties_dialog_info, 0);
- }
- return sq_properties_dialog_type;
+ static GType sq_properties_dialog_type = 0;
+
+ if (!sq_properties_dialog_type)
+ {
+ static const GTypeInfo sq_properties_dialog_info =
+ {
+ sizeof (SQPropertiesDialogClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) sq_properties_dialog_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (SQPropertiesDialog),
+ 0,
+ (GInstanceInitFunc) sq_properties_dialog_init,
+ NULL
+ };
+
+ sq_properties_dialog_type = g_type_register_static (GTK_TYPE_DIALOG, "SQPropertiesDialog", &sq_properties_dialog_info, 0);
+ }
+ return sq_properties_dialog_type;
}
static void
@@ -64,72 +64,72 @@ sq_properties_dialog_class_init(SQPropertiesDialogClass *dialog_class)
static void
sq_properties_dialog_init(SQPropertiesDialog *dialog)
{
- GtkWidget *box;
- GtkWidget *label;
+ GtkWidget *box;
+ GtkWidget *label;
- dialog->table = (GtkTable *)gtk_table_new(2, 2, FALSE);
+ dialog->table = (GtkTable *)gtk_table_new(2, 2, FALSE);
- gtk_table_set_col_spacings (dialog->table, 12);
- gtk_container_set_border_width(GTK_CONTAINER(dialog->table), 6);
- gtk_container_add(GTK_CONTAINER(((GtkDialog *)dialog)->vbox), GTK_WIDGET(dialog->table));
- gtk_widget_show (GTK_WIDGET(dialog->table));
+ gtk_table_set_col_spacings (dialog->table, 12);
+ gtk_container_set_border_width(GTK_CONTAINER(dialog->table), 6);
+ gtk_container_add(GTK_CONTAINER(((GtkDialog *)dialog)->vbox), GTK_WIDGET(dialog->table));
+ gtk_widget_show (GTK_WIDGET(dialog->table));
- box = gtk_hbox_new(6, FALSE);
- gtk_table_attach (dialog->table, box, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 3);
- gtk_widget_show (box);
+ box = gtk_hbox_new(6, FALSE);
+ gtk_table_attach (dialog->table, box, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 3);
+ gtk_widget_show (box);
- dialog->icon_image = gtk_image_new();
- gtk_box_pack_start (GTK_BOX (box), dialog->icon_image, FALSE, TRUE, 0);
- gtk_widget_show (dialog->icon_image);
+ dialog->icon_image = gtk_image_new();
+ gtk_box_pack_start (GTK_BOX (box), dialog->icon_image, FALSE, TRUE, 0);
+ gtk_widget_show (dialog->icon_image);
- label = gtk_label_new(_("Name:"));
- gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 0);
- gtk_widget_show (label);
+ label = gtk_label_new(_("Name:"));
+ gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 0);
+ gtk_widget_show (label);
- dialog->filename_label = gtk_label_new("");
- gtk_table_attach (dialog->table, dialog->filename_label, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 3);
- gtk_widget_show(dialog->filename_label);
+ dialog->filename_label = gtk_label_new("");
+ gtk_table_attach (dialog->table, dialog->filename_label, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 3);
+ gtk_widget_show(dialog->filename_label);
- dialog->prop_table = (GtkTable *)gtk_table_new(2, 1, TRUE);
- gtk_table_set_col_spacings (dialog->prop_table, 12);
- gtk_table_attach (dialog->table, GTK_WIDGET(dialog->prop_table), 0, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 3);
- gtk_widget_show(GTK_WIDGET(dialog->prop_table));
+ dialog->prop_table = (GtkTable *)gtk_table_new(2, 1, TRUE);
+ gtk_table_set_col_spacings (dialog->prop_table, 12);
+ gtk_table_attach (dialog->table, GTK_WIDGET(dialog->prop_table), 0, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 3);
+ gtk_widget_show(GTK_WIDGET(dialog->prop_table));
- label = gtk_label_new(_("Kind:"));
- gtk_misc_set_alignment(GTK_MISC(label), 1.0f, 0.5f);
- gtk_table_attach (dialog->prop_table, label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 3);
- gtk_widget_show (label);
+ label = gtk_label_new(_("Kind:"));
+ gtk_misc_set_alignment(GTK_MISC(label), 1.0f, 0.5f);
+ gtk_table_attach (dialog->prop_table, label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 3);
+ gtk_widget_show (label);
- dialog->mimetype_label = gtk_label_new("");
- gtk_table_attach (dialog->prop_table, dialog->mimetype_label, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 3);
- gtk_widget_show(dialog->mimetype_label);
+ dialog->mimetype_label = gtk_label_new("");
+ gtk_table_attach (dialog->prop_table, dialog->mimetype_label, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 3);
+ gtk_widget_show(dialog->mimetype_label);
- gtk_dialog_add_buttons(GTK_DIALOG(dialog),
- GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
- NULL);
+ gtk_dialog_add_buttons(GTK_DIALOG(dialog),
+ GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
+ NULL);
}
GtkWidget *
sq_properties_dialog_new(LSQArchive *archive, GtkIconTheme *icon_theme)
{
- GtkWidget *dialog;
- gchar *filename;
+ GtkWidget *dialog;
+ gchar *filename;
- dialog = g_object_new(sq_properties_dialog_get_type(),
- "title", _("Properties"),
- NULL);
+ dialog = g_object_new(sq_properties_dialog_get_type(),
+ "title", _("Properties"),
+ NULL);
- gtk_widget_set_size_request(dialog, 220, 400);
- gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
+ gtk_widget_set_size_request(dialog, 220, 400);
+ gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
- GdkPixbuf *icon = gtk_icon_theme_load_icon(icon_theme, thunar_vfs_mime_info_lookup_icon_name(archive->mime_info, icon_theme), 48, 0, NULL);
- gtk_image_set_from_pixbuf(GTK_IMAGE(((SQPropertiesDialog *)dialog)->icon_image), icon);
+ GdkPixbuf *icon = gtk_icon_theme_load_icon(icon_theme, thunar_vfs_mime_info_lookup_icon_name(archive->mime_info, icon_theme), 48, 0, NULL);
+ gtk_image_set_from_pixbuf(GTK_IMAGE(((SQPropertiesDialog *)dialog)->icon_image), icon);
- filename = lsq_archive_get_filename(archive);
- gtk_label_set_text(GTK_LABEL(((SQPropertiesDialog *)dialog)->filename_label), filename);
- g_free(filename);
- gtk_label_set_text(GTK_LABEL(((SQPropertiesDialog *)dialog)->mimetype_label), lsq_archive_get_mimetype(archive));
+ filename = lsq_archive_get_filename(archive);
+ gtk_label_set_text(GTK_LABEL(((SQPropertiesDialog *)dialog)->filename_label), filename);
+ g_free(filename);
+ gtk_label_set_text(GTK_LABEL(((SQPropertiesDialog *)dialog)->mimetype_label), lsq_archive_get_mimetype(archive));
- return dialog;
+ return dialog;
}
diff --git a/src/properties_dialog.h b/src/properties_dialog.h
index 9731426..33b3986 100644
--- a/src/properties_dialog.h
+++ b/src/properties_dialog.h
@@ -23,41 +23,41 @@
#define __SQ_PROPERTIES_DIALOG_H__
G_BEGIN_DECLS
-#define SQ_PROPERTIES_DIALOG(obj) ( \
- G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- sq_properties_dialog_get_type(), \
- SQPropertiesDialog))
+#define SQ_PROPERTIES_DIALOG(obj) ( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ sq_properties_dialog_get_type(), \
+ SQPropertiesDialog))
-#define SQ_IS_PROPERTIES_DIALOG(obj) ( \
- G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- sq_properties_dialog_get_type()))
+#define SQ_IS_PROPERTIES_DIALOG(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ sq_properties_dialog_get_type()))
#define SQ_PROPERTIES_DIALOG_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_CAST ((class), \
- sq_properties_dialog_get_type(), \
- SQPropertiesDialogClass))
+ G_TYPE_CHECK_CLASS_CAST ((class), \
+ sq_properties_dialog_get_type(), \
+ SQPropertiesDialogClass))
#define SQ_IS_PROPERTIES_DIALOG_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_TYPE ((class), \
- sq_properties_dialog_get_type()))
+ G_TYPE_CHECK_CLASS_TYPE ((class), \
+ sq_properties_dialog_get_type()))
typedef struct _SQPropertiesDialog SQPropertiesDialog;
struct _SQPropertiesDialog
{
- GtkDialog parent;
- GtkTable *table;
- GtkWidget *icon_image;
- GtkWidget *filename_label;
- GtkWidget *mimetype_label;
- GtkTable *prop_table;
+ GtkDialog parent;
+ GtkTable *table;
+ GtkWidget *icon_image;
+ GtkWidget *filename_label;
+ GtkWidget *mimetype_label;
+ GtkTable *prop_table;
};
typedef struct _SQPropertiesDialogClass SQPropertiesDialogClass;
struct _SQPropertiesDialogClass
{
- GtkDialogClass parent;
+ GtkDialogClass parent;
};
GtkWidget *sq_properties_dialog_new(LSQArchive *, GtkIconTheme *);
diff --git a/src/settings.c b/src/settings.c
index 92f1dc2..61fbff1 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -15,178 +15,442 @@
*/
#include <config.h>
-#include <glib.h>
-#include <glib-object.h>
-#ifdef HAVE_LIBXFCE4UTIL
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <xfconf/xfconf.h>
#include <libxfce4util/libxfce4util.h>
-#endif
#include "settings.h"
-static SQSettings *sq_global_settings = NULL;
-static GObjectClass *parent_class = NULL;
+static void
+sq_settings_init (GObject *);
+static void
+sq_settings_class_init (GObjectClass *);
static void
-sq_settings_init(SQSettings *);
+sq_settings_dispose (GObject *object);
static void
-sq_settings_class_init(SQSettingsClass *);
-static GObject *
-sq_settings_singleton_constuctor(GType, guint, GObjectConstructParam *);
+sq_settings_finalize (GObject *object);
+
+static void
+sq_settings_set_property (
+ GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+static void
+sq_settings_get_property (
+ GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static GObjectClass *parent_class = NULL;
+
+static SQSettings *settings_object;
+
+enum
+{
+ PROP_0,
+ PROP_WINDOW_WIDTH,
+ PROP_WINDOW_HEIGHT,
+ PROP_USE_THUNAR_PROPERTIES,
+};
GType
sq_settings_get_type (void)
{
- static GType sq_settings_type = 0;
-
- if (!sq_settings_type)
- {
- static const GTypeInfo sq_settings_info =
- {
- sizeof (SQSettingsClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) sq_settings_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (SQSettings),
- 0,
- (GInstanceInitFunc) sq_settings_init,
- NULL
- };
-
- sq_settings_type = g_type_register_static (G_TYPE_OBJECT, "SQSettings", &sq_settings_info, 0);
- }
- return sq_settings_type;
+ static GType sq_settings_type = 0;
+
+ if (!sq_settings_type)
+ {
+ static const GTypeInfo sq_settings_info =
+ {
+ sizeof (SQSettingsClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) sq_settings_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (SQSettings),
+ 0,
+ (GInstanceInitFunc) sq_settings_init,
+ NULL
+ };
+
+ sq_settings_type = g_type_register_static (G_TYPE_OBJECT, "SQSettings", &sq_settings_info, 0);
+ }
+ return sq_settings_type;
+}
+
+struct _SQSettingsPriv
+{
+ XfconfChannel *channel;
+
+ guint window_width;
+ guint window_height;
+ gboolean use_thunar_properties;
+};
+
+
+static void
+sq_settings_init (GObject *object)
+{
+ gchar *accelmap_path = NULL;
+
+ SQSettings *settings = SQ_SETTINGS (object);
+
+ settings->priv = g_new0 (SQSettingsPriv, 1);
+ settings->priv->channel = xfconf_channel_new ("squeeze");
+
+ accelmap_path = xfce_resource_lookup (
+ XFCE_RESOURCE_CONFIG,
+ "squeeze/accels.scm");
+ if (accelmap_path)
+ {
+ gtk_accel_map_load (accelmap_path);
+ g_free (accelmap_path);
+ accelmap_path = NULL;
+ }
+
+ settings->priv->window_width = 600;
+ settings->priv->window_height = 440;
+ settings->priv->use_thunar_properties = TRUE;
+
+ xfconf_g_property_bind (
+ settings->priv->channel,
+ "/window/width",
+ G_TYPE_UINT,
+ settings,
+ "window-width");
+ xfconf_g_property_bind (
+ settings->priv->channel,
+ "/window/height",
+ G_TYPE_UINT,
+ settings,
+ "window-height");
+
+ xfconf_g_property_bind (
+ settings->priv->channel,
+ "/window/use-thunar-properties",
+ G_TYPE_BOOLEAN,
+ settings,
+ "use-thunar-properties");
+}
+
+
+static void
+sq_settings_class_init (GObjectClass *object_class)
+{
+ GParamSpec *pspec;
+
+ SQSettingsClass *settings_class = SQ_SETTINGS_CLASS (object_class);
+
+ parent_class = g_type_class_peek_parent (settings_class);
+
+ object_class->dispose = sq_settings_dispose;
+ object_class->finalize = sq_settings_finalize;
+
+ object_class->set_property = sq_settings_set_property;
+ object_class->get_property = sq_settings_get_property;
+
+ pspec = g_param_spec_uint (
+ "window-width",
+ "",
+ "",
+ 0,
+ G_MAXUINT,
+ 600,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (
+ object_class,
+ PROP_WINDOW_WIDTH,
+ pspec);
+
+ pspec = g_param_spec_uint (
+ "window-height",
+ "",
+ "",
+ 0,
+ G_MAXUINT,
+ 400,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (
+ object_class,
+ PROP_WINDOW_HEIGHT,
+ pspec);
+
+ pspec = g_param_spec_boolean (
+ "use-thunar-properties",
+ "",
+ "",
+ TRUE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (
+ object_class,
+ PROP_USE_THUNAR_PROPERTIES,
+ pspec);
}
+/**
+ * sq_settings_dispose:
+ * @object:
+ *
+ */
static void
-sq_settings_init(SQSettings *object)
+sq_settings_dispose (GObject *object)
{
-#ifdef HAVE_LIBXFCE4UTIL
- object->xfce_rc = (GObject *)xfce_rc_config_open(XFCE_RESOURCE_CONFIG, "squeeze/squeezerc", FALSE);
-#else
+ SQSettings *settings = SQ_SETTINGS (object);
-#endif /* HAVE_LIBXFCE4UTIL */
+ if (settings->priv)
+ {
+ if (settings->priv->channel)
+ {
+ xfconf_g_property_unbind_all (settings->priv->channel);
+ g_object_unref (settings->priv->channel);
+ settings->priv->channel = NULL;
+ }
+ g_free (settings->priv);
+ settings->priv = NULL;
+ }
}
+/**
+ * sq_settings_finalize:
+ * @object:
+ *
+ */
static void
-sq_settings_class_init(SQSettingsClass *object_class)
+sq_settings_finalize (GObject *object)
{
- parent_class = g_type_class_peek_parent(object_class);
- G_OBJECT_CLASS(object_class)->constructor = sq_settings_singleton_constuctor;
+ gchar *accelmap_path = NULL;
+ /*SQSettings *settings = SQ_SETTINGS (object);*/
+
+ accelmap_path = xfce_resource_save_location (
+ XFCE_RESOURCE_CONFIG,
+ "squeeze/accels.scm",
+ TRUE);
+ if (accelmap_path)
+ {
+ gtk_accel_map_save (accelmap_path);
+ g_free (accelmap_path);
+ accelmap_path = NULL;
+ }
+
}
+
+
+/**
+ * sq_settings_new:
+ *
+ *
+ * Singleton
+ */
SQSettings *
-sq_settings_new(void)
+sq_settings_new (void)
{
- sq_global_settings = g_object_new(SQ_TYPE_SETTINGS, NULL);
+ if (settings_object == NULL)
+ {
+ settings_object = g_object_new (SQ_TYPE_SETTINGS, NULL);
+ }
+ else
+ {
+ g_object_ref (settings_object);
+ }
- return sq_global_settings;
+ return settings_object;
}
-gboolean
-sq_settings_load(SQSettings *settings)
+
+static void
+sq_settings_set_property (
+ GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
-#ifdef HAVE_LIBXFCE4UTIL
+ SQSettings *settings = SQ_SETTINGS (object);
-#else
+ switch (property_id)
+ {
+ case PROP_WINDOW_WIDTH:
+ settings->priv->window_width = g_value_get_uint (value);
+ break;
+ case PROP_WINDOW_HEIGHT:
+ settings->priv->window_height = g_value_get_uint (value);
+ break;
+ case PROP_USE_THUNAR_PROPERTIES:
+ settings->priv->use_thunar_properties = g_value_get_boolean (value);
+ break;
+ default:
+ break;
+ }
-#endif /* HAVE_LIBXFCE4UTIL */
- return TRUE;
}
-gboolean
-sq_settings_save(SQSettings *settings)
+static void
+sq_settings_get_property (
+ GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec )
{
-#ifdef HAVE_LIBXFCE4UTIL
- xfce_rc_flush(XFCE_RC(settings->xfce_rc));
-#else
+ SQSettings *settings = SQ_SETTINGS (object);
+
+ switch (property_id)
+ {
+ case PROP_WINDOW_WIDTH:
+ g_value_set_uint (
+ value,
+ settings->priv->window_width);
+ break;
+ case PROP_WINDOW_HEIGHT:
+ g_value_set_uint (
+ value,
+ settings->priv->window_height);
+ break;
+ case PROP_USE_THUNAR_PROPERTIES:
+ g_value_set_boolean (
+ value,
+ settings->priv->use_thunar_properties);
+ break;
+ default:
+ break;
-#endif /* HAVE_LIBXFCE4UTIL */
- return TRUE;
+ }
}
void
-sq_settings_set_group(SQSettings *settings, const gchar *group)
+sq_settings_set_uint_property (
+ SQSettings *settings,
+ const gchar *property_name,
+ guint value)
{
-#ifdef HAVE_LIBXFCE4UTIL
- xfce_rc_set_group(XFCE_RC(settings->xfce_rc), group);
-#else
+ GValue val = {0, };
+ g_value_init (&val, G_TYPE_UINT);
-#endif /* HAVE_LIBXFCE4UTIL */
+ g_value_set_uint (&val, value);
+
+ g_object_set_property (G_OBJECT(settings), property_name, &val);
+
+ g_value_reset (&val);
}
void
-sq_settings_write_entry(SQSettings *settings, const gchar *key, const gchar *value)
+sq_settings_set_int_property (
+ SQSettings *settings,
+ const gchar *property_name,
+ gint value)
{
-#ifdef HAVE_LIBXFCE4UTIL
- xfce_rc_write_entry(XFCE_RC(settings->xfce_rc), key, value);
-#else
+ GValue val = {0, };
+ g_value_init (&val, G_TYPE_INT);
+
+ g_value_set_int (&val, value);
-#endif /* HAVE_LIBXFCE4UTIL */
+ g_object_set_property (G_OBJECT(settings), property_name, &val);
+
+ g_value_reset (&val);
}
void
-sq_settings_write_bool_entry(SQSettings *settings, const gchar *key, const gboolean value)
+sq_settings_set_string_property (
+ SQSettings *settings,
+ const gchar *property_name,
+ const gchar *value)
{
-#ifdef HAVE_LIBXFCE4UTIL
- xfce_rc_write_bool_entry(XFCE_RC(settings->xfce_rc), key, value);
-#else
+ GValue val = {0, };
+ g_value_init (&val, G_TYPE_STRING);
+
+ g_value_set_string (&val, value);
-#endif /* HAVE_LIBXFCE4UTIL */
+ g_object_set_property (G_OBJECT(settings), property_name, &val);
+
+ g_value_reset (&val);
}
void
-sq_settings_write_int_entry(SQSettings *settings, const gchar *key, const gint value)
+sq_settings_set_boolean_property (
+ SQSettings *settings,
+ const gchar *property_name,
+ gboolean value)
{
-#ifdef HAVE_LIBXFCE4UTIL
- xfce_rc_write_int_entry(XFCE_RC(settings->xfce_rc), key, value);
-#else
+ GValue val = {0, };
+ g_value_init (&val, G_TYPE_BOOLEAN);
+
+ g_value_set_boolean (&val, value);
+
+ g_object_set_property (G_OBJECT(settings), property_name, &val);
-#endif /* HAVE_LIBXFCE4UTIL */
+ g_value_reset (&val);
}
-const gchar *
-sq_settings_read_entry(SQSettings *settings, const gchar *key, const gchar *fallback)
+guint
+sq_settings_get_uint_property (
+ SQSettings *settings,
+ const gchar *property_name)
{
-#ifdef HAVE_LIBXFCE4UTIL
- return xfce_rc_read_entry(XFCE_RC(settings->xfce_rc), key, fallback);
-#else
- return g_strdup(fallback);
-#endif /* HAVE_LIBXFCE4UTIL */
+ guint value;
+ GValue val = {0, };
+ g_value_init (&val, G_TYPE_UINT);
+
+ g_object_get_property (G_OBJECT(settings), property_name, &val);
+ value = g_value_get_uint (&val);
+
+ g_value_reset (&val);
+
+ return value;
}
-gboolean
-sq_settings_read_bool_entry(SQSettings *settings, const gchar *key, const gboolean fallback)
+gint
+sq_settings_get_int_property (
+ SQSettings *settings,
+ const gchar *property_name)
+{
+ gint value;
+ GValue val = {0, };
+ g_value_init (&val, G_TYPE_INT);
+
+ g_object_get_property (G_OBJECT(settings), property_name, &val);
+ value = g_value_get_int (&val);
+
+ g_value_reset (&val);
+
+ return value;
+}
+
+gchar *
+sq_settings_get_string_property (
+ SQSettings *settings,
+ const gchar *property_name)
{
-#ifdef HAVE_LIBXFCE4UTIL
- return xfce_rc_read_bool_entry(XFCE_RC(settings->xfce_rc), key, fallback);
-#else
- return fallback;
-#endif /* HAVE_LIBXFCE4UTIL */
+ gchar *value = NULL;
+ GValue val = {0, };
+ g_value_init (&val, G_TYPE_STRING);
+
+ g_object_get_property (G_OBJECT(settings), property_name, &val);
+ value = g_value_dup_string (&val);
+
+ g_value_reset (&val);
+
+ return value;
}
gboolean
-sq_settings_read_int_entry(SQSettings *settings, const gchar *key, const gint fallback)
-{
-#ifdef HAVE_LIBXFCE4UTIL
- return xfce_rc_read_int_entry(XFCE_RC(settings->xfce_rc), key, fallback);
-#else
- return fallback;
-#endif /* HAVE_LIBXFCE4UTIL */
-}
-
-static GObject *
-sq_settings_singleton_constuctor(GType type, guint n_construct_params, GObjectConstructParam *construct_params)
-{
- GObject *object;
- if(!sq_global_settings)
- {
- object = parent_class->constructor(type, n_construct_params, construct_params);
- sq_global_settings = SQ_SETTINGS(object);
- }
- else
- object = g_object_ref(SQ_SETTINGS(sq_global_settings));
- return object;
+sq_settings_get_boolean_property (
+ SQSettings *settings,
+ const gchar *property_name)
+{
+ gboolean value;
+ GValue val = {0, };
+ g_value_init (&val, G_TYPE_BOOLEAN);
+
+ g_object_get_property (G_OBJECT(settings), property_name, &val);
+ value = g_value_get_boolean (&val);
+
+ g_value_reset (&val);
+
+ return value;
}
diff --git a/src/settings.h b/src/settings.h
index 6fa4eca..505eb61 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -16,59 +16,99 @@
#ifndef __SQ_SETTINGS_H__
#define __SQ_SETTINGS_H__
+
G_BEGIN_DECLS
#define SQ_TYPE_SETTINGS sq_settings_get_type()
-#define SQ_SETTINGS(obj) ( \
- G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- sq_settings_get_type(), \
- SQSettings))
+#define SQ_SETTINGS(obj) ( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ SQ_TYPE_SETTINGS, \
+ SQSettings))
-#define SQ_IS_SETTINGS(obj) ( \
- G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- sq_settings_get_type()))
+#define SQ_IS_SETTINGS(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ SQ_TYPE_SETTINGS))
#define SQ_SETTINGS_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_CAST ((class), \
- sq_settings_get_type(), \
- SQSettingsClass))
+ G_TYPE_CHECK_CLASS_CAST ((class), \
+ SQ_TYPE_SETTINGS, \
+ SQSettingsClass))
#define SQ_IS_SETTINGS_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_TYPE ((class), \
- sq_settings_get_type()))
+ G_TYPE_CHECK_CLASS_TYPE ((class), \
+ SQ_TYPE_SETTINGS))
typedef struct _SQSettings SQSettings;
+typedef struct _SQSettingsPriv SQSettingsPriv;
struct _SQSettings
{
- GObject parent;
- gchar *config_file;
- GObject *xfce_rc;
+ GObject parent;
+
+ SQSettingsPriv *priv;
};
typedef struct _SQSettingsClass SQSettingsClass;
struct _SQSettingsClass
{
- GObjectClass parent;
+ GObjectClass parent;
};
-SQSettings *sq_settings_new();
-GType sq_settings_get_type ();
-
-gboolean sq_settings_load(SQSettings *);
-gboolean sq_settings_save(SQSettings *);
-
-const gchar *sq_settings_read_entry(SQSettings *settings, const gchar *key, const gchar *fallback);
-gboolean sq_settings_read_bool_entry(SQSettings *settings, const gchar *key, const gboolean fallback);
-gint sq_settings_read_int_entry(SQSettings *settings, const gchar *key, const gint fallback);
-
-void sq_settings_write_entry(SQSettings *settings, const gchar *key, const gchar *value);
-void sq_settings_write_bool_entry(SQSettings *settings, const gchar *key, const gboolean value);
-void sq_settings_write_int_entry(SQSettings *settings, const gchar *key, const gint value);
-
-void sq_settings_set_group(SQSettings *settings, const gchar *group);
+SQSettings *
+sq_settings_new (void);
+
+GType
+sq_settings_get_type (void);
+
+void
+sq_settings_set_uint_property (
+ SQSettings *,
+ const gchar *,
+ guint );
+
+void
+sq_settings_set_int_property (
+ SQSettings *,
+ const gchar *,
+ gint );
+
+void
+sq_settings_set_string_property (
+ SQSettings *,
+ const gchar *,
+ const gchar *);
+
+void
+sq_settings_set_boolean_property (
+ SQSettings *,
+ const gchar *,
+ gboolean );
+
+/**************************/
+/* Property Get Functions */
+/**************************/
+
+guint
+sq_settings_get_uint_property (
+ SQSettings *,
+ const gchar *);
+
+gint
+sq_settings_get_int_property (
+ SQSettings *,
+ const gchar *);
+
+gchar *
+sq_settings_get_string_property (
+ SQSettings *,
+ const gchar *);
+
+gboolean
+sq_settings_get_boolean_property (
+ SQSettings *,
+ const gchar *);
G_END_DECLS
diff --git a/src/throbber-fallback.h b/src/throbber-fallback.h
index fafb5f1..3fe37a8 100644
--- a/src/throbber-fallback.h
+++ b/src/throbber-fallback.h
@@ -10,12 +10,12 @@
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __SQUEEZE_THROBBER_FALLBACK_H__
diff --git a/src/throbber.c b/src/throbber.c
index c7fb347..4eaebf8 100644
--- a/src/throbber.c
+++ b/src/throbber.c
@@ -10,12 +10,12 @@
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_CONFIG_H
@@ -30,48 +30,48 @@
/* Property identifiers */
enum
{
- PROP_0,
- PROP_ANIMATED,
+ PROP_0,
+ PROP_ANIMATED,
};
-static void sq_throbber_class_init(SQThrobberClass *klass);
-static void sq_throbber_init(SQThrobber *throbber);
-static void sq_throbber_dispose(GObject *object);
-static void sq_throbber_get_property(GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void sq_throbber_set_property(GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void sq_throbber_realize(GtkWidget *widget);
-static void sq_throbber_unrealize(GtkWidget *widget);
-static void sq_throbber_size_request(GtkWidget *widget,
- GtkRequisition *requisition);
+static void sq_throbber_class_init(SQThrobberClass *klass);
+static void sq_throbber_init(SQThrobber *throbber);
+static void sq_throbber_dispose(GObject *object);
+static void sq_throbber_get_property(GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void sq_throbber_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void sq_throbber_realize(GtkWidget *widget);
+static void sq_throbber_unrealize(GtkWidget *widget);
+static void sq_throbber_size_request(GtkWidget *widget,
+ GtkRequisition *requisition);
static gboolean sq_throbber_expose_event(GtkWidget *widget,
- GdkEventExpose *event);
+ GdkEventExpose *event);
static gboolean sq_throbber_timer(gpointer user_data);
-static void sq_throbber_timer_destroy(gpointer user_data);
+static void sq_throbber_timer_destroy(gpointer user_data);
struct _SQThrobberClass
{
- GtkWidgetClass __parent__;
+ GtkWidgetClass __parent__;
};
struct _SQThrobber
{
- GtkWidget __parent__;
+ GtkWidget __parent__;
- GdkPixbuf *icon;
+ GdkPixbuf *icon;
- gboolean animated;
- gint index;
- gint timer_id;
+ gboolean animated;
+ gint index;
+ gint timer_id;
};
@@ -83,28 +83,28 @@ static GObjectClass *sq_throbber_parent_class;
GType
sq_throbber_get_type (void)
{
- static GType type = G_TYPE_INVALID;
-
- if (G_UNLIKELY (type == G_TYPE_INVALID))
- {
- static const GTypeInfo info =
- {
- sizeof (SQThrobberClass),
- NULL,
- NULL,
- (GClassInitFunc) sq_throbber_class_init,
- NULL,
- NULL,
- sizeof (SQThrobber),
- 0,
- (GInstanceInitFunc) sq_throbber_init,
- NULL,
- };
-
- type = g_type_register_static (GTK_TYPE_WIDGET, "SQThrobber", &info, 0);
- }
-
- return type;
+ static GType type = G_TYPE_INVALID;
+
+ if (G_UNLIKELY (type == G_TYPE_INVALID))
+ {
+ static const GTypeInfo info =
+ {
+ sizeof (SQThrobberClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) sq_throbber_class_init,
+ NULL,
+ NULL,
+ sizeof (SQThrobber),
+ 0,
+ (GInstanceInitFunc) sq_throbber_init,
+ NULL,
+ };
+
+ type = g_type_register_static (GTK_TYPE_WIDGET, "SQThrobber", &info, 0);
+ }
+
+ return type;
}
@@ -112,39 +112,39 @@ sq_throbber_get_type (void)
static void
sq_throbber_class_init (SQThrobberClass *klass)
{
- GtkWidgetClass *gtkwidget_class;
- GObjectClass *gobject_class;
- GdkPixbuf *icon;
-
- /* determine the parent type class */
- sq_throbber_parent_class = g_type_class_peek_parent (klass);
-
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->dispose = sq_throbber_dispose;
- gobject_class->get_property = sq_throbber_get_property;
- gobject_class->set_property = sq_throbber_set_property;
-
- gtkwidget_class = GTK_WIDGET_CLASS (klass);
- gtkwidget_class->realize = sq_throbber_realize;
- gtkwidget_class->unrealize = sq_throbber_unrealize;
- gtkwidget_class->size_request = sq_throbber_size_request;
- gtkwidget_class->expose_event = sq_throbber_expose_event;
-
- /**
- * SQThrobber:animated:
- *
- * Whether the throbber should display an animation.
- **/
- g_object_class_install_property (gobject_class,
- PROP_ANIMATED,
- g_param_spec_boolean ("animated",
- "animated", "animated", \
- FALSE, G_PARAM_READWRITE));
-
- /* register the "process-working" fallback icon */
- icon = gdk_pixbuf_new_from_inline (-1, sq_throbber_fallback, FALSE, NULL);
- gtk_icon_theme_add_builtin_icon ("process-working", 16, icon);
- g_object_unref (G_OBJECT (icon));
+ GtkWidgetClass *gtkwidget_class;
+ GObjectClass *gobject_class;
+ GdkPixbuf *icon;
+
+ /* determine the parent type class */
+ sq_throbber_parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->dispose = sq_throbber_dispose;
+ gobject_class->get_property = sq_throbber_get_property;
+ gobject_class->set_property = sq_throbber_set_property;
+
+ gtkwidget_class = GTK_WIDGET_CLASS (klass);
+ gtkwidget_class->realize = sq_throbber_realize;
+ gtkwidget_class->unrealize = sq_throbber_unrealize;
+ gtkwidget_class->size_request = sq_throbber_size_request;
+ gtkwidget_class->expose_event = sq_throbber_expose_event;
+
+ /**
+ * SQThrobber:animated:
+ *
+ * Whether the throbber should display an animation.
+ **/
+ g_object_class_install_property (gobject_class,
+ PROP_ANIMATED,
+ g_param_spec_boolean ("animated",
+ "animated", "animated", \
+ FALSE, G_PARAM_READWRITE));
+
+ /* register the "process-working" fallback icon */
+ icon = gdk_pixbuf_new_from_inline (-1, sq_throbber_fallback, FALSE, NULL);
+ gtk_icon_theme_add_builtin_icon ("process-working", 16, icon);
+ g_object_unref (G_OBJECT (icon));
}
@@ -152,8 +152,8 @@ sq_throbber_class_init (SQThrobberClass *klass)
static void
sq_throbber_init (SQThrobber *throbber)
{
- GTK_WIDGET_SET_FLAGS (throbber, GTK_NO_WINDOW);
- throbber->timer_id = -1;
+ GTK_WIDGET_SET_FLAGS (throbber, GTK_NO_WINDOW);
+ throbber->timer_id = -1;
}
@@ -161,57 +161,57 @@ sq_throbber_init (SQThrobber *throbber)
static void
sq_throbber_dispose (GObject *object)
{
- SQThrobber *throbber = SQ_THROBBER (object);
+ SQThrobber *throbber = SQ_THROBBER (object);
- /* stop any running animation */
- if (G_UNLIKELY (throbber->timer_id >= 0))
- g_source_remove (throbber->timer_id);
+ /* stop any running animation */
+ if (G_UNLIKELY (throbber->timer_id >= 0))
+ g_source_remove (throbber->timer_id);
- (*G_OBJECT_CLASS (sq_throbber_parent_class)->dispose) (object);
+ (*G_OBJECT_CLASS (sq_throbber_parent_class)->dispose) (object);
}
static void
sq_throbber_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- SQThrobber *throbber = SQ_THROBBER (object);
-
- switch (prop_id)
- {
- case PROP_ANIMATED:
- g_value_set_boolean (value, sq_throbber_get_animated (throbber));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ SQThrobber *throbber = SQ_THROBBER (object);
+
+ switch (prop_id)
+ {
+ case PROP_ANIMATED:
+ g_value_set_boolean (value, sq_throbber_get_animated (throbber));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
sq_throbber_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- SQThrobber *throbber = SQ_THROBBER (object);
-
- switch (prop_id)
- {
- case PROP_ANIMATED:
- sq_throbber_set_animated (throbber, g_value_get_boolean (value));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ SQThrobber *throbber = SQ_THROBBER (object);
+
+ switch (prop_id)
+ {
+ case PROP_ANIMATED:
+ sq_throbber_set_animated (throbber, g_value_get_boolean (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
@@ -219,17 +219,17 @@ sq_throbber_set_property (GObject *object,
static void
sq_throbber_realize (GtkWidget *widget)
{
- SQThrobber *throbber = SQ_THROBBER (widget);
- GtkIconTheme *icon_theme;
+ SQThrobber *throbber = SQ_THROBBER (widget);
+ GtkIconTheme *icon_theme;
- /* let Gtk+ realize the widget */
- (*GTK_WIDGET_CLASS (sq_throbber_parent_class)->realize) (widget);
+ /* let Gtk+ realize the widget */
+ (*GTK_WIDGET_CLASS (sq_throbber_parent_class)->realize) (widget);
- /* determine the icon theme for our screen */
- icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
+ /* determine the icon theme for our screen */
+ icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
- /* try to lookup the "process-working" icon */
- throbber->icon = gtk_icon_theme_load_icon (icon_theme, "process-working", 16, GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_NO_SVG, NULL);
+ /* try to lookup the "process-working" icon */
+ throbber->icon = gtk_icon_theme_load_icon (icon_theme, "process-working", 16, GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_NO_SVG, NULL);
}
@@ -237,71 +237,71 @@ sq_throbber_realize (GtkWidget *widget)
static void
sq_throbber_unrealize (GtkWidget *widget)
{
- SQThrobber *throbber = SQ_THROBBER (widget);
+ SQThrobber *throbber = SQ_THROBBER (widget);
- /* release the icon if any */
- if (G_LIKELY (throbber->icon != NULL))
- {
- g_object_unref (G_OBJECT (throbber->icon));
- throbber->icon = NULL;
- }
+ /* release the icon if any */
+ if (G_LIKELY (throbber->icon != NULL))
+ {
+ g_object_unref (G_OBJECT (throbber->icon));
+ throbber->icon = NULL;
+ }
- /* let Gtk+ unrealize the widget */
- (*GTK_WIDGET_CLASS (sq_throbber_parent_class)->unrealize) (widget);
+ /* let Gtk+ unrealize the widget */
+ (*GTK_WIDGET_CLASS (sq_throbber_parent_class)->unrealize) (widget);
}
static void
sq_throbber_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+ GtkRequisition *requisition)
{
- requisition->width = 16;
- requisition->height = 16;
+ requisition->width = 16;
+ requisition->height = 16;
}
static gboolean
sq_throbber_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
+ GdkEventExpose *event)
{
- SQThrobber *throbber = SQ_THROBBER (widget);
- gint icon_index;
- gint icon_cols;
- gint icon_rows;
- gint icon_x;
- gint icon_y;
-
- /* verify that we have a valid icon */
- if (G_LIKELY (throbber->icon != NULL))
- {
- /* determine the icon columns and icon rows */
- icon_cols = gdk_pixbuf_get_width (throbber->icon) / 16;
- icon_rows = gdk_pixbuf_get_height (throbber->icon) / 16;
-
- /* verify that the icon is usable */
- if (G_LIKELY (icon_cols > 0 && icon_rows > 0))
- {
- /* determine the icon index */
- icon_index = throbber->index % (icon_cols * icon_rows);
-
- /* make sure, we don't display the "empty state" while animated */
- if (G_LIKELY (throbber->timer_id >= 0))
- icon_index = MAX (icon_index, 1);
-
- /* determine the icon x/y offset for the icon index */
- icon_x = (icon_index % icon_cols) * 16;
- icon_y = (icon_index / icon_cols) * 16;
-
- /* render the given part of the icon */
- gdk_draw_pixbuf (event->window, NULL, throbber->icon, icon_x, icon_y,
- widget->allocation.x, widget->allocation.y,
- 16, 16, GDK_RGB_DITHER_NONE, 0, 0);
- }
- }
-
- return TRUE;
+ SQThrobber *throbber = SQ_THROBBER (widget);
+ gint icon_index;
+ gint icon_cols;
+ gint icon_rows;
+ gint icon_x;
+ gint icon_y;
+
+ /* verify that we have a valid icon */
+ if (G_LIKELY (throbber->icon != NULL))
+ {
+ /* determine the icon columns and icon rows */
+ icon_cols = gdk_pixbuf_get_width (throbber->icon) / 16;
+ icon_rows = gdk_pixbuf_get_height (throbber->icon) / 16;
+
+ /* verify that the icon is usable */
+ if (G_LIKELY (icon_cols > 0 && icon_rows > 0))
+ {
+ /* determine the icon index */
+ icon_index = throbber->index % (icon_cols * icon_rows);
+
+ /* make sure, we don't display the "empty state" while animated */
+ if (G_LIKELY (throbber->timer_id >= 0))
+ icon_index = MAX (icon_index, 1);
+
+ /* determine the icon x/y offset for the icon index */
+ icon_x = (icon_index % icon_cols) * 16;
+ icon_y = (icon_index / icon_cols) * 16;
+
+ /* render the given part of the icon */
+ gdk_draw_pixbuf (event->window, NULL, throbber->icon, icon_x, icon_y,
+ widget->allocation.x, widget->allocation.y,
+ 16, 16, GDK_RGB_DITHER_NONE, 0, 0);
+ }
+ }
+
+ return TRUE;
}
@@ -309,14 +309,14 @@ sq_throbber_expose_event (GtkWidget *widget,
static gboolean
sq_throbber_timer (gpointer user_data)
{
- SQThrobber *throbber = SQ_THROBBER (user_data);
+ SQThrobber *throbber = SQ_THROBBER (user_data);
- GDK_THREADS_ENTER ();
- throbber->index += 1;
- gtk_widget_queue_draw (GTK_WIDGET (throbber));
- GDK_THREADS_LEAVE ();
+ GDK_THREADS_ENTER ();
+ throbber->index += 1;
+ gtk_widget_queue_draw (GTK_WIDGET (throbber));
+ GDK_THREADS_LEAVE ();
- return throbber->animated;
+ return throbber->animated;
}
@@ -324,8 +324,8 @@ sq_throbber_timer (gpointer user_data)
static void
sq_throbber_timer_destroy (gpointer user_data)
{
- SQ_THROBBER (user_data)->index = 0;
- SQ_THROBBER (user_data)->timer_id = -1;
+ SQ_THROBBER (user_data)->index = 0;
+ SQ_THROBBER (user_data)->timer_id = -1;
}
@@ -340,7 +340,7 @@ sq_throbber_timer_destroy (gpointer user_data)
GtkWidget*
sq_throbber_new (void)
{
- return g_object_new (SQ_TYPE_THROBBER, NULL);
+ return g_object_new (SQ_TYPE_THROBBER, NULL);
}
@@ -356,8 +356,8 @@ sq_throbber_new (void)
gboolean
sq_throbber_get_animated (const SQThrobber *throbber)
{
- g_return_val_if_fail (SQ_IS_THROBBER (throbber), FALSE);
- return throbber->animated;
+ g_return_val_if_fail (SQ_IS_THROBBER (throbber), FALSE);
+ return throbber->animated;
}
@@ -371,28 +371,28 @@ sq_throbber_get_animated (const SQThrobber *throbber)
**/
void
sq_throbber_set_animated (SQThrobber *throbber,
- gboolean animated)
+ gboolean animated)
{
- g_return_if_fail (SQ_IS_THROBBER (throbber));
+ g_return_if_fail (SQ_IS_THROBBER (throbber));
- /* check if we're already in the requested state */
- if (G_UNLIKELY (throbber->animated == animated))
- return;
+ /* check if we're already in the requested state */
+ if (G_UNLIKELY (throbber->animated == animated))
+ return;
- /* pick up the new state */
- throbber->animated = animated;
+ /* pick up the new state */
+ throbber->animated = animated;
- /* start the timer if animated and not already running */
- if (animated && (throbber->timer_id < 0))
- {
- /* start the animation */
- throbber->timer_id = g_timeout_add_full (G_PRIORITY_LOW, 25, sq_throbber_timer,
- throbber, sq_throbber_timer_destroy);
- }
+ /* start the timer if animated and not already running */
+ if (animated && (throbber->timer_id < 0))
+ {
+ /* start the animation */
+ throbber->timer_id = g_timeout_add_full (G_PRIORITY_LOW, 25, sq_throbber_timer,
+ throbber, sq_throbber_timer_destroy);
+ }
- /* schedule a redraw with the new animation state */
- gtk_widget_queue_draw (GTK_WIDGET (throbber));
+ /* schedule a redraw with the new animation state */
+ gtk_widget_queue_draw (GTK_WIDGET (throbber));
- /* notify listeners */
- g_object_notify (G_OBJECT (throbber), "animated");
+ /* notify listeners */
+ g_object_notify (G_OBJECT (throbber), "animated");
}
diff --git a/src/throbber.h b/src/throbber.h
index 217cef2..d99b481 100644
--- a/src/throbber.h
+++ b/src/throbber.h
@@ -10,12 +10,12 @@
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
+ * Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __SQUEEZE_THROBBER_H__
@@ -26,7 +26,7 @@
G_BEGIN_DECLS;
typedef struct _SQThrobberClass SQThrobberClass;
-typedef struct _SQThrobber SQThrobber;
+typedef struct _SQThrobber SQThrobber;
#define SQ_TYPE_THROBBER (sq_throbber_get_type ())
#define SQ_THROBBER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SQ_TYPE_THROBBER, SQThrobber))
@@ -41,7 +41,7 @@ GtkWidget *sq_throbber_new (void) G_GNUC_MALLOC;
gboolean sq_throbber_get_animated (const SQThrobber *throbber);
void sq_throbber_set_animated(SQThrobber *throbber,
- gboolean animated);
+ gboolean animated);
G_END_DECLS;
diff --git a/src/tool_bar.c b/src/tool_bar.c
index e45caa5..04cf828 100644
--- a/src/tool_bar.c
+++ b/src/tool_bar.c
@@ -73,327 +73,327 @@ cb_sq_tool_bar_path_field_activated(GtkWidget *entry, SQToolBar *tool_bar);
GType
sq_tool_bar_get_type (void)
{
- static GType sq_tool_bar_type = 0;
-
- if (!sq_tool_bar_type)
- {
- static const GTypeInfo sq_tool_bar_info =
- {
- sizeof (SQToolBarClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) sq_tool_bar_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (SQToolBar),
- 0,
- (GInstanceInitFunc) sq_tool_bar_init,
- NULL
- };
-
- sq_tool_bar_type = g_type_register_static (SQ_TYPE_NAVIGATION_BAR, "SQToolBar", &sq_tool_bar_info, 0);
- }
- return sq_tool_bar_type;
+ static GType sq_tool_bar_type = 0;
+
+ if (!sq_tool_bar_type)
+ {
+ static const GTypeInfo sq_tool_bar_info =
+ {
+ sizeof (SQToolBarClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) sq_tool_bar_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (SQToolBar),
+ 0,
+ (GInstanceInitFunc) sq_tool_bar_init,
+ NULL
+ };
+
+ sq_tool_bar_type = g_type_register_static (SQ_TYPE_NAVIGATION_BAR, "SQToolBar", &sq_tool_bar_info, 0);
+ }
+ return sq_tool_bar_type;
}
static void
sq_tool_bar_class_init(SQToolBarClass *tool_bar_class)
{
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
+ GtkWidgetClass *widget_class;
+ GtkContainerClass *container_class;
- widget_class = (GtkWidgetClass*)tool_bar_class;
- container_class = (GtkContainerClass*)tool_bar_class;
+ widget_class = (GtkWidgetClass*)tool_bar_class;
+ container_class = (GtkContainerClass*)tool_bar_class;
- widget_class->size_request = sq_tool_bar_size_request;
- widget_class->size_allocate = sq_tool_bar_size_allocate;
+ widget_class->size_request = sq_tool_bar_size_request;
+ widget_class->size_allocate = sq_tool_bar_size_allocate;
- container_class->add = sq_tool_bar_add;
- container_class->remove = sq_tool_bar_remove;
- container_class->forall = sq_tool_bar_forall;
- container_class->child_type = sq_tool_bar_child_type;
+ container_class->add = sq_tool_bar_add;
+ container_class->remove = sq_tool_bar_remove;
+ container_class->forall = sq_tool_bar_forall;
+ container_class->child_type = sq_tool_bar_child_type;
}
static void
sq_tool_bar_init(SQToolBar *tool_bar)
{
- GtkToolItem *button = NULL;
- SQ_NAVIGATION_BAR(tool_bar)->_cb_pwd_changed = cb_sq_tool_bar_pwd_changed;
- SQ_NAVIGATION_BAR(tool_bar)->_cb_new_archive = cb_sq_tool_bar_new_archive;
- SQ_NAVIGATION_BAR(tool_bar)->_cb_store_set = cb_sq_tool_bar_store_set;
-
- GTK_WIDGET_SET_FLAGS(tool_bar, GTK_NO_WINDOW);
- gtk_widget_set_redraw_on_allocate(GTK_WIDGET(tool_bar), FALSE);
-
- tool_bar->bar = GTK_TOOLBAR(gtk_toolbar_new());
- gtk_toolbar_set_style(GTK_TOOLBAR(tool_bar->bar), GTK_TOOLBAR_ICONS);
- gtk_container_add(GTK_CONTAINER(tool_bar), GTK_WIDGET(tool_bar->bar));
- gtk_widget_show(GTK_WIDGET(tool_bar->bar));
-
- tool_bar->back_button = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK);
- gtk_toolbar_insert(GTK_TOOLBAR(tool_bar->bar), tool_bar->back_button, 0);
- g_signal_connect(G_OBJECT(tool_bar->back_button), "clicked", (GCallback)cb_sq_tool_bar_history_back, tool_bar);
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->back_button), 0);
-
- tool_bar->forward_button = gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD);
- gtk_toolbar_insert(GTK_TOOLBAR(tool_bar->bar), tool_bar->forward_button, 1);
- g_signal_connect(G_OBJECT(tool_bar->forward_button), "clicked", (GCallback)cb_sq_tool_bar_history_forward, tool_bar);
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->forward_button), 0);
-
- tool_bar->up_button = gtk_tool_button_new_from_stock(GTK_STOCK_GO_UP);
- gtk_toolbar_insert(GTK_TOOLBAR(tool_bar->bar), tool_bar->up_button, 2);
- g_signal_connect(G_OBJECT(tool_bar->up_button), "clicked", (GCallback)cb_sq_tool_bar_up, tool_bar);
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->up_button), 0);
-
- tool_bar->refresh_button = gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH);
- gtk_toolbar_insert(GTK_TOOLBAR(tool_bar->bar), tool_bar->refresh_button, 3);
- g_signal_connect(G_OBJECT(tool_bar->refresh_button), "clicked", (GCallback)cb_sq_tool_bar_refresh, tool_bar);
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->refresh_button), 0);
-
- button = gtk_separator_tool_item_new();
- gtk_toolbar_insert(GTK_TOOLBAR(tool_bar->bar), button, 4);
-
- tool_bar->home_button = gtk_tool_button_new_from_stock(GTK_STOCK_HOME);
- gtk_toolbar_insert(GTK_TOOLBAR(tool_bar->bar), tool_bar->home_button, 5);
- g_signal_connect(G_OBJECT(tool_bar->home_button), "clicked", (GCallback)cb_sq_tool_bar_home, tool_bar);
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->home_button), 0);
-
- button = gtk_separator_tool_item_new();
- gtk_toolbar_insert(GTK_TOOLBAR(tool_bar->bar), button, 6);
- button = gtk_tool_item_new();
- tool_bar->path_field = gtk_entry_new();
- gtk_tool_item_set_expand(button, TRUE);
- tool_bar->hbox = gtk_hbox_new(FALSE, 0);
-
- gtk_container_add(GTK_CONTAINER(button), tool_bar->hbox);
- gtk_box_pack_start(GTK_BOX(tool_bar->hbox), gtk_label_new(_("Location:")), FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(tool_bar->hbox), tool_bar->path_field, TRUE, TRUE, 5);
- g_signal_connect(G_OBJECT(tool_bar->path_field), "activate", (GCallback)cb_sq_tool_bar_path_field_activated, tool_bar);
- gtk_tool_item_set_visible_horizontal(button, TRUE);
- gtk_tool_item_set_homogeneous(button, FALSE);
-
- gtk_toolbar_insert(GTK_TOOLBAR(tool_bar->bar), button, 7);
- gtk_widget_show_all(GTK_WIDGET(button));
- gtk_widget_show(GTK_WIDGET(tool_bar->path_field));
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->hbox), 0);
-
- gtk_widget_show_all(GTK_WIDGET(tool_bar->bar));
- gtk_widget_ref((GtkWidget *)tool_bar);
+ GtkToolItem *button = NULL;
+ SQ_NAVIGATION_BAR(tool_bar)->_cb_pwd_changed = cb_sq_tool_bar_pwd_changed;
+ SQ_NAVIGATION_BAR(tool_bar)->_cb_new_archive = cb_sq_tool_bar_new_archive;
+ SQ_NAVIGATION_BAR(tool_bar)->_cb_store_set = cb_sq_tool_bar_store_set;
+
+ GTK_WIDGET_SET_FLAGS(tool_bar, GTK_NO_WINDOW);
+ gtk_widget_set_redraw_on_allocate(GTK_WIDGET(tool_bar), FALSE);
+
+ tool_bar->bar = GTK_TOOLBAR(gtk_toolbar_new());
+ gtk_toolbar_set_style(GTK_TOOLBAR(tool_bar->bar), GTK_TOOLBAR_ICONS);
+ gtk_container_add(GTK_CONTAINER(tool_bar), GTK_WIDGET(tool_bar->bar));
+ gtk_widget_show(GTK_WIDGET(tool_bar->bar));
+
+ tool_bar->back_button = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK);
+ gtk_toolbar_insert(GTK_TOOLBAR(tool_bar->bar), tool_bar->back_button, 0);
+ g_signal_connect(G_OBJECT(tool_bar->back_button), "clicked", (GCallback)cb_sq_tool_bar_history_back, tool_bar);
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->back_button), 0);
+
+ tool_bar->forward_button = gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD);
+ gtk_toolbar_insert(GTK_TOOLBAR(tool_bar->bar), tool_bar->forward_button, 1);
+ g_signal_connect(G_OBJECT(tool_bar->forward_button), "clicked", (GCallback)cb_sq_tool_bar_history_forward, tool_bar);
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->forward_button), 0);
+
+ tool_bar->up_button = gtk_tool_button_new_from_stock(GTK_STOCK_GO_UP);
+ gtk_toolbar_insert(GTK_TOOLBAR(tool_bar->bar), tool_bar->up_button, 2);
+ g_signal_connect(G_OBJECT(tool_bar->up_button), "clicked", (GCallback)cb_sq_tool_bar_up, tool_bar);
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->up_button), 0);
+
+ tool_bar->refresh_button = gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH);
+ gtk_toolbar_insert(GTK_TOOLBAR(tool_bar->bar), tool_bar->refresh_button, 3);
+ g_signal_connect(G_OBJECT(tool_bar->refresh_button), "clicked", (GCallback)cb_sq_tool_bar_refresh, tool_bar);
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->refresh_button), 0);
+
+ button = gtk_separator_tool_item_new();
+ gtk_toolbar_insert(GTK_TOOLBAR(tool_bar->bar), button, 4);
+
+ tool_bar->home_button = gtk_tool_button_new_from_stock(GTK_STOCK_HOME);
+ gtk_toolbar_insert(GTK_TOOLBAR(tool_bar->bar), tool_bar->home_button, 5);
+ g_signal_connect(G_OBJECT(tool_bar->home_button), "clicked", (GCallback)cb_sq_tool_bar_home, tool_bar);
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->home_button), 0);
+
+ button = gtk_separator_tool_item_new();
+ gtk_toolbar_insert(GTK_TOOLBAR(tool_bar->bar), button, 6);
+ button = gtk_tool_item_new();
+ tool_bar->path_field = gtk_entry_new();
+ gtk_tool_item_set_expand(button, TRUE);
+ tool_bar->hbox = gtk_hbox_new(FALSE, 0);
+
+ gtk_container_add(GTK_CONTAINER(button), tool_bar->hbox);
+ gtk_box_pack_start(GTK_BOX(tool_bar->hbox), gtk_label_new(_("Location:")), FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(tool_bar->hbox), tool_bar->path_field, TRUE, TRUE, 5);
+ g_signal_connect(G_OBJECT(tool_bar->path_field), "activate", (GCallback)cb_sq_tool_bar_path_field_activated, tool_bar);
+ gtk_tool_item_set_visible_horizontal(button, TRUE);
+ gtk_tool_item_set_homogeneous(button, FALSE);
+
+ gtk_toolbar_insert(GTK_TOOLBAR(tool_bar->bar), button, 7);
+ gtk_widget_show_all(GTK_WIDGET(button));
+ gtk_widget_show(GTK_WIDGET(tool_bar->path_field));
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->hbox), 0);
+
+ gtk_widget_show_all(GTK_WIDGET(tool_bar->bar));
+ gtk_widget_ref((GtkWidget *)tool_bar);
}
SQNavigationBar *
sq_tool_bar_new(SQArchiveStore *store)
{
- SQNavigationBar *bar;
+ SQNavigationBar *bar;
- bar = g_object_new(SQ_TYPE_TOOL_BAR, NULL);
+ bar = g_object_new(SQ_TYPE_TOOL_BAR, NULL);
- if(store)
- sq_navigation_bar_set_store(SQ_NAVIGATION_BAR(bar), store);
+ if(store)
+ sq_navigation_bar_set_store(SQ_NAVIGATION_BAR(bar), store);
- return bar;
+ return bar;
}
static void
sq_tool_bar_refresh(SQToolBar *tool_bar, LSQArchiveIter *path)
{
- if(SQ_NAVIGATION_BAR(tool_bar)->store && path)
- {
- gchar *text = lsq_archive_iter_get_path(path);
- gtk_entry_set_text(GTK_ENTRY(tool_bar->path_field), text);
- gtk_editable_set_position(GTK_EDITABLE(tool_bar->path_field), -1);
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->hbox), 1);
- g_free(text);
-
- if(lsq_archive_iter_has_parent(path))
- {
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->up_button), 1);
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->home_button), 1);
- }
- else
- {
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->up_button), 0);
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->home_button), 0);
- }
- if(sq_archive_store_has_future(SQ_NAVIGATION_BAR(tool_bar)->store))
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->forward_button), 1);
- else
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->forward_button), 0);
-
- if(sq_archive_store_has_history(SQ_NAVIGATION_BAR(tool_bar)->store))
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->back_button), 1);
- else
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->back_button), 0);
-
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->refresh_button), 1);
- }
- else
- {
- gtk_entry_set_text(GTK_ENTRY(tool_bar->path_field), "");
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->hbox), 0);
-
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->up_button), 0);
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->home_button), 0);
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->back_button), 0);
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->forward_button), 0);
- gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->refresh_button), 0);
- }
+ if(SQ_NAVIGATION_BAR(tool_bar)->store && path)
+ {
+ gchar *text = lsq_archive_iter_get_path(path);
+ gtk_entry_set_text(GTK_ENTRY(tool_bar->path_field), text);
+ gtk_editable_set_position(GTK_EDITABLE(tool_bar->path_field), -1);
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->hbox), 1);
+ g_free(text);
+
+ if(lsq_archive_iter_has_parent(path))
+ {
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->up_button), 1);
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->home_button), 1);
+ }
+ else
+ {
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->up_button), 0);
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->home_button), 0);
+ }
+ if(sq_archive_store_has_future(SQ_NAVIGATION_BAR(tool_bar)->store))
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->forward_button), 1);
+ else
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->forward_button), 0);
+
+ if(sq_archive_store_has_history(SQ_NAVIGATION_BAR(tool_bar)->store))
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->back_button), 1);
+ else
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->back_button), 0);
+
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->refresh_button), 1);
+ }
+ else
+ {
+ gtk_entry_set_text(GTK_ENTRY(tool_bar->path_field), "");
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->hbox), 0);
+
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->up_button), 0);
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->home_button), 0);
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->back_button), 0);
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->forward_button), 0);
+ gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->refresh_button), 0);
+ }
}
static void
sq_tool_bar_size_request(GtkWidget *widget, GtkRequisition *requisition)
{
- SQToolBar *tool_bar = SQ_TOOL_BAR(widget);
+ SQToolBar *tool_bar = SQ_TOOL_BAR(widget);
- if(tool_bar->bar && GTK_WIDGET_VISIBLE(tool_bar->bar))
- gtk_widget_size_request(GTK_WIDGET(tool_bar->bar), requisition);
+ if(tool_bar->bar && GTK_WIDGET_VISIBLE(tool_bar->bar))
+ gtk_widget_size_request(GTK_WIDGET(tool_bar->bar), requisition);
- if(requisition->width < 400)
- requisition->width = 400;
+ if(requisition->width < 400)
+ requisition->width = 400;
- widget->requisition = *requisition;
+ widget->requisition = *requisition;
}
static void
sq_tool_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
- SQToolBar *tool_bar = SQ_TOOL_BAR(widget);
+ SQToolBar *tool_bar = SQ_TOOL_BAR(widget);
- widget->allocation = *allocation;
+ widget->allocation = *allocation;
- if(tool_bar->bar && GTK_WIDGET_VISIBLE(tool_bar->bar))
- gtk_widget_size_allocate(GTK_WIDGET(tool_bar->bar), allocation);
+ if(tool_bar->bar && GTK_WIDGET_VISIBLE(tool_bar->bar))
+ gtk_widget_size_allocate(GTK_WIDGET(tool_bar->bar), allocation);
}
static GType
sq_tool_bar_child_type(GtkContainer *container)
{
- if(!SQ_TOOL_BAR(container)->bar)
- return GTK_TYPE_WIDGET;
- else
- return G_TYPE_NONE;
+ if(!SQ_TOOL_BAR(container)->bar)
+ return GTK_TYPE_WIDGET;
+ else
+ return G_TYPE_NONE;
}
static void
sq_tool_bar_add(GtkContainer *container, GtkWidget *child)
{
- SQToolBar *tool_bar = SQ_TOOL_BAR(container);
+ SQToolBar *tool_bar = SQ_TOOL_BAR(container);
- g_return_if_fail(GTK_IS_WIDGET(child));
+ g_return_if_fail(GTK_IS_WIDGET(child));
- if(((GtkWidget*)tool_bar->bar) != child)
- {
- g_warning("DON'T set another child as toolbar");
- return;
- }
+ if(((GtkWidget*)tool_bar->bar) != child)
+ {
+ g_warning("DON'T set another child as toolbar");
+ return;
+ }
- gtk_widget_set_parent(child, GTK_WIDGET(tool_bar));
+ gtk_widget_set_parent(child, GTK_WIDGET(tool_bar));
}
static void
sq_tool_bar_remove(GtkContainer *container, GtkWidget *child)
{
- SQToolBar *tool_bar = SQ_TOOL_BAR(container);
- gboolean widget_was_visible;
+ SQToolBar *tool_bar = SQ_TOOL_BAR(container);
+ gboolean widget_was_visible;
- g_return_if_fail(GTK_IS_WIDGET(child));
- g_return_if_fail(((GtkWidget*)tool_bar->bar) == child);
+ g_return_if_fail(GTK_IS_WIDGET(child));
+ g_return_if_fail(((GtkWidget*)tool_bar->bar) == child);
- widget_was_visible = GTK_WIDGET_VISIBLE(child);
+ widget_was_visible = GTK_WIDGET_VISIBLE(child);
- gtk_widget_unparent(child);
- tool_bar->bar = NULL;
+ gtk_widget_unparent(child);
+ tool_bar->bar = NULL;
- if(widget_was_visible)
- gtk_widget_queue_resize(GTK_WIDGET(container));
+ if(widget_was_visible)
+ gtk_widget_queue_resize(GTK_WIDGET(container));
}
static void
sq_tool_bar_forall(GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data)
{
- SQToolBar *tool_bar = SQ_TOOL_BAR(container);
+ SQToolBar *tool_bar = SQ_TOOL_BAR(container);
- g_return_if_fail(callback != NULL);
+ g_return_if_fail(callback != NULL);
- if(tool_bar->bar)
- (* callback)(GTK_WIDGET(tool_bar->bar), callback_data);
+ if(tool_bar->bar)
+ (* callback)(GTK_WIDGET(tool_bar->bar), callback_data);
}
static void
cb_sq_tool_bar_pwd_changed(SQArchiveStore *store, LSQArchiveIter *path, SQNavigationBar *bar)
{
- SQToolBar *tool_bar = SQ_TOOL_BAR(bar);
- sq_tool_bar_refresh(tool_bar, path);
+ SQToolBar *tool_bar = SQ_TOOL_BAR(bar);
+ sq_tool_bar_refresh(tool_bar, path);
}
static void
cb_sq_tool_bar_new_archive(SQArchiveStore *store, SQNavigationBar *bar)
{
- SQToolBar *tool_bar = SQ_TOOL_BAR(bar);
- LSQArchiveIter *path = sq_archive_store_get_pwd(bar->store);
- sq_tool_bar_refresh(tool_bar, path);
- lsq_archive_iter_unref(path);
+ SQToolBar *tool_bar = SQ_TOOL_BAR(bar);
+ LSQArchiveIter *path = sq_archive_store_get_pwd(bar->store);
+ sq_tool_bar_refresh(tool_bar, path);
+ lsq_archive_iter_unref(path);
}
static void
cb_sq_tool_bar_history_back(GtkWidget *back_button, SQToolBar *tool_bar)
{
- sq_archive_store_go_back(SQ_NAVIGATION_BAR(tool_bar)->store);
+ sq_archive_store_go_back(SQ_NAVIGATION_BAR(tool_bar)->store);
}
static void
cb_sq_tool_bar_history_forward(GtkWidget *forward_button, SQToolBar *tool_bar)
{
- sq_archive_store_go_forward(SQ_NAVIGATION_BAR(tool_bar)->store);
+ sq_archive_store_go_forward(SQ_NAVIGATION_BAR(tool_bar)->store);
}
static void
cb_sq_tool_bar_up(GtkWidget *up_button, SQToolBar *tool_bar)
{
- sq_archive_store_go_up(SQ_NAVIGATION_BAR(tool_bar)->store);
+ sq_archive_store_go_up(SQ_NAVIGATION_BAR(tool_bar)->store);
}
static void
cb_sq_tool_bar_home(GtkWidget *home_button, SQToolBar *tool_bar)
{
- LSQArchive *archive = sq_archive_store_get_archive(SQ_NAVIGATION_BAR(tool_bar)->store);
- LSQArchiveIter *path = lsq_archive_get_iter(archive, NULL);
- sq_archive_store_set_pwd(SQ_NAVIGATION_BAR(tool_bar)->store, path);
- lsq_archive_iter_unref(path);
+ LSQArchive *archive = sq_archive_store_get_archive(SQ_NAVIGATION_BAR(tool_bar)->store);
+ LSQArchiveIter *path = lsq_archive_get_iter(archive, NULL);
+ sq_archive_store_set_pwd(SQ_NAVIGATION_BAR(tool_bar)->store, path);
+ lsq_archive_iter_unref(path);
}
static void
cb_sq_tool_bar_refresh(GtkWidget *refresh_button, SQToolBar *tool_bar)
{
- LSQArchive *archive = sq_archive_store_get_archive(SQ_NAVIGATION_BAR(tool_bar)->store);
- lsq_archive_operate(archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL);
+ LSQArchive *archive = sq_archive_store_get_archive(SQ_NAVIGATION_BAR(tool_bar)->store);
+ lsq_archive_operate(archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL);
}
static void
cb_sq_tool_bar_path_field_activated(GtkWidget *entry, SQToolBar *tool_bar)
{
- LSQArchive *archive = sq_archive_store_get_archive(SQ_NAVIGATION_BAR(tool_bar)->store);
- const gchar *path = gtk_entry_get_text(GTK_ENTRY(entry));
- LSQArchiveIter *iter = lsq_archive_get_iter(archive, path);
- if(iter)
- {
- sq_archive_store_set_pwd(SQ_NAVIGATION_BAR(tool_bar)->store, iter);
- lsq_archive_iter_unref(iter);
- }
+ LSQArchive *archive = sq_archive_store_get_archive(SQ_NAVIGATION_BAR(tool_bar)->store);
+ const gchar *path = gtk_entry_get_text(GTK_ENTRY(entry));
+ LSQArchiveIter *iter = lsq_archive_get_iter(archive, path);
+ if(iter)
+ {
+ sq_archive_store_set_pwd(SQ_NAVIGATION_BAR(tool_bar)->store, iter);
+ lsq_archive_iter_unref(iter);
+ }
}
static void
cb_sq_tool_bar_store_set(SQNavigationBar *bar)
{
- SQToolBar *tool_bar = SQ_TOOL_BAR(bar);
- if(bar->store)
- {
- LSQArchiveIter *path = sq_archive_store_get_pwd(bar->store);
- sq_tool_bar_refresh(tool_bar, path);
- lsq_archive_iter_unref(path);
- }
- else
- {
- sq_tool_bar_refresh(tool_bar, NULL);
- }
+ SQToolBar *tool_bar = SQ_TOOL_BAR(bar);
+ if(bar->store)
+ {
+ LSQArchiveIter *path = sq_archive_store_get_pwd(bar->store);
+ sq_tool_bar_refresh(tool_bar, path);
+ lsq_archive_iter_unref(path);
+ }
+ else
+ {
+ sq_tool_bar_refresh(tool_bar, NULL);
+ }
}
diff --git a/src/tool_bar.h b/src/tool_bar.h
index 8f0dbfa..1b03965 100644
--- a/src/tool_bar.h
+++ b/src/tool_bar.h
@@ -20,47 +20,47 @@ G_BEGIN_DECLS
#define SQ_TYPE_TOOL_BAR sq_tool_bar_get_type()
-#define SQ_TOOL_BAR(obj)( \
- G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- SQ_TYPE_TOOL_BAR, \
- SQToolBar))
+#define SQ_TOOL_BAR(obj)( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ SQ_TYPE_TOOL_BAR, \
+ SQToolBar))
-#define SQ_IS_TOOL_BAR(obj) ( \
- G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- SQ_TYPE_TOOL_BAR))
+#define SQ_IS_TOOL_BAR(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ SQ_TYPE_TOOL_BAR))
#define SQ_TOOL_BAR_CLASS(klass) ( \
- G_TYPE_CHECK_CLASS_CAST ((klass), \
- SQ_TYPE_TOOL_BAR, \
- SQToolBarClass))
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ SQ_TYPE_TOOL_BAR, \
+ SQToolBarClass))
#define SQ_IS_TOOL_BAR_CLASS(class) ( \
- G_TYPE_CHECK_CLASS_TYPE ((class), \
- SQ_TYPE_TOOL_BAR()))
+ G_TYPE_CHECK_CLASS_TYPE ((class), \
+ SQ_TYPE_TOOL_BAR()))
typedef struct _SQToolBar SQToolBar;
struct _SQToolBar
{
- SQNavigationBar parent;
- GtkToolbar *bar;
- GtkToolItem *back_button;
- GtkToolItem *forward_button;
- GtkToolItem *up_button;
- GtkToolItem *home_button;
- GtkToolItem *refresh_button;
- GtkWidget *path_field;
- GtkWidget *hbox;
+ SQNavigationBar parent;
+ GtkToolbar *bar;
+ GtkToolItem *back_button;
+ GtkToolItem *forward_button;
+ GtkToolItem *up_button;
+ GtkToolItem *home_button;
+ GtkToolItem *refresh_button;
+ GtkWidget *path_field;
+ GtkWidget *hbox;
};
typedef struct _SQToolBarClass SQToolBarClass;
struct _SQToolBarClass
{
- SQNavigationBarClass parent_class;
+ SQNavigationBarClass parent_class;
};
-GType sq_tool_bar_get_type();
+GType sq_tool_bar_get_type();
SQNavigationBar *sq_tool_bar_new();
G_END_DECLS
More information about the Xfce4-commits
mailing list