Re: [PATCH] add location button context menu



Am Montag, den 16.05.2005, 15:49 +0200 schrieb Alexander Larsson:
> On Fri, 2005-04-29 at 22:06 +0200, Christian Neumair wrote:
> > This is the second version of a patch I've submitted about 2.5 months
> > ago to nautilus-list [1]. There were no direct followups, but I was now
> > asked to update the patch, though, so it looks like people are
> > interested in it.
> > The new version only has the Cut, Copy, Paste, Trash + Delete and
> > Properties items in the context menu, but - in contrast to the last
> > version - doesn't make nautilus spit out g_warnings. Also, I've added a
> > context menu to the navigation view "Location:" label.
> > Comments, suggestions?
> > 
> > [1]
> > http://mail.gnome.org/archives/nautilus-list/2005-February/msg00040.html
> 
> I like this idea. Is there a later version of this patch fixing the
> various bugs pointed out somewhere?

Here comes a new version. It has grown somewhat large. It adds some
context menu code to the NautilusView interface so that other views can
react appropriately as well and ports the directory view-related code to
that semantics. Also note that I've added a new item on top of the
context menu for opening the currently open folder in a new nav window.
Are you OK with the popup menu code being potentially async or should we
force to return a gboolean? Currently, we just return "FALSE" for the
button_press_event handlers, since we can't know whether the popup
succeeded, but who cares? :)
I've adapted to the old
fm_directory_view_pop_up_background/selection_context_menu semantics
here.

-- 
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.2
diff -u -r1.2 nautilus-view.c
--- libnautilus-private/nautilus-view.c	22 Nov 2004 15:24:36 -0000	1.2
+++ libnautilus-private/nautilus-view.c	17 May 2005 08:56:32 -0000
@@ -249,3 +249,15 @@
 	
 	return (* NAUTILUS_VIEW_GET_IFACE (view)->get_zoom_level) (view);
 }
+
+void
+nautilus_view_popup_menu (NautilusView         *view,
+			  GdkEventButton       *event,
+			  NautilusViewMenuType  type)
+{
+	g_return_if_fail (NAUTILUS_IS_VIEW (view));
+
+	if (NAUTILUS_VIEW_GET_IFACE (view)->popup_menu != NULL) {
+		(* NAUTILUS_VIEW_GET_IFACE (view)->popup_menu) (view, event, type);
+	}
+}
Index: libnautilus-private/nautilus-view.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-view.h,v
retrieving revision 1.2
diff -u -r1.2 nautilus-view.h
--- libnautilus-private/nautilus-view.h	22 Nov 2004 15:24:36 -0000	1.2
+++ libnautilus-private/nautilus-view.h	17 May 2005 08:56:32 -0000
@@ -42,6 +42,18 @@
 typedef struct _NautilusView NautilusView; /* dummy typedef */
 typedef struct _NautilusViewIface NautilusViewIface;
 
+typedef enum {
+	/* context menu for the selection */
+	NAUTILUS_VIEW_MENU_SELECTION,
+	/* context menu when clicking the background */
+	NAUTILUS_VIEW_MENU_BACKGROUND,
+	/* additional 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. */
+	NAUTILUS_VIEW_MENU_LOCATION
+} NautilusViewMenuType;
+
 struct _NautilusViewIface 
 {
 	GTypeInterface g_iface;
@@ -105,7 +117,13 @@
         void           (* restore_default_zoom_level) (NautilusView          *view);
         gboolean       (* can_zoom_in)	 	  (NautilusView          *view);
         gboolean       (* can_zoom_out)	 	  (NautilusView          *view);
-	
+
+	/* Request popup of popup menus. The view may display the popup synchronously, asynchronously
+	 * or not react to the popup request at all. */
+	void           (* popup_menu)             (NautilusView         *view,
+						   GdkEventButton       *event,
+						   NautilusViewMenuType  type);
+
 	/* Padding for future expansion */
 	void (*_reserved1) (void);
 	void (*_reserved2) (void);
@@ -114,7 +132,6 @@
 	void (*_reserved5) (void);
 	void (*_reserved6) (void);
 	void (*_reserved7) (void);
-	void (*_reserved8) (void);
 };
 
 GType             nautilus_view_get_type             (void);
@@ -141,6 +158,9 @@
 gboolean          nautilus_view_can_zoom_in                (NautilusView      *view);
 gboolean          nautilus_view_can_zoom_out               (NautilusView      *view);
 NautilusZoomLevel nautilus_view_get_zoom_level             (NautilusView      *view);
+void              nautilus_view_popup_menu                 (NautilusView         *view,
+							    GdkEventButton       *event,
+							    NautilusViewMenuType  type);
 
 G_END_DECLS
 
Index: src/nautilus-location-bar.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-location-bar.c,v
retrieving revision 1.105
diff -u -r1.105 nautilus-location-bar.c
--- src/nautilus-location-bar.c	12 May 2005 14:55:13 -0000	1.105
+++ src/nautilus-location-bar.c	17 May 2005 08:56:32 -0000
@@ -258,6 +258,32 @@
 	gtk_widget_set_size_request (widget, width, -1);
 }
 
+static gboolean
+label_button_pressed_callback (GtkWidget             *widget,
+			       GdkEventButton        *event)
+{
+	NautilusNavigationWindow *window;
+	NautilusView             *view;
+
+	if (event->button != 3) {
+		return FALSE;
+	}
+
+	window = nautilus_location_bar_get_window (widget->parent);
+
+	view = NAUTILUS_WINDOW (window)->content_view;
+	/* only pop-up if the URI in the entry matches the displayed location */
+	if (view == NULL ||
+	    g_utf8_collate (gtk_label_get_text (GTK_LABEL (widget)), LOCATION_LABEL)) {
+		return FALSE;
+	}
+
+	nautilus_view_popup_menu (view, event, NAUTILUS_VIEW_MENU_LOCATION);
+
+	return FALSE;
+}
+
+
 static int
 get_editable_number_of_chars (GtkEditable *editable)
 {
@@ -401,6 +427,11 @@
 	eel_accessibility_set_up_label_widget_relation (label, entry);
 
 	gtk_container_add (GTK_CONTAINER (bar), hbox);
+
+
+	/* Label context menu */
+	g_signal_connect (event_box, "button-press-event",
+			  G_CALLBACK (label_button_pressed_callback), NULL);
 
 	/* Drag source */
 	gtk_drag_source_set (GTK_WIDGET (event_box), 
Index: src/nautilus-spatial-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-spatial-window.c,v
retrieving revision 1.439
diff -u -r1.439 nautilus-spatial-window.c
--- src/nautilus-spatial-window.c	17 Apr 2005 16:55:23 -0000	1.439
+++ src/nautilus-spatial-window.c	17 May 2005 08:56:33 -0000
@@ -488,6 +488,22 @@
 	*push_in = TRUE;
 }
 
+static gboolean
+location_button_pressed_callback (GtkWidget      *widget,
+				  GdkEventButton *event,
+				  NautilusWindow *window)
+{
+	if (event->button == 3 &&
+	    window->content_view != NULL) {
+		nautilus_view_popup_menu (window->content_view,
+					  event,
+					  NAUTILUS_VIEW_MENU_LOCATION);
+	}
+
+	return FALSE;
+}
+
+
 static void
 location_button_clicked_callback (GtkWidget *widget, NautilusSpatialWindow *window)
 {
@@ -697,6 +713,10 @@
 	gtk_widget_show (window->details->content_box);
 
 	window->details->location_button = gtk_button_new ();
+	g_signal_connect (window->details->location_button,
+			  "button-press-event",
+			  G_CALLBACK (location_button_pressed_callback),
+			  window);
 	gtk_button_set_relief (GTK_BUTTON (window->details->location_button),
 			       GTK_RELIEF_NORMAL);
 	rc_style = gtk_widget_get_modifier_style (window->details->location_button);
@@ -706,7 +726,6 @@
 				 rc_style);
 
 	gtk_widget_show (window->details->location_button);
-
 	hbox = gtk_hbox_new (FALSE, 3);
 	gtk_container_add (GTK_CONTAINER (window->details->location_button), 
 			   hbox);
Index: src/file-manager/fm-actions.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-actions.h,v
retrieving revision 1.6
diff -u -r1.6 fm-actions.h
--- src/file-manager/fm-actions.h	16 May 2005 16:25:03 -0000	1.6
+++ src/file-manager/fm-actions.h	17 May 2005 08:56:33 -0000
@@ -27,6 +27,7 @@
 
 #define FM_ACTION_OPEN "Open"
 #define FM_ACTION_OPEN_ALTERNATE "OpenAlternate"
+#define FM_ACTION_LOCATION_OPEN_ALTERNATE "LocationOpenAlternate"
 #define FM_ACTION_OTHER_APPLICATION1 "OtherApplication1"
 #define FM_ACTION_OTHER_APPLICATION2 "OtherApplication2"
 #define FM_ACTION_NEW_FOLDER "New Folder"
@@ -36,9 +37,12 @@
 #define FM_ACTION_NO_TEMPLATES "No Templates"
 #define FM_ACTION_EMPTY_TRASH "Empty Trash"
 #define FM_ACTION_CUT "Cut"
+#define FM_ACTION_LOCATION_CUT "LocationCut"
 #define FM_ACTION_COPY "Copy"
+#define FM_ACTION_LOCATION_COPY "LocationCopy"
 #define FM_ACTION_PASTE "Paste"
 #define FM_ACTION_PASTE_FILES_INTO "Paste Files Into"
+#define FM_ACTION_LOCATION_PASTE "LocationPaste"
 #define FM_ACTION_NEW_LAUNCHER "New Launcher"
 #define FM_ACTION_RENAME "Rename"
 #define FM_ACTION_DUPLICATE "Duplicate"
@@ -46,7 +50,9 @@
 #define FM_ACTION_SELECT_ALL "Select All"
 #define FM_ACTION_SELECT_PATTERN "Select Pattern"
 #define FM_ACTION_TRASH "Trash"
+#define FM_ACTION_LOCATION_TRASH "LocationTrash"
 #define FM_ACTION_DELETE "Delete"
+#define FM_ACTION_LOCATION_DELETE "LocationDelete"
 #define FM_ACTION_SHOW_HIDDEN_FILES "Show Hidden Files"
 #define FM_ACTION_CONNECT_TO_SERVER_LINK "Connect To Server Link"
 #define FM_ACTION_MOUNT_VOLUME "Mount Volume"
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.673
diff -u -r1.673 fm-directory-view.c
--- src/file-manager/fm-directory-view.c	16 May 2005 16:25:03 -0000	1.673
+++ src/file-manager/fm-directory-view.c	17 May 2005 08:56:36 -0000
@@ -125,6 +125,8 @@
 #define FM_DIRECTORY_VIEW_POPUP_PATH_BACKGROUND_SCRIPTS_PLACEHOLDER	"/background/Before Zoom Items/New Object Items/Scripts/Scripts Placeholder"
 #define FM_DIRECTORY_VIEW_POPUP_PATH_BACKGROUND_NEW_DOCUMENTS_PLACEHOLDER "/background/Before Zoom Items/New Object Items/New Documents/New Documents Placeholder"
 
+#define FM_DIRECTORY_VIEW_POPUP_PATH_LOCATION				"/location"
+
 #define MAX_MENU_LEVELS 5
 
 enum {
@@ -370,6 +372,22 @@
 static void action_unmount_volume_callback         (GtkAction *action,
 						    gpointer   data);
 
+/* location popup-related actions */
+
+static void action_location_open_alternate_callback (GtkAction *action,
+						     gpointer   callback_data);
+
+static void action_location_cut_callback            (GtkAction *action,
+						     gpointer   callback_data);
+static void action_location_copy_callback           (GtkAction *action,
+						     gpointer   callback_data);
+/* paste is handled by action_paste_files_callback */
+
+static void action_location_trash_callback          (GtkAction *action,
+						     gpointer   callback_data);
+static void action_location_delete_callback         (GtkAction *action,
+						     gpointer   callback_data);
+
 EEL_CLASS_BOILERPLATE (FMDirectoryView, fm_directory_view, GTK_TYPE_SCROLLED_WINDOW)
 
 EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, add_file)
@@ -1578,6 +1596,8 @@
         iface->can_zoom_in = (gpointer)fm_directory_view_can_zoom_in;
         iface->can_zoom_out = (gpointer)fm_directory_view_can_zoom_out;
 	iface->get_zoom_level = (gpointer)fm_directory_view_get_zoom_level;
+
+	iface->popup_menu = (gpointer)fm_directory_view_popup_menu;
 }
 
 static void
