[balsa] Close notification bubble with parent



commit fdb3658a1bb73ebb648dc0488222d8cd69c7be7a
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Mon Jan 18 20:13:33 2010 -0500

    Close notification bubble with parent
    
    	* libbalsa/information.c (lbi_notification_parent_weak_notify),
    	(lbi_notification_closed_cb), (libbalsa_information_varg): close
    	notification bubble with parent.

 ChangeLog              |    6 ++++++
 libbalsa/information.c |   33 ++++++++++++++++++++++++++++++++-
 2 files changed, 38 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c103427..edf4bb7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2010-01-18  Peter Bloomfield
 
+	* libbalsa/information.c (lbi_notification_parent_weak_notify),
+	(lbi_notification_closed_cb), (libbalsa_information_varg): close
+	notification bubble with parent.
+
+2010-01-18  Peter Bloomfield
+
 	* src/balsa-app.h: move nm_state and check_mail_skipped from
 	BalsaApplication to BalsaWindow.
 	* src/main-window.c: ditto.
diff --git a/libbalsa/information.c b/libbalsa/information.c
index cc946ae..7c17069 100644
--- a/libbalsa/information.c
+++ b/libbalsa/information.c
@@ -41,6 +41,29 @@ static gboolean libbalsa_information_idle_handler(struct information_data*);
 
 LibBalsaInformationFunc libbalsa_real_information_func;
 
+static void lbi_notification_closed_cb(NotifyNotification * note,
+                                       gpointer data);
+
+#ifdef HAVE_NOTIFY
+static void
+lbi_notification_parent_weak_notify(gpointer data, GObject * parent)
+{
+    NotifyNotification *note = NOTIFY_NOTIFICATION(data);
+    g_signal_handlers_disconnect_by_func(note, lbi_notification_closed_cb,
+                                         parent);
+    notify_notification_close(note, NULL);
+    g_object_unref(note);
+}
+
+static void
+lbi_notification_closed_cb(NotifyNotification * note, gpointer data)
+{
+    GObject *parent = G_OBJECT(data);
+    g_object_weak_unref(parent, lbi_notification_parent_weak_notify, note);
+    g_object_unref(note);
+}
+#endif
+
 /*
  * We are adding an idle handler - we do not need to hold the gdk lock
  * for this.
@@ -103,8 +126,16 @@ libbalsa_information_varg(GtkWindow *parent, LibBalsaInformationType type,
         g_string_free(escaped, TRUE);
 
         notify_notification_set_timeout(note, 7000);    /* 7 seconds */
+        if (parent) {
+            /* Close with parent if earlier. */
+            g_object_weak_ref(G_OBJECT(parent),
+                              lbi_notification_parent_weak_notify, note);
+            g_signal_connect(note, "closed",
+                             G_CALLBACK(lbi_notification_closed_cb),
+                             parent);
+        } else
+            g_object_unref(note);
         notify_notification_show(note, NULL);
-        g_object_unref(note);
         return;
     }
     /* Fall through to the ordinary notification scheme */



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