[gthumb/ext] implement the bookmarks as an extension to make the code cleaner
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb/ext] implement the bookmarks as an extension to make the code cleaner
- Date: Sun, 1 Nov 2009 14:19:45 +0000 (UTC)
commit d2c7e048d4200ba3a4b3fcb93a945fec528fe3d5
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Nov 1 15:17:58 2009 +0100
implement the bookmarks as an extension to make the code cleaner
configure.ac | 3 +
data/ui/Makefile.am | 1 -
extensions/Makefile.am | 1 +
extensions/bookmarks/Makefile.am | 34 ++
.../bookmarks/actions.c | 37 ++-
.../bookmarks/actions.h | 15 +-
extensions/bookmarks/bookmarks.extension.in.in | 11 +
extensions/bookmarks/callbacks.c | 337 ++++++++++++++++++++
.../bookmarks/callbacks.h | 13 +-
extensions/bookmarks/data/Makefile.am | 3 +
extensions/bookmarks/data/ui/Makefile.am | 5 +
.../bookmarks/data}/ui/bookmarks.ui | 0
{gthumb => extensions/bookmarks}/dlg-bookmarks.c | 8 +-
{gthumb => extensions/bookmarks}/dlg-bookmarks.h | 2 +-
.../dlg-bookmarks.h => extensions/bookmarks/main.c | 36 ++-
gthumb/Makefile.am | 2 -
gthumb/gth-browser-actions-callbacks.c | 30 --
gthumb/gth-browser-actions-entries.h | 12 -
gthumb/gth-browser-ui.h | 10 +-
gthumb/gth-browser.c | 220 +-------------
gthumb/gth-browser.h | 26 ++
gthumb/gth-main-default-hooks.c | 7 +
gthumb/gth-main.c | 3 +-
po/POTFILES.in | 22 ++-
24 files changed, 532 insertions(+), 306 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 7c605f6..1b1eaf1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -279,6 +279,9 @@ data/icons/scalable/apps/Makefile
data/ui/Makefile
help/Makefile
extensions/Makefile
+extensions/bookmarks/Makefile
+extensions/bookmarks/data/Makefile
+extensions/bookmarks/data/ui/Makefile
extensions/catalogs/Makefile
extensions/catalogs/data/Makefile
extensions/catalogs/data/ui/Makefile
diff --git a/data/ui/Makefile.am b/data/ui/Makefile.am
index 3250dd5..5602caf 100644
--- a/data/ui/Makefile.am
+++ b/data/ui/Makefile.am
@@ -1,6 +1,5 @@
uidir = $(datadir)/gthumb-2.0/ui
ui_DATA = \
- bookmarks.ui \
extensions.ui \
filter-editor.ui \
overwrite-dialog.ui \
diff --git a/extensions/Makefile.am b/extensions/Makefile.am
index b16f2b1..6a326f0 100644
--- a/extensions/Makefile.am
+++ b/extensions/Makefile.am
@@ -1,4 +1,5 @@
SUBDIRS = \
+ bookmarks \
catalogs \
comments \
desktop_background \
diff --git a/extensions/bookmarks/Makefile.am b/extensions/bookmarks/Makefile.am
new file mode 100644
index 0000000..c685c83
--- /dev/null
+++ b/extensions/bookmarks/Makefile.am
@@ -0,0 +1,34 @@
+SUBDIRS = data
+
+extensiondir = $(libdir)/gthumb-2.0/extensions
+extension_LTLIBRARIES = libbookmarks.la
+
+libbookmarks_la_SOURCES = \
+ actions.c \
+ actions.h \
+ callbacks.c \
+ callbacks.h \
+ dlg-bookmarks.c \
+ dlg-bookmarks.h \
+ main.c
+
+libbookmarks_la_CFLAGS = $(GTHUMB_CFLAGS) $(DISABLE_DEPRECATED) $(WARNINGS) -I$(top_srcdir) -I$(top_builddir)/gthumb
+libbookmarks_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
+libbookmarks_la_LIBADD = $(GTHUMB_LIBS)
+libbookmarks_la_DEPENDENCIES = $(top_builddir)/gthumb/gthumb$(EXEEXT)
+
+extensioninidir = $(extensiondir)
+extensionini_in_files = bookmarks.extension.in.in
+extensionini_DATA = $(extensionini_in_files:.extension.in.in=.extension)
+
+%.extension.in: %.extension.in.in $(extension_LTLIBRARIES)
+ sed -e "s|%LIBRARY%|`. ./$(extension_LTLIBRARIES) && echo $$dlname`|" \
+ $< > $@
+
+%.extension: %.extension.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@
+
+EXTRA_DIST = $(extensionini_in_files)
+
+DISTCLEANFILES = $(extensionini_DATA)
+
+-include $(top_srcdir)/git.mk
diff --git a/gthumb/dlg-bookmarks.h b/extensions/bookmarks/actions.c
similarity index 54%
copy from gthumb/dlg-bookmarks.h
copy to extensions/bookmarks/actions.c
index 47499aa..838bb41 100644
--- a/gthumb/dlg-bookmarks.h
+++ b/extensions/bookmarks/actions.c
@@ -3,7 +3,7 @@
/*
* GThumb
*
- * Copyright (C) 2001-2008 The Free Software Foundation, Inc.
+ * Copyright (C) 2008 Free Software Foundation, Inc.
*
* 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
@@ -20,11 +20,36 @@
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
*/
-#ifndef DLG_BOOKMARKS_H
-#define DLG_BOOKMARKS_H
-#include "gth-browser.h"
+#include <config.h>
+#include <gthumb.h>
+#include "dlg-bookmarks.h"
-void dlg_bookmarks (GthBrowser *browser);
-#endif /* DLG_BOOKMARKS_H */
+void
+gth_browser_activate_action_bookmarks_add (GtkAction *action,
+ GthBrowser *browser)
+{
+ GBookmarkFile *bookmarks;
+ GFile *location;
+ char *uri;
+
+ location = gth_browser_get_location (browser);
+ if (location == NULL)
+ return;
+
+ bookmarks = gth_main_get_default_bookmarks ();
+ uri = g_file_get_uri (location);
+ _g_bookmark_file_add_uri (bookmarks, uri);
+ gth_main_bookmarks_changed ();
+
+ g_free (uri);
+}
+
+
+void
+gth_browser_activate_action_bookmarks_edit (GtkAction *action,
+ GthBrowser *browser)
+{
+ dlg_bookmarks (browser);
+}
diff --git a/gthumb/dlg-bookmarks.h b/extensions/bookmarks/actions.h
similarity index 71%
copy from gthumb/dlg-bookmarks.h
copy to extensions/bookmarks/actions.h
index 47499aa..a9a947f 100644
--- a/gthumb/dlg-bookmarks.h
+++ b/extensions/bookmarks/actions.h
@@ -3,7 +3,7 @@
/*
* GThumb
*
- * Copyright (C) 2001-2008 The Free Software Foundation, Inc.
+ * Copyright (C) 2009 Free Software Foundation, Inc.
*
* 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
@@ -20,11 +20,14 @@
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
*/
-#ifndef DLG_BOOKMARKS_H
-#define DLG_BOOKMARKS_H
+#ifndef ACTIONS_H
+#define ACTIONS_H
-#include "gth-browser.h"
+#include <gtk/gtkaction.h>
-void dlg_bookmarks (GthBrowser *browser);
+#define DEFINE_ACTION(x) void x (GtkAction *action, gpointer data);
-#endif /* DLG_BOOKMARKS_H */
+DEFINE_ACTION(gth_browser_activate_action_bookmarks_add)
+DEFINE_ACTION(gth_browser_activate_action_bookmarks_edit)
+
+#endif /* ACTIONS_H */
diff --git a/extensions/bookmarks/bookmarks.extension.in.in b/extensions/bookmarks/bookmarks.extension.in.in
new file mode 100644
index 0000000..52b43ae
--- /dev/null
+++ b/extensions/bookmarks/bookmarks.extension.in.in
@@ -0,0 +1,11 @@
+[Extension]
+_Name=Bookmarks
+_Description=Add bookmarks support.
+_Authors=Paolo Bacchilega <paobac src gnome org>
+Copyright=Copyright © 2008-2009 The Free Software Foundation, Inc.
+Version=1.0
+URL=http://live.gnome.org/gthumb
+
+[Loader]
+Type=module
+File=%LIBRARY%
diff --git a/extensions/bookmarks/callbacks.c b/extensions/bookmarks/callbacks.c
new file mode 100644
index 0000000..9b7401d
--- /dev/null
+++ b/extensions/bookmarks/callbacks.c
@@ -0,0 +1,337 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * 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 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 Street #330, Boston, MA 02111-1307, USA.
+ */
+
+
+#include <config.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+#include <gthumb.h>
+#include "actions.h"
+
+
+#define BROWSER_DATA_KEY "bookmarks-browser-data"
+
+
+static const char *fixed_ui_info =
+"<ui>"
+" <menubar name='MenuBar'>"
+" <placeholder name='OtherMenus'>"
+" <menu name='Bookmarks' action='BookmarksMenu'>"
+" <menuitem action='Bookmarks_Add'/>"
+" <menuitem action='Bookmarks_Edit'/>"
+" <separator/>"
+" <menu name='SystemBookmarks' action='SystemBookmarksMenu'>"
+" </menu>"
+" <separator name='BookmarkListSeparator'/>"
+" <placeholder name='BookmarkList'/>"
+" </menu>"
+" </placeholder>"
+" </menubar>"
+"</ui>";
+
+
+static GtkActionEntry bookmarks_action_entries[] = {
+ { "BookmarksMenu", NULL, N_("_Bookmarks") },
+ { "SystemBookmarksMenu", NULL, N_("_System Bookmarks") },
+
+ { "Bookmarks_Add", GTK_STOCK_ADD,
+ N_("_Add Bookmark"), "<control>D",
+ N_("Add current location to bookmarks"),
+ G_CALLBACK (gth_browser_activate_action_bookmarks_add) },
+
+ { "Bookmarks_Edit", NULL,
+ N_("_Edit Bookmarks..."), "<control>B",
+ N_("Edit bookmarks"),
+ G_CALLBACK (gth_browser_activate_action_bookmarks_edit) },
+};
+static guint bookmarks_action_entries_size = G_N_ELEMENTS (bookmarks_action_entries);
+
+
+typedef struct {
+ GthBrowser *browser;
+ GtkActionGroup *actions;
+ guint bookmarks_changed_id;
+} BrowserData;
+
+
+static void
+browser_data_free (BrowserData *data)
+{
+ if (data->bookmarks_changed_id != 0) {
+ g_signal_handler_disconnect (gth_main_get_default_monitor (),
+ data->bookmarks_changed_id);
+ data->bookmarks_changed_id = 0;
+ }
+ g_free (data);
+}
+
+
+#define BUFFER_SIZE 4096
+
+
+typedef struct {
+ GthBrowser *browser;
+ GInputStream *stream;
+ char buffer[BUFFER_SIZE];
+ GString *file_content;
+} UpdateBookmarksData;
+
+
+static void
+update_bookmakrs_data_free (UpdateBookmarksData *data)
+{
+ g_input_stream_close (data->stream, NULL, NULL);
+ g_object_unref (data->stream);
+ g_string_free (data->file_content, TRUE);
+ g_object_unref (data->browser);
+ g_free (data);
+}
+
+
+static void
+update_system_bookmark_list_from_content (GthBrowser *browser,
+ const char *content)
+{
+ GtkWidget *bookmark_list;
+ GtkWidget *menu;
+ char **lines;
+ int i;
+
+ bookmark_list = gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), "/MenuBar/OtherMenus/Bookmarks/SystemBookmarks");
+ menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (bookmark_list));
+
+ _gtk_container_remove_children (GTK_CONTAINER (menu), NULL, NULL);
+
+ lines = g_strsplit (content, "\n", -1);
+ for (i = 0; lines[i] != NULL; i++) {
+ char **line;
+ char *uri;
+ GFile *file;
+ GIcon *icon;
+ char *name;
+
+ line = g_strsplit (lines[i], " ", 2);
+ uri = line[0];
+ if (uri == NULL)
+ continue;
+
+ file = g_file_new_for_uri (uri);
+ icon = _g_file_get_icon (file);
+ name = g_strdup (strchr (lines[i], ' '));
+ if (name == NULL)
+ name = _g_file_get_display_name (file);
+ if (name == NULL)
+ name = g_file_get_parse_name (file);
+
+ _gth_browser_add_file_menu_item_full (browser,
+ menu,
+ file,
+ icon,
+ name,
+ GTH_ACTION_GO_TO,
+ i,
+ -1);
+
+ g_free (name);
+ g_object_unref (icon);
+ g_object_unref (file);
+ g_strfreev (line);
+ }
+ g_strfreev (lines);
+
+ if (i > 0)
+ gtk_widget_show (bookmark_list);
+}
+
+
+static void
+update_system_bookmark_list_ready (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ UpdateBookmarksData *data = user_data;
+ gssize size;
+
+ size = g_input_stream_read_finish (data->stream, result, NULL);
+ if (size < 0) {
+ update_bookmakrs_data_free (data);
+ return;
+ }
+
+ if (size > 0) {
+ data->buffer[size + 1] = '\0';
+ g_string_append (data->file_content, data->buffer);
+
+ g_input_stream_read_async (data->stream,
+ data->buffer,
+ BUFFER_SIZE - 1,
+ G_PRIORITY_DEFAULT,
+ NULL,
+ update_system_bookmark_list_ready,
+ data);
+ return;
+ }
+
+ update_system_bookmark_list_from_content (data->browser, data->file_content->str);
+ update_bookmakrs_data_free (data);
+}
+
+
+static void
+_gth_browser_update_system_bookmark_list (GthBrowser *browser)
+{
+ char *bookmark_file_path;
+ GFile *bookmark_file;
+ GFileInputStream *input_stream;
+ UpdateBookmarksData *data;
+
+ bookmark_file_path = g_build_filename (g_get_home_dir (), ".gtk-bookmarks", NULL);
+ bookmark_file = g_file_new_for_path (bookmark_file_path);
+ g_free (bookmark_file_path);
+
+ input_stream = g_file_read (bookmark_file, NULL, NULL);
+ g_object_unref (bookmark_file);
+
+ if (input_stream == NULL)
+ return;
+
+ data = g_new0 (UpdateBookmarksData, 1);
+ data->browser = g_object_ref (browser);
+ data->stream = (GInputStream*) input_stream;
+ data->file_content = g_string_new ("");
+
+ g_input_stream_read_async (data->stream,
+ data->buffer,
+ BUFFER_SIZE - 1,
+ G_PRIORITY_DEFAULT,
+ NULL,
+ update_system_bookmark_list_ready,
+ data);
+}
+
+
+static void
+_gth_browser_update_bookmark_list (GthBrowser *browser)
+{
+ GtkWidget *menu;
+ GtkWidget *bookmark_list;
+ GtkWidget *bookmark_list_separator;
+ GBookmarkFile *bookmarks;
+ char **uris;
+ gsize length;
+ int i;
+
+ bookmark_list = gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), "/MenuBar/OtherMenus/Bookmarks/BookmarkList");
+ menu = gtk_widget_get_parent (bookmark_list);
+
+ _gtk_container_remove_children (GTK_CONTAINER (menu), bookmark_list, NULL);
+
+ bookmarks = gth_main_get_default_bookmarks ();
+ uris = g_bookmark_file_get_uris (bookmarks, &length);
+
+ bookmark_list_separator = gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), "/MenuBar/OtherMenus/Bookmarks/BookmarkListSeparator");
+ if (length > 0)
+ gtk_widget_show (bookmark_list_separator);
+ else
+ gtk_widget_hide (bookmark_list_separator);
+
+ for (i = 0; uris[i] != NULL; i++) {
+ GFile *file;
+
+ file = g_file_new_for_uri (uris[i]);
+ _gth_browser_add_file_menu_item (browser,
+ menu,
+ file,
+ GTH_ACTION_GO_TO,
+ i);
+
+ g_object_unref (file);
+ }
+
+ _gth_browser_update_system_bookmark_list (browser);
+
+ g_strfreev (uris);
+}
+
+
+static void
+bookmarks_changed_cb (GthMonitor *monitor,
+ gpointer user_data)
+{
+ BrowserData *data = user_data;
+ _gth_browser_update_bookmark_list (data->browser);
+}
+
+
+void
+bookmarks__gth_browser_construct_cb (GthBrowser *browser)
+{
+ BrowserData *data;
+ GError *error = NULL;
+
+ g_return_if_fail (GTH_IS_BROWSER (browser));
+
+ data = g_new0 (BrowserData, 1);
+ data->browser = browser;
+
+ data->actions = gtk_action_group_new ("Bookmarks Actions");
+ gtk_action_group_set_translation_domain (data->actions, NULL);
+ gtk_action_group_add_actions (data->actions,
+ bookmarks_action_entries,
+ bookmarks_action_entries_size,
+ browser);
+ gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), data->actions, 0);
+
+ if (! gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), fixed_ui_info, -1, &error)) {
+ g_message ("building menus failed: %s", error->message);
+ g_error_free (error);
+ }
+
+ data->bookmarks_changed_id = g_signal_connect (gth_main_get_default_monitor (),
+ "bookmarks-changed",
+ G_CALLBACK (bookmarks_changed_cb),
+ data);
+
+ g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free);
+}
+
+
+void
+bookmarks__gth_browser_construct_idle_callback_cb (GthBrowser *browser)
+{
+ _gth_browser_update_bookmark_list (browser);
+}
+
+
+void
+bookmarks__gth_browser_update_sensitivity_cb (GthBrowser *browser)
+{
+ BrowserData *data;
+ /*GtkAction *action;*/
+
+ data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
+ g_return_if_fail (data != NULL);
+
+ /*action = gtk_action_group_get_action (data->actions, "Edit_AddToCatalog");
+ sensitive = n_selected > 0;
+ g_object_set (action, "sensitive", sensitive, NULL);*/
+}
diff --git a/gthumb/dlg-bookmarks.h b/extensions/bookmarks/callbacks.h
similarity index 74%
copy from gthumb/dlg-bookmarks.h
copy to extensions/bookmarks/callbacks.h
index 47499aa..fd43de2 100644
--- a/gthumb/dlg-bookmarks.h
+++ b/extensions/bookmarks/callbacks.h
@@ -3,7 +3,7 @@
/*
* GThumb
*
- * Copyright (C) 2001-2008 The Free Software Foundation, Inc.
+ * Copyright (C) 2009 Free Software Foundation, Inc.
*
* 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
@@ -20,11 +20,12 @@
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
*/
-#ifndef DLG_BOOKMARKS_H
-#define DLG_BOOKMARKS_H
+#ifndef CALLBACKS_H
+#define CALLBACKS_H
-#include "gth-browser.h"
+#include <gthumb.h>
-void dlg_bookmarks (GthBrowser *browser);
+void bookmarks__gth_browser_construct_cb (GthBrowser *browser);
+void bookmarks__gth_browser_construct_idle_callback_cb (GthBrowser *browser);
-#endif /* DLG_BOOKMARKS_H */
+#endif /* CALLBACKS_H */
diff --git a/extensions/bookmarks/data/Makefile.am b/extensions/bookmarks/data/Makefile.am
new file mode 100644
index 0000000..c1713cf
--- /dev/null
+++ b/extensions/bookmarks/data/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS = ui
+
+-include $(top_srcdir)/git.mk
diff --git a/extensions/bookmarks/data/ui/Makefile.am b/extensions/bookmarks/data/ui/Makefile.am
new file mode 100644
index 0000000..67ae221
--- /dev/null
+++ b/extensions/bookmarks/data/ui/Makefile.am
@@ -0,0 +1,5 @@
+uidir = $(datadir)/gthumb-2.0/ui
+ui_DATA = bookmarks.ui
+EXTRA_DIST = $(ui_DATA)
+
+-include $(top_srcdir)/git.mk
diff --git a/data/ui/bookmarks.ui b/extensions/bookmarks/data/ui/bookmarks.ui
similarity index 100%
rename from data/ui/bookmarks.ui
rename to extensions/bookmarks/data/ui/bookmarks.ui
diff --git a/gthumb/dlg-bookmarks.c b/extensions/bookmarks/dlg-bookmarks.c
similarity index 97%
rename from gthumb/dlg-bookmarks.c
rename to extensions/bookmarks/dlg-bookmarks.c
index ae20418..fa5a7c7 100644
--- a/gthumb/dlg-bookmarks.c
+++ b/extensions/bookmarks/dlg-bookmarks.c
@@ -22,11 +22,7 @@
#include <config.h>
#include <gtk/gtk.h>
-#include "glib-utils.h"
-#include "gth-browser.h"
-#include "gth-main.h"
-#include "gth-uri-list.h"
-#include "gtk-utils.h"
+#include <gthumb.h>
typedef struct {
@@ -171,7 +167,7 @@ dlg_bookmarks (GthBrowser *browser)
data = g_new0 (DialogData, 1);
data->browser = browser;
data->do_not_update = FALSE;
- data->builder = _gtk_builder_new_from_file ("bookmarks.ui", NULL);
+ data->builder = _gtk_builder_new_from_file ("bookmarks.ui", "bookmarks");
/* Get the widgets. */
diff --git a/gthumb/dlg-bookmarks.h b/extensions/bookmarks/dlg-bookmarks.h
similarity index 97%
copy from gthumb/dlg-bookmarks.h
copy to extensions/bookmarks/dlg-bookmarks.h
index 47499aa..caa4910 100644
--- a/gthumb/dlg-bookmarks.h
+++ b/extensions/bookmarks/dlg-bookmarks.h
@@ -23,7 +23,7 @@
#ifndef DLG_BOOKMARKS_H
#define DLG_BOOKMARKS_H
-#include "gth-browser.h"
+#include <gthumb.h>
void dlg_bookmarks (GthBrowser *browser);
diff --git a/gthumb/dlg-bookmarks.h b/extensions/bookmarks/main.c
similarity index 55%
rename from gthumb/dlg-bookmarks.h
rename to extensions/bookmarks/main.c
index 47499aa..d68edd4 100644
--- a/gthumb/dlg-bookmarks.h
+++ b/extensions/bookmarks/main.c
@@ -3,7 +3,7 @@
/*
* GThumb
*
- * Copyright (C) 2001-2008 The Free Software Foundation, Inc.
+ * Copyright (C) 2009 Free Software Foundation, Inc.
*
* 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
@@ -20,11 +20,35 @@
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
*/
-#ifndef DLG_BOOKMARKS_H
-#define DLG_BOOKMARKS_H
-#include "gth-browser.h"
+#include <config.h>
+#include <gtk/gtk.h>
+#include <gthumb.h>
+#include "callbacks.h"
-void dlg_bookmarks (GthBrowser *browser);
-#endif /* DLG_BOOKMARKS_H */
+G_MODULE_EXPORT void
+gthumb_extension_activate (void)
+{
+ gth_hook_add_callback ("gth-browser-construct", 10, G_CALLBACK (bookmarks__gth_browser_construct_cb), NULL);
+ gth_hook_add_callback ("gth-browser-construct-idle-callback", 10, G_CALLBACK (bookmarks__gth_browser_construct_idle_callback_cb), NULL);
+}
+
+
+G_MODULE_EXPORT void
+gthumb_extension_deactivate (void)
+{
+}
+
+
+G_MODULE_EXPORT gboolean
+gthumb_extension_is_configurable (void)
+{
+ return FALSE;
+}
+
+
+G_MODULE_EXPORT void
+gthumb_extension_configure (GtkWindow *parent)
+{
+}
diff --git a/gthumb/Makefile.am b/gthumb/Makefile.am
index f51c75a..2b7e80a 100644
--- a/gthumb/Makefile.am
+++ b/gthumb/Makefile.am
@@ -112,7 +112,6 @@ PUBLIC_HEADER_FILES = \
$(NULL)
PRIVATE_HEADER_FILES = \
- dlg-bookmarks.h \
dlg-edit-metadata.h \
dlg-extensions.h \
gth-browser-actions-callbacks.h \
@@ -132,7 +131,6 @@ gthumb_SOURCES = \
$(EXTERNAL) \
$(PUBLIC_HEADER_FILES) \
$(PRIVATE_HEADER_FILES) \
- dlg-bookmarks.c \
dlg-edit-metadata.c \
dlg-extensions.c \
dlg-personalize-filters.c \
diff --git a/gthumb/gth-browser-actions-callbacks.c b/gthumb/gth-browser-actions-callbacks.c
index 77a3e1e..6b671f7 100644
--- a/gthumb/gth-browser-actions-callbacks.c
+++ b/gthumb/gth-browser-actions-callbacks.c
@@ -22,7 +22,6 @@
#include <config.h>
#include <glib/gi18n.h>
-#include "dlg-bookmarks.h"
#include "dlg-extensions.h"
#include "dlg-edit-metadata.h"
#include "dlg-personalize-filters.h"
@@ -41,35 +40,6 @@
void
-gth_browser_activate_action_bookmarks_add (GtkAction *action,
- GthBrowser *browser)
-{
- GBookmarkFile *bookmarks;
- GFile *location;
- char *uri;
-
- location = gth_browser_get_location (browser);
- if (location == NULL)
- return;
-
- bookmarks = gth_main_get_default_bookmarks ();
- uri = g_file_get_uri (location);
- _g_bookmark_file_add_uri (bookmarks, uri);
- gth_main_bookmarks_changed ();
-
- g_free (uri);
-}
-
-
-void
-gth_browser_activate_action_bookmarks_edit (GtkAction *action,
- GthBrowser *browser)
-{
- dlg_bookmarks (browser);
-}
-
-
-void
gth_browser_activate_action_file_open (GtkAction *action,
GthBrowser *browser)
{
diff --git a/gthumb/gth-browser-actions-entries.h b/gthumb/gth-browser-actions-entries.h
index a928687..412ce6d 100644
--- a/gthumb/gth-browser-actions-entries.h
+++ b/gthumb/gth-browser-actions-entries.h
@@ -32,8 +32,6 @@ static GtkActionEntry gth_browser_action_entries[] = {
{ "EditMenu", NULL, N_("_Edit") },
{ "ViewMenu", NULL, N_("_View") },
{ "GoMenu", NULL, N_("_Go") },
- { "BookmarksMenu", NULL, N_("_Bookmarks") },
- { "SystemBookmarksMenu", NULL, N_("_System Bookmarks") },
{ "HelpMenu", NULL, N_("_Help") },
{ "OpenWithMenu", NULL, N_("Open _With") },
@@ -157,16 +155,6 @@ static GtkActionEntry gth_browser_action_entries[] = {
N_("Delete the list of visited locations"),
G_CALLBACK (gth_browser_activate_action_go_clear_history) },
- { "Bookmarks_Add", GTK_STOCK_ADD,
- N_("_Add Bookmark"), "<control>D",
- N_("Add current location to bookmarks"),
- G_CALLBACK (gth_browser_activate_action_bookmarks_add) },
-
- { "Bookmarks_Edit", NULL,
- N_("_Edit Bookmarks..."), "<control>B",
- N_("Edit bookmarks"),
- G_CALLBACK (gth_browser_activate_action_bookmarks_edit) },
-
{ "View_BrowserMode", GTH_STOCK_BROWSER_MODE,
N_("Browser"), "Escape",
N_("View the folders"),
diff --git a/gthumb/gth-browser-ui.h b/gthumb/gth-browser-ui.h
index b40765b..36d0b28 100644
--- a/gthumb/gth-browser-ui.h
+++ b/gthumb/gth-browser-ui.h
@@ -88,15 +88,7 @@ static const char *fixed_ui_info =
" <separator name='BeforeHistoryList'/>"
" <placeholder name='HistoryList'/>"
" </menu>"
-" <menu name='Bookmarks' action='BookmarksMenu'>"
-" <menuitem action='Bookmarks_Add'/>"
-" <menuitem action='Bookmarks_Edit'/>"
-" <separator/>"
-" <menu name='SystemBookmarks' action='SystemBookmarksMenu'>"
-" </menu>"
-" <separator name='BookmarkListSeparator'/>"
-" <placeholder name='BookmarkList'/>"
-" </menu>"
+" <placeholder name='OtherMenus'/>"
" <menu name='Help' action='HelpMenu'>"
" <menuitem action='Help_Help'/>"
" <menuitem action='Help_Shortcuts'/>"
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 4688b88..d60b7db 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -73,16 +73,6 @@
typedef void (*GthBrowserCallback) (GthBrowser *, gboolean cancelled, gpointer user_data);
-typedef enum {
- GTH_ACTION_GO_TO,
- GTH_ACTION_GO_INTO,
- GTH_ACTION_GO_BACK,
- GTH_ACTION_GO_FORWARD,
- GTH_ACTION_GO_UP,
- GTH_ACTION_LIST_CHILDREN,
- GTH_ACTION_VIEW
-} GthAction;
-
enum {
LOCATION_READY,
LAST_SIGNAL
@@ -128,7 +118,6 @@ struct _GthBrowserPrivateData {
/* Browser data */
guint help_message_cid;
- gulong bookmarks_changed_id;
gulong folder_changed_id;
gulong file_renamed_id;
gulong metadata_changed_id;
@@ -297,7 +286,7 @@ activate_go_to_menu_item (GtkMenuItem *menuitem,
}
-static void
+void
_gth_browser_add_file_menu_item_full (GthBrowser *browser,
GtkWidget *menu,
GFile *file,
@@ -369,7 +358,7 @@ _gth_browser_add_file_menu_item_full (GthBrowser *browser,
}
-static void
+void
_gth_browser_add_file_menu_item (GthBrowser *browser,
GtkWidget *menu,
GFile *file,
@@ -717,194 +706,6 @@ _gth_browser_add_to_history (GthBrowser *browser,
}
-#define BUFFER_SIZE 4096
-
-
-typedef struct {
- GthBrowser *browser;
- GInputStream *stream;
- char buffer[BUFFER_SIZE];
- GString *file_content;
-} UpdateBookmarksData;
-
-
-static void
-update_bookmakrs_data_free (UpdateBookmarksData *data)
-{
- g_input_stream_close (data->stream, NULL, NULL);
- g_object_unref (data->stream);
- g_string_free (data->file_content, TRUE);
- g_object_unref (data->browser);
- g_free (data);
-}
-
-
-static void
-update_system_bookmark_list_from_content (GthBrowser *browser,
- const char *content)
-{
- GtkWidget *bookmark_list;
- GtkWidget *menu;
- char **lines;
- int i;
-
- bookmark_list = gtk_ui_manager_get_widget (browser->priv->ui, "/MenuBar/Bookmarks/SystemBookmarks");
- menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (bookmark_list));
-
- _gtk_container_remove_children (GTK_CONTAINER (menu), NULL, NULL);
-
- lines = g_strsplit (content, "\n", -1);
- for (i = 0; lines[i] != NULL; i++) {
- char **line;
- char *uri;
- GFile *file;
- GIcon *icon;
- char *name;
-
- line = g_strsplit (lines[i], " ", 2);
- uri = line[0];
- if (uri == NULL)
- continue;
-
- file = g_file_new_for_uri (uri);
- icon = _g_file_get_icon (file);
- name = g_strdup (strchr (lines[i], ' '));
- if (name == NULL)
- name = _g_file_get_display_name (file);
- if (name == NULL)
- name = g_file_get_parse_name (file);
-
- _gth_browser_add_file_menu_item_full (browser,
- menu,
- file,
- icon,
- name,
- GTH_ACTION_GO_TO,
- i,
- -1);
-
- g_free (name);
- g_object_unref (icon);
- g_object_unref (file);
- g_strfreev (line);
- }
- g_strfreev (lines);
-
- if (i > 0)
- gtk_widget_show (bookmark_list);
-}
-
-
-static void
-update_system_bookmark_list_ready (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
-{
- UpdateBookmarksData *data = user_data;
- gssize size;
-
- size = g_input_stream_read_finish (data->stream, result, NULL);
- if (size < 0) {
- update_bookmakrs_data_free (data);
- return;
- }
-
- if (size > 0) {
- data->buffer[size + 1] = '\0';
- g_string_append (data->file_content, data->buffer);
-
- g_input_stream_read_async (data->stream,
- data->buffer,
- BUFFER_SIZE - 1,
- G_PRIORITY_DEFAULT,
- NULL,
- update_system_bookmark_list_ready,
- data);
- return;
- }
-
- update_system_bookmark_list_from_content (data->browser, data->file_content->str);
- update_bookmakrs_data_free (data);
-}
-
-
-static void
-_gth_browser_update_system_bookmark_list (GthBrowser *browser)
-{
- char *bookmark_file_path;
- GFile *bookmark_file;
- GFileInputStream *input_stream;
- UpdateBookmarksData *data;
-
- bookmark_file_path = g_build_filename (g_get_home_dir (), ".gtk-bookmarks", NULL);
- bookmark_file = g_file_new_for_path (bookmark_file_path);
- g_free (bookmark_file_path);
-
- input_stream = g_file_read (bookmark_file, NULL, NULL);
- g_object_unref (bookmark_file);
-
- if (input_stream == NULL)
- return;
-
- data = g_new0 (UpdateBookmarksData, 1);
- data->browser = g_object_ref (browser);
- data->stream = (GInputStream*) input_stream;
- data->file_content = g_string_new ("");
-
- g_input_stream_read_async (data->stream,
- data->buffer,
- BUFFER_SIZE - 1,
- G_PRIORITY_DEFAULT,
- NULL,
- update_system_bookmark_list_ready,
- data);
-}
-
-
-static void
-_gth_browser_update_bookmark_list (GthBrowser *browser)
-{
- GtkWidget *menu;
- GtkWidget *bookmark_list;
- GtkWidget *bookmark_list_separator;
- GBookmarkFile *bookmarks;
- char **uris;
- gsize length;
- int i;
-
- bookmark_list = gtk_ui_manager_get_widget (browser->priv->ui, "/MenuBar/Bookmarks/BookmarkList");
- menu = gtk_widget_get_parent (bookmark_list);
-
- _gtk_container_remove_children (GTK_CONTAINER (menu), bookmark_list, NULL);
-
- bookmarks = gth_main_get_default_bookmarks ();
- uris = g_bookmark_file_get_uris (bookmarks, &length);
-
- bookmark_list_separator = gtk_ui_manager_get_widget (browser->priv->ui, "/MenuBar/Bookmarks/BookmarkListSeparator");
- if (length > 0)
- gtk_widget_show (bookmark_list_separator);
- else
- gtk_widget_hide (bookmark_list_separator);
-
- for (i = 0; uris[i] != NULL; i++) {
- GFile *file;
-
- file = g_file_new_for_uri (uris[i]);
- _gth_browser_add_file_menu_item (browser,
- menu,
- file,
- GTH_ACTION_GO_TO,
- i);
-
- g_object_unref (file);
- }
-
- _gth_browser_update_system_bookmark_list (browser);
-
- g_strfreev (uris);
-}
-
-
static void
_gth_browser_monitor_entry_points (GthBrowser *browser)
{
@@ -2054,8 +1855,6 @@ _gth_browser_real_close (GthBrowser *browser)
/* disconnect from the monitor */
g_signal_handler_disconnect (gth_main_get_default_monitor (),
- browser->priv->bookmarks_changed_id);
- g_signal_handler_disconnect (gth_main_get_default_monitor (),
browser->priv->folder_changed_id);
g_signal_handler_disconnect (gth_main_get_default_monitor (),
browser->priv->file_renamed_id);
@@ -2518,14 +2317,6 @@ filterbar_personalize_cb (GthFilterbar *filterbar,
static void
-bookmarks_changed_cb (GthMonitor *monitor,
- GthBrowser *browser)
-{
- _gth_browser_update_bookmark_list (browser);
-}
-
-
-static void
file_attributes_ready_cb (GthFileSource *file_source,
GList *files,
GError *error,
@@ -3106,7 +2897,7 @@ _gth_browser_construct_step2 (gpointer data)
{
GthBrowser *browser = data;
- _gth_browser_update_bookmark_list (browser);
+ gth_hook_invoke ("gth-browser-construct-idle-callback", browser);
_gth_browser_monitor_entry_points (browser);
}
@@ -3617,11 +3408,6 @@ _gth_browser_construct (GthBrowser *browser)
/**/
- browser->priv->bookmarks_changed_id =
- g_signal_connect (gth_main_get_default_monitor (),
- "bookmarks-changed",
- G_CALLBACK (bookmarks_changed_cb),
- browser);
browser->priv->folder_changed_id =
g_signal_connect (gth_main_get_default_monitor (),
"folder-changed",
diff --git a/gthumb/gth-browser.h b/gthumb/gth-browser.h
index a412ef0..7b089e8 100644
--- a/gthumb/gth-browser.h
+++ b/gthumb/gth-browser.h
@@ -50,6 +50,16 @@ typedef enum { /*< skip >*/
GTH_BROWSER_N_PAGES
} GthBrowserPage;
+typedef enum {
+ GTH_ACTION_GO_TO,
+ GTH_ACTION_GO_INTO,
+ GTH_ACTION_GO_BACK,
+ GTH_ACTION_GO_FORWARD,
+ GTH_ACTION_GO_UP,
+ GTH_ACTION_LIST_CHILDREN,
+ GTH_ACTION_VIEW
+} GthAction;
+
struct _GthBrowser
{
GthWindow __parent;
@@ -160,6 +170,22 @@ void gth_browser_unfullscreen (GthBrowser *browser);
void gth_browser_file_menu_popup (GthBrowser *browser,
GdkEventButton *event);
+/* protected methods */
+
+void _gth_browser_add_file_menu_item (GthBrowser *browser,
+ GtkWidget *menu,
+ GFile *file,
+ GthAction action,
+ int steps);
+void _gth_browser_add_file_menu_item_full (GthBrowser *browser,
+ GtkWidget *menu,
+ GFile *file,
+ GIcon *icon,
+ const char *display_name,
+ GthAction action,
+ int steps,
+ int position);
+
G_END_DECLS
#endif /* GTH_BROWSER_H */
diff --git a/gthumb/gth-main-default-hooks.c b/gthumb/gth-main-default-hooks.c
index 0a08f9c..ea068c6 100644
--- a/gthumb/gth-main-default-hooks.c
+++ b/gthumb/gth-main-default-hooks.c
@@ -48,6 +48,13 @@ gth_main_register_default_hooks (void)
gth_hook_register ("gth-browser-construct", 1);
/**
+ * Called in an idle callback after the window has been initialized.
+ *
+ * @browser (GthBrowser*): the relative window.
+ **/
+ gth_hook_register ("gth-browser-construct-idle-callback", 1);
+
+ /**
* Called when the window is realized.
*
* @browser (GthBrowser*): the window.
diff --git a/gthumb/gth-main.c b/gthumb/gth-main.c
index ea171de..50d6e8b 100644
--- a/gthumb/gth-main.c
+++ b/gthumb/gth-main.c
@@ -1151,7 +1151,8 @@ gth_main_activate_extensions (void)
const char *mandatory_extensions[] = { "file_viewer",
"jpeg_utils",
NULL };
- const char *default_extensions[] = { "catalogs",
+ const char *default_extensions[] = { "bookmarks",
+ "catalogs",
"comments",
"desktop_background",
"exiv2",
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ff22581..15678f0 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -10,13 +10,21 @@ copy-n-paste/eggsmclient-xsmp.c
data/gthumb.desktop.in.in
data/gthumb-import.desktop.in.in
data/gthumb.schemas.in
-[type: gettext/glade]data/ui/bookmarks.ui
[type: gettext/glade]data/ui/extensions.ui
[type: gettext/glade]data/ui/filter-editor.ui
[type: gettext/glade]data/ui/overwrite-dialog.ui
[type: gettext/glade]data/ui/personalize-filters.ui
[type: gettext/glade]data/ui/preferences.ui
[type: gettext/glade]data/ui/sort-order.ui
+extensions/bookmarks/actions.c
+extensions/bookmarks/actions.h
+extensions/bookmarks/bookmarks.extension.in.in
+extensions/bookmarks/callbacks.c
+extensions/bookmarks/callbacks.h
+[type: gettext/glade]extensions/bookmarks/data/ui/bookmarks.ui
+extensions/bookmarks/dlg-bookmarks.c
+extensions/bookmarks/dlg-bookmarks.h
+extensions/bookmarks/main.c
extensions/catalogs/actions.c
extensions/catalogs/actions.h
extensions/catalogs/callbacks.c
@@ -41,6 +49,12 @@ extensions/comments/gth-metadata-provider-comment.h
extensions/comments/gth-test-category.c
extensions/comments/gth-test-category.h
extensions/comments/main.c
+extensions/desktop_background/actions.c
+extensions/desktop_background/actions.h
+extensions/desktop_background/callbacks.c
+extensions/desktop_background/callbacks.h
+extensions/desktop_background/desktop_background.extension.in.in
+extensions/desktop_background/main.c
extensions/exiv2/exiv2.extension.in.in
extensions/exiv2/exiv2-utils.cpp
extensions/exiv2/exiv2-utils.h
@@ -231,8 +245,6 @@ extensions/slideshow/main.c
extensions/slideshow/preferences.c
extensions/slideshow/preferences.h
extensions/slideshow/slideshow.extension.in.in
-gthumb/dlg-bookmarks.c
-gthumb/dlg-bookmarks.h
gthumb/dlg-edit-metadata.c
gthumb/dlg-edit-metadata.h
gthumb/dlg-extensions.c
@@ -383,6 +395,8 @@ gthumb/gth-string-list.c
gthumb/gth-string-list.h
gthumb/gth-tags-entry.c
gthumb/gth-tags-entry.h
+gthumb/gth-tags-expander.c
+gthumb/gth-tags-expander.h
gthumb/gth-tags-file.c
gthumb/gth-tags-file.h
gthumb/gth-task.c
@@ -399,6 +413,8 @@ gthumb/gth-thumb-loader.c
gthumb/gth-thumb-loader.h
gthumb/gth-time.c
gthumb/gth-time.h
+gthumb/gth-time-selector.c
+gthumb/gth-time-selector.h
gthumb/gth-toggle-menu-tool-button.c
gthumb/gth-toggle-menu-tool-button.h
gthumb/gth-toolbox.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]