@@ -2909,6 +2929,7 @@
 		 can_zoom_out, (view));
 }
 
+
 GtkWidget *
 fm_directory_view_get_background_widget (FMDirectoryView *view)
 {
@@ -5260,15 +5281,13 @@
 	
 static void
 copy_or_cut_files (FMDirectoryView *view,
-		   gboolean cut)
+		   GList           *clipboard_contents,
+		   gboolean         cut)
 {
 	int count;
 	char *status_string, *name;
-	GList *clipboard_contents;
 	ClipboardInfo *info;
 	
-	clipboard_contents = fm_directory_view_get_selection (view);
-
 	info = g_new0 (ClipboardInfo, 1);
 	info->file_uris = convert_file_list_to_uri_list (clipboard_contents);
 	info->cut = cut;
@@ -5311,8 +5330,6 @@
 		}
 	}
 
-	nautilus_file_list_free (clipboard_contents);
-	
 	nautilus_window_info_set_status (view->details->window,
 					 status_string);
 	g_free (status_string);
@@ -5322,14 +5339,28 @@
 action_copy_files_callback (GtkAction *action,
 			    gpointer callback_data)
 {
-	copy_or_cut_files (callback_data, FALSE);
+	FMDirectoryView *view;
+	GList *selection;
+
+	view = FM_DIRECTORY_VIEW (callback_data);
+
+	selection = fm_directory_view_get_selection (view);
+	copy_or_cut_files (view, selection, FALSE);
+	nautilus_file_list_free (selection);
 }
 
 static void
 action_cut_files_callback (GtkAction *action,
 			   gpointer callback_data)
 {
-	copy_or_cut_files (callback_data, TRUE);
+	FMDirectoryView *view;
+	GList *selection;
+
+	view = FM_DIRECTORY_VIEW (callback_data);
+
+	selection = fm_directory_view_get_selection (view);
+	copy_or_cut_files (view, selection, TRUE);
+	nautilus_file_list_free (selection);
 }
 
 static GList *
