nautilus r14035 - in branches/gnome-2-22: . libnautilus-private src



Author: cneumair
Date: Fri Apr  4 15:53:59 2008
New Revision: 14035
URL: http://svn.gnome.org/viewvc/nautilus?rev=14035&view=rev

Log:
2008-04-04  Christian Neumair  <cneumair gnome org>

	* libnautilus-private/nautilus-file-operations.c (volume_mount_cb),
	(nautilus_file_operations_mount_volume):
	* libnautilus-private/nautilus-file-operations.h:
	* libnautilus-private/nautilus-mime-actions.c
	(activation_mount_not_mounted_callback),
	(activation_mount_not_mounted):
	* src/nautilus-application.c (startup_volume_mount_cb),
	(automount_all_volumes), (volume_added_callback):
	* src/nautilus-places-sidebar.c (open_selected_bookmark),
	(mount_shortcut_cb):
	* src/nautilus-window-manage-views.c (mount_not_mounted_callback),
	(got_file_info_for_view_selection_callback):
	Inhibit autorun in mount callbacks after finishing mounts rather than
	before mounting.

	It is neccessary because the mount may take a very long time (floppy,
	password prompt), which may take longer than the inhibition timeout.

	This approach works because with the current HAL volume monitor
	implementation, GVolumeMonitor signal emission is scheduled, while the
	mount callbacks are invoked synchronously.

	This should also fix the not working inhibition on startup, which
	could happen because parallel mounts in the background and the rest of
	the startup process eat resources, so the mounts may also take longer
	than the inhibition timeout.


Modified:
   branches/gnome-2-22/ChangeLog
   branches/gnome-2-22/libnautilus-private/nautilus-file-operations.c
   branches/gnome-2-22/libnautilus-private/nautilus-file-operations.h
   branches/gnome-2-22/libnautilus-private/nautilus-mime-actions.c
   branches/gnome-2-22/src/nautilus-application.c
   branches/gnome-2-22/src/nautilus-places-sidebar.c
   branches/gnome-2-22/src/nautilus-window-manage-views.c

Modified: branches/gnome-2-22/libnautilus-private/nautilus-file-operations.c
==============================================================================
--- branches/gnome-2-22/libnautilus-private/nautilus-file-operations.c	(original)
+++ branches/gnome-2-22/libnautilus-private/nautilus-file-operations.c	Fri Apr  4 15:53:59 2008
@@ -2015,6 +2015,9 @@
 	GError *error;
 	char *primary;
 	char *name;
+	gboolean inhibit_autorun;
+
+	inhibit_autorun = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (mount_op), "inhibit-autorun"));
 
 	error = NULL;
 	if (!g_volume_mount_finish (G_VOLUME (source_object), res, &error)) {
@@ -2028,6 +2031,10 @@
 			g_free (primary);
 		}
 		g_error_free (error);
+	} else {
+		if (inhibit_autorun) {
+			nautilus_inhibit_autorun_for_volume (G_VOLUME (source_object));
+		}
 	}
 	
 	g_object_unref (mount_op);
@@ -2036,11 +2043,13 @@
 
 void
 nautilus_file_operations_mount_volume (GtkWindow *parent_window,
-				       GVolume *volume)
+				       GVolume *volume,
+				       gboolean inhibit_autorun)
 {
 	GMountOperation *mount_op;
 	
 	mount_op = eel_mount_operation_new (parent_window);
+	g_object_set_data (G_OBJECT (mount_op), "inhibit-autorun", GINT_TO_POINTER (inhibit_autorun));
 	g_volume_mount (volume, 0, mount_op, NULL, volume_mount_cb, mount_op);
 }
 

Modified: branches/gnome-2-22/libnautilus-private/nautilus-file-operations.h
==============================================================================
--- branches/gnome-2-22/libnautilus-private/nautilus-file-operations.h	(original)
+++ branches/gnome-2-22/libnautilus-private/nautilus-file-operations.h	Fri Apr  4 15:53:59 2008
@@ -92,7 +92,8 @@
 					     gboolean                        eject,
 					     gboolean                        check_trash);
 void nautilus_file_operations_mount_volume  (GtkWindow                      *parent_window,
-					     GVolume                        *volume);
+					     GVolume                        *volume,
+					     gboolean                        inhibit_autorun);
 								
 
 void nautilus_file_operations_copy      (GList                *files,

Modified: branches/gnome-2-22/libnautilus-private/nautilus-mime-actions.c
==============================================================================
--- branches/gnome-2-22/libnautilus-private/nautilus-mime-actions.c	(original)
+++ branches/gnome-2-22/libnautilus-private/nautilus-mime-actions.c	Fri Apr  4 15:53:59 2008
@@ -1235,6 +1235,7 @@
 	ActivateParameters *parameters = user_data;
 	GError *error;
 	NautilusFile *file;
+	GFile *location;
 
 	file = parameters->not_mounted->data;
 		
@@ -1255,6 +1256,10 @@
 		}
 
 		g_error_free (error);
+	} else {
+		location = nautilus_file_get_location (file);
+		nautilus_inhibit_autorun_for_file (location);
+		g_object_unref (G_OBJECT (location));
 	}
 	
 	parameters->not_mounted = g_list_delete_link (parameters->not_mounted,
@@ -1276,7 +1281,6 @@
 		mount_op = eel_mount_operation_new (parameters->parent_window);
 		g_signal_connect (mount_op, "active_changed", (GCallback)activate_mount_op_active, parameters);
 		location = nautilus_file_get_location (file);
-		nautilus_inhibit_autorun_for_file (location);
 		g_file_mount_enclosing_volume (location, 0, mount_op, parameters->cancellable,
 					       activation_mount_not_mounted_callback, parameters);
 		g_object_unref (location);

Modified: branches/gnome-2-22/src/nautilus-application.c
==============================================================================
--- branches/gnome-2-22/src/nautilus-application.c	(original)
+++ branches/gnome-2-22/src/nautilus-application.c	Fri Apr  4 15:53:59 2008
@@ -174,11 +174,8 @@
 			 GAsyncResult *res,
 			 gpointer user_data)
 {
-	if (!g_volume_mount_finish (G_VOLUME (source_object), res, NULL)) {
-		/* There was an error mounting the volume, so we
-		   clear the automount part. This is otherwise done
-		   when the mount is added to the volume monitor */
-		g_object_set_data (source_object, "nautilus-automounted", GINT_TO_POINTER (0));
+	if (g_volume_mount_finish (G_VOLUME (source_object), res, NULL)) {
+		nautilus_inhibit_autorun_for_volume (G_VOLUME (source_object));
 	}
 }
 
@@ -205,8 +202,6 @@
 				g_object_unref (mount);
 				continue;
 			}
-			
-			nautilus_inhibit_autorun_for_volume (volume);
 
 			/* pass NULL as GMountOperation to avoid user interaction */
 			g_volume_mount (volume, 0, NULL, NULL, startup_volume_mount_cb, NULL);
@@ -1334,7 +1329,7 @@
 	if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_MEDIA_AUTOMOUNT) &&
 	    g_volume_should_automount (volume) &&
 	    g_volume_can_mount (volume)) {
-		nautilus_file_operations_mount_volume (NULL, volume);
+		nautilus_file_operations_mount_volume (NULL, volume, FALSE);
 	}
 }
 

Modified: branches/gnome-2-22/src/nautilus-places-sidebar.c
==============================================================================
--- branches/gnome-2-22/src/nautilus-places-sidebar.c	(original)
+++ branches/gnome-2-22/src/nautilus-places-sidebar.c	Fri Apr  4 15:53:59 2008
@@ -1315,8 +1315,7 @@
 		GVolume *volume;
 		gtk_tree_model_get (model, &iter, PLACES_SIDEBAR_COLUMN_VOLUME, &volume, -1);
 		if (volume != NULL) {
-			nautilus_inhibit_autorun_for_volume (volume);
-			nautilus_file_operations_mount_volume (NULL, volume);
+			nautilus_file_operations_mount_volume (NULL, volume, TRUE);
 			g_object_unref (volume);
 		}
 	}
@@ -1431,8 +1430,7 @@
 			    -1);
 
 	if (volume != NULL) {
-		nautilus_inhibit_autorun_for_volume (volume);
-		nautilus_file_operations_mount_volume (NULL, volume);
+		nautilus_file_operations_mount_volume (NULL, volume, TRUE);
 		g_object_unref (volume);
 	}
 }

Modified: branches/gnome-2-22/src/nautilus-window-manage-views.c
==============================================================================
--- branches/gnome-2-22/src/nautilus-window-manage-views.c	(original)
+++ branches/gnome-2-22/src/nautilus-window-manage-views.c	Fri Apr  4 15:53:59 2008
@@ -923,6 +923,7 @@
 		window->details->mount_error = NULL;
 		g_error_free (error);
 	} else {
+		nautilus_inhibit_autorun_for_file (G_FILE (source_object));
 		nautilus_file_invalidate_all_attributes (window->details->determine_view_file);
 		nautilus_file_call_when_ready (window->details->determine_view_file,
 					       NAUTILUS_FILE_ATTRIBUTE_INFO |
@@ -968,7 +969,6 @@
 		data->cancellable = g_cancellable_new ();
 		data->window = window;
 		window->details->mount_cancellable = data->cancellable;
-		nautilus_inhibit_autorun_for_file (location);
 		g_file_mount_enclosing_volume (location, 0, mount_op, window->details->mount_cancellable,
 					       mount_not_mounted_callback, data);
 		g_object_unref (location);



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