[gnome-settings-daemon] updates: Make sure only one notification appears



commit f22af4598ffa289ab084a17dcdb8676e596b07df
Author: Richard Hughes <richard hughsie com>
Date:   Mon Jan 14 15:25:00 2013 +0000

    updates: Make sure only one notification appears
    
    With an unfinished "yum-complete-transaction to run"[1],
    the updates plugin started filling the message tray with "Software
    Updates Failed" errors.
    
    This patch removes the previous notification when adding a new one.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=691627

 plugins/updates/gsd-updates-manager.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/plugins/updates/gsd-updates-manager.c b/plugins/updates/gsd-updates-manager.c
index bb242ab..dc60e12 100644
--- a/plugins/updates/gsd-updates-manager.c
+++ b/plugins/updates/gsd-updates-manager.c
@@ -57,6 +57,7 @@ struct GsdUpdatesManagerPrivate
         guint                    offline_update_id;
         PkError                 *offline_update_error;
         NotifyNotification      *notification_updates;
+        NotifyNotification      *notification_offline_success;
         PkControl               *control;
         PkTask                  *task;
         guint                    inhibit_cookie;
@@ -1229,6 +1230,13 @@ check_offline_update_cb (gpointer user_data)
 
         /* do the bubble */
         g_debug ("title=%s, message=%s", title, message);
+
+        /* close any existing notification */
+        if (manager->priv->notification_offline_success != NULL) {
+                notify_notification_close (manager->priv->notification_offline_success, NULL);
+                manager->priv->notification_offline_success = NULL;
+        }
+
         notification = notify_notification_new (title,
                                                 message,
                                                 GSD_UPDATES_ICON_URGENT);
@@ -1252,6 +1260,9 @@ check_offline_update_cb (gpointer user_data)
                                         _("OK"), libnotify_action_cb, manager, NULL);
         g_signal_connect (notification, "closed",
                           G_CALLBACK (on_notification_closed), NULL);
+        manager->priv->notification_offline_success = notification;
+        g_object_add_weak_pointer (G_OBJECT (manager->priv->notification_offline_success),
+                                   (void **) &manager->priv->notification_offline_success);
         ret = notify_notification_show (notification, &error);
         if (!ret) {
                 g_warning ("error: %s", error->message);


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