@@ -5761,6 +5792,101 @@
 }
 
 static void
+action_location_open_alternate_callback (GtkAction *action,
+					 gpointer   callback_data)
+{
+	FMDirectoryView *view;
+	NautilusFile *file;
+
+	view = FM_DIRECTORY_VIEW (callback_data);
+
+	file = view->details->directory_as_file;
+	g_return_if_fail (file != NULL);
+
+	fm_directory_view_activate_file (view,
+					 file,
+					 NAUTILUS_WINDOW_OPEN_IN_NAVIGATION,
+					 0);
+}
+
+static void
+action_location_cut_callback (GtkAction *action,
+			      gpointer   callback_data)
+{
+	FMDirectoryView *view;
+	NautilusFile *file;
+	GList *files;
+
+	view = FM_DIRECTORY_VIEW (callback_data);
+
+	file = fm_directory_view_get_directory_as_file (view);
+	g_return_if_fail (file != NULL);
+
+	files = g_list_append (NULL, file);
+	copy_or_cut_files (view, files, TRUE);
+	nautilus_file_list_free (files);
+}
+
+static void
+action_location_copy_callback (GtkAction *action,
+			       gpointer   callback_data)
+{
+	FMDirectoryView *view;
+	NautilusFile *file;
+	GList *files;
+
+	view = FM_DIRECTORY_VIEW (callback_data);
+
+	file = fm_directory_view_get_directory_as_file (view);
+	g_return_if_fail (file != NULL);
+
+	files = g_list_append (NULL, file);
+	copy_or_cut_files (view, files, FALSE);
+	nautilus_file_list_free (files);
+}
+
+static void
+action_location_trash_callback (GtkAction *action,
+				gpointer   callback_data)
+{
+	FMDirectoryView *view;
+	NautilusFile *file;
+	GList *files;
+
+	view = FM_DIRECTORY_VIEW (callback_data);
+
+	file = fm_directory_view_get_directory_as_file (view);
+	g_return_if_fail (file != NULL);
+
+	files = g_list_append (NULL, file);
+	trash_or_delete_files (view, files);
+	g_list_free (files);
+}
+
+static void
+action_location_delete_callback (GtkAction *action,
+				 gpointer   callback_data)
+{
+	FMDirectoryView *view;
+	NautilusFile *file;
+	char *file_uri;
+	GList *files;
+
+	view = FM_DIRECTORY_VIEW (callback_data);
+
+	file = fm_directory_view_get_directory_as_file (view);
+	g_return_if_fail (file != NULL);
+
+	file_uri = nautilus_file_get_uri (file);
+
+	files = g_list_append (NULL, file_uri);
+	nautilus_file_operations_delete (files, GTK_WIDGET (view));
+
+	g_free (file_uri);
+	g_list_free (files);
+}
+
+static void
 fm_directory_view_init_show_hidden_files (FMDirectoryView *view)
 {
 	NautilusWindowShowHiddenFilesMode mode;
@@ -5933,6 +6059,36 @@
     N_("Open File and Close window"), "<alt><shift>Down",                /* label, accelerator */
     NULL,                   /* tooltip */ 
     G_CALLBACK (action_open_close_parent_callback) },
+
+  /* Location-specific actions */
+  { FM_ACTION_LOCATION_OPEN_ALTERNATE, NULL,                  /* name, stock id */
+    N_("Open in Navigation Window"), "",                /* label, accelerator */
+    N_("Open the open folder in a navigation window"),                   /* tooltip */ 
+    G_CALLBACK (action_location_open_alternate_callback) },
+
+  { FM_ACTION_LOCATION_CUT, GTK_STOCK_CUT,                  /* name, stock id */
+    NULL, "",                /* label, accelerator */
+    N_("Prepare the open folder to be moved with a Paste Files command"),                   /* tooltip */ 
+    G_CALLBACK (action_location_cut_callback) },
+  { FM_ACTION_LOCATION_COPY, GTK_STOCK_COPY,                  /* name, stock id */
+    NULL, "",                /* label, accelerator */
+    N_("Prepare the open folder to be copied with a Paste Files command"),                   /* tooltip */ 
+    G_CALLBACK (action_location_copy_callback) },
+  /* We make accelerator "" instead of null here to not inherit the stock
+     accelerator for paste */
+  { "Paste", GTK_STOCK_PASTE,                  /* name, stock id */
+    NULL, "",                /* label, accelerator */
+    N_("Move or copy files previously selected by a Cut Files or Copy Files command into the open folder"),                   /* tooltip */ 
+    G_CALLBACK (action_paste_files_callback) },
+
+  { FM_ACTION_LOCATION_TRASH, GTK_STOCK_DELETE,                  /* name, stock id */
+    N_("Mo_ve to Trash"), "",                /* label, accelerator */
+    N_("Move the open folder to the Trash"),                   /* tooltip */ 
+    G_CALLBACK (action_location_trash_callback) },
+  { FM_ACTION_LOCATION_DELETE, GTK_STOCK_DELETE,                  /* name, stock id */
+    N_("_Delete"), "",                /* label, accelerator */
+    N_("Delete the open folder, without moving to the Trash"),                   /* tooltip */ 
+    G_CALLBACK (action_location_delete_callback) },
 };
 
 static GtkToggleActionEntry directory_view_toggle_entries[] = {
@@ -6207,7 +6363,7 @@
 	action = gtk_action_group_get_action (view->details->dir_action_group,
 					      FM_ACTION_PASTE);
 	gtk_action_set_sensitive (action, !is_read_only);
-	
+
 	action = gtk_action_group_get_action (view->details->dir_action_group,
 					      FM_ACTION_PASTE_FILES_INTO);
 	gtk_action_set_visible (action, can_paste_files_into);
@@ -6222,6 +6378,65 @@
 	}
 }
 
