[PATCH 3/4] applet: correctly update notification messages



---
 src/applet.c | 46 +++++++++++++++++-----------------------------
 1 file changed, 17 insertions(+), 29 deletions(-)

diff --git a/src/applet.c b/src/applet.c
index 66984de..bcbc76d 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -869,17 +869,6 @@ applet_menu_item_create_device_item_helper (NMDevice *device,
        return item;
 }
 
-static void
-applet_clear_notify (NMApplet *applet)
-{
-       if (applet->notification == NULL)
-               return;
-
-       notify_notification_close (applet->notification, NULL);
-       g_object_unref (applet->notification);
-       applet->notification = NULL;
-}
-
 static gboolean
 applet_notify_server_has_actions (void)
 {
@@ -930,19 +919,28 @@ applet_do_notify (NMApplet *applet,
        if (!nm_secret_agent_get_registered (NM_SECRET_AGENT (applet->agent)))
                return;
 
-       applet_clear_notify (applet);
-
        escaped = utils_escape_notify_message (message);
-       notify = notify_notification_new (summary,
-                                         escaped,
-                                         icon ? icon : GTK_STOCK_NETWORK
+
+       if (applet->notification == NULL) {
+               notify = notify_notification_new (summary,
+                                                 escaped,
+                                                 icon ? icon : GTK_STOCK_NETWORK
 #if HAVE_LIBNOTIFY_07
-                                         );
+                                                 );
 #else
-                                         , NULL);
+                                                , NULL);
 #endif
+
+               applet->notification = notify;
+       } else {
+               notify = applet->notification;
+               notify_notification_update (notify,
+                                           summary,
+                                           escaped,
+                                           icon ? icon : GTK_STOCK_NETWORK);
+       }
+
        g_free (escaped);
-       applet->notification = notify;
 
 #if HAVE_LIBNOTIFY_07
        notify_notification_set_hint (notify, "transient", g_variant_new_boolean (TRUE));
@@ -3386,11 +3384,6 @@ status_icon_size_changed_cb (GtkStatusIcon *icon,
 static void
 status_icon_activate_cb (GtkStatusIcon *icon, NMApplet *applet)
 {
-       /* Have clicking on the applet act also as acknowledgement
-        * of the notification. 
-        */
-       applet_clear_notify (applet);
-
        /* Kill any old menu */
        if (applet->menu)
                g_object_unref (applet->menu);
@@ -3416,11 +3409,6 @@ status_icon_popup_menu_cb (GtkStatusIcon *icon,
                            guint32 activate_time,
                            NMApplet *applet)
 {
-       /* Have clicking on the applet act also as acknowledgement
-        * of the notification. 
-        */
-       applet_clear_notify (applet);
-
        nma_context_menu_update (applet);
        gtk_menu_popup (GTK_MENU (applet->context_menu), NULL, NULL,
                        gtk_status_icon_position_menu, icon,
-- 
1.8.1.2



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