aboutsummaryrefslogtreecommitdiff
path: root/src/indicator-notifications.c
diff options
context:
space:
mode:
authorJason Conti <jason.conti@gmail.com>2012-02-29 13:38:00 -0500
committerJason Conti <jason.conti@gmail.com>2012-02-29 13:38:00 -0500
commit3db69aea40bf6b1771c0509b32dfb6c60eb4744a (patch)
tree072411e5316149fe84b620fa8ec6f3f518a34b48 /src/indicator-notifications.c
parentf42975190563442919702ac925b7a141a056c1bb (diff)
downloadayatana-indicator-notifications-3db69aea40bf6b1771c0509b32dfb6c60eb4744a.tar.gz
ayatana-indicator-notifications-3db69aea40bf6b1771c0509b32dfb6c60eb4744a.tar.bz2
ayatana-indicator-notifications-3db69aea40bf6b1771c0509b32dfb6c60eb4744a.zip
* Implement secondary-activate to dismiss or reactivate the unread icon
on middle click.
Diffstat (limited to 'src/indicator-notifications.c')
-rw-r--r--src/indicator-notifications.c52
1 files changed, 42 insertions, 10 deletions
diff --git a/src/indicator-notifications.c b/src/indicator-notifications.c
index 03b9099..ac9b016 100644
--- a/src/indicator-notifications.c
+++ b/src/indicator-notifications.c
@@ -104,12 +104,17 @@ static void indicator_notifications_finalize(GObject *object);
static GtkImage *get_image(IndicatorObject *io);
static GtkMenu *get_menu(IndicatorObject *io);
static const gchar *get_accessible_desc(IndicatorObject *io);
+static void indicator_notifications_middle_click(IndicatorObject *io,
+ IndicatorObjectEntry *entry,
+ guint time,
+ gpointer user_data);
/* Utility Functions */
static void clear_menuitems(IndicatorNotifications *self);
static void insert_menuitem(IndicatorNotifications *self, GtkWidget *item);
static void remove_menuitem(IndicatorNotifications *self, GtkWidget *item);
static GdkPixbuf *load_icon(const gchar *name, gint size);
+static void set_unread(IndicatorNotifications *self, gboolean unread);
static void update_clear_item_markup(IndicatorNotifications *self);
/* Callbacks */
@@ -140,6 +145,7 @@ indicator_notifications_class_init(IndicatorNotificationsClass *klass)
io_class->get_image = get_image;
io_class->get_menu = get_menu;
io_class->get_accessible_desc = get_accessible_desc;
+ io_class->secondary_activate = indicator_notifications_middle_click;
return;
}
@@ -231,8 +237,6 @@ indicator_notifications_dispose(GObject *object)
static void
indicator_notifications_finalize(GObject *object)
{
- /*IndicatorNotifications *self = INDICATOR_NOTIFICATIONS(object);*/
-
G_OBJECT_CLASS (indicator_notifications_parent_class)->finalize (object);
return;
}
@@ -285,6 +289,16 @@ get_accessible_desc(IndicatorObject *io)
return self->priv->accessible_desc;
}
+static void
+indicator_notifications_middle_click(IndicatorObject *io, IndicatorObjectEntry *entry,
+ guint time, gpointer user_data)
+{
+ IndicatorNotifications *self = INDICATOR_NOTIFICATIONS(io);
+
+ if(g_list_length(self->priv->visible_items) > 0)
+ set_unread(self, !self->priv->have_unread);
+}
+
/**
* clear_menuitems:
* @self: the indicator
@@ -433,6 +447,30 @@ load_icon(const gchar *name, gint size)
}
/**
+ * set_unread:
+ * @self: the indicator object
+ * @unread: the unread status
+ *
+ * Sets the unread status of the indicator and updates the icons.
+ **/
+static void
+set_unread(IndicatorNotifications *self, gboolean unread)
+{
+ g_return_if_fail(IS_INDICATOR_NOTIFICATIONS(self));
+
+ if(unread) {
+ if(self->priv->pixbuf_unread != NULL)
+ gtk_image_set_from_pixbuf(self->priv->image, self->priv->pixbuf_unread);
+ }
+ else {
+ if(self->priv->pixbuf_read != NULL)
+ gtk_image_set_from_pixbuf(self->priv->image, self->priv->pixbuf_read);
+ }
+
+ self->priv->have_unread = unread;
+}
+
+/**
* update_clear_item_markup:
* @self: the indicator object
*
@@ -492,10 +530,7 @@ menu_visible_notify_cb(GtkWidget *menu, G_GNUC_UNUSED GParamSpec *pspec, gpointe
gboolean visible;
g_object_get(G_OBJECT(menu), "visible", &visible, NULL);
if(!visible) {
- if(self->priv->pixbuf_read != NULL) {
- self->priv->have_unread = FALSE;
- gtk_image_set_from_pixbuf(self->priv->image, self->priv->pixbuf_read);
- }
+ set_unread(self, FALSE);
}
}
@@ -527,10 +562,7 @@ message_received_cb(DBusSpy *spy, Notification *note, gpointer user_data)
insert_menuitem(self, item);
- if(self->priv->pixbuf_unread != NULL) {
- self->priv->have_unread = TRUE;
- gtk_image_set_from_pixbuf(self->priv->image, self->priv->pixbuf_unread);
- }
+ set_unread(self, TRUE);
}
/**