[notification-daemon] Add support for resident notifications



commit 323dc4bae2ccf573261cfdd2880c36ca7e5fd8a2
Author: William Jon McCann <jmccann redhat com>
Date:   Thu Oct 28 19:20:59 2010 -0400

    Add support for resident notifications
    
    These don't close automatically when the user invokes an action on them.
    This is useful for things like music players.

 src/daemon.c          |    5 ++++-
 src/nd-notification.c |   17 +++++++++++++++++
 src/nd-notification.h |    1 +
 3 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/src/daemon.c b/src/daemon.c
index f93002c..aee57c3 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -167,7 +167,10 @@ on_notification_action_invoked (NdNotification *notification,
                                        g_variant_new ("(us)", nd_notification_get_id (notification), action),
                                        NULL);
 
-        nd_notification_close (notification, ND_NOTIFICATION_CLOSED_USER);
+        /* resident notifications don't close when actions are invoked */
+        if (! nd_notification_get_is_resident (notification)) {
+                nd_notification_close (notification, ND_NOTIFICATION_CLOSED_USER);
+        }
 }
 
 /* ---------------------------------------------------------------------------------------------- */
diff --git a/src/nd-notification.c b/src/nd-notification.c
index fb5ddc2..755eb9a 100644
--- a/src/nd-notification.c
+++ b/src/nd-notification.c
@@ -240,6 +240,23 @@ nd_notification_get_is_transient (NdNotification *notification)
         return ret;
 }
 
+gboolean
+nd_notification_get_is_resident (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, "resident");
+        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 5e0124b..2d4b264 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_resident     (NdNotification *notification);
 gboolean              nd_notification_get_is_transient    (NdNotification *notification);
 
 void                  nd_notification_close               (NdNotification *notification,



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