diff options
author | Matthias Clasen <mclasen@redhat.com> | 2014-01-27 21:52:01 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-01-27 21:53:49 -0500 |
commit | 3d17e3f88c8e4ef7add2b5db1884dc6c43b1e884 (patch) | |
tree | a1dbc183afaae93da743a14c93e6de6c81a5987c /gtk/gtkplacessidebar.c | |
parent | 04e8d9fa5ed795c003d9dae98b4cb6705fe5457f (diff) | |
download | gtk+-3d17e3f88c8e4ef7add2b5db1884dc6c43b1e884.tar.gz |
GtkPlacesSidebar: Stop drives that can be stopped
Removable USB drives or memory sticks should be powered down
when the eject button is pressed. For this, we need to call
g_drive_stop() instead of g_drive_eject(), provided the drive
can be stopped.
https://bugzilla.gnome.org/show_bug.cgi?id=723121
Diffstat (limited to 'gtk/gtkplacessidebar.c')
-rw-r--r-- | gtk/gtkplacessidebar.c | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c index e53680bef1..738c3b7ab3 100644 --- a/gtk/gtkplacessidebar.c +++ b/gtk/gtkplacessidebar.c @@ -2636,6 +2636,35 @@ unmount_shortcut_cb (GtkMenuItem *item, } static void +drive_stop_cb (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + GtkPlacesSidebar *sidebar; + GError *error; + gchar *primary; + gchar *name; + + sidebar = user_data; + + error = NULL; + if (!g_drive_stop_finish (G_DRIVE (source_object), res, &error)) + { + if (error->code != G_IO_ERROR_FAILED_HANDLED) + { + name = g_drive_get_name (G_DRIVE (source_object)); + primary = g_strdup_printf (_("Unable to stop %s"), name); + g_free (name); + emit_show_error_message (sidebar, primary, error->message); + g_free (primary); + } + g_error_free (error); + } + + g_object_unref (sidebar); +} + +static void drive_eject_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) @@ -2738,8 +2767,14 @@ do_eject (GMount *mount, g_volume_eject_with_operation (volume, 0, mount_op, NULL, volume_eject_cb, g_object_ref (sidebar)); else if (drive != NULL) - g_drive_eject_with_operation (drive, 0, mount_op, NULL, drive_eject_cb, - g_object_ref (sidebar)); + { + if (g_drive_can_stop (drive)) + g_drive_stop (drive, 0, mount_op, NULL, drive_stop_cb, + g_object_ref (sidebar)); + else + g_drive_eject_with_operation (drive, 0, mount_op, NULL, drive_eject_cb, + g_object_ref (sidebar)); + } g_object_unref (mount_op); } @@ -2940,35 +2975,6 @@ start_shortcut_cb (GtkMenuItem *item, } static void -drive_stop_cb (GObject *source_object, - GAsyncResult *res, - gpointer user_data) -{ - GtkPlacesSidebar *sidebar; - GError *error; - gchar *primary; - gchar *name; - - sidebar = user_data; - - error = NULL; - if (!g_drive_stop_finish (G_DRIVE (source_object), res, &error)) - { - if (error->code != G_IO_ERROR_FAILED_HANDLED) - { - name = g_drive_get_name (G_DRIVE (source_object)); - primary = g_strdup_printf (_("Unable to stop %s"), name); - g_free (name); - emit_show_error_message (sidebar, primary, error->message); - g_free (primary); - } - g_error_free (error); - } - - g_object_unref (sidebar); -} - -static void stop_shortcut_cb (GtkMenuItem *item, GtkPlacesSidebar *sidebar) { |