From 27a4b02329b62efffa89419d73be7c1f10838d76 Mon Sep 17 00:00:00 2001 From: Jason Conti Date: Wed, 15 Mar 2017 14:58:36 -0400 Subject: * Add option to clear the notifications using middle click on the notification icon. * Bump version. --- configure.ac | 2 +- ...launchpad.indicator.notifications.gschema.xml.in.in | 5 +++++ src/indicator-notifications.c | 18 ++++++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index c99c54a..3ec1f55 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([indicator-notifications], [0.3.2], [jason.conti@gmail.com]) +AC_INIT([indicator-notifications], [0.3.3], [jason.conti@gmail.com]) AM_INIT_AUTOMAKE([-Wall -Werror]) diff --git a/data/net.launchpad.indicator.notifications.gschema.xml.in.in b/data/net.launchpad.indicator.notifications.gschema.xml.in.in index 43ece43..a4c6dde 100644 --- a/data/net.launchpad.indicator.notifications.gschema.xml.in.in +++ b/data/net.launchpad.indicator.notifications.gschema.xml.in.in @@ -5,6 +5,11 @@ <_summary>Discard notifications by application name <_description>If an application name is in the blacklist, all notifications matching the application name will be discarded. + + false + <_summary>Clear notifications on middle click + <_description>Normally when middle clicking the notification icon, the unread status will be toggled if the queue is not empty. With this option enabled, the notification queue will be cleared instead. + false <_summary>Hide the indicator diff --git a/src/indicator-notifications.c b/src/indicator-notifications.c index 0ca4a6a..41164c9 100644 --- a/src/indicator-notifications.c +++ b/src/indicator-notifications.c @@ -65,6 +65,7 @@ struct _IndicatorNotificationsPrivate { GList *visible_items; GList *hidden_items; + gboolean clear_on_middle_click; gboolean have_unread; gboolean hide_indicator; @@ -88,6 +89,7 @@ struct _IndicatorNotificationsPrivate { #define NOTIFICATIONS_SCHEMA "net.launchpad.indicator.notifications" #define NOTIFICATIONS_KEY_BLACKLIST "blacklist" +#define NOTIFICATIONS_KEY_CLEAR_MC "clear-on-middle-click" #define NOTIFICATIONS_KEY_HIDE_INDICATOR "hide-indicator" #define NOTIFICATIONS_KEY_MAX_ITEMS "max-items" @@ -196,6 +198,7 @@ indicator_notifications_init(IndicatorNotifications *self) /* Connect to GSettings */ self->priv->settings = g_settings_new(NOTIFICATIONS_SCHEMA); + self->priv->clear_on_middle_click = g_settings_get_boolean(self->priv->settings, NOTIFICATIONS_KEY_CLEAR_MC); self->priv->hide_indicator = g_settings_get_boolean(self->priv->settings, NOTIFICATIONS_KEY_HIDE_INDICATOR); self->priv->max_items = g_settings_get_int(self->priv->settings, NOTIFICATIONS_KEY_MAX_ITEMS); update_blacklist(self); @@ -289,8 +292,16 @@ indicator_notifications_middle_click(IndicatorObject *io, IndicatorObjectEntry * { IndicatorNotifications *self = INDICATOR_NOTIFICATIONS(io); - if(g_list_length(self->priv->visible_items) > 0) - set_unread(self, !self->priv->have_unread); + /* Clear the notifications */ + if(self->priv->clear_on_middle_click) { + clear_menuitems(self); + set_unread(self, FALSE); + } + /* Otherwise toggle unread status */ + else { + if(g_list_length(self->priv->visible_items) > 0) + set_unread(self, !self->priv->have_unread); + } } /** @@ -524,6 +535,9 @@ setting_changed_cb(GSettings *settings, gchar *key, gpointer user_data) self->priv->hide_indicator = g_settings_get_boolean(settings, NOTIFICATIONS_KEY_HIDE_INDICATOR); update_indicator_visibility(self); } + else if(g_strcmp0(key, NOTIFICATIONS_KEY_CLEAR_MC) == 0) { + self->priv->clear_on_middle_click = g_settings_get_boolean(self->priv->settings, NOTIFICATIONS_KEY_CLEAR_MC); + } else if(g_strcmp0(key, NOTIFICATIONS_KEY_BLACKLIST) == 0) { update_blacklist(self); } -- cgit v1.2.3