[nautilus] Always call back from nautilus_file_unmount/eject, even on success



commit 5e7f95842228f289b2940f23e63a2dd3b2cca842
Author: Alexander Larsson <alexl redhat com>
Date:   Mon Mar 8 13:48:27 2010 +0100

    Always call back from nautilus_file_unmount/eject, even on success

 libnautilus-private/nautilus-file.c |   37 +++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index fdb1bdc..7890211 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -1217,6 +1217,25 @@ nautilus_file_mount (NautilusFile                   *file,
 	}
 }
 
+typedef struct {
+	NautilusFile *file;
+	NautilusFileOperationCallback callback;
+	gpointer callback_data;
+} UnmountData;
+
+static void
+unmount_done (void *callback_data)
+{
+	UnmountData *data;
+
+	data = (UnmountData *)callback_data;
+	if (data->callback) {
+		data->callback (data->file, NULL, NULL, data->callback_data);
+	}
+	nautilus_file_unref (data->file);
+	g_free (data);
+}
+
 void
 nautilus_file_unmount (NautilusFile                   *file,
 		       GMountOperation                *mount_op,
@@ -1225,6 +1244,7 @@ nautilus_file_unmount (NautilusFile                   *file,
 		       gpointer                        callback_data)
 {
 	GError *error;
+	UnmountData *data;
 
 	if (file->details->can_unmount) {
 		if (NAUTILUS_FILE_GET_CLASS (file)->unmount != NULL) {
@@ -1240,7 +1260,13 @@ nautilus_file_unmount (NautilusFile                   *file,
 		}
 	} else if (file->details->mount != NULL &&
 		   g_mount_can_unmount (file->details->mount)) {
-		nautilus_file_operations_unmount_mount (NULL, file->details->mount, FALSE, TRUE);
+		data = g_new0 (UnmountData, 1);
+		data->file = nautilus_file_ref (file);
+		data->callback = callback;
+		data->callback_data = callback_data;
+		nautilus_file_operations_unmount_mount_full (NULL, file->details->mount, FALSE, TRUE, unmount_done, data);
+	} else if (callback) {
+		callback (file, NULL, NULL, callback_data);
 	}
 }
 
@@ -1252,6 +1278,7 @@ nautilus_file_eject (NautilusFile                   *file,
 		     gpointer                        callback_data)
 {
 	GError *error;
+	UnmountData *data;
 
 	if (file->details->can_eject) {
 		if (NAUTILUS_FILE_GET_CLASS (file)->eject != NULL) {
@@ -1267,7 +1294,13 @@ nautilus_file_eject (NautilusFile                   *file,
 		}
 	} else if (file->details->mount != NULL &&
 		   g_mount_can_eject (file->details->mount)) {
-		nautilus_file_operations_unmount_mount (NULL, file->details->mount, TRUE, TRUE);
+		data = g_new0 (UnmountData, 1);
+		data->file = nautilus_file_ref (file);
+		data->callback = callback;
+		data->callback_data = callback_data;
+		nautilus_file_operations_unmount_mount_full (NULL, file->details->mount, TRUE, TRUE, unmount_done, data);
+	} else if (callback) {
+		callback (file, NULL, NULL, callback_data);
 	}
 }
 



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