[nautilus] Add nautilus_file_operations_unmount_mount_full with a callback



commit 7fb5d7f6e4c32ab391eb9f3a61c0cab59c585874
Author: Alexander Larsson <alexl redhat com>
Date:   Mon Mar 8 13:32:39 2010 +0100

    Add nautilus_file_operations_unmount_mount_full with a callback

 libnautilus-private/nautilus-file-operations.c |   38 ++++++++++++++++++++----
 libnautilus-private/nautilus-file-operations.h |    7 ++++
 2 files changed, 39 insertions(+), 6 deletions(-)
---
diff --git a/libnautilus-private/nautilus-file-operations.c b/libnautilus-private/nautilus-file-operations.c
index 9f3503e..2aae361 100644
--- a/libnautilus-private/nautilus-file-operations.c
+++ b/libnautilus-private/nautilus-file-operations.c
@@ -1996,12 +1996,14 @@ typedef struct {
 	gboolean eject;
 	GMount *mount;
 	GtkWindow *parent_window;
+	NautilusUnmountCallback callback;
+	gpointer callback_data;
 } UnmountData;
 
 static void
 unmount_mount_callback (GObject *source_object,
-			 GAsyncResult *res,
-			 gpointer user_data)
+			GAsyncResult *res,
+			gpointer user_data)
 {
 	UnmountData *data = user_data;
 	GError *error;
@@ -2029,6 +2031,13 @@ unmount_mount_callback (GObject *source_object,
 					       data->parent_window);
 			g_free (primary);
 		}
+	}
+
+	if (data->callback) {
+		data->callback (data->callback_data);
+	}
+
+	if (error != NULL) {
 		g_error_free (error);
 	}
 	
@@ -2204,15 +2213,19 @@ prompt_empty_trash (GtkWindow *parent_window)
 }
 
 void
-nautilus_file_operations_unmount_mount (GtkWindow                      *parent_window,
-					GMount                         *mount,
-					gboolean                        eject,
-					gboolean                        check_trash)
+nautilus_file_operations_unmount_mount_full (GtkWindow                      *parent_window,
+					     GMount                         *mount,
+					     gboolean                        eject,
+					     gboolean                        check_trash,
+					     NautilusUnmountCallback         callback,
+					     gpointer                        callback_data)
 {
 	UnmountData *data;
 	int response;
 
 	data = g_new0 (UnmountData, 1);
+	data->callback = callback;
+	data->callback_data = callback_data;
 	if (parent_window) {
 		data->parent_window = parent_window;
 		eel_add_weak_pointer (&data->parent_window);
@@ -2239,6 +2252,9 @@ nautilus_file_operations_unmount_mount (GtkWindow                      *parent_w
 					   NULL);
 			return;
 		} else if (response == GTK_RESPONSE_CANCEL) {
+			if (callback) {
+				callback (callback_data);
+			}
 			eel_remove_weak_pointer (&data->parent_window);
 			g_object_unref (data->mount);
 			g_free (data);
@@ -2249,6 +2265,16 @@ nautilus_file_operations_unmount_mount (GtkWindow                      *parent_w
 	do_unmount (data);
 }
 
+void
+nautilus_file_operations_unmount_mount (GtkWindow                      *parent_window,
+					GMount                         *mount,
+					gboolean                        eject,
+					gboolean                        check_trash)
+{
+	nautilus_file_operations_unmount_mount_full (parent_window, mount, eject,
+						     check_trash, NULL, NULL);
+}
+
 static void
 mount_callback_data_notify (gpointer data,
 			    GObject *object)
diff --git a/libnautilus-private/nautilus-file-operations.h b/libnautilus-private/nautilus-file-operations.h
index 7c19e25..b851bce 100644
--- a/libnautilus-private/nautilus-file-operations.h
+++ b/libnautilus-private/nautilus-file-operations.h
@@ -40,6 +40,7 @@ typedef void (* NautilusDeleteCallback)    (GHashTable *debuting_uris,
 					    gpointer    callback_data);
 typedef void (* NautilusMountCallback)     (GVolume    *volume,
 					    GObject    *callback_data_object);
+typedef void (* NautilusUnmountCallback)   (gpointer    callback_data);
 
 /* FIXME: int copy_action should be an enum */
 
@@ -93,6 +94,12 @@ void nautilus_file_operations_unmount_mount (GtkWindow                      *par
 					     GMount                         *mount,
 					     gboolean                        eject,
 					     gboolean                        check_trash);
+void nautilus_file_operations_unmount_mount_full (GtkWindow                 *parent_window,
+						  GMount                    *mount,
+						  gboolean                   eject,
+						  gboolean                   check_trash,
+						  NautilusUnmountCallback    callback,
+						  gpointer                   callback_data);
 void nautilus_file_operations_mount_volume  (GtkWindow                      *parent_window,
 					     GVolume                        *volume,
 					     gboolean                        allow_autorun);



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