[gnome-disk-utility] Don't present "disk is failing" notification more than once



commit 0f0cfb8fd9bf687ee900fa78f966c1150a472b10
Author: David Zeuthen <zeuthen gmail com>
Date:   Thu Nov 15 12:13:31 2012 -0500

    Don't present "disk is failing" notification more than once
    
    Without this fix, we would present the notification on *every*
    UDisksClient::changed signal even though the user had already
    dismissed it (very annoying behavior).
    
    With this fix we'll present the notification again after user
    dismissal, ONLY if
    
     a. the problem goes away - for example the user removing the
        failing disk; and
    
     b. the problem comes back - for example, the user attaching another
        failing disk (same disk or other - doesn't matter)
    
    Signed-off-by: David Zeuthen <zeuthen gmail com>

 src/notify/gdusdmonitor.c |   29 +++++++++++++++++------------
 1 files changed, 17 insertions(+), 12 deletions(-)
---
diff --git a/src/notify/gdusdmonitor.c b/src/notify/gdusdmonitor.c
index 7267663..92224a9 100644
--- a/src/notify/gdusdmonitor.c
+++ b/src/notify/gdusdmonitor.c
@@ -289,18 +289,23 @@ update_notification (GduSdMonitor        *monitor,
 {
   if (g_list_length (problems) > 0)
     {
-      g_warn_if_fail (*notification == NULL);
-      *notification = notify_notification_new (title, text, icon_name);
-      notify_notification_set_urgency (*notification, NOTIFY_URGENCY_CRITICAL);
-      notify_notification_set_timeout (*notification, NOTIFY_EXPIRES_NEVER);
-      notify_notification_set_hint_string (*notification, "desktop-entry", "gnome-disks");
-      notify_notification_add_action (*notification,
-                                      action,
-                                      action_label,
-                                      (NotifyActionCallback) on_examine_action_clicked,
-                                      monitor,
-                                      NULL);
-      notify_notification_show (*notification, NULL);
+      /* it could be the notification has already been presented, in that
+       * case, don't show another one
+       */
+      if (*notification == NULL)
+        {
+          *notification = notify_notification_new (title, text, icon_name);
+          notify_notification_set_urgency (*notification, NOTIFY_URGENCY_CRITICAL);
+          notify_notification_set_timeout (*notification, NOTIFY_EXPIRES_NEVER);
+          notify_notification_set_hint_string (*notification, "desktop-entry", "gnome-disks");
+          notify_notification_add_action (*notification,
+                                          action,
+                                          action_label,
+                                          (NotifyActionCallback) on_examine_action_clicked,
+                                          monitor,
+                                          NULL);
+          notify_notification_show (*notification, NULL);
+        }
     }
   else
     {



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