a11y: When a menu item opens a submenu, set its expandable state

To help distinguish submenu opening items, mark them as expandable.
Previously, they only indicated that they had a popup, which is too general.
This commit is contained in:
Lukáš Tyrychtr 2023-04-19 11:18:48 +02:00
parent 40ac37245d
commit afbcbb8404

View File

@ -560,12 +560,21 @@ static void
update_accessible_properties (GtkModelButton *button)
{
if (button->menu_name || button->popover)
gtk_accessible_update_property (GTK_ACCESSIBLE (button),
GTK_ACCESSIBLE_PROPERTY_HAS_POPUP, TRUE,
-1);
{
gtk_accessible_update_state (GTK_ACCESSIBLE (button),
GTK_ACCESSIBLE_STATE_EXPANDED, FALSE,
-1);
gtk_accessible_update_property (GTK_ACCESSIBLE (button),
GTK_ACCESSIBLE_PROPERTY_HAS_POPUP, TRUE,
-1);
}
else
gtk_accessible_reset_property (GTK_ACCESSIBLE (button),
GTK_ACCESSIBLE_PROPERTY_HAS_POPUP);
{
gtk_accessible_reset_property (GTK_ACCESSIBLE (button),
GTK_ACCESSIBLE_PROPERTY_HAS_POPUP);
gtk_accessible_reset_state (GTK_ACCESSIBLE (button),
GTK_ACCESSIBLE_STATE_EXPANDED);
}
if (button->popover)
gtk_accessible_update_relation (GTK_ACCESSIBLE (button),
@ -1043,7 +1052,12 @@ switch_menu (GtkModelButton *button)
stack = gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_STACK);
if (stack != NULL)
gtk_stack_set_visible_child_name (GTK_STACK (stack), button->menu_name);
{
gtk_stack_set_visible_child_name (GTK_STACK (stack), button->menu_name);
gtk_accessible_update_state (GTK_ACCESSIBLE (button),
GTK_ACCESSIBLE_STATE_EXPANDED, TRUE,
-1);
}
}
static void
@ -1063,6 +1077,10 @@ gtk_model_button_clicked (GtkModelButton *self)
gtk_popover_popup (GTK_POPOVER (submenu));
gtk_popover_menu_set_open_submenu (menu, submenu);
gtk_popover_menu_set_parent_menu (GTK_POPOVER_MENU (submenu), GTK_WIDGET (menu));
gtk_accessible_update_state (GTK_ACCESSIBLE (self),
GTK_ACCESSIBLE_STATE_EXPANDED, TRUE,
-1);
}
else if (!self->keep_open)
{
@ -1071,6 +1089,10 @@ gtk_model_button_clicked (GtkModelButton *self)
popover = gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_POPOVER);
if (popover)
gtk_popover_popdown (GTK_POPOVER (popover));
gtk_accessible_update_state (GTK_ACCESSIBLE (self),
GTK_ACCESSIBLE_STATE_EXPANDED, FALSE,
-1);
}
if (self->action_helper)