From 39810bbf1c3128d0bcaf292e200776173de212cd Mon Sep 17 00:00:00 2001 From: Jason Conti Date: Sun, 28 Aug 2016 15:49:33 -0400 Subject: * Added back hide_on_activate = false on the notification menuitem - Enables using space when in keyboard navigation to avoid closing the menu * Added custom close icons for selected and deselected notifications - Since we don't set PRELIGHT, needed a way to show the selected notification during keyboard navigation - gtk-close is deprecated anyway, so might as well use our own - Can be replaced by the icon theme to look more appropriate --- src/notification-menuitem.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/notification-menuitem.c b/src/notification-menuitem.c index 08274cf..3240de1 100644 --- a/src/notification-menuitem.c +++ b/src/notification-menuitem.c @@ -11,6 +11,8 @@ #include "urlregex.h" #define NOTIFICATION_MENUITEM_MAX_CHARS 42 +#define NOTIFICATION_MENUITEM_CLOSE_SELECT "indicator-notification-close-select" +#define NOTIFICATION_MENUITEM_CLOSE_DESELECT "indicator-notification-close-deselect" enum { CLICKED, @@ -50,6 +52,7 @@ notification_menuitem_class_init(NotificationMenuItemClass *klass) g_type_class_add_private(klass, sizeof(NotificationMenuItemPrivate)); + menu_item_class->hide_on_activate = FALSE; menu_item_class->activate = notification_menuitem_activate; menu_item_class->select = notification_menuitem_select; menu_item_class->deselect = notification_menuitem_deselect; @@ -87,7 +90,7 @@ notification_menuitem_init(NotificationMenuItem *self) gtk_box_pack_start(GTK_BOX(self->priv->hbox), self->priv->label, TRUE, TRUE, 0); gtk_widget_show(self->priv->label); - self->priv->close_image = gtk_image_new_from_icon_name("gtk-close", GTK_ICON_SIZE_MENU); + self->priv->close_image = gtk_image_new_from_icon_name(NOTIFICATION_MENUITEM_CLOSE_DESELECT, GTK_ICON_SIZE_MENU); gtk_widget_show(self->priv->close_image); gtk_box_pack_start(GTK_BOX(self->priv->hbox), self->priv->close_image, FALSE, FALSE, 0); @@ -229,12 +232,25 @@ notification_menuitem_button_release(GtkWidget *widget, GdkEventButton *event) static void notification_menuitem_select(GtkMenuItem *menuitem) { - /* FIXME: breaks keyboard navigation */ + g_return_if_fail(IS_NOTIFICATION_MENUITEM(menuitem)); + + NotificationMenuItem *self = NOTIFICATION_MENUITEM(menuitem); + + gtk_image_set_from_icon_name(GTK_IMAGE(self->priv->close_image), + NOTIFICATION_MENUITEM_CLOSE_SELECT, + GTK_ICON_SIZE_MENU); } static void notification_menuitem_deselect(GtkMenuItem *menuitem) { + g_return_if_fail(IS_NOTIFICATION_MENUITEM(menuitem)); + + NotificationMenuItem *self = NOTIFICATION_MENUITEM(menuitem); + + gtk_image_set_from_icon_name(GTK_IMAGE(self->priv->close_image), + NOTIFICATION_MENUITEM_CLOSE_DESELECT, + GTK_ICON_SIZE_MENU); } static gboolean -- cgit v1.2.3