From a7e121384cf2b5ee470ccade9defdf27273b1797 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 13 Jun 2019 00:12:33 +0000 Subject: [PATCH] popover menubar: Use a pseudo state Use :selected instead of .active to mark the active item. --- gtk/gtkpopovermenubar.c | 14 +++----------- gtk/theme/Adwaita/_common.scss | 14 +++++++------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/gtk/gtkpopovermenubar.c b/gtk/gtkpopovermenubar.c index 119fbacd59..7716397dfe 100644 --- a/gtk/gtkpopovermenubar.c +++ b/gtk/gtkpopovermenubar.c @@ -60,7 +60,6 @@ #include "gtkmarshalers.h" #include "gtkstylecontext.h" #include "gtkgestureclick.h" -#include "gtkeventcontrollerkey.h" #include "gtkeventcontrollermotion.h" #include "gtkactionmuxerprivate.h" #include "gtkmenutrackerprivate.h" @@ -130,21 +129,13 @@ set_active_item (GtkPopoverMenuBar *bar, if (changed) { - GtkStyleContext *context; - if (bar->active_item) - { - context = gtk_widget_get_style_context (GTK_WIDGET (bar->active_item)); - gtk_style_context_remove_class (context, "active"); - } + gtk_widget_unset_state_flags (GTK_WIDGET (bar->active_item), GTK_STATE_FLAG_SELECTED); bar->active_item = item; if (bar->active_item) - { - context = gtk_widget_get_style_context (GTK_WIDGET (bar->active_item)); - gtk_style_context_add_class (context, "active"); - } + gtk_widget_set_state_flags (GTK_WIDGET (bar->active_item), GTK_STATE_FLAG_SELECTED, FALSE); } if (bar->active_item) @@ -214,6 +205,7 @@ gtk_popover_menu_bar_focus (GtkWidget *widget, { GtkPopoverMenuBar *bar = GTK_POPOVER_MENU_BAR (widget); GtkWidget *next; + if (bar->active_item && gtk_widget_get_mapped (GTK_WIDGET (bar->active_item->popover))) { diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss index 62cd4b871b..1f6398dbc1 100644 --- a/gtk/theme/Adwaita/_common.scss +++ b/gtk/theme/Adwaita/_common.scss @@ -16,7 +16,6 @@ $window_radius: $button_radius + 3; -gtk-secondary-caret-color: $selected_bg_color } -modelbutton:focus(visible), button:focus(visible), checkbutton:focus(visible), radiobutton:focus(visible), @@ -4696,7 +4695,7 @@ menubar { min-height: 16px; padding: 4px 8px; - &.active { //Seems like it :hover even with keyboard focus + &:selected { //Seems like it :hover even with keyboard focus box-shadow: inset 0 -3px $selected_bg_color; color: $link_color; } @@ -4711,13 +4710,14 @@ menubar { } popover.menu { - & .flat.image-button.model { + & button.flat.image-button.model { padding: 0; border: none; } - & .flat.image-button.model:hover { + & button.flat.image-button.model:selected { border: none; - color: gray; + color: $selected_fg_color; + background: $selected_bg_color; } & box.inline-buttons { @@ -4761,12 +4761,12 @@ popover.menu { margin-right: 0; } - & modelbutton:hover { + & modelbutton:selected { color: $selected_fg_color; background-color: $selected_bg_color; } - & modelbutton:hover accelerator { + & modelbutton:selected accelerator { color: mix($selected_fg_color, gray, 50%); } }