From bug 309844 [1]: "In spatial nautilus, it is possible to access the currently displayed folder's right-click menu from the location button (lower left). From there you can act on the opened menu (cut/copy, open properties, etc). It would be nice to be able to access the same menu directly from the path bar in a browser window." Proposed patch attached. Note that its architecture theoretically allows that the gtk_toggle_button_get_active check in path_bar_button_pressed_callback is removed and a location menu is generated for all locations displayed in the pathbar - but we'd have to adapt nautilus_view_pop_up_location_context_menu to optionally take a location for which the menu should be generated. [1] http://bugzilla.gnome.org/show_bug.cgi?id=309844 -- Christian Neumair <chris gnome-de org>
Index: src/nautilus-navigation-window.c =================================================================== RCS file: /cvs/gnome/nautilus/src/nautilus-navigation-window.c,v retrieving revision 1.433 diff -u -p -r1.433 nautilus-navigation-window.c --- src/nautilus-navigation-window.c 8 Jul 2005 11:25:51 -0000 1.433 +++ src/nautilus-navigation-window.c 9 Jul 2005 15:40:29 -0000 @@ -115,6 +115,9 @@ static void navigation_bar_location_chan static void path_bar_location_changed_callback (GtkWidget *widget, const char *uri, NautilusNavigationWindow *window); +static void path_bar_path_set_callback (GtkWidget *widget, + const char *uri, + NautilusNavigationWindow *window); static void always_use_location_entry_changed (gpointer callback_data); @@ -188,6 +191,8 @@ nautilus_navigation_window_instance_init g_signal_connect_object (window->path_bar, "path_clicked", G_CALLBACK (path_bar_location_changed_callback), window, 0); + g_signal_connect_object (window->path_bar, "path_set", + G_CALLBACK (path_bar_path_set_callback), window, 0); gtk_box_pack_start (GTK_BOX (hbox), window->path_bar, @@ -270,6 +275,58 @@ always_use_location_entry_changed (gpoin } } +static gboolean +path_bar_button_pressed_callback (GtkWidget *widget, + GdkEventButton *event, + NautilusNavigationWindow *window) +{ + NautilusView *view; + + if (event->button != 3 || + !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { + return FALSE; + } + + view = NAUTILUS_WINDOW (window)->content_view; + if (view == NULL) { + return FALSE; + } + + nautilus_view_pop_up_location_context_menu (view, event); + + return TRUE; +} + +static void +path_bar_path_set_callback (GtkWidget *widget, + const char *uri, + NautilusNavigationWindow *window) +{ + GList *children, *l; + GtkWidget *child; + + children = gtk_container_get_children (GTK_CONTAINER (widget)); + + for (l = children; l != NULL; l = l->next) { + child = GTK_WIDGET (l->data); + + if (!GTK_IS_TOGGLE_BUTTON (child)) { + continue; + } + + if (!g_signal_handler_find (child, + G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, + 0, 0, NULL, + path_bar_button_pressed_callback, + window)) { + g_signal_connect (child, "button-press-event", + G_CALLBACK (path_bar_button_pressed_callback), + window); + } + } + + g_list_free (children); +} static void path_bar_location_changed_callback (GtkWidget *widget, @@ -280,7 +337,6 @@ path_bar_location_changed_callback (GtkW nautilus_window_go_to (NAUTILUS_WINDOW (window), uri); } - static void navigation_bar_location_changed_callback (GtkWidget *widget, const char *uri, @@ -300,7 +356,6 @@ navigation_bar_location_changed_callback } window->details->temporary_navigation_bar = FALSE; } - nautilus_window_go_to (NAUTILUS_WINDOW (window), uri); } Index: src/nautilus-pathbar.c =================================================================== RCS file: /cvs/gnome/nautilus/src/nautilus-pathbar.c,v retrieving revision 1.1 diff -u -p -r1.1 nautilus-pathbar.c --- src/nautilus-pathbar.c 8 Jul 2005 11:25:51 -0000 1.1 +++ src/nautilus-pathbar.c 9 Jul 2005 15:40:30 -0000 @@ -42,6 +42,7 @@ enum { PATH_CLICKED, + PATH_SET, LAST_SIGNAL }; @@ -67,7 +68,7 @@ static gboolean desktop_is_home; #define DEFAULT_ICON "gnome-fs-directory" #define DEFAULT_DESKTOP_ICON "gnome-fs-desktop" #define DEFAULT_HOME_ICON "gnome-fs-home" -#define DEFAULT_FILESYSTEM_ICON "gnome-fs-blockdev" +#define DEFAULT_FILESYSTEM_ICON "gnome-dev-harddisk" typedef struct _ButtonData ButtonData; @@ -267,6 +268,15 @@ nautilus_path_bar_class_init (NautilusPa g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); + path_bar_signals [PATH_SET] = + g_signal_new ("path-set", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NautilusPathBarClass, path_set), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, + G_TYPE_STRING); } @@ -1571,6 +1581,8 @@ nautilus_path_bar_update_path (NautilusP } gtk_widget_pop_composite_child (); + + g_signal_emit (path_bar, path_bar_signals [PATH_SET], 0, file_path); return result; } Index: src/nautilus-pathbar.h =================================================================== RCS file: /cvs/gnome/nautilus/src/nautilus-pathbar.h,v retrieving revision 1.1 diff -u -p -r1.1 nautilus-pathbar.h --- src/nautilus-pathbar.h 8 Jul 2005 11:25:51 -0000 1.1 +++ src/nautilus-pathbar.h 9 Jul 2005 15:40:30 -0000 @@ -68,6 +68,8 @@ struct _NautilusPathBarClass void (* path_clicked) (NautilusPathBar *path_bar, const char *file_path); + void (* path_set) (NautilusPathBar *path_bar, + const char *file_path); }; GType nautilus_path_bar_get_type (void) G_GNUC_CONST;
Attachment:
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil