nautilus r14215 - in branches/multiview: . libnautilus-private src/file-manager



Author: cneumair
Date: Sat May 31 10:40:11 2008
New Revision: 14215
URL: http://svn.gnome.org/viewvc/nautilus?rev=14215&view=rev

Log:
2008-05-31  Christian Neumair  <cneumair gnome org>

	* libnautilus-private/nautilus-mime-actions.c
	(confirm_multiple_windows), (activate_files),
	(activation_mountable_mounted), (nautilus_mime_activate_files),
	(nautilus_mime_activate_file):
	* libnautilus-private/nautilus-mime-actions.h:
	* src/file-manager/fm-directory-view.c
	(fm_directory_view_confirm_multiple),
	(fm_directory_view_activate_files), (action_open_callback),
	(action_open_close_parent_callback),
	(action_open_alternate_callback), (action_open_new_tab_callback),
	(action_open_folder_window_callback):
	* src/file-manager/fm-directory-view.h:
	* src/file-manager/fm-icon-view.c
	(icon_container_activate_callback),
	(icon_container_activate_alternate_callback):
	* src/file-manager/fm-list-view.c (activate_selected_items),
	(activate_selected_items_alternate):
	* src/file-manager/nautilus-directory-view-ui.xml:
	Fix order and confirmation when opening multiple tabs. All tabs are
	activated at once, instead of activating each separately. Refer to tabs
	rather than windows in the confirmation dialog.
	Also list "New Tab" above "New Window" in background context menu.


Modified:
   branches/multiview/ChangeLog
   branches/multiview/libnautilus-private/nautilus-mime-actions.c
   branches/multiview/libnautilus-private/nautilus-mime-actions.h
   branches/multiview/src/file-manager/fm-directory-view.c
   branches/multiview/src/file-manager/fm-directory-view.h
   branches/multiview/src/file-manager/fm-icon-view.c
   branches/multiview/src/file-manager/fm-list-view.c
   branches/multiview/src/file-manager/nautilus-directory-view-ui.xml

Modified: branches/multiview/libnautilus-private/nautilus-mime-actions.c
==============================================================================
--- branches/multiview/libnautilus-private/nautilus-mime-actions.c	(original)
+++ branches/multiview/libnautilus-private/nautilus-mime-actions.c	Sat May 31 10:40:11 2008
@@ -73,6 +73,7 @@
 	NautilusFileListHandle *files_handle;
 	gboolean tried_mounting;
 	char *activation_directory;
+	gboolean user_confirmation;
 } ActivateParameters;
 
 /* Number of seconds until cancel dialog shows up */
@@ -973,7 +974,9 @@
 }
 
 static gboolean
-confirm_multiple_windows (GtkWindow *parent_window, int count)
+confirm_multiple_windows (GtkWindow *parent_window,
+			  int count,
+			  gboolean use_tabs)
 {
 	GtkDialog *dialog;
 	char *prompt;
@@ -985,8 +988,13 @@
 	}
 
 	prompt = _("Are you sure you want to open all files?");
-	detail = g_strdup_printf (ngettext("This will open %d separate window.",
-					   "This will open %d separate windows.", count), count);
+	if (use_tabs) {
+		detail = g_strdup_printf (ngettext("This will open %d separate tab.",
+						   "This will open %d separate tabs.", count), count);
+	} else {
+		detail = g_strdup_printf (ngettext("This will open %d separate window.",
+						   "This will open %d separate windows.", count), count);
+	}
 	dialog = eel_show_yes_no_dialog (prompt, detail, 
 					 GTK_STOCK_OK, GTK_STOCK_CANCEL,
 					 parent_window);
@@ -1002,6 +1010,7 @@
 activate_files (ActivateParameters *parameters)
 {
 	NautilusWindowInfo *window_info;
+	NautilusWindowOpenFlags flags;
 	NautilusFile *file;
 	GList *launch_desktop_files;
 	GList *launch_files;
@@ -1135,16 +1144,33 @@
 
 	open_in_view_files = g_list_reverse (open_in_view_files);
 	count = g_list_length (open_in_view_files);
-	if (parameters->slot_info != NULL &&
-	    confirm_multiple_windows (parameters->parent_window, count)) {
-		NautilusWindowOpenFlags flags;
 
-		flags = parameters->flags;
-		if (count > 1) {
-			if ((parameters->flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW) == 0) {
-				flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB;
-			}
+	flags = parameters->flags;
+	if (count > 1) {
+		if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ENABLE_TABS) &&
+		    (parameters->flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW) == 0) {
+			flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB;
+		} else {
+			flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW;
 		}
+	}
+
+	if (parameters->slot_info != NULL &&
+	    (!parameters->user_confirmation ||
+	     confirm_multiple_windows (parameters->parent_window, count,
+				       (flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB) != 0))) {
+
+		if ((flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB) != 0 &&
+		    eel_preferences_get_enum (NAUTILUS_PREFERENCES_NEW_TAB_POSITION) ==
+		    NAUTILUS_NEW_TAB_POSITION_AFTER_CURRENT_TAB) {
+			/* When inserting N tabs after the current one,
+			 * we first open tab N, then tab N-1, ..., then tab 0.
+			 * Each of them is appended to the current tab, i.e.
+			 * prepended to the list of tabs to open.
+			 */
+			open_in_view_files = g_list_reverse (open_in_view_files);
+		}
+
 
 		for (l = open_in_view_files; l != NULL; l = l->next) {
 			GFile *f;
@@ -1466,6 +1492,7 @@
 {
 	ActivateParameters *parameters = callback_data;
 	NautilusFile *target_file;
+	int position;
 
 	/* Remove from list of files that have to be mounted */
 	parameters->mountables = g_list_remove (parameters->mountables, file); 
@@ -1473,13 +1500,16 @@
 
 	if (error == NULL) {
 		/* Replace file with the result of the mount */
-		
 		target_file = nautilus_file_get (result_location);
 		
+		position = g_list_index (parameters->files, file);
+
 		parameters->files = g_list_remove (parameters->files, file); 
 		nautilus_file_unref (file);
 		
-		parameters->files = g_list_prepend (parameters->files, target_file);
+		parameters->files = g_list_insert (parameters->files,
+						   target_file,
+						   position);
 	} else {
 		/* Remove failed file */
 		
@@ -1547,7 +1577,8 @@
 			      GList *files,
 			      const char *launch_directory,
 			      NautilusWindowOpenMode mode,
-			      NautilusWindowOpenFlags flags)
+			      NautilusWindowOpenFlags flags,
+			      gboolean user_confirmation)
 {
 	ActivateParameters *parameters;
 	char *file_name;
@@ -1575,6 +1606,7 @@
 	parameters->files = nautilus_file_list_copy (files);
 	parameters->mode = mode;
 	parameters->flags = flags;
+	parameters->user_confirmation = user_confirmation;
 
 	file_count = g_list_length (files);
 	if (file_count == 1) {
@@ -1627,6 +1659,6 @@
 	g_return_if_fail (NAUTILUS_IS_FILE (file));
 
 	files = g_list_prepend (NULL, file);
-	nautilus_mime_activate_files (parent_window, slot_info, files, launch_directory, mode, flags);
+	nautilus_mime_activate_files (parent_window, slot_info, files, launch_directory, mode, flags, FALSE);
 	g_list_free (files);
 }

Modified: branches/multiview/libnautilus-private/nautilus-mime-actions.h
==============================================================================
--- branches/multiview/libnautilus-private/nautilus-mime-actions.h	(original)
+++ branches/multiview/libnautilus-private/nautilus-mime-actions.h	Sat May 31 10:40:11 2008
@@ -49,7 +49,8 @@
 									   GList                   *files,
 									   const char              *launch_directory,
 									   NautilusWindowOpenMode   mode,
-									   NautilusWindowOpenFlags  flags);
+									   NautilusWindowOpenFlags  flags,
+									   gboolean                 user_confirmation);
 void                   nautilus_mime_activate_file                        (GtkWindow               *parent_window,
 									   NautilusWindowSlotInfo  *slot_info,
 									   NautilusFile            *file,

Modified: branches/multiview/src/file-manager/fm-directory-view.c
==============================================================================
--- branches/multiview/src/file-manager/fm-directory-view.c	(original)
+++ branches/multiview/src/file-manager/fm-directory-view.c	Sat May 31 10:40:11 2008
@@ -315,8 +315,6 @@
 								FMDirectoryView      *view);
 static void     open_one_in_new_window                         (gpointer              data,
 								gpointer              callback_data);
-static void     open_one_in_new_tab                            (gpointer              data,
-								gpointer              callback_data);
 static void     open_one_in_folder_window                      (gpointer              data,
 								gpointer              callback_data);
 static void     schedule_update_menus                          (FMDirectoryView      *view);
@@ -608,8 +606,10 @@
 	return GTK_WINDOW (window);
 }
 
-gboolean
-fm_directory_view_confirm_multiple_windows (GtkWindow *parent_window, int count)
+static gboolean
+fm_directory_view_confirm_multiple (GtkWindow *parent_window,
+				    int count,
+				    gboolean tabs)
 {
 	GtkDialog *dialog;
 	char *prompt;
@@ -621,8 +621,13 @@
 	}
 
 	prompt = _("Are you sure you want to open all files?");
-	detail = g_strdup_printf (ngettext("This will open %'d separate window.",
-					   "This will open %'d separate windows.", count), count);
+	if (tabs) {
+		detail = g_strdup_printf (ngettext("This will open %'d separate tab.",
+						   "This will open %'d separate tabs.", count), count);
+	} else {
+		detail = g_strdup_printf (ngettext("This will open %'d separate window.",
+						   "This will open %'d separate windows.", count), count);
+	}
 	dialog = eel_show_yes_no_dialog (prompt, detail, 
 					 GTK_STOCK_OK, GTK_STOCK_CANCEL,
 					 parent_window);
@@ -695,7 +700,8 @@
 fm_directory_view_activate_files (FMDirectoryView *view,
 				  GList *files,
 				  NautilusWindowOpenMode mode,
-				  NautilusWindowOpenFlags flags)
+				  NautilusWindowOpenFlags flags,
+				  gboolean confirm_multiple)
 {
 	char *path;
 
@@ -705,7 +711,8 @@
 				      files,
 				      path,
 				      mode,
-				      flags);
+				      flags,
+				      confirm_multiple);
 
 	g_free (path);
 }
@@ -742,7 +749,8 @@
 	fm_directory_view_activate_files (view,
 					  selection,
 					  NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
-					  0);
+					  0,
+					  TRUE);
 	nautilus_file_list_free (selection);
 }
 
@@ -759,7 +767,8 @@
 	fm_directory_view_activate_files (view,
 					  selection,
 					  NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
-					  NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND);
+					  NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND,
+					  TRUE);
 	nautilus_file_list_free (selection);
 }
 
@@ -777,7 +786,7 @@
 
 	window = fm_directory_view_get_containing_window (view);
 
-	if (fm_directory_view_confirm_multiple_windows (window, g_list_length (selection))) {
+	if (fm_directory_view_confirm_multiple (window, g_list_length (selection), FALSE)) {
 		g_list_foreach (selection, open_one_in_new_window, view);
 	}
 
@@ -792,13 +801,21 @@
 	GList *selection;
 	GtkWindow *window;
 
+	if (!eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ENABLE_TABS)) {
+		return;
+	}
+
 	view = FM_DIRECTORY_VIEW (callback_data);
 	selection = fm_directory_view_get_selection (view);
 
 	window = fm_directory_view_get_containing_window (view);
 
-	if (fm_directory_view_confirm_multiple_windows (window, g_list_length (selection))) {
-		g_list_foreach (selection, open_one_in_new_tab, view);
+	if (fm_directory_view_confirm_multiple (window, g_list_length (selection), TRUE)) {
+		fm_directory_view_activate_files (view,
+						  selection,
+						  NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
+						  NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB,
+						  FALSE);
 	}
 
 	nautilus_file_list_free (selection);
@@ -817,7 +834,7 @@
 
 	window = fm_directory_view_get_containing_window (view);
 
-	if (fm_directory_view_confirm_multiple_windows (window, g_list_length (selection))) {
+	if (fm_directory_view_confirm_multiple (window, g_list_length (selection), FALSE)) {
 		g_list_foreach (selection, open_one_in_folder_window, view);
 	}
 
@@ -3984,22 +4001,6 @@
 }
 
 static void
-open_one_in_new_tab (gpointer data, gpointer callback_data)
-{
-	g_assert (NAUTILUS_IS_FILE (data));
-	g_assert (FM_IS_DIRECTORY_VIEW (callback_data));
-
-	if (!eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ENABLE_TABS)) {
-		return;
-	}
-
-	fm_directory_view_activate_file (FM_DIRECTORY_VIEW (callback_data),
-					 NAUTILUS_FILE (data),
-					 NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
-					 NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB);
-}
-
-static void
 open_one_in_folder_window (gpointer data, gpointer callback_data)
 {
 	g_assert (NAUTILUS_IS_FILE (data));

Modified: branches/multiview/src/file-manager/fm-directory-view.h
==============================================================================
--- branches/multiview/src/file-manager/fm-directory-view.h	(original)
+++ branches/multiview/src/file-manager/fm-directory-view.h	Sat May 31 10:40:11 2008
@@ -388,15 +388,14 @@
 void                fm_directory_view_activate_files                   (FMDirectoryView        *view,
 									GList                  *files,
 									NautilusWindowOpenMode  mode,
-									NautilusWindowOpenFlags flags);
+									NautilusWindowOpenFlags flags,
+									gboolean                confirm_multiple);
 void                fm_directory_view_activate_file                    (FMDirectoryView        *view,
 									NautilusFile           *file,
 									NautilusWindowOpenMode  mode,
 									NautilusWindowOpenFlags flags);
 void                fm_directory_view_start_batching_selection_changes (FMDirectoryView  *view);
 void                fm_directory_view_stop_batching_selection_changes  (FMDirectoryView  *view);
