summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--libnautilus-private/nautilus-file.c3
-rw-r--r--libnautilus-private/nautilus-file.h2
-rw-r--r--libnautilus-private/nautilus-mime-actions.c37
-rw-r--r--libnautilus-private/nautilus-vfs-file.c5
-rw-r--r--src/file-manager/fm-directory-view.c4
6 files changed, 50 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 1d426b09b..b407db74c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2007-12-07 Alexander Larsson <alexl@redhat.com>
+ * libnautilus-private/nautilus-file.[ch]:
+ * libnautilus-private/nautilus-vfs-file.c:
+ * src/file-manager/fm-directory-view.c:
+ Add optional cancellable arg to nautilus_file_mount
+
+ * libnautilus-private/nautilus-mime-actions.c:
+ Implement cancellation of file activation
+
+2007-12-07 Alexander Larsson <alexl@redhat.com>
+
* libnautilus-private/nautilus-file-operations.c:
Implement nautilus_file_set_permissions_recursive
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index ae1645cc3..5d5a7a3ae 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -856,6 +856,7 @@ nautilus_file_can_eject (NautilusFile *file)
void
nautilus_file_mount (NautilusFile *file,
GMountOperation *mount_op,
+ GCancellable *cancellable,
NautilusFileOperationCallback callback,
gpointer callback_data)
{
@@ -870,7 +871,7 @@ nautilus_file_mount (NautilusFile *file,
g_error_free (error);
}
} else {
- NAUTILUS_FILE_GET_CLASS (file)->mount (file, mount_op, callback, callback_data);
+ NAUTILUS_FILE_GET_CLASS (file)->mount (file, mount_op, cancellable, callback, callback_data);
}
}
diff --git a/libnautilus-private/nautilus-file.h b/libnautilus-private/nautilus-file.h
index e0895f6ac..b2c94481d 100644
--- a/libnautilus-private/nautilus-file.h
+++ b/libnautilus-private/nautilus-file.h
@@ -250,6 +250,7 @@ gboolean nautilus_file_can_eject (Nautilu
void nautilus_file_mount (NautilusFile *file,
GMountOperation *mount_op,
+ GCancellable *cancellable,
NautilusFileOperationCallback callback,
gpointer callback_data);
void nautilus_file_unmount (NautilusFile *file,
@@ -476,6 +477,7 @@ typedef struct {
void (* mount) (NautilusFile *file,
GMountOperation *mount_op,
+ GCancellable *cancellable,
NautilusFileOperationCallback callback,
gpointer callback_data);
void (* unmount) (NautilusFile *file,
diff --git a/libnautilus-private/nautilus-mime-actions.c b/libnautilus-private/nautilus-mime-actions.c
index 0f34eca43..84d0a462a 100644
--- a/libnautilus-private/nautilus-mime-actions.c
+++ b/libnautilus-private/nautilus-mime-actions.c
@@ -68,6 +68,7 @@ typedef struct {
NautilusWindowOpenMode mode;
NautilusWindowOpenFlags flags;
char *timed_wait_prompt;
+ gboolean timed_wait_active;
NautilusFileListHandle *files_handle;
gboolean tried_mounting;
char *activation_directory;
@@ -851,10 +852,8 @@ file_was_cancelled (NautilusFile *file)
error != NULL &&
error->domain == G_IO_ERROR &&
error->code == G_IO_ERROR_CANCELLED;
-
}
-
static gboolean
file_was_not_mounted (NautilusFile *file)
{
@@ -870,6 +869,10 @@ file_was_not_mounted (NautilusFile *file)
static void
activation_parameters_free (ActivateParameters *parameters)
{
+ if (parameters->timed_wait_active) {
+ eel_timed_wait_stop (cancel_activate_callback, parameters);
+ }
+
if (parameters->window_info) {
g_object_remove_weak_pointer (G_OBJECT (parameters->window_info), (gpointer *)&parameters->window_info);
}
@@ -889,12 +892,22 @@ activation_parameters_free (ActivateParameters *parameters)
static void
cancel_activate_callback (gpointer callback_data)
{
- /* TODO-gio */
+ ActivateParameters *parameters = callback_data;
+
+ parameters->timed_wait_active = FALSE;
+
+ g_cancellable_cancel (parameters->cancellable);
+
+ if (parameters->files_handle) {
+ nautilus_file_list_cancel_call_when_ready (parameters->files_handle);
+ activation_parameters_free (parameters);
+ }
}
static void
activation_start_timed_cancel (ActivateParameters *parameters)
{
+ parameters->timed_wait_active = TRUE;
eel_timed_wait_start_with_duration
(DELAY_UNTIL_CANCEL_MSECS,
cancel_activate_callback,
@@ -909,9 +922,14 @@ activate_mount_op_active (EelMountOperation *operation,
ActivateParameters *parameters)
{
if (is_active) {
- eel_timed_wait_stop (cancel_activate_callback, parameters);
+ if (parameters->timed_wait_active) {
+ eel_timed_wait_stop (cancel_activate_callback, parameters);
+ parameters->timed_wait_active = FALSE;
+ }
} else {
- activation_start_timed_cancel (parameters);
+ if (!parameters->timed_wait_active) {
+ activation_start_timed_cancel (parameters);
+ }
}
}
@@ -1190,7 +1208,6 @@ activate_files (ActivateParameters *parameters)
g_list_free (open_in_app_parameters);
g_list_free (unhandled_open_in_app_files);
- eel_timed_wait_stop (cancel_activate_callback, parameters);
activation_parameters_free (parameters);
}
@@ -1326,7 +1343,6 @@ activate_activation_uris_ready_callback (GList *files_ignore,
}
if (parameters->files == NULL) {
- eel_timed_wait_stop (cancel_activate_callback, parameters);
activation_parameters_free (parameters);
return;
}
@@ -1388,7 +1404,6 @@ activation_get_activation_uris (ActivateParameters *parameters)
}
if (parameters->files == NULL) {
- eel_timed_wait_stop (cancel_activate_callback, parameters);
activation_parameters_free (parameters);
return;
}
@@ -1439,6 +1454,11 @@ activation_mountable_mounted (NautilusFile *file,
eel_show_error_dialog (_("Unable to mount location"),
error->message, NULL);
}
+
+ if (error->code == G_IO_ERROR_CANCELLED) {
+ activation_parameters_free (parameters);
+ return;
+ }
}
/* Mount more mountables */
@@ -1458,6 +1478,7 @@ activation_mount_mountables (ActivateParameters *parameters)
g_signal_connect (mount_op, "active_changed", (GCallback)activate_mount_op_active, parameters);
nautilus_file_mount (file,
mount_op,
+ parameters->cancellable,
activation_mountable_mounted,
parameters);
g_object_unref (mount_op);
diff --git a/libnautilus-private/nautilus-vfs-file.c b/libnautilus-private/nautilus-vfs-file.c
index 09f4e386d..1c3a2904b 100644
--- a/libnautilus-private/nautilus-vfs-file.c
+++ b/libnautilus-private/nautilus-vfs-file.c
@@ -250,6 +250,7 @@ vfs_file_mount_callback (GObject *source_object,
static void
vfs_file_mount (NautilusFile *file,
GMountOperation *mount_op,
+ GCancellable *cancellable,
NautilusFileOperationCallback callback,
gpointer callback_data)
{
@@ -269,6 +270,10 @@ vfs_file_mount (NautilusFile *file,
}
op = nautilus_file_operation_new (file, callback, callback_data);
+ if (cancellable) {
+ g_object_unref (op->cancellable);
+ op->cancellable = g_object_ref (cancellable);
+ }
location = nautilus_file_get_location (file);
g_file_mount_mountable (location,
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index b888bda06..b9ab6649a 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -5704,7 +5704,7 @@ action_mount_volume_callback (GtkAction *action,
if (nautilus_file_can_mount (file)) {
mount_op = eel_mount_operation_new (fm_directory_view_get_containing_window (view));
- nautilus_file_mount (file, mount_op,
+ nautilus_file_mount (file, mount_op, NULL,
NULL, NULL);
g_object_unref (mount_op);
}
@@ -5794,7 +5794,7 @@ action_self_mount_volume_callback (GtkAction *action,
}
mount_op = eel_mount_operation_new (fm_directory_view_get_containing_window (view));
- nautilus_file_mount (file, mount_op, NULL, NULL);
+ nautilus_file_mount (file, mount_op, NULL, NULL, NULL);
g_object_unref (mount_op);
}