[notification-daemon] Add support for the transient hint



commit ab447732fe828634449cd10d74d7f02588346061
Author: William Jon McCann <jmccann redhat com>
Date:   Thu Oct 28 19:16:56 2010 -0400

    Add support for the transient hint
    
    Once the bubble is shown it is removed from the queue when it is
    closed or times out.  Normal notifications persist until they
    are acted on.

 src/nd-bubble.c       |    8 ++++++++
 src/nd-bubble.h       |    1 +
 src/nd-notification.c |   17 +++++++++++++++++
 src/nd-notification.h |    1 +
 src/nd-queue.c        |    8 ++++++++
 5 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/src/nd-bubble.c b/src/nd-bubble.c
index f8376b4..fe7df77 100644
--- a/src/nd-bubble.c
+++ b/src/nd-bubble.c
@@ -79,6 +79,14 @@ static void     on_notification_changed (NdNotification *notification,
 
 G_DEFINE_TYPE (NdBubble, nd_bubble, GTK_TYPE_WINDOW)
 
+NdNotification *
+nd_bubble_get_notification (NdBubble *bubble)
+{
+        g_return_val_if_fail (ND_IS_BUBBLE (bubble), NULL);
+
+        return bubble->priv->notification;
+}
+
 static gboolean
 nd_bubble_configure_event (GtkWidget         *widget,
                            GdkEventConfigure *event)
diff --git a/src/nd-bubble.h b/src/nd-bubble.h
index 617c653..4ddfbfb 100644
--- a/src/nd-bubble.h
+++ b/src/nd-bubble.h
@@ -53,6 +53,7 @@ GType               nd_bubble_get_type                      (void);
 
 NdBubble *          nd_bubble_new_for_notification          (NdNotification *notification);
 
+NdNotification *    nd_bubble_get_notification              (NdBubble       *bubble);
 
 G_END_DECLS
 
diff --git a/src/nd-notification.c b/src/nd-notification.c
index dffb099..fb5ddc2 100644
--- a/src/nd-notification.c
+++ b/src/nd-notification.c
@@ -223,6 +223,23 @@ nd_notification_get_is_closed (NdNotification *notification)
         return notification->is_closed;
 }
 
+gboolean
+nd_notification_get_is_transient (NdNotification *notification)
+{
+        gboolean  ret;
+        GVariant *value;
+
+        ret = FALSE;
+        g_return_val_if_fail (ND_IS_NOTIFICATION (notification), FALSE);
+
+        value = g_hash_table_lookup (notification->hints, "transient");
+        if (value != NULL) {
+                ret = g_variant_get_boolean (value);
+        }
+
+        return ret;
+}
+
 guint32
 nd_notification_get_id (NdNotification *notification)
 {
diff --git a/src/nd-notification.h b/src/nd-notification.h
index b6dc19b..5e0124b 100644
--- a/src/nd-notification.h
+++ b/src/nd-notification.h
@@ -72,6 +72,7 @@ GHashTable *          nd_notification_get_hints           (NdNotification *notif
 
 GdkPixbuf *           nd_notification_load_image          (NdNotification *notification,
                                                            int             size);
+gboolean              nd_notification_get_is_transient    (NdNotification *notification);
 
 void                  nd_notification_close               (NdNotification *notification,
                                                            NdNotificationClosedReason reason);
diff --git a/src/nd-queue.c b/src/nd-queue.c
index a07edd2..a3a0164 100644
--- a/src/nd-queue.c
+++ b/src/nd-queue.c
@@ -590,7 +590,15 @@ static void
 on_bubble_destroyed (NdBubble *bubble,
                      NdQueue  *queue)
 {
+        NdNotification *notification;
+
         g_debug ("Bubble destroyed");
+        notification = nd_bubble_get_notification (bubble);
+        if (nd_notification_get_is_transient (notification)) {
+                g_debug ("Bubble is transient");
+                nd_notification_close (notification, ND_NOTIFICATION_CLOSED_EXPIRED);
+        }
+
         queue_update (queue);
 }
 



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