+/* updates the location button context menu,
+ * except the paste menu item, which is handled
+ * by real_update_paste_menu */
+static void
+real_update_location_menu (FMDirectoryView *view)
+{
+	GtkAction *action;
+	gboolean is_read_only;
+	gboolean show_separate_delete_command;
+	char *label;
+	char *tip;
+
+	if (nautilus_window_info_get_window_type (view->details->window) == NAUTILUS_WINDOW_NAVIGATION) {
+		label = _("Open in New Window");
+	} else {
+		label = _("_Browse Folder");
+	}
+	action = gtk_action_group_get_action (view->details->dir_action_group,
+					      FM_ACTION_LOCATION_OPEN_ALTERNATE);
+	g_object_set (action,
+		      "label", label,
+		      NULL);
+
+	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)) {
+		label = _("_Delete from Trash");
+		tip = _("Delete all selected items permanently");
+		show_separate_delete_command = FALSE;
+	} else {
+		label = _("Mo_ve to Trash");
+		tip = _("Move each selected item to the Trash");
+		show_separate_delete_command = show_delete_command_auto_value;
+	}
+
+	action = gtk_action_group_get_action (view->details->dir_action_group,
+					      FM_ACTION_LOCATION_TRASH);
+	g_object_set (action,
+		      "label", label,
+		      "tooltip", tip,
+		      NULL);
+	gtk_action_set_sensitive (action, !is_read_only);
+
+	action = gtk_action_group_get_action (view->details->dir_action_group,
+					      FM_ACTION_LOCATION_DELETE);
+	gtk_action_set_visible (action, show_separate_delete_command);
+	if (show_separate_delete_command) {
+		gtk_action_set_sensitive (action, !is_read_only);
+	}
+
+	/* we silently assume that fm_directory_view_supports_properties always returns the same value
+	 * => don't update sensitivity of FM_ACTION_SELF_PROPERTIES */
+}
+
 static void
 clipboard_changed_callback (NautilusClipboardMonitor *monitor, FMDirectoryView *view)
 {
@@ -6485,9 +6700,9 @@
  * Return value: NautilusDirectory for this view.
  * 
  **/
-void 
+static void 
 fm_directory_view_pop_up_selection_context_menu  (FMDirectoryView *view, 
-						  GdkEventButton *event)
+						  GdkEventButton  *event)
 {
 	g_assert (FM_IS_DIRECTORY_VIEW (view));
 
@@ -6512,9 +6727,9 @@
  * Return value: NautilusDirectory for this view.
  * 
  **/
-void 
+static void 
 fm_directory_view_pop_up_background_context_menu (FMDirectoryView *view, 
-						  GdkEventButton *event)
+						  GdkEventButton  *event)
 {
 	g_assert (FM_IS_DIRECTORY_VIEW (view));
 
@@ -6528,6 +6743,62 @@
 				      EEL_DEFAULT_POPUP_MENU_DISPLACEMENT,
 				      EEL_DEFAULT_POPUP_MENU_DISPLACEMENT,
 				      event);
