Am Donnerstag, den 14.07.2005, 15:21 +0200 schrieb Alexander Larsson: > On Thu, 2005-07-14 at 13:11 +0200, Christian Neumair wrote: > > Am Mittwoch, den 13.07.2005, 10:57 +0200 schrieb Alexander Larsson: > > > On Sun, 2005-07-10 at 15:39 +0200, Christian Neumair wrote: > > > > 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 > > > > > > I dunno. Its very strange that it only works for the current directory > > > button. > > > > Isn't it better than nothing at all? For now the most important thing is > > IMHO to be able to change the viewed containers' properties. > > I don't think adding something that feels internally inconsistent is > good. Is it better than nothing? I dunno, but I think a non-internaly > inconsistent solution is much better, and quite doable. If we add one > solution now it will end up much harder to come with a right solution > later. Proposed patch #2 attached. Maybe sb. else finds the time to review it while you're away. -- Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-view.c =================================================================== RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-view.c,v retrieving revision 1.3 diff -u -p -r1.3 nautilus-view.c --- libnautilus-private/nautilus-view.c 17 May 2005 13:27:29 -0000 1.3 +++ libnautilus-private/nautilus-view.c 20 Jul 2005 12:38:52 -0000 @@ -252,11 +252,12 @@ nautilus_view_get_zoom_level (NautilusVi void nautilus_view_pop_up_location_context_menu (NautilusView *view, - GdkEventButton *event) + GdkEventButton *event, + const char *location) { g_return_if_fail (NAUTILUS_IS_VIEW (view)); if (NAUTILUS_VIEW_GET_IFACE (view)->pop_up_location_context_menu != NULL) { - (* NAUTILUS_VIEW_GET_IFACE (view)->pop_up_location_context_menu) (view, event); + (* NAUTILUS_VIEW_GET_IFACE (view)->pop_up_location_context_menu) (view, event, location); } } Index: libnautilus-private/nautilus-view.h =================================================================== RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-view.h,v retrieving revision 1.3 diff -u -p -r1.3 nautilus-view.h --- libnautilus-private/nautilus-view.h 17 May 2005 13:27:29 -0000 1.3 +++ libnautilus-private/nautilus-view.h 20 Jul 2005 12:38:52 -0000 @@ -109,11 +109,14 @@ struct _NautilusViewIface /* Request popup of context menu referring to the open location. * This is triggered in spatial windows by right-clicking the location button, * in navigational windows by right-clicking the "Location:" label in the - * navigation bar. + * navigation bar or any of the buttons in the pathbar. + * The location parameter specifies the location this popup should be displayed for. + * If it is NULL, the currently displayed location should be used. * The view may display the popup synchronously, asynchronously * or not react to the popup request at all. */ void (* pop_up_location_context_menu) (NautilusView *view, - GdkEventButton *event); + GdkEventButton *event, + const char *location); /* Padding for future expansion */ void (*_reserved1) (void); @@ -150,7 +153,8 @@ gboolean nautilus_view_can_zoom gboolean nautilus_view_can_zoom_out (NautilusView *view); NautilusZoomLevel nautilus_view_get_zoom_level (NautilusView *view); void nautilus_view_pop_up_location_context_menu (NautilusView *view, - GdkEventButton *event); + GdkEventButton *event, + const char *location); G_END_DECLS Index: src/nautilus-location-bar.c =================================================================== RCS file: /cvs/gnome/nautilus/src/nautilus-location-bar.c,v retrieving revision 1.107 diff -u -p -r1.107 nautilus-location-bar.c --- src/nautilus-location-bar.c 2 Jun 2005 16:16:55 -0000 1.107 +++ src/nautilus-location-bar.c 20 Jul 2005 12:38:54 -0000 @@ -279,7 +279,7 @@ label_button_pressed_callback (GtkWidget return FALSE; } - nautilus_view_pop_up_location_context_menu (view, event); + nautilus_view_pop_up_location_context_menu (view, event, NULL); return FALSE; } Index: src/nautilus-navigation-window.c =================================================================== RCS file: /cvs/gnome/nautilus/src/nautilus-navigation-window.c,v retrieving revision 1.436 diff -u -p -r1.436 nautilus-navigation-window.c --- src/nautilus-navigation-window.c 13 Jul 2005 12:23:37 -0000 1.436 +++ src/nautilus-navigation-window.c 20 Jul 2005 12:38:55 -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, @@ -313,6 +318,59 @@ path_bar_location_changed_callback (GtkW } } +static gboolean +path_bar_button_pressed_callback (GtkWidget *widget, + GdkEventButton *event, + NautilusNavigationWindow *window) +{ + NautilusView *view; + char *location; + + if (event->button == 3) { + view = NAUTILUS_WINDOW (window)->content_view; + if (view != NULL) { + location = nautilus_path_bar_get_path_for_button ( + NAUTILUS_PATH_BAR (window->path_bar), widget); + nautilus_view_pop_up_location_context_menu ( + view, event, location); + return TRUE; + } + } + + + return FALSE; +} + +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 navigation_bar_location_changed_callback (GtkWidget *widget, @@ -1226,7 +1284,6 @@ nautilus_navigation_window_save_geometry g_free (geometry_string); } } - static void Index: src/nautilus-pathbar.c =================================================================== RCS file: /cvs/gnome/nautilus/src/nautilus-pathbar.c,v retrieving revision 1.2 diff -u -p -r1.2 nautilus-pathbar.c --- src/nautilus-pathbar.c 9 Jul 2005 21:28:27 -0000 1.2 +++ src/nautilus-pathbar.c 20 Jul 2005 12:38:57 -0000 @@ -42,6 +42,7 @@ enum { PATH_CLICKED, + PATH_SET, LAST_SIGNAL }; @@ -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); } @@ -1572,6 +1582,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; } @@ -1590,7 +1602,25 @@ nautilus_path_bar_set_path (NautilusPath return nautilus_path_bar_update_path (path_bar, file_path); } +char * +nautilus_path_bar_get_path_for_button (NautilusPathBar *path_bar, + GtkWidget *button) +{ + GList *list; + + g_return_val_if_fail (NAUTILUS_IS_PATH_BAR (path_bar), NULL); + g_return_val_if_fail (button != NULL, NULL); + + for (list = path_bar->button_list; list; list = list->next) { + ButtonData *button_data; + button_data = BUTTON_DATA (list->data); + if (button_data->button == button) { + return button_data->path; + } + } + return NULL; +} /** * _nautilus_path_bar_up: 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 20 Jul 2005 12:38:57 -0000 @@ -68,11 +68,15 @@ 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; gboolean nautilus_path_bar_set_path (NautilusPathBar *path_bar, const char *file_path); +char * nautilus_path_bar_get_path_for_button (NautilusPathBar *path_bar, + GtkWidget *button); void nautilus_path_bar_up (NautilusPathBar *path_bar); void nautilus_path_bar_down (NautilusPathBar *path_bar); Index: src/nautilus-spatial-window.c =================================================================== RCS file: /cvs/gnome/nautilus/src/nautilus-spatial-window.c,v retrieving revision 1.449 diff -u -p -r1.449 nautilus-spatial-window.c --- src/nautilus-spatial-window.c 13 Jul 2005 10:39:43 -0000 1.449 +++ src/nautilus-spatial-window.c 20 Jul 2005 12:38:57 -0000 @@ -498,7 +498,7 @@ location_button_pressed_callback (GtkWid { if (event->button == 3 && window->content_view != NULL) { - nautilus_view_pop_up_location_context_menu (window->content_view, event); + nautilus_view_pop_up_location_context_menu (window->content_view, event, NULL); } return FALSE; Index: src/file-manager/fm-actions.h =================================================================== RCS file: /cvs/gnome/nautilus/src/file-manager/fm-actions.h,v retrieving revision 1.8 diff -u -p -r1.8 fm-actions.h --- src/file-manager/fm-actions.h 1 Jul 2005 10:30:33 -0000 1.8 +++ src/file-manager/fm-actions.h 20 Jul 2005 12:38:58 -0000 @@ -34,6 +34,7 @@ #define FM_ACTION_PROPERTIES "Properties" #define FM_ACTION_PROPERTIES_ACCEL "PropertiesAccel" #define FM_ACTION_SELF_PROPERTIES "SelfProperties" +#define FM_ACTION_LOCATION_SELF_PROPERTIES "LocationSelfProperties" #define FM_ACTION_NO_TEMPLATES "No Templates" #define FM_ACTION_EMPTY_TRASH "Empty Trash" #define FM_ACTION_CUT "Cut" Index: src/file-manager/fm-directory-view.c =================================================================== RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v retrieving revision 1.701 diff -u -p -r1.701 fm-directory-view.c --- src/file-manager/fm-directory-view.c 11 Jul 2005 10:07:53 -0000 1.701 +++ src/file-manager/fm-directory-view.c 20 Jul 2005 12:39:04 -0000 @@ -174,6 +174,7 @@ struct FMDirectoryViewDetails NautilusWindowInfo *window; NautilusDirectory *model; NautilusFile *directory_as_file; + NautilusFile *location_popup_directory_as_file; GtkActionGroup *dir_action_group; guint dir_merge_id; @@ -391,6 +392,8 @@ static void action_location_trash_callba gpointer callback_data); static void action_location_delete_callback (GtkAction *action, gpointer callback_data); +static void action_location_self_properties_callback (GtkAction *action, + gpointer callback_data); EEL_CLASS_BOILERPLATE (FMDirectoryView, fm_directory_view, GTK_TYPE_SCROLLED_WINDOW) @@ -1791,6 +1794,7 @@ fm_directory_view_finalize (GObject *obj eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST, sort_directories_first_changed_callback, view); + nautilus_file_unref (view->details->location_popup_directory_as_file); g_hash_table_destroy (view->details->non_ready_files); g_free (view->details); @@ -5965,7 +5969,7 @@ action_location_open_alternate_callback view = FM_DIRECTORY_VIEW (callback_data); - file = view->details->directory_as_file; + file = view->details->location_popup_directory_as_file; g_return_if_fail (file != NULL); fm_directory_view_activate_file (view, @@ -5984,7 +5988,7 @@ action_location_cut_callback (GtkAction view = FM_DIRECTORY_VIEW (callback_data); - file = fm_directory_view_get_directory_as_file (view); + file = view->details->location_popup_directory_as_file; g_return_if_fail (file != NULL); files = g_list_append (NULL, file); @@ -6002,7 +6006,7 @@ action_location_copy_callback (GtkAction view = FM_DIRECTORY_VIEW (callback_data); - file = fm_directory_view_get_directory_as_file (view); + file = view->details->location_popup_directory_as_file; g_return_if_fail (file != NULL); files = g_list_append (NULL, file); @@ -6020,7 +6024,7 @@ action_location_trash_callback (GtkActio view = FM_DIRECTORY_VIEW (callback_data); - file = fm_directory_view_get_directory_as_file (view); + file = view->details->location_popup_directory_as_file; g_return_if_fail (file != NULL); files = g_list_append (NULL, file); @@ -6039,7 +6043,7 @@ action_location_delete_callback (GtkActi view = FM_DIRECTORY_VIEW (callback_data); - file = fm_directory_view_get_directory_as_file (view); + file = view->details->location_popup_directory_as_file; g_return_if_fail (file != NULL); file_uri = nautilus_file_get_uri (file); @@ -6052,6 +6056,28 @@ action_location_delete_callback (GtkActi } static void +action_location_self_properties_callback (GtkAction *action, + gpointer callback_data) +{ + FMDirectoryView *view; + NautilusFile *file; + GList *files; + + g_assert (FM_IS_DIRECTORY_VIEW (callback_data)); + + view = FM_DIRECTORY_VIEW (callback_data); + + file = view->details->location_popup_directory_as_file; + g_return_if_fail (file != NULL); + + files = g_list_append (NULL, file); + + fm_properties_window_present (files, GTK_WIDGET (view)); + + nautilus_file_list_free (files); +} + +static void fm_directory_view_init_show_hidden_files (FMDirectoryView *view) { NautilusWindowShowHiddenFilesMode mode; @@ -6110,7 +6136,7 @@ static const GtkActionEntry directory_vi G_CALLBACK (action_properties_callback) }, { "SelfProperties", GTK_STOCK_PROPERTIES, /* name, stock id */ N_("_Properties"), NULL, /* label, accelerator */ - N_("View or modify the properties of the open folder"), /* tooltip */ + N_("View or modify the properties of this folder"), /* tooltip */ G_CALLBACK (action_self_properties_callback) }, { "New Folder", NULL, /* name, stock id */ N_("Create _Folder"), "<control><shift>N", /* label, accelerator */ @@ -6252,6 +6278,10 @@ static const GtkActionEntry directory_vi N_("_Delete"), "", /* label, accelerator */ N_("Delete this folder, without moving to the Trash"), /* tooltip */ G_CALLBACK (action_location_delete_callback) }, + { FM_ACTION_LOCATION_SELF_PROPERTIES, GTK_STOCK_PROPERTIES, /* name, stock id */ + N_("_Properties"), NULL, /* label, accelerator */ + N_("View or modify the properties of this folder"), /* tooltip */ + G_CALLBACK (action_location_self_properties_callback) }, }; static const GtkToggleActionEntry directory_view_toggle_entries[] = { @@ -6569,7 +6599,8 @@ real_update_paste_menu (FMDirectoryView } static void -real_update_location_menu (FMDirectoryView *view) +real_update_location_menu (FMDirectoryView *view, + const char *location) { GtkAction *action; gboolean is_read_only; @@ -6589,20 +6620,36 @@ real_update_location_menu (FMDirectoryVi "label", label, NULL); - is_read_only = fm_directory_view_is_read_only (view); + nautilus_file_unref (view->details->location_popup_directory_as_file); + view->details->location_popup_directory_as_file = NULL; + + if (location == NULL) { + view->details->location_popup_directory_as_file = + nautilus_file_ref (view->details->directory_as_file); + } else { + view->details->location_popup_directory_as_file = + nautilus_file_get (location); + } + + if (view->details->location_popup_directory_as_file != NULL) { + is_read_only = !nautilus_file_can_write ( + view->details->location_popup_directory_as_file); + } else { + is_read_only = fm_directory_view_is_read_only (view); + } action = gtk_action_group_get_action (view->details->dir_action_group, FM_ACTION_LOCATION_CUT); gtk_action_set_sensitive (action, !is_read_only); - if (view->details->directory_as_file != NULL && - nautilus_file_is_in_trash (view->details->directory_as_file)) { + if (view->details->location_popup_directory_as_file != NULL && + nautilus_file_is_in_trash (view->details->location_popup_directory_as_file)) { label = _("_Delete from Trash"); - tip = _("Delete the open folder permanently"); + tip = _("Delete this folder permanently"); show_separate_delete_command = FALSE; } else { label = _("Mo_ve to Trash"); - tip = _("Move the open folder to the Trash"); + tip = _("Move this folder to the Trash"); show_separate_delete_command = show_delete_command_auto_value; } @@ -6622,7 +6669,7 @@ real_update_location_menu (FMDirectoryVi } /* we silently assume that fm_directory_view_supports_properties always returns the same value. - * Therefore, we don't update the sensitivity of FM_ACTION_SELF_PROPERTIES */ + * Therefore, we don't update the sensitivity of FM_ACTION_LOCATION_SELF_PROPERTIES */ } static void @@ -6821,6 +6868,13 @@ real_update_menus (FMDirectoryView *view !FM_IS_DESKTOP_ICON_VIEW (view)); action = gtk_action_group_get_action (view->details->dir_action_group, + FM_ACTION_LOCATION_SELF_PROPERTIES); + gtk_action_set_sensitive (action, + fm_directory_view_supports_properties (view)); + gtk_action_set_visible (action, + !FM_IS_DESKTOP_ICON_VIEW (view)); + + action = gtk_action_group_get_action (view->details->dir_action_group, FM_ACTION_EMPTY_TRASH); g_object_set (action, "label", _("E_mpty Trash"), @@ -6929,16 +6983,19 @@ fm_directory_view_pop_up_background_cont * Pop up a context menu appropriate to the view globally. * @view: FMDirectoryView of interest. * @event: GdkEventButton triggering the popup. + * @location: The location the popup-menu should be created for, + * or NULL for the currently displayed location. * **/ void fm_directory_view_pop_up_location_context_menu (FMDirectoryView *view, - GdkEventButton *event) + GdkEventButton *event, + const char *location) { g_assert (FM_IS_DIRECTORY_VIEW (view)); /* always update the menu before showing it. Shouldn't be too expensive. */ - real_update_location_menu (view); + real_update_location_menu (view, location); eel_pop_up_context_menu (create_popup_menu (view, FM_DIRECTORY_VIEW_POPUP_PATH_LOCATION), Index: src/file-manager/fm-directory-view.h =================================================================== RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.h,v retrieving revision 1.141 diff -u -p -r1.141 fm-directory-view.h --- src/file-manager/fm-directory-view.h 5 Jul 2005 12:23:35 -0000 1.141 +++ src/file-manager/fm-directory-view.h 20 Jul 2005 12:39:05 -0000 @@ -379,7 +379,8 @@ void fm_directory_view_po void fm_directory_view_pop_up_selection_context_menu (FMDirectoryView *view, GdkEventButton *event); void fm_directory_view_pop_up_location_context_menu (FMDirectoryView *view, - GdkEventButton *event); + GdkEventButton *event, + const char *location); void fm_directory_view_send_selection_change (FMDirectoryView *view); gboolean fm_directory_view_should_show_file (FMDirectoryView *view, NautilusFile *file); Index: src/file-manager/nautilus-directory-view-ui.xml =================================================================== RCS file: /cvs/gnome/nautilus/src/file-manager/nautilus-directory-view-ui.xml,v retrieving revision 1.76 diff -u -p -r1.76 nautilus-directory-view-ui.xml --- src/file-manager/nautilus-directory-view-ui.xml 6 Jul 2005 14:02:38 -0000 1.76 +++ src/file-manager/nautilus-directory-view-ui.xml 20 Jul 2005 12:39:08 -0000 @@ -165,6 +165,6 @@ <menuitem name="Delete" action="LocationDelete"/> </placeholder> <separator/> - <menuitem name="Properties" action="SelfProperties"/> + <menuitem name="LocationSelfProperties" action="LocationSelfProperties"/> </popup> </ui>
Attachment:
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil