[nautilus] view: cleanup "Open in new Tab/Window" items when using separate windows



commit 2cd9c4b84059f3e00ed6222ab43c34a974e2c550
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Mar 21 12:17:08 2011 -0400

    view: cleanup "Open in new Tab/Window" items when using separate windows
    
    We were displaying a lot of useless entries in the menus in such case.

 src/nautilus-actions.h             |    2 -
 src/nautilus-directory-view-ui.xml |    2 -
 src/nautilus-view.c                |  171 ++++++++----------------------------
 3 files changed, 37 insertions(+), 138 deletions(-)
---
diff --git a/src/nautilus-actions.h b/src/nautilus-actions.h
index e00f395..dfb3c60 100644
--- a/src/nautilus-actions.h
+++ b/src/nautilus-actions.h
@@ -56,10 +56,8 @@
 #define NAUTILUS_ACTION_OPEN "Open"
 #define NAUTILUS_ACTION_OPEN_ALTERNATE "OpenAlternate"
 #define NAUTILUS_ACTION_OPEN_IN_NEW_TAB "OpenInNewTab"
-#define NAUTILUS_ACTION_OPEN_FOLDER_WINDOW "OpenFolderWindow"
 #define NAUTILUS_ACTION_LOCATION_OPEN_ALTERNATE "LocationOpenAlternate"
 #define NAUTILUS_ACTION_LOCATION_OPEN_IN_NEW_TAB "LocationOpenInNewTab"
-#define NAUTILUS_ACTION_LOCATION_OPEN_FOLDER_WINDOW "LocationOpenFolderWindow"
 #define NAUTILUS_ACTION_OTHER_APPLICATION1 "OtherApplication1"
 #define NAUTILUS_ACTION_OTHER_APPLICATION2 "OtherApplication2"
 #define NAUTILUS_ACTION_NEW_FOLDER "New Folder"
diff --git a/src/nautilus-directory-view-ui.xml b/src/nautilus-directory-view-ui.xml
index e45ef60..9ed18bf 100644
--- a/src/nautilus-directory-view-ui.xml
+++ b/src/nautilus-directory-view-ui.xml
@@ -134,7 +134,6 @@
 		<menuitem name="Open" action="Open"/>
 		<menuitem name="OpenInNewTab" action="OpenInNewTab"/>
 		<menuitem name="OpenAlternate" action="OpenAlternate"/>
-		<menuitem name="OpenFolderWindow" action="OpenFolderWindow"/>
 		<separator name="applications separator"/>
 		<placeholder name="Applications Placeholder"/>
 		<menu action="Open With">
@@ -200,7 +199,6 @@
 	<placeholder name="Open Placeholder">
 		<menuitem name="LocationOpenInNewTab" action="LocationOpenInNewTab"/>
 		<menuitem name="LocationOpenAlternate" action="LocationOpenAlternate"/>
-		<menuitem name="LocationOpenFolderWindow" action="LocationOpenFolderWindow"/>
 	</placeholder>
 	<separator name="Location After Open Separator"/>
 	<placeholder name="Clipboard Actions">
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index 3fdf9e5..d228f1e 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -282,8 +282,6 @@ static void     clipboard_changed_callback                     (NautilusClipboar
 								NautilusView      *view);
 static void     open_one_in_new_window                         (gpointer              data,
 								gpointer              callback_data);
-static void     open_one_in_folder_window                      (gpointer              data,
-								gpointer              callback_data);
 static void     schedule_update_menus                          (NautilusView      *view);
 static void     schedule_update_menus_callback                 (gpointer              callback_data);
 static void     remove_update_menus_timeout_callback           (NautilusView      *view);
@@ -1226,26 +1224,6 @@ action_open_new_tab_callback (GtkAction *action,
 }
 
 static void
-action_open_folder_window_callback (GtkAction *action,
-				    gpointer callback_data)
-{
-	NautilusView *view;
-	GList *selection;
-	GtkWindow *window;
-
-	view = NAUTILUS_VIEW (callback_data);
-	selection = nautilus_view_get_selection (view);
-
-	window = nautilus_view_get_containing_window (view);
-
-	if (nautilus_view_confirm_multiple (window, g_list_length (selection), FALSE)) {
-		g_list_foreach (selection, open_one_in_folder_window, view);
-	}
-
-	nautilus_file_list_free (selection);
-}
-
-static void
 app_chooser_dialog_response_cb (GtkDialog *dialog,
 				gint response_id,
 				gpointer user_data)
@@ -4184,17 +4162,6 @@ open_one_in_new_window (gpointer data, gpointer callback_data)
 				     NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW);
 }
 
-static void
-open_one_in_folder_window (gpointer data, gpointer callback_data)
-{
-	g_assert (NAUTILUS_IS_FILE (data));
-	g_assert (NAUTILUS_IS_VIEW (callback_data));
-
-	nautilus_view_activate_file (NAUTILUS_VIEW (callback_data),
-				     NAUTILUS_FILE (data),
-				     0);
-}
-
 NautilusFile *
 nautilus_view_get_directory_as_file (NautilusView *view)
 {
@@ -6828,23 +6795,6 @@ action_location_open_in_new_tab_callback (GtkAction *action,
 }
 
 static void
-action_location_open_folder_window_callback (GtkAction *action,
-					     gpointer   callback_data)
-{
-	NautilusView *view;
-	NautilusFile *file;
-
-	view = NAUTILUS_VIEW (callback_data);
-
-	file = view->details->location_popup_directory_as_file;
-	g_return_if_fail (file != NULL);
-
-	nautilus_view_activate_file (view,
-				     file,
-				     0);
-}
-
-static void
 action_location_cut_callback (GtkAction *action,
 			      gpointer   callback_data)
 {
@@ -7034,10 +6984,6 @@ static const GtkActionEntry directory_view_entries[] = {
   /* label, accelerator */       N_("Open in New _Tab"), "<control><shift>o",
   /* tooltip */                  N_("Open each selected item in a new tab"),
 				 G_CALLBACK (action_open_new_tab_callback) },
-  /* name, stock id */         { "OpenFolderWindow", NULL,
-  /* label, accelerator */       N_("Open in _Folder Window"), NULL,
-  /* tooltip */                  N_("Open each selected item in a folder window"),
-				 G_CALLBACK (action_open_folder_window_callback) },
   /* name, stock id */         { "OtherApplication1", NULL,
   /* label, accelerator */       N_("Other _Application..."), NULL,
   /* tooltip */                  N_("Choose another application with which to open the selected item"),
@@ -7199,11 +7145,6 @@ static const GtkActionEntry directory_view_entries[] = {
   /* tooltip */                  N_("Open this folder in a new tab"),
 				 G_CALLBACK (action_location_open_in_new_tab_callback) },
 
-  /* name, stock id */         { NAUTILUS_ACTION_LOCATION_OPEN_FOLDER_WINDOW, NULL,
-  /* label, accelerator */       N_("Open in _Folder Window"), "",
-  /* tooltip */                  N_("Open this folder in a folder window"),
-				 G_CALLBACK (action_location_open_folder_window_callback) },
-
   /* name, stock id */         { NAUTILUS_ACTION_LOCATION_CUT, GTK_STOCK_CUT,
   /* label, accelerator */       NULL, "",
   /* tooltip */                  N_("Prepare this folder to be moved with a Paste command"),
@@ -8172,24 +8113,20 @@ real_update_location_menu (NautilusView *view)
 	gboolean is_desktop_or_home_dir;
 	gboolean can_delete_file, show_delete;
 	gboolean show_separate_delete_command;
-	gboolean show_open_folder_window;
 	gboolean show_open_in_new_tab;
+	gboolean show_open_alternate;
 	GList l;
 	char *label;
 	char *tip;
 
-	show_open_folder_window = FALSE;
-	show_open_in_new_tab = TRUE;
-
-	if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
-		label = _("Open in New _Window");
-	} else {
-		label = _("Browse in New _Window");
-		show_open_folder_window = TRUE;
-	}
+	show_open_in_new_tab = g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER);
+	show_open_alternate = g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER);
 
 	action = gtk_action_group_get_action (view->details->dir_action_group,
 					      NAUTILUS_ACTION_LOCATION_OPEN_ALTERNATE);
+	gtk_action_set_visible (action, show_open_alternate);
+
+	label = _("Open in New _Window");
 	g_object_set (action,
 		      "label", label,
 		      NULL);
@@ -8198,20 +8135,10 @@ real_update_location_menu (NautilusView *view)
 					      NAUTILUS_ACTION_LOCATION_OPEN_IN_NEW_TAB);
 	gtk_action_set_visible (action, show_open_in_new_tab);
 
-	if (show_open_in_new_tab) {
-		if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
-			label = _("Open in New _Tab");
-		} else {
-			label = _("Browse in New _Tab");
-		}
-		g_object_set (action,
-			      "label", label,
-			      NULL);
-	}
-
-	action = gtk_action_group_get_action (view->details->dir_action_group,
-					      NAUTILUS_ACTION_LOCATION_OPEN_FOLDER_WINDOW);
-	gtk_action_set_visible (action, show_open_folder_window);
+	label = _("Open in New _Tab");
+	g_object_set (action,
+		      "label", label,
+		      NULL);
 
 	file = view->details->location_popup_directory_as_file;
 	g_assert (NAUTILUS_IS_FILE (file));
