summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2012-12-11 11:25:45 -0500
committerCosimo Cecchi <cosimoc@gnome.org>2012-12-11 11:29:03 -0500
commit463e8d1b1922474e4cf591a3029ea813804bd3e7 (patch)
treeed0d139355d7394803caf8387bca815aaf7e9de9
parente6b70a2cb8acdc1998e89e54e2a9819853f05793 (diff)
downloadnautilus-463e8d1b1922474e4cf591a3029ea813804bd3e7.tar.gz
places-sidebar: make sure to always notify when unmounting
When unmounting from the sidebar with an operation other than eject, we still need to set up the progress notification, as some drives return FALSE for can_eject. https://bugzilla.redhat.com/show_bug.cgi?id=885133
-rw-r--r--libnautilus-private/nautilus-file-operations.c42
-rw-r--r--libnautilus-private/nautilus-file-operations.h1
-rw-r--r--libnautilus-private/nautilus-file.c4
-rw-r--r--src/nautilus-places-sidebar.c79
4 files changed, 74 insertions, 52 deletions
diff --git a/libnautilus-private/nautilus-file-operations.c b/libnautilus-private/nautilus-file-operations.c
index 85d5a6f1f..d95533194 100644
--- a/libnautilus-private/nautilus-file-operations.c
+++ b/libnautilus-private/nautilus-file-operations.c
@@ -2028,12 +2028,26 @@ nautilus_file_operations_delete (GList *files,
typedef struct {
gboolean eject;
GMount *mount;
+ GMountOperation *mount_operation;
GtkWindow *parent_window;
NautilusUnmountCallback callback;
gpointer callback_data;
} UnmountData;
static void
+unmount_data_free (UnmountData *data)
+{
+ if (data->parent_window) {
+ g_object_remove_weak_pointer (G_OBJECT (data->parent_window),
+ (gpointer *) &data->parent_window);
+ }
+
+ g_clear_object (&data->mount_operation);
+ g_object_unref (data->mount);
+ g_free (data);
+}
+
+static void
unmount_mount_callback (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
@@ -2073,14 +2087,8 @@ unmount_mount_callback (GObject *source_object,
if (error != NULL) {
g_error_free (error);
}
-
- if (data->parent_window) {
- g_object_remove_weak_pointer (G_OBJECT (data->parent_window),
- (gpointer *) &data->parent_window);
- }
- g_object_unref (data->mount);
- g_free (data);
+ unmount_data_free (data);
}
static void
@@ -2088,7 +2096,11 @@ do_unmount (UnmountData *data)
{
GMountOperation *mount_op;
- mount_op = gtk_mount_operation_new (data->parent_window);
+ if (data->mount_operation) {
+ mount_op = g_object_ref (data->mount_operation);
+ } else {
+ mount_op = gtk_mount_operation_new (data->parent_window);
+ }
if (data->eject) {
g_mount_eject_with_operation (data->mount,
0,
@@ -2260,6 +2272,7 @@ empty_trash_for_unmount_done (gboolean success,
void
nautilus_file_operations_unmount_mount_full (GtkWindow *parent_window,
GMount *mount,
+ GMountOperation *mount_operation,
gboolean eject,
gboolean check_trash,
NautilusUnmountCallback callback,
@@ -2277,6 +2290,9 @@ nautilus_file_operations_unmount_mount_full (GtkWindow *par
(gpointer *) &data->parent_window);
}
+ if (mount_operation) {
+ data->mount_operation = g_object_ref (mount_operation);
+ }
data->eject = eject;
data->mount = g_object_ref (mount);
@@ -2302,13 +2318,7 @@ nautilus_file_operations_unmount_mount_full (GtkWindow *par
callback (callback_data);
}
- if (data->parent_window) {
- g_object_remove_weak_pointer (G_OBJECT (data->parent_window),
- (gpointer *) &data->parent_window);
- }
-
- g_object_unref (data->mount);
- g_free (data);
+ unmount_data_free (data);
return;
}
}
@@ -2322,7 +2332,7 @@ nautilus_file_operations_unmount_mount (GtkWindow *parent_w
gboolean eject,
gboolean check_trash)
{
- nautilus_file_operations_unmount_mount_full (parent_window, mount, eject,
+ nautilus_file_operations_unmount_mount_full (parent_window, mount, NULL, eject,
check_trash, NULL, NULL);
}
diff --git a/libnautilus-private/nautilus-file-operations.h b/libnautilus-private/nautilus-file-operations.h
index 55f747931..e0af1001c 100644
--- a/libnautilus-private/nautilus-file-operations.h
+++ b/libnautilus-private/nautilus-file-operations.h
@@ -107,6 +107,7 @@ void nautilus_file_operations_unmount_mount (GtkWindow *par
gboolean check_trash);
void nautilus_file_operations_unmount_mount_full (GtkWindow *parent_window,
GMount *mount,
+ GMountOperation *mount_operation,
gboolean eject,
gboolean check_trash,
NautilusUnmountCallback callback,
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index af421022f..84be583bd 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -1262,7 +1262,7 @@ nautilus_file_unmount (NautilusFile *file,
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);
+ nautilus_file_operations_unmount_mount_full (NULL, file->details->mount, NULL, FALSE, TRUE, unmount_done, data);
} else if (callback) {
callback (file, NULL, NULL, callback_data);
}
@@ -1296,7 +1296,7 @@ nautilus_file_eject (NautilusFile *file,
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);
+ nautilus_file_operations_unmount_mount_full (NULL, file->details->mount, NULL, TRUE, TRUE, unmount_done, data);
} else if (callback) {
callback (file, NULL, NULL, callback_data);
}
diff --git a/src/nautilus-places-sidebar.c b/src/nautilus-places-sidebar.c
index adf07fbb3..224a2da90 100644
--- a/src/nautilus-places-sidebar.c
+++ b/src/nautilus-places-sidebar.c
@@ -1975,13 +1975,55 @@ unmount_done (gpointer data)
}
static void
+show_unmount_progress_cb (GMountOperation *op,
+ const gchar *message,
+ gint64 time_left,
+ gint64 bytes_left,
+ gpointer user_data)
+{
+ NautilusApplication *app = NAUTILUS_APPLICATION (g_application_get_default ());
+
+ if (bytes_left == 0) {
+ nautilus_application_notify_unmount_done (app, message);
+ } else {
+ nautilus_application_notify_unmount_show (app, message);
+ }
+}
+
+static void
+show_unmount_progress_aborted_cb (GMountOperation *op,
+ gpointer user_data)
+{
+ NautilusApplication *app = NAUTILUS_APPLICATION (g_application_get_default ());
+ nautilus_application_notify_unmount_done (app, NULL);
+}
+
+static GMountOperation *
+get_unmount_operation (NautilusPlacesSidebar *sidebar)
+{
+ GMountOperation *mount_op;
+
+ mount_op = gtk_mount_operation_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (sidebar))));
+ g_signal_connect (mount_op, "show-unmount-progress",
+ G_CALLBACK (show_unmount_progress_cb), sidebar);
+ g_signal_connect (mount_op, "aborted",
+ G_CALLBACK (show_unmount_progress_aborted_cb), sidebar);
+
+ return mount_op;
+}
+
+static void
do_unmount (GMount *mount,
NautilusPlacesSidebar *sidebar)
{
+ GMountOperation *mount_op;
+
if (mount != NULL) {
- nautilus_file_operations_unmount_mount_full (NULL, mount, FALSE, TRUE,
+ mount_op = get_unmount_operation (sidebar);
+ nautilus_file_operations_unmount_mount_full (NULL, mount, mount_op, FALSE, TRUE,
unmount_done,
g_object_ref (sidebar->window));
+ g_object_unref (mount_op);
}
}
@@ -2013,30 +2055,6 @@ unmount_shortcut_cb (GtkMenuItem *item,
}
static void
-show_unmount_progress_cb (GMountOperation *op,
- const gchar *message,
- gint64 time_left,
- gint64 bytes_left,
- gpointer user_data)
-{
- NautilusApplication *app = NAUTILUS_APPLICATION (g_application_get_default ());
-
- if (bytes_left == 0) {
- nautilus_application_notify_unmount_done (app, message);
- } else {
- nautilus_application_notify_unmount_show (app, message);
- }
-}
-
-static void
-show_unmount_progress_aborted_cb (GMountOperation *op,
- gpointer user_data)
-{
- NautilusApplication *app = NAUTILUS_APPLICATION (g_application_get_default ());
- nautilus_application_notify_unmount_done (app, NULL);
-}
-
-static void
drive_eject_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
@@ -2126,9 +2144,8 @@ do_eject (GMount *mount,
GDrive *drive,
NautilusPlacesSidebar *sidebar)
{
- GMountOperation *mount_op;
+ GMountOperation *mount_op = get_unmount_operation (sidebar);
- mount_op = gtk_mount_operation_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (sidebar))));
if (mount != NULL) {
g_mount_eject_with_operation (mount, 0, mount_op, NULL, mount_eject_cb,
g_object_ref (sidebar->window));
@@ -2140,10 +2157,6 @@ do_eject (GMount *mount,
g_object_ref (sidebar->window));
}
- g_signal_connect (mount_op, "show-unmount-progress",
- G_CALLBACK (show_unmount_progress_cb), sidebar);
- g_signal_connect (mount_op, "aborted",
- G_CALLBACK (show_unmount_progress_aborted_cb), sidebar);
g_object_unref (mount_op);
}
@@ -2381,9 +2394,7 @@ stop_shortcut_cb (GtkMenuItem *item,
-1);
if (drive != NULL) {
- GMountOperation *mount_op;
-
- mount_op = gtk_mount_operation_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (sidebar))));
+ GMountOperation *mount_op = get_unmount_operation (sidebar);
g_drive_stop (drive, G_MOUNT_UNMOUNT_NONE, mount_op, NULL, drive_stop_cb,
g_object_ref (sidebar->window));
g_object_unref (mount_op);