[Xfce4-commits] <squeeze:stephan/new-ui> Start Rewrite of UI
Stephan Arts
noreply at xfce.org
Fri May 10 09:38:03 CEST 2013
Updating branch refs/heads/stephan/new-ui
to 2c5f2dfed54de51f16f68f6a403a3b8c209d8a46 (commit)
from 40a75344fa2918b78db21818bdb6bab987bee012 (commit)
commit 2c5f2dfed54de51f16f68f6a403a3b8c209d8a46
Author: Stephan Arts <stephan at xfce.org>
Date: Mon May 6 22:06:50 2013 +0200
Start Rewrite of UI
configure.in.in => configure.ac.in | 31 +-
src/Makefile.am | 32 +--
src/main.c | 247 +++--------
src/notebook.c | 916 ------------------------------------
src/notebook.h | 90 ----
src/path_bar.c | 767 ------------------------------
src/path_bar.h | 69 ---
7 files changed, 76 insertions(+), 2076 deletions(-)
diff --git a/configure.in.in b/configure.ac.in
similarity index 86%
rename from configure.in.in
rename to configure.ac.in
index c037b4b..cce8d3e 100644
--- a/configure.in.in
+++ b/configure.ac.in
@@ -70,7 +70,6 @@ dnl Check for i18n support
XDT_I18N([@LINGUAS@])
-XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.20.0])
XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.24.0])
XDT_CHECK_PACKAGE([GOBJECT], [gobject-2.0], [2.24.0])
XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.20.0])
@@ -95,26 +94,18 @@ if test x"$check_for_pcre" = x"yes"; then
fi
AM_CONDITIONAL([HAVE_PCRE], [test x"$ac_cv_header_pcre_h" = x"yes" -a x"$ac_cv_lib_pcre_main" = x"yes"])
-
-AC_ARG_ENABLE([pathbar],
- [AC_HELP_STRING([--disable-pathbar],
- [Do not compile support for a PathBar (default=enabled)])],
- [sq_pathbar=$enableval],
- [sq_pathbar=yes])
-if test "$sq_pathbar" = "yes"; then
- AC_DEFINE([ENABLE_PATHBAR], [1], [Define if we should include pathbar support])
-fi
-AM_CONDITIONAL([ENABLE_PATHBAR], [test "$sq_pathbar" = "yes"])
-
-AC_ARG_ENABLE([toolbar],
- [AC_HELP_STRING([--disable-toolbar],
- [Do not compile support for a ToolBar (default=enabled)])],
- [sq_toolbar=$enableval],
- [sq_toolbar=yes])
-if test "$sq_toolbar" = "yes"; then
- AC_DEFINE([ENABLE_TOOLBAR], [1], [Define if we should include toolbar support])
+AC_ARG_ENABLE([gtk3],
+ [AC_HELP_STRING([--enable-gtk3],
+ [Compile against GTK+-3.0 (default=disabled)])],
+ [enable_gtk3=$enableval], [enable_gtk3=no])
+if test "x$enable_gtk3" = "xyes"; then
+ XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.10.0])
+ XDT_CHECK_PACKAGE([GTK], [gtk+-3.0], [3.2.0])
+else
+ XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1], [4.10.0])
+ XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.24.0])
fi
-AM_CONDITIONAL([ENABLE_TOOLBAR], [test "$sq_toolbar" = "yes"])
+AM_CONDITIONAL([ENABLE_GTK3], [test "x$enable_gtk3" = "xyes"])
AC_ARG_ENABLE([iter-slices],
[AC_HELP_STRING([--disable-iter-slices],
diff --git a/src/Makefile.am b/src/Makefile.am
index cdeef19..85f05dd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,34 +1,7 @@
bin_PROGRAMS = squeeze
-if ENABLE_PATHBAR
-PATHBAR_FILES = path_bar.c path_bar.h
-else
-PATHBAR_FILES =
-endif
-
-if ENABLE_TOOLBAR
-TOOLBAR_FILES = tool_bar.c tool_bar.h
-else
-TOOLBAR_FILES =
-endif
-
squeeze_SOURCES = \
- main.c main.h \
- application.c application.h \
- main_window.c main_window.h \
- navigation_bar.c navigation_bar.h \
- notebook.c notebook.h \
- $(TOOLBAR_FILES) \
- $(PATHBAR_FILES) \
- settings.c settings.h \
- archive_store.c archive_store.h \
- message_dialog.c message_dialog.h \
- throbber-fallback.c throbber-fallback.h \
- throbber.c throbber.h \
- new_dialog.c new_dialog.h \
- extract_dialog.c extract_dialog.h \
- widget_factory.c widget_factory.h
-# location_entry.c location_entry.h
+ main.c main.h
squeeze_CFLAGS = \
-DDATADIR=\"$(datadir)\" \
@@ -36,8 +9,10 @@ squeeze_CFLAGS = \
-DLOCALEDIR=\"$(localedir)\" \
$(GTK_CFLAGS) \
$(GLIB_CFLAGS) \
+ $(XFCONF_CFLAGS) \
$(DBUS_CFLAGS) \
$(GIO_CFLAGS) \
+ $(LIBXFCE4UI_CFLAGS) \
$(LIBXFCE4UTIL_CFLAGS)
squeeze_LDADD = \
@@ -48,6 +23,7 @@ squeeze_LDFLAGS = \
$(GLIB_LIBS) \
$(GIO_LIBS) \
$(XFCONF_LIBS) \
+ $(LIBXFCE4UI_LIBS) \
$(LIBXFCE4UTIL_LIBS)
diff --git a/src/main.c b/src/main.c
index 6353075..6f46ba8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,210 +1,85 @@
/*
- * 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 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.
- *
+ * 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.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
*/
#include <config.h>
#include <string.h>
+
#include <glib.h>
-#include <glib-object.h>
-#include <gtk/gtk.h>
#include <gio/gio.h>
-#include <libxfce4util/libxfce4util.h>
-#include <libsqueeze/libsqueeze.h>
+#include <xfconf/xfconf.h>
+#include <gtk/gtk.h>
-#include "settings.h"
-#include "archive_store.h"
-#include "navigation_bar.h"
-#include "notebook.h"
-#include "application.h"
-#include "widget_factory.h"
-#include "main_window.h"
+#include <libxfce4ui/libxfce4ui.h>
+#include <libxfce4util/libxfce4util.h>
-#include "main.h"
+#include <libsqueeze/libsqueeze.h>
gboolean version = FALSE;
-gboolean extract_archive = FALSE;
-gchar *extract_archive_path = NULL;
-
-gchar *new_archive = NULL;
-gchar *add_archive_path = NULL;
-
-gpointer command;
-
-gint opened_archives = 0;
-
static GOptionEntry entries[] =
{
- { "extract-to", 'x', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &extract_archive_path,
- NULL,
- N_("[destination path]")
- },
- { "extract", 'e', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &extract_archive,
- NULL,
- NULL
- },
- { "add-to", 'd', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &add_archive_path,
- NULL,
- N_("[archive path] [file1] [file2] ... [fileN]")
- },
- { "new", 'n', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &new_archive,
- NULL,
- N_("[file1] [file2] ... [fileN]")
- },
- { "version", 'v', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &version,
- N_("Version information"),
- NULL
- },
- { NULL }
+ { "version", 'V', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &version,
+ N_("Version information"),
+ NULL
+ },
+ { NULL, ' ', 0, 0, NULL, NULL, NULL }
};
-#if 0
-void
-cb_main_window_destroy(SQMainWindow *window, gpointer data)
-{
- gtk_main_quit();
-}
-#endif
-
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
- GtkWidget *main_window = NULL;
- GtkIconTheme *sq_icon_theme;
- SQApplication *sq_app = NULL;
- GError *cli_error = NULL;
- gint i = 0;
- GFile *file = NULL;
- gchar *current_dir;
-
- #ifdef ENABLE_NLS
- bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
- #endif
-
- if(!gtk_init_with_args(&argc, &argv, _("[archive name]"), entries, PACKAGE, &cli_error))
- {
- if ( cli_error != NULL )
- {
- g_print (_("%s: %s\nTry %s --help to see a full list of available command line options.\n"), PACKAGE, cli_error->message, PACKAGE_NAME);
- g_error_free (cli_error);
- return 1;
- }
- }
- current_dir = g_get_current_dir();
-
- lsq_init();
-
- sq_icon_theme = gtk_icon_theme_get_default();
- sq_app = sq_application_new(sq_icon_theme);
-
- gtk_window_set_default_icon_name("squeeze");
-
- g_signal_connect(G_OBJECT(sq_app), "destroy", G_CALLBACK(gtk_main_quit), NULL);
-
- if(version)
- {
- g_print("%s\n", PACKAGE_STRING);
- return 0;
- }
-
-
- 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(GTK_WIDGET(main_window));
- }
- }
-
-
- g_object_unref(sq_app);
- gtk_main();
- lsq_shutdown();
-
- return 0;
+ GError *cli_error = NULL;
+ GtkWidget *window;
+
+ #ifdef ENABLE_NLS
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+ #endif
+
+ if(!gtk_init_with_args(&argc, &argv, "", entries, PACKAGE, &cli_error))
+ {
+ if (cli_error != NULL)
+ {
+ g_print (
+ _("%s: %s\n\n"
+ "Try %s --help to see a full list of\n"
+ "available command line options.\n"),
+ PACKAGE,
+ cli_error->message,
+ PACKAGE_NAME);
+
+ g_error_free (cli_error);
+ return 1;
+ }
+ }
+
+ if(version)
+ {
+ g_print("%s\n", PACKAGE_STRING);
+ return 0;
+ }
+
+ xfconf_init(NULL);
+
+ gtk_window_set_default_icon_name("squeeze");
+
+ xfconf_shutdown();
+
+ return 0;
}
diff --git a/src/notebook.c b/src/notebook.c
deleted file mode 100644
index 15e31a4..0000000
--- a/src/notebook.c
+++ /dev/null
@@ -1,916 +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 "settings.h"
-#include "archive_store.h"
-#include "navigation_bar.h"
-#include "tool_bar.h"
-#include "path_bar.h"
-#include "notebook.h"
-#include "throbber.h"
-
-static void
-sq_notebook_class_init(SQNotebookClass *archive_class);
-
-static void
-sq_notebook_init(SQNotebook *archive);
-static void
-sq_notebook_dispose(GObject *object);
-
-static void
-sq_notebook_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void
-sq_notebook_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-
-static void
-sq_notebook_treeview_reset_columns(LSQArchive *archive, GtkTreeView *treeview);
-
-static SQArchiveStore *
-sq_notebook_get_store(SQNotebook *notebook, gint page_nr);
-static GtkTreeView *
-sq_notebook_get_tree_view(SQNotebook *notebook, gint page_nr);
-
-static void
-cb_notebook_close_archive(GtkButton *button, GtkWidget *child);
-
-static void
-cb_notebook_archive_refreshed(LSQArchive *archive, GtkTreeView *tree_view);
-static void
-cb_notebook_archive_state_changed(LSQArchive *archive, SQNotebook *notebook);
-static void
-cb_notebook_tab_archive_state_changed(LSQArchive *archive, GtkContainer *widget);
-static void
-cb_notebook_file_activated(SQArchiveStore *, LSQArchiveIter *, SQNotebook *);
-
-static void
-cb_sq_notebook_page_switched(SQNotebook *notebook, GtkNotebookPage *, guint page_nr, gpointer data);
-static void
-cb_sq_notebook_page_removed(SQNotebook *notebook, gpointer data);
-
-static void
-cb_sq_notebook_notify_proxy(GObject *obj, GParamSpec *pspec, gpointer user_data);
-
-enum {
- SQ_NOTEBOOK_MULTI_TAB = 1,
- SQ_NOTEBOOK_STORE_SHOW_FULL_PATH,
- SQ_NOTEBOOK_STORE_SHOW_ICONS,
- SQ_NOTEBOOK_STORE_SORT_FOLDERS_FIRST,
- SQ_NOTEBOOK_STORE_SORT_CASE_SENSITIVE,
- SQ_NOTEBOOK_TREE_RULES_HINT
-};
-
-enum
-{
- SQ_NOTEBOOK_SIGNAL_ARCHIVE_REMOVED = 0,
- SQ_NOTEBOOK_SIGNAL_PAGE_UP,
- SQ_NOTEBOOK_SIGNAL_PAGE_DOWN,
- SQ_NOTEBOOK_SIGNAL_FILE_ACTIVATED,
- SQ_NOTEBOOK_SIGNAL_STATE_CHANGED, /* is emitted when the state of the active archive changed */
- SQ_NOTEBOOK_SIGNAL_COUNT
-};
-
-static gint sq_notebook_signals[SQ_NOTEBOOK_SIGNAL_COUNT];
-
-static GObjectClass *parent_class;
-
-GType
-sq_notebook_get_type (void)
-{
- static GType sq_notebook_type = 0;
-
- if (!sq_notebook_type)
- {
- static const GTypeInfo sq_notebook_info =
- {
- sizeof (SQNotebookClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) sq_notebook_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (SQNotebook),
- 0,
- (GInstanceInitFunc) sq_notebook_init,
- NULL
- };
-
- sq_notebook_type = g_type_register_static (GTK_TYPE_NOTEBOOK, "SQNotebook", &sq_notebook_info, 0);
- }
- return sq_notebook_type;
-}
-
-static void
-sq_notebook_class_init(SQNotebookClass *notebook_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (notebook_class);
- GParamSpec *pspec = NULL;
-
- parent_class = gtk_type_class (GTK_TYPE_NOTEBOOK);
-
- object_class->set_property = sq_notebook_set_property;
- object_class->get_property = sq_notebook_get_property;
- object_class->dispose = sq_notebook_dispose;
-
- sq_notebook_signals[SQ_NOTEBOOK_SIGNAL_ARCHIVE_REMOVED] = g_signal_new("archive-removed",
- G_TYPE_FROM_CLASS(notebook_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- 0,
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0,
- NULL);
-
- sq_notebook_signals[SQ_NOTEBOOK_SIGNAL_PAGE_UP] = g_signal_new("page-up",
- G_TYPE_FROM_CLASS(notebook_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0, NULL);
-
- sq_notebook_signals[SQ_NOTEBOOK_SIGNAL_PAGE_DOWN] = g_signal_new("page-down",
- G_TYPE_FROM_CLASS(notebook_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0, NULL);
-
- sq_notebook_signals[SQ_NOTEBOOK_SIGNAL_FILE_ACTIVATED] = g_signal_new("file-activated",
- G_TYPE_FROM_CLASS(notebook_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_notebook_signals[SQ_NOTEBOOK_SIGNAL_STATE_CHANGED] = g_signal_new("archive-state-changed",
- G_TYPE_FROM_CLASS(notebook_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_OBJECT, NULL);
-
- pspec = g_param_spec_boolean("multi_tab",
- "",
- "",
- TRUE,
- G_PARAM_READWRITE); g_object_class_install_property(object_class, SQ_NOTEBOOK_MULTI_TAB, pspec);
-
- 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_NOTEBOOK_STORE_SHOW_FULL_PATH, 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_NOTEBOOK_STORE_SHOW_ICONS, 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_NOTEBOOK_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_NOTEBOOK_STORE_SORT_CASE_SENSITIVE, pspec);
-
- pspec = g_param_spec_boolean("rules-hint",
- _("Rules hint"),
- _("Make the row background colors alternate"),
- FALSE,
- G_PARAM_READWRITE);
- g_object_class_install_property(object_class, SQ_NOTEBOOK_TREE_RULES_HINT, pspec);
-}
-
-static void
-sq_notebook_init(SQNotebook *notebook)
-{
- g_signal_connect(G_OBJECT(notebook), "switch-page", G_CALLBACK(cb_sq_notebook_page_switched), NULL);
- g_signal_connect(G_OBJECT(notebook), "archive-removed", G_CALLBACK(cb_sq_notebook_page_removed), NULL);
-
- g_signal_connect(G_OBJECT(notebook), "page-up", G_CALLBACK(gtk_notebook_next_page), NULL);
- g_signal_connect(G_OBJECT(notebook), "page-down", G_CALLBACK(gtk_notebook_prev_page), NULL);
-
- notebook->settings = sq_settings_new();
-
- notebook->current_page_fix = 0;
- notebook->props._rules_hint = sq_settings_read_bool_entry(notebook->settings, "RulesHint", FALSE);
- notebook->props._show_full_path = sq_settings_read_bool_entry(notebook->settings, "ShowFullPath", FALSE);
- notebook->props._show_icons = sq_settings_read_bool_entry(notebook->settings, "ShowIcons", TRUE);
- notebook->props._sort_folders_first = sq_settings_read_bool_entry(notebook->settings, "SortFoldersFirst", TRUE);
- notebook->props._sort_case_sensitive = sq_settings_read_bool_entry(notebook->settings, "SortCaseSensitive", TRUE);
- notebook->multi_tab = TRUE;
- notebook->accel_group = NULL;
-
- notebook->tool_tips = gtk_tooltips_new();
- gtk_tooltips_enable(notebook->tool_tips);
- gtk_notebook_set_tab_border(GTK_NOTEBOOK(notebook), 0);
- gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE);
- gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook), TRUE);
-}
-
-static void
-sq_notebook_dispose(GObject *object)
-{
- /* TODO: unref archive_stores */
- GtkNotebook *notebook = GTK_NOTEBOOK(object);
- SQNotebook *sq_notebook = SQ_NOTEBOOK(object);
- gint n;
- gint i = 0;
-
- if(sq_notebook->settings)
- {
- sq_settings_write_bool_entry(sq_notebook->settings, "RulesHint", sq_notebook->props._rules_hint);
- sq_settings_write_bool_entry(sq_notebook->settings, "ShowFullPath", sq_notebook->props._show_full_path);
- sq_settings_write_bool_entry(sq_notebook->settings, "ShowIcons", sq_notebook->props._show_icons);
- sq_settings_write_bool_entry(sq_notebook->settings, "SortFoldersFirst", sq_notebook->props._sort_folders_first);
- sq_settings_write_bool_entry(sq_notebook->settings, "SortCaseSensitive", sq_notebook->props._sort_case_sensitive);
-
- sq_settings_save(sq_notebook->settings);
-
- g_object_unref(G_OBJECT(sq_notebook->settings));
- sq_notebook->settings = NULL;
- }
-
- n = gtk_notebook_get_n_pages(notebook);
- for(i = n-1; i >= 0; --i)
- {
- GtkWidget *scrolledwindow = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i);
- GtkWidget *treeview = gtk_bin_get_child(GTK_BIN(scrolledwindow));
- GtkTreeModel *archive_store = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
-
- LSQArchive *archive = sq_archive_store_get_archive(SQ_ARCHIVE_STORE(archive_store));
-
- if(archive)
- g_signal_handlers_disconnect_by_func(archive, cb_notebook_archive_refreshed, treeview);
-
- if(SQ_NOTEBOOK(notebook)->navigation_bar)
- sq_navigation_bar_set_store(((SQNotebook *)notebook)->navigation_bar, NULL);
-
- g_object_unref(archive_store);
-
- lsq_close_archive(archive);
- gtk_notebook_remove_page(notebook, i);
- }
-
- parent_class->dispose(object);
-}
-
-GtkWidget *
-sq_notebook_new(SQNavigationBar *bar, gboolean use_tabs, GtkAccelGroup *accel_group)
-{
- SQNotebook *notebook;
-
- notebook = g_object_new(SQ_TYPE_NOTEBOOK, NULL);
-
- sq_notebook_set_navigation_bar(notebook, bar);
-
- notebook->multi_tab = use_tabs;
- notebook->accel_group = accel_group;
-
- gtk_widget_add_accelerator(GTK_WIDGET(notebook), "page-up", accel_group, 0xff55, GDK_CONTROL_MASK, 0);
- gtk_widget_add_accelerator(GTK_WIDGET(notebook), "page-down", accel_group, 0xff56, GDK_CONTROL_MASK, 0);
-
- return (GtkWidget *)notebook;
-}
-
-static void
-sq_notebook_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
-{
- switch(prop_id)
- {
- case SQ_NOTEBOOK_MULTI_TAB:
- SQ_NOTEBOOK(object)->multi_tab = g_value_get_boolean(value);
- break;
- case SQ_NOTEBOOK_STORE_SHOW_FULL_PATH:
- {
- SQArchiveStore *store = sq_notebook_get_store(SQ_NOTEBOOK(object), SQ_NOTEBOOK(object)->current_page_fix);
- if(store)
- sq_archive_store_set_show_full_path(store, g_value_get_boolean(value));
- SQ_NOTEBOOK(object)->props._show_full_path = g_value_get_boolean(value);
- break;
- }
- case SQ_NOTEBOOK_STORE_SHOW_ICONS:
- {
- SQArchiveStore *store = sq_notebook_get_store(SQ_NOTEBOOK(object), SQ_NOTEBOOK(object)->current_page_fix);
- if(store)
- sq_archive_store_set_show_icons(store, g_value_get_boolean(value));
- SQ_NOTEBOOK(object)->props._show_icons = g_value_get_boolean(value);
- break;
- }
- case SQ_NOTEBOOK_STORE_SORT_FOLDERS_FIRST:
- {
- SQArchiveStore *store = sq_notebook_get_store(SQ_NOTEBOOK(object), SQ_NOTEBOOK(object)->current_page_fix);
- if(store)
- sq_archive_store_set_sort_folders_first(store, g_value_get_boolean(value));
- SQ_NOTEBOOK(object)->props._sort_folders_first = g_value_get_boolean(value);
- break;
- }
- case SQ_NOTEBOOK_STORE_SORT_CASE_SENSITIVE:
- {
- SQArchiveStore *store = sq_notebook_get_store(SQ_NOTEBOOK(object), SQ_NOTEBOOK(object)->current_page_fix);
- if(store)
- sq_archive_store_set_sort_case_sensitive(store, g_value_get_boolean(value));
- SQ_NOTEBOOK(object)->props._sort_case_sensitive = g_value_get_boolean(value);
- break;
- }
- case SQ_NOTEBOOK_TREE_RULES_HINT:
- {
- GtkTreeView *tree = sq_notebook_get_tree_view(SQ_NOTEBOOK(object), SQ_NOTEBOOK(object)->current_page_fix);
- if(tree)
- gtk_tree_view_set_rules_hint(tree, g_value_get_boolean(value));
- SQ_NOTEBOOK(object)->props._rules_hint = g_value_get_boolean(value);
- break;
- }
- }
-}
-
-static void
-sq_notebook_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
-{
- switch(prop_id)
- {
- case SQ_NOTEBOOK_MULTI_TAB:
- g_value_set_boolean(value, SQ_NOTEBOOK(object)->multi_tab);
- break;
- case SQ_NOTEBOOK_STORE_SHOW_FULL_PATH:
- {
- SQArchiveStore *store = sq_notebook_get_store(SQ_NOTEBOOK(object), SQ_NOTEBOOK(object)->current_page_fix);
- if(store)
- g_value_set_boolean(value, sq_archive_store_get_show_full_path(store));
- else
- g_value_set_boolean(value, SQ_NOTEBOOK(object)->props._show_full_path);
- break;
- }
- case SQ_NOTEBOOK_STORE_SHOW_ICONS:
- {
- SQArchiveStore *store = sq_notebook_get_store(SQ_NOTEBOOK(object), SQ_NOTEBOOK(object)->current_page_fix);
- if(store)
- g_value_set_boolean(value, sq_archive_store_get_show_icons(store));
- else
- g_value_set_boolean(value, SQ_NOTEBOOK(object)->props._show_icons);
- break;
- }
- case SQ_NOTEBOOK_STORE_SORT_FOLDERS_FIRST:
- {
- SQArchiveStore *store = sq_notebook_get_store(SQ_NOTEBOOK(object), SQ_NOTEBOOK(object)->current_page_fix);
- if(store)
- g_value_set_boolean(value, sq_archive_store_get_sort_folders_first(store));
- else
- g_value_set_boolean(value, SQ_NOTEBOOK(object)->props._sort_folders_first);
- break;
- }
- case SQ_NOTEBOOK_STORE_SORT_CASE_SENSITIVE:
- {
- SQArchiveStore *store = sq_notebook_get_store(SQ_NOTEBOOK(object), SQ_NOTEBOOK(object)->current_page_fix);
- if(store)
- g_value_set_boolean(value, sq_archive_store_get_sort_case_sensitive(store));
- else
- g_value_set_boolean(value, SQ_NOTEBOOK(object)->props._sort_case_sensitive);
- break;
- }
- case SQ_NOTEBOOK_TREE_RULES_HINT:
- {
- GtkTreeView *tree = sq_notebook_get_tree_view(SQ_NOTEBOOK(object), SQ_NOTEBOOK(object)->current_page_fix);
- if(tree)
- g_value_set_boolean(value, gtk_tree_view_get_rules_hint(tree));
- else
- g_value_set_boolean(value, SQ_NOTEBOOK(object)->props._rules_hint);
- break;
- }
- }
-}
-
-gboolean
-sq_notebook_get_multi_tab(SQNotebook *notebook)
-{
- return notebook->multi_tab;
-}
-
-SQArchiveStore *
-sq_notebook_get_active_store(SQNotebook *notebook)
-{
- gint page_nr = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
-
- return sq_notebook_get_store(notebook, page_nr);
-}
-
-static SQArchiveStore *
-sq_notebook_get_store(SQNotebook *notebook, gint page_nr)
-{
- GtkWidget *scrolledwindow = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), page_nr);
- GtkWidget *treeview;
- GtkTreeModel *archive_store;
- if(!scrolledwindow)
- return NULL;
- treeview = gtk_bin_get_child(GTK_BIN(scrolledwindow));
- archive_store = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
- return SQ_ARCHIVE_STORE(archive_store);
-}
-
-GtkTreeView *
-sq_notebook_get_active_tree_view(SQNotebook *notebook)
-{
- gint page_nr = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
-
- return sq_notebook_get_tree_view(notebook, page_nr);
-}
-
-static GtkTreeView *
-sq_notebook_get_tree_view(SQNotebook *notebook, gint page_nr)
-{
- GtkWidget *scrolledwindow = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), page_nr);
- GtkWidget *treeview;
- if(!scrolledwindow)
- return NULL;
- treeview = gtk_bin_get_child(GTK_BIN(scrolledwindow));
- return GTK_TREE_VIEW(treeview);
-}
-
-void
-sq_notebook_set_navigation_bar(SQNotebook *notebook, SQNavigationBar *bar)
-{
- if(notebook->navigation_bar)
- {
- sq_navigation_bar_set_store(notebook->navigation_bar, NULL);
- gtk_widget_unref(GTK_WIDGET(notebook->navigation_bar));
- }
-
- notebook->props._up_dir = TRUE;
-
- if(bar)
- {
-#ifdef ENABLE_TOOLBAR
- if(SQ_IS_TOOL_BAR(bar))
- notebook->props._up_dir = FALSE;
-#endif
-#ifdef ENABLE_PATHBAR
- if(SQ_IS_PATH_BAR(bar))
- notebook->props._up_dir = FALSE;
-#endif
- }
-
- if(bar)
- gtk_widget_ref(GTK_WIDGET(bar));
-
- if(gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)))
- {
- SQArchiveStore *archive_store = sq_notebook_get_active_store(notebook);
- notebook->navigation_bar = bar;
- if(bar)
- sq_navigation_bar_set_store(notebook->navigation_bar, archive_store);
- if(archive_store)
- g_object_set(G_OBJECT(archive_store), "show_up_dir", notebook->props._up_dir, NULL);
- }
- else
- notebook->navigation_bar = bar;
-
-}
-
-void
-sq_notebook_add_archive(SQNotebook *notebook, LSQArchive *archive, gboolean new_archive)
-{
- GtkWidget *lbl_hbox = gtk_hbox_new(FALSE, 0);
- gchar *filename = lsq_archive_get_filename(archive);
- gchar *filepath = lsq_archive_get_path(archive);
- GtkWidget *label = gtk_label_new(filename);
- GtkWidget *archive_image = gtk_image_new_from_icon_name("unknown", GTK_ICON_SIZE_MENU);
- GtkWidget *throbber = sq_throbber_new();
- GtkWidget *alignment = gtk_alignment_new(0.5,0.5,1,1);
- GtkWidget *close_button;
- GtkWidget *close_image;
- GtkWidget *scroll_window;
- GtkWidget *tree_view;
- GtkTreeSelection *selection;
- GtkTreeModel *tree_model;
- gint page_nr;
-
- gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 4, 0, 0, 0);
-
- gtk_container_add(GTK_CONTAINER(alignment), throbber);
-
- /*thunar_vfs_mime_info_lookup_icon_name(lsq_archive_get_mimetype(archive), notebook->icon_theme), GTK_ICON_SIZE_MENU);*/
- close_button = gtk_button_new();
- close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
- scroll_window = gtk_scrolled_window_new(NULL, NULL);
-
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-
- gtk_button_set_image(GTK_BUTTON(close_button), close_image);
- gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
-
- gtk_widget_set_size_request(lbl_hbox, -1, 22);
-
- gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_MIDDLE);
- gtk_label_set_max_width_chars(GTK_LABEL(label), 20);
-
- gtk_tooltips_set_tip(notebook->tool_tips, label, filepath, NULL);
-
- tree_view = gtk_tree_view_new();
- g_signal_connect(G_OBJECT(tree_view), "notify", G_CALLBACK(cb_sq_notebook_notify_proxy), notebook);
- gtk_tree_view_set_enable_search(GTK_TREE_VIEW(tree_view), TRUE);
-
- selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW (tree_view) );
- gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
-
- tree_model = sq_archive_store_new(archive, notebook->props._show_icons, notebook->props._up_dir, notebook->icon_theme);
- sq_archive_store_set_show_full_path(SQ_ARCHIVE_STORE(tree_model), notebook->props._show_full_path);
- sq_archive_store_set_sort_folders_first(SQ_ARCHIVE_STORE(tree_model), notebook->props._sort_folders_first);
- sq_archive_store_set_sort_case_sensitive(SQ_ARCHIVE_STORE(tree_model), notebook->props._sort_case_sensitive);
- g_signal_connect(G_OBJECT(tree_model), "notify", G_CALLBACK(cb_sq_notebook_notify_proxy), notebook);
-
- gtk_box_pack_start(GTK_BOX(lbl_hbox), archive_image, FALSE, FALSE, 3);
- gtk_box_pack_start(GTK_BOX(lbl_hbox), alignment, FALSE, FALSE, 3);
- gtk_box_pack_start(GTK_BOX(lbl_hbox), label, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(lbl_hbox), close_button, FALSE, FALSE, 0);
- gtk_widget_show_all(lbl_hbox);
- gtk_widget_show_all(tree_view);
- gtk_widget_show(scroll_window);
-
- g_signal_connect(G_OBJECT(archive), "refreshed", G_CALLBACK(cb_notebook_archive_refreshed), tree_view);
- g_signal_connect(G_OBJECT(archive), "state-changed", G_CALLBACK(cb_notebook_archive_state_changed), notebook);
- g_signal_connect(G_OBJECT(archive), "state-changed", G_CALLBACK(cb_notebook_tab_archive_state_changed), lbl_hbox);
-
- g_signal_connect(G_OBJECT(close_button), "clicked", G_CALLBACK(cb_notebook_close_archive), scroll_window);
- g_signal_connect(G_OBJECT(tree_model), "file-activated", G_CALLBACK(cb_notebook_file_activated), notebook);
-
-
- sq_archive_store_connect_treeview(SQ_ARCHIVE_STORE(tree_model), GTK_TREE_VIEW(tree_view));
-
- gtk_tree_view_set_model(GTK_TREE_VIEW(tree_view), tree_model);
- gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree_view), notebook->props._rules_hint);
-
- //FIXME: for now it's here, should it be?
- sq_notebook_treeview_reset_columns(archive, GTK_TREE_VIEW(tree_view));
-
- if(gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)))
- gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), TRUE);
- else
- gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
-
- gtk_container_add(GTK_CONTAINER(scroll_window), tree_view);
-
- page_nr = gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scroll_window, lbl_hbox);
- if(page_nr >= 0)
- {
- gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), page_nr);
- gtk_widget_grab_focus(tree_view);
- }
-
- if(new_archive == FALSE)
- {
- g_object_unref( lsq_archive_operate( archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL, NULL, NULL) );
- }
- g_free(filename);
- g_free(filepath);
-
-}
-
-static void
-cb_notebook_close_archive(GtkButton *button, GtkWidget *child)
-{
- GtkNotebook *notebook = GTK_NOTEBOOK(gtk_widget_get_parent(child));
- gint n;
-
- GtkWidget *treeview = gtk_bin_get_child(GTK_BIN(child));
- GtkTreeModel *archive_store = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
-
- LSQArchive *archive = sq_archive_store_get_archive(SQ_ARCHIVE_STORE(archive_store));
-
- if(archive)
- {
- g_signal_handlers_disconnect_by_func(archive, cb_notebook_archive_refreshed, treeview);
- }
- if(SQ_NOTEBOOK(notebook)->navigation_bar)
- sq_navigation_bar_set_store(((SQNotebook *)notebook)->navigation_bar, NULL);
- g_object_unref(archive_store);
-
- lsq_close_archive(archive);
-
- n = gtk_notebook_page_num(notebook, child);
- gtk_notebook_remove_page(notebook, n);
- g_signal_emit(G_OBJECT(notebook), sq_notebook_signals[SQ_NOTEBOOK_SIGNAL_ARCHIVE_REMOVED], 0, NULL);
-}
-
-void
-sq_notebook_close_active_archive(SQNotebook *notebook)
-{
- gint n = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
- GtkWidget *scrolledwindow = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), n);
- GtkWidget *treeview = gtk_bin_get_child(GTK_BIN(scrolledwindow));
- GtkTreeModel *archive_store = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
-
- LSQArchive *archive = sq_archive_store_get_archive(SQ_ARCHIVE_STORE(archive_store));
-
- if(archive)
- g_signal_handlers_disconnect_by_func(archive, cb_notebook_archive_refreshed, treeview);
- if(SQ_NOTEBOOK(notebook)->navigation_bar)
- sq_navigation_bar_set_store(notebook->navigation_bar, NULL);
- g_object_unref(archive_store);
-
- lsq_close_archive(archive);
-
- gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), n);
- g_signal_emit(G_OBJECT(notebook), sq_notebook_signals[SQ_NOTEBOOK_SIGNAL_ARCHIVE_REMOVED], 0, NULL);
-}
-
-void
-cb_notebook_archive_refreshed(LSQArchive *archive, GtkTreeView *treeview)
-{
- GtkTreeModel *archive_store = gtk_tree_view_get_model(treeview);
- /*
- * Some archives are done refreshing so fast there is not even an
- * archive store to accomodate them.
- */
- g_object_ref(archive_store);
- gtk_tree_view_set_model(treeview, NULL);
- sq_archive_store_set_archive(SQ_ARCHIVE_STORE(archive_store), archive);
- gtk_tree_view_set_model(treeview, archive_store);
- g_object_unref(archive_store);
- sq_notebook_treeview_reset_columns(archive, treeview);
-}
-
-static void
-cb_notebook_archive_state_changed(LSQArchive *archive, SQNotebook *notebook)
-{
- if(sq_notebook_is_active_archive(notebook, archive))
- g_signal_emit(G_OBJECT(notebook), sq_notebook_signals[SQ_NOTEBOOK_SIGNAL_STATE_CHANGED], 0, archive, NULL);
-}
-
-static void
-cb_notebook_tab_archive_state_changed(LSQArchive *archive, GtkContainer *widget)
-{
- GList *children = gtk_container_get_children(widget);
- switch(lsq_archive_get_state(archive))
- {
- case LSQ_ARCHIVE_STATE_IDLE:
- gtk_widget_show(GTK_WIDGET(children->data));
- sq_throbber_set_animated(SQ_THROBBER(gtk_bin_get_child(GTK_BIN(children->next->data))), FALSE);
- gtk_widget_hide(GTK_WIDGET(children->next->data));
- break;
- default:
- gtk_widget_hide(GTK_WIDGET(children->data));
- sq_throbber_set_animated(SQ_THROBBER(gtk_bin_get_child(GTK_BIN(children->next->data))), TRUE);
- gtk_widget_show(GTK_WIDGET(children->next->data));
- break;
- }
-
- g_list_free(children);
-}
-
-static void
-sq_notebook_treeview_reset_columns(LSQArchive *archive, GtkTreeView *treeview)
-{
- GtkCellRenderer *renderer = NULL;
- GtkTreeViewColumn *column = NULL;
- guint x = 0;
-
- GList *columns = gtk_tree_view_get_columns(treeview);
- gboolean show_only_filenames = FALSE;
-
- while(columns)
- {
- gtk_tree_view_remove_column(treeview, columns->data);
- columns = columns->next;
- }
- g_list_free(columns);
-
- column = gtk_tree_view_column_new();
-
- renderer = gtk_cell_renderer_pixbuf_new();
- g_object_set(G_OBJECT(renderer), "stock-size", GTK_ICON_SIZE_SMALL_TOOLBAR, NULL);
- gtk_tree_view_column_pack_start(column, renderer, FALSE);
- gtk_tree_view_column_set_attributes(column, renderer, "gicon", SQ_ARCHIVE_STORE_EXTRA_PROP_ICON, NULL);
-
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(column, renderer, TRUE);
- gtk_tree_view_column_set_attributes(column, renderer, "text", LSQ_ARCHIVE_PROP_FILENAME + SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT, NULL);
-
- gtk_tree_view_column_set_resizable(column, TRUE);
- gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
- gtk_tree_view_column_set_sort_column_id(column, LSQ_ARCHIVE_PROP_FILENAME + SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT);
- gtk_tree_view_column_set_title(column, lsq_archive_get_entry_property_name(archive, LSQ_ARCHIVE_PROP_FILENAME));
- gtk_tree_view_append_column(treeview, column);
-
- if(!show_only_filenames)
- {
- for(x = LSQ_ARCHIVE_PROP_USER; x < lsq_archive_n_entry_properties(archive); ++x)
- {
- switch(lsq_archive_get_entry_property_type(archive, x))
- {
- default:
- if ( LSQ_TYPE_DATETIME != lsq_archive_get_entry_property_type(archive, x) )
- {
-#ifdef DEBUG
- g_debug("Should not be reached");
-#endif
- continue;
- }
- case(G_TYPE_CHAR):
- case(G_TYPE_DOUBLE):
- case(G_TYPE_FLOAT):
- case(G_TYPE_INT):
- case(G_TYPE_INT64):
- case(G_TYPE_LONG):
- case(G_TYPE_STRING):
- case(G_TYPE_UINT):
- case(G_TYPE_UINT64):
- case(G_TYPE_ULONG):
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(lsq_archive_get_entry_property_name(archive, x), renderer, "text", x+SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT, NULL);
- break;
- }
- gtk_tree_view_column_set_resizable(column, TRUE);
- gtk_tree_view_column_set_sort_column_id(column, x+SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT);
- gtk_tree_view_append_column(treeview, column);
- }
- }
- gtk_tree_view_set_search_column(treeview, LSQ_ARCHIVE_PROP_FILENAME + SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT);
-}
-
-void
-sq_notebook_set_icon_theme(SQNotebook *notebook, GtkIconTheme *icon_theme)
-{
- notebook->icon_theme = icon_theme;
-}
-
-static void
-cb_sq_notebook_page_switched(SQNotebook *notebook, GtkNotebookPage *page, guint page_nr, gpointer data)
-{
- SQArchiveStore *archive_store = sq_notebook_get_store(notebook, page_nr);
- if(notebook->navigation_bar)
- sq_navigation_bar_set_store(notebook->navigation_bar, archive_store);
- if(archive_store)
- {
- g_object_set(G_OBJECT(archive_store), "show_up_dir", notebook->props._up_dir, NULL);
- }
- notebook->current_page_fix = page_nr;
- g_object_notify(G_OBJECT(notebook), "show-icons");
- g_object_notify(G_OBJECT(notebook), "rules-hint");
-}
-
-static void
-cb_sq_notebook_page_removed(SQNotebook *notebook, gpointer data)
-{
- if(!gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)))
- {
- if(notebook->navigation_bar)
- sq_navigation_bar_set_store(notebook->navigation_bar, NULL);
- }
- if(gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)) > 1)
- gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), TRUE);
- else
- gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
-}
-
-static void
-cb_notebook_file_activated(SQArchiveStore *store, LSQArchiveIter *iter, SQNotebook *notebook)
-{
- g_signal_emit(G_OBJECT(notebook), sq_notebook_signals[SQ_NOTEBOOK_SIGNAL_FILE_ACTIVATED], 0, iter, NULL);
-}
-
-gboolean
-sq_notebook_is_active_archive(SQNotebook *notebook, LSQArchive *archive)
-{
- SQArchiveStore *archive_store = sq_notebook_get_active_store(notebook);
- LSQArchive * lp_archive;
- if(!archive_store)
- return FALSE;
- lp_archive = sq_archive_store_get_archive(archive_store);
- if(lp_archive == archive)
- return TRUE;
- return FALSE;
-}
-
-void
-sq_notebook_get_active_archive(SQNotebook *notebook, LSQArchive **lp_archive)
-{
- gint n = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
-
- sq_notebook_page_get_archive(notebook, lp_archive, n);
-}
-
-GtkWidget *
-sq_notebook_get_active_child(SQNotebook *notebook)
-{
- gint n = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
-
- return gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), n);
-}
-
-void
-sq_notebook_page_set_archive(SQNotebook *notebook, LSQArchive *archive, gint n)
-{
- if(gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)))
- {
- GtkWidget *scrolledwindow = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), n);
- GtkWidget *treeview = gtk_bin_get_child(GTK_BIN(scrolledwindow));
- GtkTreeModel *store = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
-
- sq_archive_store_set_archive(SQ_ARCHIVE_STORE(store), archive);
-
- g_signal_connect(G_OBJECT(archive), "refreshed", G_CALLBACK(cb_notebook_archive_refreshed), treeview);
-
- g_object_unref( lsq_archive_operate( archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL, NULL, NULL ) );
-
-
- gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), store);
- }
- else
- sq_notebook_add_archive(SQ_NOTEBOOK(notebook), archive, FALSE);
-}
-
-GSList *
-sq_notebook_get_selected_items(SQNotebook *notebook)
-{
- GtkWidget *scrolledwindow = sq_notebook_get_active_child(notebook);
- GtkTreeIter iter;
- GSList *filenames = NULL;
-
- GtkWidget *treeview = gtk_bin_get_child(GTK_BIN(scrolledwindow));
- GtkTreeModel *store = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
- GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(treeview));
- GList *rows = gtk_tree_selection_get_selected_rows(selection, &store);
- GList *_rows = rows;
- while(_rows)
- {
- LSQArchiveIter *entry;
- gtk_tree_model_get_iter(store, &iter, _rows->data);
- entry = sq_archive_store_get_archive_iter(SQ_ARCHIVE_STORE(store), &iter);
-
- lsq_archive_iter_ref(entry);
- filenames = g_slist_prepend(filenames, entry);
-
- _rows = _rows->next;
- }
- g_list_free(rows);
-
- return filenames;
-}
-
-
-void
-sq_notebook_page_get_archive(SQNotebook *notebook, LSQArchive **lp_archive, gint n)
-{
- SQArchiveStore *store = sq_notebook_get_store(notebook, n);
-
- if(lp_archive)
- (*lp_archive) = sq_archive_store_get_archive(store);
-}
-
-static void
-cb_sq_notebook_notify_proxy(GObject *obj, GParamSpec *pspec, gpointer user_data)
-{
- if(strcmp(g_param_spec_get_name(pspec), "show-icons") == 0)
- {
- GtkTreeView *treeview;
- SQArchiveStore *store;
-
- g_object_notify(user_data, g_param_spec_get_name(pspec));
-
- treeview = sq_notebook_get_active_tree_view(SQ_NOTEBOOK(user_data));
- store = SQ_ARCHIVE_STORE(gtk_tree_view_get_model(treeview));
-
- sq_notebook_treeview_reset_columns(sq_archive_store_get_archive(store), treeview);
- }
- if(strcmp(g_param_spec_get_name(pspec), "show-full-path") == 0 || strcmp(g_param_spec_get_name(pspec), "sort-folders-first") == 0 || strcmp(g_param_spec_get_name(pspec), "sort-case-sensitive") == 0)
- {
- g_object_notify(user_data, g_param_spec_get_name(pspec));
- }
- if(strcmp(g_param_spec_get_name(pspec), "rules-hint") == 0)
- {
- g_object_notify(user_data, g_param_spec_get_name(pspec));
- }
-}
-
diff --git a/src/notebook.h b/src/notebook.h
deleted file mode 100644
index b104c26..0000000
--- a/src/notebook.h
+++ /dev/null
@@ -1,90 +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_NOTEBOOK_H__
-#define __SQRCHIVER_NOTEBOOK_H__
-G_BEGIN_DECLS
-
-#define SQ_TYPE_NOTEBOOK sq_notebook_get_type()
-
-#define SQ_NOTEBOOK(obj) ( \
- G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- sq_notebook_get_type(), \
- SQNotebook))
-
-#define SQ_IS_NOTEBOOK(obj) ( \
- G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- sq_notebook_get_type()))
-
-#define SQ_NOTEBOOK_CLASS(klass) ( \
- G_TYPE_CHECK_CLASS_CAST ((klass), \
- sq_notebook_get_type(), \
- SQNotebookClass))
-
-#define SQ_IS_NOTEBOOK_CLASS(klass) ( \
- G_TYPE_CHECK_CLASS_TYPE ((klass), \
- sq_notebook_get_type()))
-
-typedef struct _SQNotebook SQNotebook;
-
-struct _SQNotebook
-{
- GtkNotebook parent;
- SQNavigationBar *navigation_bar;
- gboolean multi_tab;
- SQSettings *settings;
- struct
- {
- gboolean _show_full_path;
- gboolean _show_icons;
- gboolean _up_dir;
- gboolean _sort_folders_first;
- gboolean _sort_case_sensitive;
- gboolean _rules_hint;
- } props;
- GtkIconTheme *icon_theme;
- GtkAccelGroup *accel_group;
- GtkTooltips *tool_tips;
- gint current_page_fix;
-};
-
-typedef struct _SQNotebookClass SQNotebookClass;
-
-struct _SQNotebookClass
-{
- GtkNotebookClass parent;
-};
-
-GtkWidget *sq_notebook_new (SQNavigationBar *, gboolean , GtkAccelGroup *);
-GType sq_notebook_get_type ();
-
-void sq_notebook_set_navigation_bar(SQNotebook *, SQNavigationBar *);
-void sq_notebook_add_archive(SQNotebook *, LSQArchive *, gboolean);
-void sq_notebook_page_set_archive(SQNotebook *, LSQArchive *, gint n);
-void sq_notebook_page_get_archive(SQNotebook *, LSQArchive **, gint n);
-void sq_notebook_set_icon_theme(SQNotebook *, GtkIconTheme *);
-void sq_notebook_get_active_archive(SQNotebook *, LSQArchive **);
-gboolean sq_notebook_is_active_archive(SQNotebook *, LSQArchive *);
-GtkWidget *sq_notebook_get_active_child(SQNotebook *notebook);
-SQArchiveStore *sq_notebook_get_active_store(SQNotebook *notebook);
-GtkTreeView *sq_notebook_get_active_tree_view(SQNotebook *notebook);
-gboolean sq_notebook_get_multi_tab(SQNotebook *notebook);
-void sq_notebook_close_active_archive(SQNotebook *);
-
-GSList *sq_notebook_get_selected_items(SQNotebook *notebook);
-
-G_END_DECLS
-#endif /* __SQRCHIVER_NOTEBOOK_H__ */
diff --git a/src/path_bar.c b/src/path_bar.c
deleted file mode 100644
index 2bb3b4d..0000000
--- a/src/path_bar.c
+++ /dev/null
@@ -1,767 +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.
- */
-/*
- * Based on code written by Benedikt Meurer <benny at xfce.org>
- */
-
-#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 "archive_store.h"
-#include "navigation_bar.h"
-#include "path_bar.h"
-
-#ifndef SQ_PATH_BAR_SCROLL_INIT_TIMEOUT
-#define SQ_PATH_BAR_SCROLL_INIT_TIMEOUT 1000
-#endif
-
-#ifndef SQ_PATH_BAR_SCROLL_TIMEOUT
-#define SQ_PATH_BAR_SCROLL_TIMEOUT 500
-#endif
-
-#define SQ_SCROLL_NONE 0
-#define SQ_SCROLL_LEFT 1
-#define SQ_SCROLL_RIGHT 2
-
-#define SQ_PATH_BAR_PATH_BUTTON_ITER "sq-path-bar-path-iter"
-
-static void
-sq_path_bar_class_init(SQPathBarClass *archive_class);
-
-static void
-sq_path_bar_init(SQPathBar *archive);
-
-static void
-sq_path_bar_size_request(GtkWidget *widget, GtkRequisition *requisition);
-static void
-sq_path_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation);
-
-static GType
-sq_path_bar_child_type(GtkContainer *container);
-static void
-sq_path_bar_add(GtkContainer *container, GtkWidget *child);
-static void
-sq_path_bar_remove(GtkContainer *container, GtkWidget *child);
-static void
-sq_path_bar_forall(GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data);
-
-static void
-cb_sq_path_bar_pwd_changed(SQArchiveStore *store, LSQArchiveIter *, SQNavigationBar *bar);
-static void
-cb_sq_path_bar_new_archive(SQArchiveStore *store, SQNavigationBar *bar);
-static void
-cb_sq_path_bar_store_set(SQNavigationBar *bar);
-
-static void
-cb_sq_path_bar_path_button_clicked(GtkRadioButton *button, SQPathBar *path_bar);
-
-static void
-sq_path_bar_scroll_left(SQPathBar *path_bar);
-static void
-sq_path_bar_scroll_right(SQPathBar *path_bar);
-
-static gboolean
-cb_sq_path_bar_init_timeout(gpointer user_data);
-static gboolean
-cb_sq_path_bar_timeout(gpointer user_data);
-
-static gboolean
-cb_sq_path_bar_left_button_pressed(GtkWidget *widget, GdkEventButton *event, gpointer user_data);
-static gboolean
-cb_sq_path_bar_right_button_pressed(GtkWidget *widget, GdkEventButton *event, gpointer user_data);
-static gboolean
-cb_sq_path_bar_scroll_button_released(GtkWidget *widget, GdkEventButton *event, gpointer user_data);
-
-static void
-cb_sq_path_bar_left_clicked(GtkWidget *widget, gpointer user_data);
-static void
-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 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));
-}
-
-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));
-}
-
-SQNavigationBar *
-sq_path_bar_new(SQArchiveStore *store)
-{
- SQNavigationBar *bar;
-
- bar = g_object_new(SQ_TYPE_PATH_BAR, NULL);
-
- if(store)
- sq_navigation_bar_set_store(SQ_NAVIGATION_BAR(bar), store);
-
- 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;
-}
-
-static void
-sq_path_bar_add(GtkContainer *container, GtkWidget *child)
-{
- SQPathBar *path_bar = SQ_PATH_BAR(container);
-
- g_return_if_fail(GTK_IS_WIDGET(child));
-
- /* 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;
-
- g_return_if_fail(GTK_IS_WIDGET(child));
-
- widget_was_visible = GTK_WIDGET_VISIBLE(child);
-
- gtk_widget_unparent(child);
-
- /* 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);
-
- g_return_if_fail(callback != NULL);
-
- 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);
- }
-}
-
-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;
-}
-
-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;
- GtkTextDirection direction;
-
- widget->allocation = *allocation;
-
- 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);
-}
-
-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;
-}
-
-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;
-}
-
-static void
-cb_sq_path_bar_path_button_clicked(GtkRadioButton *button, SQPathBar *path_bar)
-{
- LSQArchiveIter *path;
-
- if(path_bar->updating)
- return;
-
- 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);
-}
-
-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;
-}
-
-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;
-}
-
-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);
- }
-
- 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;
-}
-
-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;
-}
-
-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;
-}
-
-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;
-}
-
-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));
-}
-
-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));
-}
-
-static void
-cb_sq_path_bar_store_set(SQNavigationBar *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);
-}
-
diff --git a/src/path_bar.h b/src/path_bar.h
deleted file mode 100644
index eaea3fd..0000000
--- a/src/path_bar.h
+++ /dev/null
@@ -1,69 +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_PATH_BAR_H__
-#define __SQRCHIVER_PATH_BAR_H__
-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_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))
-
-#define SQ_IS_PATH_BAR_CLASS(klass) ( \
- G_TYPE_CHECK_CLASS_TYPE ((klass), \
- 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;
-};
-
-typedef struct _SQPathBarClass SQPathBarClass;
-
-struct _SQPathBarClass
-{
- SQNavigationBarClass parent_class;
-};
-
-GType sq_path_bar_get_type();
-SQNavigationBar *sq_path_bar_new(SQArchiveStore *);
-
-G_END_DECLS
-#endif /* __SQRCHIVER_PATH_BAR_H__*/
More information about the Xfce4-commits
mailing list