@@ -8357,12 +8284,12 @@ real_update_menus (NautilusView *view)
 	gboolean vfolder_directory;
 	gboolean disable_command_line;
 	gboolean show_open_alternate;
+	gboolean show_open_in_new_tab;
 	gboolean can_open;
 	gboolean show_app;
 	gboolean show_save_search;
 	gboolean save_search_sensitive;
 	gboolean show_save_search_as;
-	gboolean show_open_folder_window;
 	gboolean show_desktop_target;
 	GtkAction *action;
 	GAppInfo *app;
@@ -8485,73 +8412,49 @@ real_update_menus (NautilusView *view)
 
 	show_open_alternate = file_list_all_are_folders (selection) &&
 		selection_count > 0 &&
-		!(nautilus_window_get_window_type (view->details->window) == NAUTILUS_WINDOW_DESKTOP &&
-		  g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER));
-	show_open_folder_window = FALSE;
-
-	if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
-		if (selection_count == 0 || selection_count == 1) {
-			label_with_underscore = g_strdup (_("Open in New _Window"));
-		} else {
-			label_with_underscore = g_strdup_printf (ngettext("Open in %'d New _Window",
-									  "Open in %'d New _Windows",
-									  selection_count), 
-								 selection_count);
-		}
-	} else {
-		if (selection_count == 0 || selection_count == 1) {
-			label_with_underscore = g_strdup (_("Browse in New _Window"));
-		} else {
-			label_with_underscore = g_strdup_printf (ngettext("Browse in %'d New _Window",
-									  "Browse in %'d New _Windows",
-									  selection_count), 
-								 selection_count);
-		}
-		show_open_folder_window = show_open_alternate;
-	}
+		g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER) &&
+		!(nautilus_window_get_window_type (view->details->window) == NAUTILUS_WINDOW_DESKTOP);
 
 	action = gtk_action_group_get_action (view->details->dir_action_group,
 					      NAUTILUS_ACTION_OPEN_ALTERNATE);
-	g_object_set (action, "label", 
-		      label_with_underscore,
-		      NULL);
-	g_free (label_with_underscore);
 
 	gtk_action_set_sensitive (action,  selection_count != 0);
 	gtk_action_set_visible (action, show_open_alternate);
 
-	if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
-		if (selection_count == 0 || selection_count == 1) {
-			label_with_underscore = g_strdup (_("Open in New _Tab"));
-		} else {
-			label_with_underscore = g_strdup_printf (ngettext("Open in %'d New _Tab",
-									  "Open in %'d New _Tabs",
-									  selection_count), 
-								 selection_count);
-		}
+	if (selection_count == 0 || selection_count == 1) {
+		label_with_underscore = g_strdup (_("Open in New _Window"));
 	} else {
-		if (selection_count == 0 || selection_count == 1) {
-			label_with_underscore = g_strdup (_("Browse in New _Tab"));
-		} else {
-			label_with_underscore = g_strdup_printf (ngettext("Browse in %'d New _Tab",
-									  "Browse in %'d New _Tabs",
-									  selection_count), 
-								 selection_count);
-		}
+		label_with_underscore = g_strdup_printf (ngettext("Open in %'d New _Window",
+								  "Open in %'d New _Windows",
+								  selection_count), 
+							 selection_count);
 	}
+
+	g_object_set (action, "label", 
+		      label_with_underscore,
+		      NULL);
+	g_free (label_with_underscore);
+
+	show_open_in_new_tab = show_open_alternate;
 	action = gtk_action_group_get_action (view->details->dir_action_group,
 					      NAUTILUS_ACTION_OPEN_IN_NEW_TAB);
 	gtk_action_set_sensitive (action, selection_count != 0);
-	gtk_action_set_visible (action, show_open_alternate);
+	gtk_action_set_visible (action, show_open_in_new_tab);
+
+	if (selection_count == 0 || selection_count == 1) {
+		label_with_underscore = g_strdup (_("Open in New _Tab"));
+	} else {
+		label_with_underscore = g_strdup_printf (ngettext("Open in %'d New _Tab",
+								  "Open in %'d New _Tabs",
+								  selection_count), 
+							 selection_count);
+	}
+
 	g_object_set (action, "label", 
 		      label_with_underscore,
 		      NULL);
 	g_free (label_with_underscore);
 
-	action = gtk_action_group_get_action (view->details->dir_action_group,
-					      NAUTILUS_ACTION_OPEN_FOLDER_WINDOW);
-	gtk_action_set_visible (action, show_open_folder_window);
-
 	/* Broken into its own function just for convenience */
 	reset_open_with_menu (view, selection);
 	reset_extension_actions_menu (view, selection);



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