+}
+
+
+/**
+ * fm_directory_view_pop_up_location_context_menu
+ *
+ * Pop up a context menu appropriate to the view globally.
+ * @view: FMDirectoryView of interest.
+ * @event: GdkEventButton triggering the popup.
+ *
+ **/
+static void 
+fm_directory_view_pop_up_location_context_menu (FMDirectoryView *view, 
+						GdkEventButton  *event)
+{
+	g_assert (FM_IS_DIRECTORY_VIEW (view));
+
+	/* always update the menu before showing it. Shouldn't be too expensive. */
+	real_update_location_menu (view);
+
+	eel_pop_up_context_menu (create_popup_menu 
+				      (view, FM_DIRECTORY_VIEW_POPUP_PATH_LOCATION),
+				      EEL_DEFAULT_POPUP_MENU_DISPLACEMENT,
+				      EEL_DEFAULT_POPUP_MENU_DISPLACEMENT,
+				      event);
+}
+
+/*
+ * Pop up a context menu appropriate to the view globally.
+ * @view: FMDirectoryView of interest.
+ * @event: GdkEventButton triggering the popup.
+ * @type: the type of the context menu to be popped up.
+ * */
+void
+fm_directory_view_popup_menu (FMDirectoryView      *view,
+			      GdkEventButton       *event,
+			      NautilusViewMenuType  type)
+{
+	g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
+
+	switch (type) {
+		case NAUTILUS_VIEW_MENU_SELECTION:
+			fm_directory_view_pop_up_selection_context_menu (view, event);
+			break;
+
+		case NAUTILUS_VIEW_MENU_BACKGROUND:
+			fm_directory_view_pop_up_background_context_menu (view, event);
+			break;
+
+		case NAUTILUS_VIEW_MENU_LOCATION:
+			fm_directory_view_pop_up_location_context_menu (view, event);
+			break;
+
+		default:
+			g_assert_not_reached ();
+	}
 }
 
 static void
Index: src/file-manager/fm-directory-view.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.h,v
retrieving revision 1.136
diff -u -r1.136 fm-directory-view.h
--- src/file-manager/fm-directory-view.h	3 May 2005 01:00:50 -0000	1.136
+++ src/file-manager/fm-directory-view.h	17 May 2005 08:56:36 -0000
@@ -360,10 +360,10 @@
 GtkWindow	   *fm_directory_view_get_containing_window	       (FMDirectoryView  *view);
 NautilusFile       *fm_directory_view_get_directory_as_file            (FMDirectoryView  *view);
 EelBackground *     fm_directory_view_get_background                   (FMDirectoryView  *view);
-void                fm_directory_view_pop_up_background_context_menu   (FMDirectoryView  *view,
-									GdkEventButton   *event);
-void                fm_directory_view_pop_up_selection_context_menu    (FMDirectoryView  *view,
-									GdkEventButton   *event); 
+void                fm_directory_view_popup_menu                       (FMDirectoryView      *view,
+									GdkEventButton       *event,
+									NautilusViewMenuType  type);
+
 void                fm_directory_view_send_selection_change            (FMDirectoryView *view);
 gboolean            fm_directory_view_should_show_file                 (FMDirectoryView  *view,
 									NautilusFile     *file);
Index: src/file-manager/fm-icon-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-icon-view.c,v
retrieving revision 1.306
diff -u -r1.306 fm-icon-view.c
--- src/file-manager/fm-icon-view.c	19 Apr 2005 12:01:17 -0000	1.306
+++ src/file-manager/fm-icon-view.c	17 May 2005 08:56:37 -0000
@@ -2031,8 +2031,9 @@
 	g_assert (NAUTILUS_IS_ICON_CONTAINER (container));
 	g_assert (FM_IS_ICON_VIEW (icon_view));
 
