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 --- data/icons/Makefile.am | 2 + .../indicator-notification-close-deselect.svg | 79 ++++++++++++++++++++++ data/icons/indicator-notification-close-select.svg | 61 +++++++++++++++++ src/notification-menuitem.c | 20 +++++- 4 files changed, 160 insertions(+), 2 deletions(-) create mode 100644 data/icons/indicator-notification-close-deselect.svg create mode 100644 data/icons/indicator-notification-close-select.svg diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am index 97f2535..2543305 100644 --- a/data/icons/Makefile.am +++ b/data/icons/Makefile.am @@ -1,6 +1,8 @@ iconsdir = $(INDICATORICONSDIR) icons_DATA = \ + indicator-notification-close-select.svg \ + indicator-notification-close-deselect.svg \ indicator-notification-read.svg \ indicator-notification-unread.svg diff --git a/data/icons/indicator-notification-close-deselect.svg b/data/icons/indicator-notification-close-deselect.svg new file mode 100644 index 0000000..3e92220 --- /dev/null +++ b/data/icons/indicator-notification-close-deselect.svg @@ -0,0 +1,79 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/data/icons/indicator-notification-close-select.svg b/data/icons/indicator-notification-close-select.svg new file mode 100644 index 0000000..21f5026 --- /dev/null +++ b/data/icons/indicator-notification-close-select.svg @@ -0,0 +1,61 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + 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