Commit 00a42fe8 authored by Christian Neumair's avatar Christian Neumair Committed by Christian Neumair

Inhibit autorun in mount callbacks after finishing mounts rather than

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.

svn path=/trunk/; revision=14034
parent 9ed118a9
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.
2008-04-03 Christian Neumair <cneumair@gnome.org>
* libnautilus-private/nautilus-bookmark.c
......
......@@ -2017,6 +2017,9 @@ volume_mount_cb (GObject *source_object,
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)) {
......@@ -2030,6 +2033,10 @@ volume_mount_cb (GObject *source_object,
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);
......@@ -2038,11 +2045,13 @@ volume_mount_cb (GObject *source_object,
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);
}
......
......@@ -92,7 +92,8 @@ void nautilus_file_operations_unmount_mount (GtkWindow *par
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,
......
......@@ -1235,6 +1235,7 @@ activation_mount_not_mounted_callback (GObject *source_object,
ActivateParameters *parameters = user_data;
GError *error;
NautilusFile *file;
GFile *location;
file = parameters->not_mounted->data;
......@@ -1255,6 +1256,10 @@ activation_mount_not_mounted_callback (GObject *source_object,
}
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 @@ activation_mount_not_mounted (ActivateParameters *parameters)
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);
......
......@@ -172,11 +172,8 @@ startup_volume_mount_cb (GObject *source_object,
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));
}
}
......@@ -203,8 +200,6 @@ automount_all_volumes (NautilusApplication *application)
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);
......@@ -1332,7 +1327,7 @@ volume_added_callback (GVolumeMonitor *monitor,
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);
}
}
......
......@@ -1325,8 +1325,7 @@ open_selected_bookmark (NautilusPlacesSidebar *sidebar,
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);
}
}
......@@ -1441,8 +1440,7 @@ mount_shortcut_cb (GtkMenuItem *item,
-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);
}
}
......
......@@ -913,6 +913,7 @@ mount_not_mounted_callback (GObject *source_object,
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 |
......@@ -958,7 +959,6 @@ got_file_info_for_view_selection_callback (NautilusFile *file,
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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment