aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Conti <jason.conti@gmail.com>2012-02-26 11:25:51 -0500
committerJason Conti <jason.conti@gmail.com>2012-02-26 11:25:51 -0500
commitdf8ae866eb73d9f58938e8eb710a3931d6d8b6b7 (patch)
tree8be6ae658b84f171b0ef3d67e6ace8080391727e /src
parentbafd8363f436bfd947751c99f5bcd28357c6a60a (diff)
downloadayatana-indicator-notifications-df8ae866eb73d9f58938e8eb710a3931d6d8b6b7.tar.gz
ayatana-indicator-notifications-df8ae866eb73d9f58938e8eb710a3931d6d8b6b7.tar.bz2
ayatana-indicator-notifications-df8ae866eb73d9f58938e8eb710a3931d6d8b6b7.zip
* 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.
Diffstat (limited to 'src')
-rw-r--r--src/indicator-notifications.c4
-rw-r--r--src/notification.c19
-rw-r--r--src/notification.h4
3 files changed, 18 insertions, 9 deletions
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 <string.h>
#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 *);