-	fm_directory_view_pop_up_selection_context_menu 
-		(FM_DIRECTORY_VIEW (icon_view), event);
+	fm_directory_view_popup_menu (FM_DIRECTORY_VIEW (icon_view),
+				      event,
+				      NAUTILUS_VIEW_MENU_SELECTION);
 }
 
 static void
@@ -2043,8 +2044,9 @@
 	g_assert (NAUTILUS_IS_ICON_CONTAINER (container));
 	g_assert (FM_IS_ICON_VIEW (icon_view));
 
-	fm_directory_view_pop_up_background_context_menu 
-		(FM_DIRECTORY_VIEW (icon_view), event);
+	fm_directory_view_popup_menu (FM_DIRECTORY_VIEW (icon_view),
+				      event,
+				      NAUTILUS_VIEW_MENU_BACKGROUND);
 }
 
 static gboolean
Index: src/file-manager/fm-list-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-view.c,v
retrieving revision 1.242
diff -u -r1.242 fm-list-view.c
--- src/file-manager/fm-list-view.c	3 May 2005 01:00:50 -0000	1.242
+++ src/file-manager/fm-list-view.c	17 May 2005 08:56:38 -0000
@@ -438,9 +438,13 @@
 do_popup_menu (GtkWidget *widget, FMListView *view, GdkEventButton *event)
 {
  	if (tree_view_has_selection (GTK_TREE_VIEW (widget))) {
-		fm_directory_view_pop_up_selection_context_menu (FM_DIRECTORY_VIEW (view), event);
+		fm_directory_view_popup_menu (FM_DIRECTORY_VIEW (view),
+					      event,
+					      NAUTILUS_VIEW_MENU_SELECTION);
 	} else {
-                fm_directory_view_pop_up_background_context_menu (FM_DIRECTORY_VIEW (view), event);
+		fm_directory_view_popup_menu (FM_DIRECTORY_VIEW (view),
+					      event,
+					      NAUTILUS_VIEW_MENU_BACKGROUND);
 	}
 }
 
@@ -754,7 +758,9 @@
 	switch (event->keyval) {
 	case GDK_F10:
 		if (event->state & GDK_CONTROL_MASK) {
-			fm_directory_view_pop_up_background_context_menu (view, &button_event);
+			fm_directory_view_popup_menu (view,
+						      &button_event,
+						      NAUTILUS_VIEW_MENU_BACKGROUND);
 		}
 		break;
 	case GDK_space:
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.73
diff -u -r1.73 nautilus-directory-view-ui.xml
--- src/file-manager/nautilus-directory-view-ui.xml	16 May 2005 16:25:03 -0000	1.73
+++ src/file-manager/nautilus-directory-view-ui.xml	17 May 2005 08:56:46 -0000
@@ -149,4 +149,22 @@
         </placeholder>
         <menuitem name="Connect To Server Link" action="Connect To Server Link"/>
 </popup>
+<popup name="location">
+	<placeholder name="Open Placeholder">
+		<menuitem name="LocationOpenAlternate" action="LocationOpenAlternate"/>
+	</placeholder>
+	<separator/>
+	<placeholder name="Clipboard Actions">
+		<menuitem name="Cut" action="LocationCut"/>
+		<menuitem name="Copy" action="LocationCopy"/>
+		<menuitem name="Paste" action="Paste"/>
+	</placeholder>
+	<separator/>
+	<placeholder name="Dangerous File Actions">
+		<menuitem name="Trash" action="LocationTrash"/>
+		<menuitem name="Delete" action="LocationDelete"/>
+	</placeholder>
+	<separator/>
+	<menuitem name="Properties" action="SelfProperties"/>
+</popup>
 </ui>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]