From df8ae866eb73d9f58938e8eb710a3931d6d8b6b7 Mon Sep 17 00:00:00 2001 From: Jason Conti Date: Sun, 26 Feb 2012 11:25:51 -0500 Subject: * Rename notification_is_volume to notification_is_private. * Add filters for indicator-sound and brightness notifications. * Strip whitespace leading and trailing whitespace from the summary and body. --- src/notification.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/notification.c') diff --git a/src/notification.c b/src/notification.c index 0788ec2..b75679d 100644 --- a/src/notification.c +++ b/src/notification.c @@ -2,6 +2,7 @@ * notification.c - A gobject subclass to represent a org.freedesktop.Notification.Notify message. */ +#include #include "notification.h" #define COLUMN_APP_NAME 0 @@ -45,7 +46,7 @@ notification_init(Notification *self) self->priv->body = NULL; self->priv->expire_timeout = 0; self->priv->timestamp = NULL; - self->priv->is_volume = FALSE; + self->priv->is_private = FALSE; } static void @@ -122,12 +123,16 @@ notification_new_from_dbus_message(GDBusMessage *message) g_assert(g_variant_is_of_type(child, G_VARIANT_TYPE_STRING)); self->priv->summary = g_variant_dup_string(child, &(self->priv->summary_length)); + g_strstrip(self->priv->summary); + self->priv->summary_length = strlen(self->priv->summary); /* body */ child = g_variant_get_child_value(body, COLUMN_BODY); g_assert(g_variant_is_of_type(child, G_VARIANT_TYPE_STRING)); self->priv->body = g_variant_dup_string(child, &(self->priv->body_length)); + g_strstrip(self->priv->body); + self->priv->body_length = strlen(self->priv->body); /* hints */ child = g_variant_get_child_value(body, COLUMN_HINTS); @@ -136,8 +141,12 @@ notification_new_from_dbus_message(GDBusMessage *message) /* check for volume hint */ value = g_variant_lookup_value(child, X_CANONICAL_PRIVATE_SYNCHRONOUS, G_VARIANT_TYPE_STRING); if(value != NULL) { - if(g_strcmp0(g_variant_get_string(value, NULL), "volume") == 0) { - self->priv->is_volume = TRUE; + const gchar *private_string = g_variant_get_string(value, NULL); + + if((g_strcmp0(private_string, "volume") == 0) || + (g_strcmp0(private_string, "brightness") == 0) || + (g_strcmp0(private_string, "indicator-sound") == 0)) { + self->priv->is_private = TRUE; } } @@ -183,9 +192,9 @@ notification_timestamp_for_locale(Notification *self) } gboolean -notification_is_volume(Notification *self) +notification_is_private(Notification *self) { - return self->priv->is_volume; + return self->priv->is_private; } /** -- cgit v1.2.3