[gnome-flashback] notifications: close bubble on API call



commit 453781f5ccdc68953a480369d656478a0142665e
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Sep 7 15:57:47 2018 +0300

    notifications: close bubble on API call
    
    If notification is closed with API call make sure that notification
    bubble is also closed / destroyed.

 gnome-flashback/libnotifications/gf-bubble.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
---
diff --git a/gnome-flashback/libnotifications/gf-bubble.c b/gnome-flashback/libnotifications/gf-bubble.c
index 21cf8ae..f185a6c 100644
--- a/gnome-flashback/libnotifications/gf-bubble.c
+++ b/gnome-flashback/libnotifications/gf-bubble.c
@@ -48,6 +48,7 @@ typedef struct
 
   guint           timeout_id;
   gulong          changed_id;
+  gulong          closed_id;
 } GfBubblePrivate;
 
 G_DEFINE_TYPE_WITH_PRIVATE (GfBubble, gf_bubble, GF_TYPE_POPUP_WINDOW)
@@ -400,6 +401,15 @@ notification_changed_cb (NdNotification *notification,
   update_bubble (bubble);
 }
 
+static void
+notification_closed_cb (NdNotification *notification,
+                        gint            reason,
+                        GfBubble       *bubble)
+{
+  if (reason == ND_NOTIFICATION_CLOSED_API)
+    gtk_widget_destroy (GTK_WIDGET (bubble));
+}
+
 static void
 gf_bubble_dispose (GObject *object)
 {
@@ -421,6 +431,12 @@ gf_bubble_dispose (GObject *object)
       priv->changed_id = 0;
     }
 
+  if (priv->closed_id != 0)
+    {
+      g_signal_handler_disconnect (priv->notification, priv->closed_id);
+      priv->closed_id = 0;
+    }
+
   G_OBJECT_CLASS (gf_bubble_parent_class)->dispose (object);
 }
 
@@ -674,10 +690,15 @@ gf_bubble_new_for_notification (NdNotification *notification)
   priv = gf_bubble_get_instance_private (bubble);
 
   priv->notification = g_object_ref (notification);
+
   priv->changed_id = g_signal_connect (notification, "changed",
                                        G_CALLBACK (notification_changed_cb),
                                        bubble);
 
+  priv->closed_id = g_signal_connect (notification, "closed",
+                                      G_CALLBACK (notification_closed_cb),
+                                      bubble);
+
   update_bubble (bubble);
 
   return bubble;


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