popover menubar: Use a pseudo state

Use :selected instead of .active to
mark the active item.
This commit is contained in:
Matthias Clasen 2019-06-13 00:12:33 +00:00
parent 6c7cb8d862
commit a7e121384c
2 changed files with 10 additions and 18 deletions

View File

@ -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)))
{

View File

@ -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%);
}
}