From 075f579472944457b372c8aa127ab612cc8f9b5e Mon Sep 17 00:00:00 2001 From: Eric Koegel Date: Fri, 1 Feb 2013 08:08:16 +0300 Subject: [PATCH] Fix eject/unmount notifications so that it correctly says when it was successful. --- src/xfdesktop-notify.c | 14 ++++++++++++-- src/xfdesktop-notify.h | 4 ++-- src/xfdesktop-volume-icon.c | 14 ++++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/xfdesktop-notify.c b/src/xfdesktop-notify.c index 1430e39..ae55a96 100644 --- a/src/xfdesktop-notify.c +++ b/src/xfdesktop-notify.c @@ -168,7 +168,7 @@ xfdesktop_notify_unmount (GMount *mount) void -xfdesktop_notify_unmount_finish (GMount *mount) +xfdesktop_notify_unmount_finish (GMount *mount, gboolean unmount_successful) { const gchar * const *icon_names; NotifyNotification *notification = NULL; @@ -215,6 +215,11 @@ xfdesktop_notify_unmount_finish (GMount *mount) g_object_set_data (G_OBJECT (mount), "xfdesktop-notification", NULL); } + /* if the unmount operation wasn't successful then stop here, otherwise + * display a message letting the user know it has been removed */ + if(!unmount_successful) + return; + summary = _("Unmount Finished"); message = g_strdup_printf (_("The device \"%s\" has been safely removed from the system. "), name); @@ -343,7 +348,7 @@ xfdesktop_notify_eject (GVolume *volume) void -xfdesktop_notify_eject_finish (GVolume *volume) +xfdesktop_notify_eject_finish (GVolume *volume, gboolean eject_successful) { const gchar * const *icon_names; NotifyNotification *notification = NULL; @@ -390,6 +395,11 @@ xfdesktop_notify_eject_finish (GVolume *volume) g_object_set_data (G_OBJECT (volume), "xfdesktop-notification", NULL); } + /* if the eject operation wasn't successful then stop here, otherwise + * display a message letting the user know it has been removed */ + if(!eject_successful) + return; + summary = _("Eject Finished"); message = g_strdup_printf (_("The device \"%s\" has been safely removed from the system. "), name); diff --git a/src/xfdesktop-notify.h b/src/xfdesktop-notify.h index a547b65..55d08b3 100644 --- a/src/xfdesktop-notify.h +++ b/src/xfdesktop-notify.h @@ -27,9 +27,9 @@ G_BEGIN_DECLS void xfdesktop_notify_unmount (GMount *mount); -void xfdesktop_notify_unmount_finish (GMount *mount); +void xfdesktop_notify_unmount_finish (GMount *mount, gboolean unmount_successful); void xfdesktop_notify_eject (GVolume *volume); -void xfdesktop_notify_eject_finish (GVolume *volume); +void xfdesktop_notify_eject_finish (GVolume *volume, gboolean eject_successful); void xfdesktop_notify_uninit (void); G_END_DECLS diff --git a/src/xfdesktop-volume-icon.c b/src/xfdesktop-volume-icon.c index 50bcc45..902842a 100644 --- a/src/xfdesktop-volume-icon.c +++ b/src/xfdesktop-volume-icon.c @@ -468,12 +468,15 @@ xfdesktop_volume_icon_eject_finish(GObject *object, GtkWidget *toplevel = icon_view ? gtk_widget_get_toplevel(icon_view) : NULL; GVolume *volume = G_VOLUME(object); GError *error = NULL; + gboolean eject_successful; g_return_if_fail(G_IS_VOLUME(object)); g_return_if_fail(G_IS_ASYNC_RESULT(result)); g_return_if_fail(XFDESKTOP_IS_VOLUME_ICON(icon)); - if(!g_volume_eject_with_operation_finish(volume, result, &error)) { + eject_successful = g_volume_eject_with_operation_finish(volume, result, &error); + + if(!eject_successful) { /* ignore GIO errors handled internally */ if(error->domain != G_IO_ERROR || error->code != G_IO_ERROR_FAILED_HANDLED) { gchar *volume_name = g_volume_get_name(volume); @@ -494,7 +497,7 @@ xfdesktop_volume_icon_eject_finish(GObject *object, } #ifdef HAVE_LIBNOTIFY - xfdesktop_notify_eject_finish(volume); + xfdesktop_notify_eject_finish(volume, eject_successful); #endif g_object_unref(icon); @@ -510,12 +513,15 @@ xfdesktop_volume_icon_unmount_finish(GObject *object, GtkWidget *toplevel = gtk_widget_get_toplevel(icon_view); GMount *mount = G_MOUNT(object); GError *error = NULL; + gboolean unmount_successful; g_return_if_fail(G_IS_MOUNT(object)); g_return_if_fail(G_IS_ASYNC_RESULT(result)); g_return_if_fail(XFDESKTOP_IS_VOLUME_ICON(icon)); - if(!g_mount_unmount_with_operation_finish(mount, result, &error)) { + unmount_successful = g_mount_unmount_with_operation_finish(mount, result, &error); + + if(!unmount_successful) { /* ignore GIO errors handled internally */ if(error->domain != G_IO_ERROR || error->code != G_IO_ERROR_FAILED_HANDLED) { gchar *mount_name = g_mount_get_name(mount); @@ -536,7 +542,7 @@ xfdesktop_volume_icon_unmount_finish(GObject *object, } #ifdef HAVE_LIBNOTIFY - xfdesktop_notify_unmount_finish(mount); + xfdesktop_notify_unmount_finish(mount, unmount_successful); #endif g_object_unref(icon); -- 1.7.10.4