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/indicator-notifications.c | 4 ++-- src/notification.c | 19 ++++++++++++++----- src/notification.h | 4 ++-- 3 files changed, 18 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/indicator-notifications.c b/src/indicator-notifications.c index be8fe31..8d9a070 100644 --- a/src/indicator-notifications.c +++ b/src/indicator-notifications.c @@ -573,8 +573,8 @@ message_received_cb(DBusSpy *spy, Notification *note, gpointer user_data) g_return_if_fail(IS_INDICATOR_NOTIFICATIONS(user_data)); IndicatorNotifications *self = INDICATOR_NOTIFICATIONS(user_data); - /* Discard volume notifications */ - if(notification_is_volume(note) || notification_is_empty(note)) + /* Discard useless notifications */ + if(notification_is_private(note) || notification_is_empty(note)) return; GtkWidget *item = new_notification_menuitem(note); 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; } /** diff --git a/src/notification.h b/src/notification.h index a1f98f1..3009998 100644 --- a/src/notification.h +++ b/src/notification.h @@ -46,7 +46,7 @@ struct _NotificationPrivate { gint expire_timeout; GDateTime *timestamp; - gboolean is_volume; + gboolean is_private; }; #define NOTIFICATION_GET_PRIVATE(o) \ @@ -61,7 +61,7 @@ const gchar *notification_get_summary(Notification *); const gchar *notification_get_body(Notification *); gint64 notification_get_timestamp(Notification *); gchar *notification_timestamp_for_locale(Notification *); -gboolean notification_is_volume(Notification *); +gboolean notification_is_private(Notification *); gboolean notification_is_empty(Notification *); void notification_print(Notification *); -- cgit v1.2.3