-gboolean            fm_directory_view_confirm_multiple_windows         (GtkWindow        *parent_window,
-									int               window_count);
 void                fm_directory_view_queue_file_change                (FMDirectoryView  *view,
 									NautilusFile     *file);
 void                fm_directory_view_notify_selection_changed         (FMDirectoryView  *view);

Modified: branches/multiview/src/file-manager/fm-icon-view.c
==============================================================================
--- branches/multiview/src/file-manager/fm-icon-view.c	(original)
+++ branches/multiview/src/file-manager/fm-icon-view.c	Sat May 31 10:40:11 2008
@@ -1714,7 +1714,8 @@
 
 	fm_directory_view_activate_files (FM_DIRECTORY_VIEW (icon_view),
 					  file_list, 
-					  NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, 0);
+					  NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, 0,
+					  TRUE);
 }
 
 static void
@@ -1764,7 +1765,8 @@
 	fm_directory_view_activate_files (FM_DIRECTORY_VIEW (icon_view), 
 					  file_list, 
 					  NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
-					  flags);
+					  flags,
+					  TRUE);
 }
 
 static void

Modified: branches/multiview/src/file-manager/fm-list-view.c
==============================================================================
--- branches/multiview/src/file-manager/fm-list-view.c	(original)
+++ branches/multiview/src/file-manager/fm-list-view.c	Sat May 31 10:40:11 2008
@@ -230,7 +230,8 @@
 	fm_directory_view_activate_files (FM_DIRECTORY_VIEW (view),
 					  file_list,
 					  NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
-					  0);
+					  0,
+					  TRUE);
 	nautilus_file_list_free (file_list);
 
 }
@@ -252,7 +253,8 @@
 					  file_list,
 					  NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
 					  NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND |
-					  NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW);
+					  NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW,
+					  TRUE);
 	nautilus_file_list_free (file_list);
 
 }

Modified: branches/multiview/src/file-manager/nautilus-directory-view-ui.xml
==============================================================================
--- branches/multiview/src/file-manager/nautilus-directory-view-ui.xml	(original)
+++ branches/multiview/src/file-manager/nautilus-directory-view-ui.xml	Sat May 31 10:40:11 2008
@@ -116,8 +116,8 @@
 <popup name="selection">
 	<placeholder name="Open Placeholder">
 		<menuitem name="Open" action="Open"/>
-		<menuitem name="OpenAlternate" action="OpenAlternate"/>
 		<menuitem name="OpenInNewTab" action="OpenInNewTab"/>
+		<menuitem name="OpenAlternate" action="OpenAlternate"/>
 		<menuitem name="OpenFolderWindow" action="OpenFolderWindow"/>
 		<separator name="applications separator"/>
 		<placeholder name="Applications Placeholder"/>



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