summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2006-06-16 15:40:18 +0000
committerAlexander Larsson <alexl@src.gnome.org>2006-06-16 15:40:18 +0000
commit1a7f1da177985095aa6c9b8000e24ab06e76aace (patch)
tree11c03c01e3b630281f06ae990c286db358de506f
parent2f6ea5757cd326d1e898332cf40c87c2906a2a0a (diff)
downloadnautilus-1a7f1da177985095aa6c9b8000e24ab06e76aace.tar.gz
Add items_updated signal
2006-06-16 Alexander Larsson <alexl@redhat.com> * libnautilus-extension/nautilus-menu-provider.[ch]: Add items_updated signal * libnautilus-private/Makefile.am: * libnautilus-private/nautilus-signaller.[ch]: * src/nautilus-signaller.[ch]: * src/Makefile.am: Move NautilusSignaller to libnautilus-private. Add popup_menu_changed signal. * src/nautilus-application.c: Signal popup_menu_changed when a menu provider emits items_updated. * src/file-manager/fm-directory-view.c: * src/nautilus-window.c: Handle popup_menu_changed. * src/nautilus-emblem-sidebar.c: * src/nautilus-history-sidebar.c: * src/nautilus-navigation-window-menus.c: * src/nautilus-navigation-window.c: * src/nautilus-property-browser.c: * src/nautilus-spatial-window.c: * src/nautilus-window-menus.c: Update includes. Patch from RUAUDEL Frédéric <ruaudel@embl.fr>
-rw-r--r--ChangeLog30
-rw-r--r--libnautilus-extension/nautilus-menu-provider.c22
-rw-r--r--libnautilus-extension/nautilus-menu-provider.h3
-rw-r--r--libnautilus-private/Makefile.am2
-rw-r--r--libnautilus-private/nautilus-signaller.c (renamed from src/nautilus-signaller.c)9
-rw-r--r--libnautilus-private/nautilus-signaller.h (renamed from src/nautilus-signaller.h)0
-rw-r--r--src/Makefile.am2
-rw-r--r--src/file-manager/fm-directory-view.c5
-rw-r--r--src/nautilus-application.c34
-rw-r--r--src/nautilus-emblem-sidebar.c2
-rw-r--r--src/nautilus-history-sidebar.c2
-rw-r--r--src/nautilus-navigation-window-menus.c2
-rw-r--r--src/nautilus-navigation-window.c2
-rw-r--r--src/nautilus-property-browser.c2
-rw-r--r--src/nautilus-spatial-window.c2
-rw-r--r--src/nautilus-window-menus.c2
-rw-r--r--src/nautilus-window.c6
17 files changed, 117 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 2793e9bac..383a3ac93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,35 @@
2006-06-16 Alexander Larsson <alexl@redhat.com>
+ * libnautilus-extension/nautilus-menu-provider.[ch]:
+ Add items_updated signal
+
+ * libnautilus-private/Makefile.am:
+ * libnautilus-private/nautilus-signaller.[ch]:
+ * src/nautilus-signaller.[ch]:
+ * src/Makefile.am:
+ Move NautilusSignaller to libnautilus-private.
+ Add popup_menu_changed signal.
+
+ * src/nautilus-application.c:
+ Signal popup_menu_changed when a menu provider emits items_updated.
+
+ * src/file-manager/fm-directory-view.c:
+ * src/nautilus-window.c:
+ Handle popup_menu_changed.
+
+ * src/nautilus-emblem-sidebar.c:
+ * src/nautilus-history-sidebar.c:
+ * src/nautilus-navigation-window-menus.c:
+ * src/nautilus-navigation-window.c:
+ * src/nautilus-property-browser.c:
+ * src/nautilus-spatial-window.c:
+ * src/nautilus-window-menus.c:
+ Update includes.
+
+ Patch from RUAUDEL Frédéric <ruaudel@embl.fr>
+
+2006-06-16 Alexander Larsson <alexl@redhat.com>
+
* libnautilus-private/nautilus-column-utilities.c:
Add selinux context column
diff --git a/libnautilus-extension/nautilus-menu-provider.c b/libnautilus-extension/nautilus-menu-provider.c
index 956c5ec0e..b3929f04e 100644
--- a/libnautilus-extension/nautilus-menu-provider.c
+++ b/libnautilus-extension/nautilus-menu-provider.c
@@ -31,6 +31,20 @@
static void
nautilus_menu_provider_base_init (gpointer g_class)
{
+ static gboolean initialized = FALSE;
+
+ if (!initialized)
+ {
+ /* This signal should be emited each time the extension modify the list of menu items */
+ g_signal_new ("items_updated",
+ NAUTILUS_TYPE_MENU_PROVIDER,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+ initialized = TRUE;
+ }
}
GType
@@ -107,4 +121,12 @@ nautilus_menu_provider_get_toolbar_items (NautilusMenuProvider *provider,
}
}
+/* This function emit a signal to inform nautilus that its item list has changed */
+void
+nautilus_menu_provider_emit_items_updated_signal (NautilusMenuProvider* provider)
+{
+ g_return_if_fail (NAUTILUS_IS_MENU_PROVIDER (provider));
+
+ g_signal_emit_by_name (provider, "items_updated");
+}
diff --git a/libnautilus-extension/nautilus-menu-provider.h b/libnautilus-extension/nautilus-menu-provider.h
index a7a9a2470..da335fb6a 100644
--- a/libnautilus-extension/nautilus-menu-provider.h
+++ b/libnautilus-extension/nautilus-menu-provider.h
@@ -72,6 +72,9 @@ GList *nautilus_menu_provider_get_toolbar_items (NautilusMen
GtkWidget *window,
NautilusFileInfo *current_folder);
+/* This function emit a signal to inform nautilus that its item list has changed. */
+void nautilus_menu_provider_emit_items_updated_signal (NautilusMenuProvider *provider);
+
G_END_DECLS
#endif
diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am
index 74bd798b7..5ee3b697a 100644
--- a/libnautilus-private/Makefile.am
+++ b/libnautilus-private/Makefile.am
@@ -170,6 +170,8 @@ libnautilus_private_la_SOURCES = \
nautilus-sidebar-provider.h \
nautilus-sidebar.c \
nautilus-sidebar.h \
+ nautilus-signaller.h \
+ nautilus-signaller.c \
nautilus-query.c \
nautilus-query.h \
nautilus-thumbnails.c \
diff --git a/src/nautilus-signaller.c b/libnautilus-private/nautilus-signaller.c
index c4ee2c120..4ae97ed56 100644
--- a/src/nautilus-signaller.c
+++ b/libnautilus-private/nautilus-signaller.c
@@ -38,6 +38,7 @@ typedef GObjectClass NautilusSignallerClass;
enum {
HISTORY_LIST_CHANGED,
EMBLEMS_CHANGED,
+ POPUP_MENU_CHANGED,
LAST_SIGNAL
};
@@ -85,4 +86,12 @@ nautilus_signaller_class_init (NautilusSignallerClass *class)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ signals[POPUP_MENU_CHANGED] =
+ g_signal_new ("popup_menu_changed",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
diff --git a/src/nautilus-signaller.h b/libnautilus-private/nautilus-signaller.h
index eff25a905..eff25a905 100644
--- a/src/nautilus-signaller.h
+++ b/libnautilus-private/nautilus-signaller.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 4a2c4c83e..091bb8dbf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -111,8 +111,6 @@ nautilus_SOURCES = \
nautilus-side-pane.h \
nautilus-sidebar-title.c \
nautilus-sidebar-title.h \
- nautilus-signaller.c \
- nautilus-signaller.h \
nautilus-spatial-window.c \
nautilus-spatial-window.h \
nautilus-throbber.c \
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index e8e7d7389..a8621e205 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -103,6 +103,7 @@
#include <libnautilus-private/nautilus-trash-directory.h>
#include <libnautilus-private/nautilus-trash-monitor.h>
#include <libnautilus-private/nautilus-ui-utilities.h>
+#include <libnautilus-private/nautilus-signaller.h>
#include <unistd.h>
/* Number of seconds until cancel dialog shows up */
@@ -1957,6 +1958,10 @@ fm_directory_view_init (FMDirectoryView *view)
/* React to clipboard changes */
g_signal_connect_object (nautilus_clipboard_monitor_get (), "clipboard_changed",
G_CALLBACK (clipboard_changed_callback), view, 0);
+
+ /* Register to menu provider extension signal managing menu updates */
+ g_signal_connect_object (nautilus_signaller_get_current (), "popup_menu_changed",
+ G_CALLBACK (fm_directory_view_update_menus), view, G_CONNECT_SWAPPED);
gtk_widget_show (GTK_WIDGET (view));
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index d0daa6ed2..cfc971458 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -81,6 +81,8 @@
#include <libnautilus-private/nautilus-undo-manager.h>
#include <libnautilus-private/nautilus-desktop-link-monitor.h>
#include <libnautilus-private/nautilus-directory-private.h>
+#include <libnautilus-private/nautilus-signaller.h>
+#include <libnautilus-extension/nautilus-menu-provider.h>
#include <bonobo-activation/bonobo-activation.h>
#ifdef HAVE_STARTUP_NOTIFICATION
#define SN_API_NOT_YET_FROZEN Yes_i_know_DO_IT
@@ -349,12 +351,44 @@ migrate_old_nautilus_files (void)
}
static void
+menu_provider_items_updated_handler (NautilusMenuProvider *provider, GtkWidget* parent_window, gpointer data)
+{
+
+ g_signal_emit_by_name (nautilus_signaller_get_current (),
+ "popup_menu_changed");
+}
+
+static void
+menu_provider_init_callback (void)
+{
+ GList *items;
+ GList *providers;
+ GList *l;
+
+ providers = nautilus_module_get_extensions_for_type (NAUTILUS_TYPE_MENU_PROVIDER);
+ items = NULL;
+
+ for (l = providers; l != NULL; l = l->next) {
+ NautilusMenuProvider *provider = NAUTILUS_MENU_PROVIDER (l->data);
+
+ g_signal_connect_after (G_OBJECT (provider), "items_updated",
+ (GCallback)menu_provider_items_updated_handler,
+ NULL);
+ }
+
+ nautilus_module_extension_list_free (providers);
+}
+
+static void
finish_startup (NautilusApplication *application)
{
/* initialize nautilus modules */
nautilus_module_init ();
nautilus_module_add_type (FM_TYPE_DITEM_PAGE);
+
+ /* attach menu-provider module callback */
+ menu_provider_init_callback ();
/* initialize URI authentication manager */
gnome_authentication_manager_init ();
diff --git a/src/nautilus-emblem-sidebar.c b/src/nautilus-emblem-sidebar.c
index c52c839b1..434af07af 100644
--- a/src/nautilus-emblem-sidebar.c
+++ b/src/nautilus-emblem-sidebar.c
@@ -30,7 +30,6 @@
#include <config.h>
#include "nautilus-emblem-sidebar.h"
-#include "nautilus-signaller.h"
#include <stdio.h>
#include <eel/eel-gtk-macros.h>
@@ -68,6 +67,7 @@
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-sidebar-provider.h>
#include <libnautilus-private/nautilus-module.h>
+#include <libnautilus-private/nautilus-signaller.h>
struct NautilusEmblemSidebarDetails {
NautilusWindowInfo *window;
diff --git a/src/nautilus-history-sidebar.c b/src/nautilus-history-sidebar.c
index 8f6a1066a..aece0139f 100644
--- a/src/nautilus-history-sidebar.c
+++ b/src/nautilus-history-sidebar.c
@@ -43,8 +43,8 @@
#include <libnautilus-private/nautilus-global-preferences.h>
#include <libnautilus-private/nautilus-sidebar-provider.h>
#include <libnautilus-private/nautilus-module.h>
+#include <libnautilus-private/nautilus-signaller.h>
-#include "nautilus-signaller.h"
#include "nautilus-history-sidebar.h"
#define NAUTILUS_HISTORY_SIDEBAR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_HISTORY_SIDEBAR, NautilusHistorySidebarClass))
diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c
index 6a1b9def5..84693e545 100644
--- a/src/nautilus-navigation-window-menus.c
+++ b/src/nautilus-navigation-window-menus.c
@@ -36,7 +36,6 @@
#include "nautilus-bookmarks-window.h"
#include "nautilus-file-management-properties.h"
#include "nautilus-property-browser.h"
-#include "nautilus-signaller.h"
#include "nautilus-window-manage-views.h"
#include "nautilus-window-private.h"
#include "nautilus-window-bookmarks.h"
@@ -61,6 +60,7 @@
#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-undo-manager.h>
#include <libnautilus-private/nautilus-search-engine.h>
+#include <libnautilus-private/nautilus-signaller.h>
#define MENU_PATH_HISTORY_PLACEHOLDER "/MenuBar/Other Menus/Go/History Placeholder"
diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c
index 8af998f19..c5a2d9b34 100644
--- a/src/nautilus-navigation-window.c
+++ b/src/nautilus-navigation-window.c
@@ -35,7 +35,6 @@
#include "nautilus-application.h"
#include "nautilus-bookmarks-window.h"
#include "nautilus-main.h"
-#include "nautilus-signaller.h"
#include "nautilus-location-bar.h"
#include "nautilus-pathbar.h"
#include "nautilus-query-editor.h"
@@ -85,6 +84,7 @@
#include <libnautilus-private/nautilus-module.h>
#include <libnautilus-private/nautilus-sidebar-provider.h>
#include <libnautilus-private/nautilus-search-directory.h>
+#include <libnautilus-private/nautilus-signaller.h>
#include <math.h>
#include <sys/time.h>
diff --git a/src/nautilus-property-browser.c b/src/nautilus-property-browser.c
index 2c949e954..66a425cb1 100644
--- a/src/nautilus-property-browser.c
+++ b/src/nautilus-property-browser.c
@@ -32,7 +32,6 @@
#include <math.h>
#include "nautilus-property-browser.h"
-#include "nautilus-signaller.h"
#include <eel/eel-gdk-extensions.h>
#include <eel/eel-gdk-pixbuf-extensions.h>
#include <eel/eel-glib-extensions.h>
@@ -84,6 +83,7 @@
#include <libnautilus-private/nautilus-file.h>
#include <libnautilus-private/nautilus-global-preferences.h>
#include <libnautilus-private/nautilus-metadata.h>
+#include <libnautilus-private/nautilus-signaller.h>
#include <atk/atkrelationset.h>
/* property types */
diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c
index 79e8a3c3c..33de7a6b9 100644
--- a/src/nautilus-spatial-window.c
+++ b/src/nautilus-spatial-window.c
@@ -40,7 +40,6 @@
#include "nautilus-main.h"
#include "nautilus-query-editor.h"
#include "nautilus-search-bar.h"
-#include "nautilus-signaller.h"
#include "nautilus-window-manage-views.h"
#include "nautilus-zoom-control.h"
#include <eel/eel-debug.h>
@@ -81,6 +80,7 @@
#include <libnautilus-private/nautilus-undo.h>
#include <libnautilus-private/nautilus-search-directory.h>
#include <libnautilus-private/nautilus-search-engine.h>
+#include <libnautilus-private/nautilus-signaller.h>
#include <math.h>
#include <sys/time.h>
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index a82a8a047..8d6e3bed8 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -34,7 +34,6 @@
#include "nautilus-connect-server-dialog.h"
#include "nautilus-file-management-properties.h"
#include "nautilus-property-browser.h"
-#include "nautilus-signaller.h"
#include "nautilus-window-manage-views.h"
#include "nautilus-window-bookmarks.h"
#include "nautilus-window-private.h"
@@ -68,6 +67,7 @@
#include <libnautilus-private/nautilus-undo-manager.h>
#include <libnautilus-private/nautilus-search-directory.h>
#include <libnautilus-private/nautilus-search-engine.h>
+#include <libnautilus-private/nautilus-signaller.h>
#define MENU_PATH_EXTENSION_ACTIONS "/MenuBar/File/Extension Actions"
#define POPUP_PATH_EXTENSION_ACTIONS "/background/Before Zoom Items/Extension Actions"
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index e6a589cab..ace88e9b7 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -36,7 +36,6 @@
#include "nautilus-bookmarks-window.h"
#include "nautilus-information-panel.h"
#include "nautilus-main.h"
-#include "nautilus-signaller.h"
#include "nautilus-window-manage-views.h"
#include "nautilus-window-bookmarks.h"
#include "nautilus-zoom-control.h"
@@ -79,6 +78,7 @@
#include <libnautilus-private/nautilus-clipboard.h>
#include <libnautilus-private/nautilus-undo.h>
#include <libnautilus-private/nautilus-search-directory.h>
+#include <libnautilus-private/nautilus-signaller.h>
#include <math.h>
#include <sys/time.h>
@@ -190,6 +190,10 @@ nautilus_window_init (NautilusWindow *window)
G_CALLBACK (icons_changed_callback), window,
0);
+ /* Register to menu provider extension signal managing menu updates */
+ g_signal_connect_object (nautilus_signaller_get_current (), "popup_menu_changed",
+ G_CALLBACK (nautilus_window_load_extension_menus), window, G_CONNECT_SWAPPED);
+
gtk_quit_add_destroy (1, GTK_OBJECT (window));
/* Keep the main event loop alive as long as the window exists */