aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/notification.c23
-rw-r--r--src/notification.h3
-rw-r--r--src/notifications-service.c3
3 files changed, 28 insertions, 1 deletions
diff --git a/src/notification.c b/src/notification.c
index d99a1f8..c76da87 100644
--- a/src/notification.c
+++ b/src/notification.c
@@ -15,6 +15,8 @@
#define COLUMN_COUNT 8
+#define X_CANONICAL_PRIVATE_SYNCHRONOUS "x-canonical-private-synchronous"
+
static void notification_class_init(NotificationClass *klass);
static void notification_init(Notification *self);
static void notification_dispose(GObject *object);
@@ -43,6 +45,7 @@ notification_init(Notification *self)
self->priv->body = NULL;
self->priv->expire_timeout = 0;
self->priv->timestamp = NULL;
+ self->priv->is_volume = FALSE;
}
static void
@@ -93,7 +96,7 @@ notification_new_from_dbus_message(GDBusMessage *message)
self->priv->timestamp = g_date_time_new_now_local();
GVariant *body = g_dbus_message_get_body(message);
- GVariant *child = NULL;
+ GVariant *child = NULL, *value = NULL;
g_assert(g_variant_is_of_type(body, G_VARIANT_TYPE_TUPLE));
g_assert(g_variant_n_children(body) == COLUMN_COUNT);
@@ -126,6 +129,18 @@ notification_new_from_dbus_message(GDBusMessage *message)
self->priv->body = g_variant_dup_string(child,
&(self->priv->body_length));
+ /* hints */
+ child = g_variant_get_child_value(body, COLUMN_HINTS);
+ g_assert(g_variant_is_of_type(child, G_VARIANT_TYPE_DICTIONARY));
+
+ /* 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;
+ }
+ }
+
child = NULL;
return self;
@@ -167,6 +182,12 @@ notification_timestamp_for_locale(Notification *self)
return g_date_time_format(self->priv->timestamp, "%X %x");
}
+gboolean
+notification_is_volume(Notification *self)
+{
+ return self->priv->is_volume;
+}
+
void
notification_print(Notification *self)
{
diff --git a/src/notification.h b/src/notification.h
index d9a67fe..5fc944a 100644
--- a/src/notification.h
+++ b/src/notification.h
@@ -45,6 +45,8 @@ struct _NotificationPrivate {
gsize body_length;
gint expire_timeout;
GDateTime *timestamp;
+
+ gboolean is_volume;
};
#define NOTIFICATION_GET_PRIVATE(o) \
@@ -59,6 +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 *);
void notification_print(Notification *);
G_END_DECLS
diff --git a/src/notifications-service.c b/src/notifications-service.c
index 38fa247..71b7c40 100644
--- a/src/notifications-service.c
+++ b/src/notifications-service.c
@@ -217,6 +217,9 @@ log_to_file(const gchar *domain, GLogLevelFlags level, const gchar *message, gpo
static void
message_received_cb(DBusSpy *spy, Notification *note, gpointer user_data)
{
+ /* Discard volume notifications */
+ if(notification_is_volume(note)) return;
+
g_object_ref(note);
g_idle_add(add_notification_item, note);
}