Merge branch 'add_toggle_button_role' into 'main'

a11y: Introduce a dedicated role for toggle buttons

See merge request GNOME/gtk!5549
This commit is contained in:
Emmanuele Bassi 2023-02-23 15:22:16 +00:00
commit 2b4dd182c1
3 changed files with 13 additions and 1 deletions

View File

@ -273,6 +273,8 @@ gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
case GTK_ACCESSIBLE_ROLE_WINDOW:
return ATSPI_ROLE_FRAME;
case GTK_ACCESSIBLE_ROLE_TOGGLE_BUTTON:
return ATSPI_ROLE_TOGGLE_BUTTON;
default:
break;
}

View File

@ -1306,6 +1306,9 @@ typedef enum {
* @GTK_ACCESSIBLE_ROLE_WIDGET: An interactive component of a graphical user
* interface. This is the role that GTK uses by default for widgets.
* @GTK_ACCESSIBLE_ROLE_WINDOW: An application window.
* @GTK_ACCESSIBLE_ROLE_TOGGLE_BUTTON: A type of push button
* which stays pressed until depressed by a second activation.
* Since: 4.10
*
* The accessible role for a [iface@Accessible] implementation.
*
@ -1390,7 +1393,8 @@ typedef enum {
GTK_ACCESSIBLE_ROLE_TREE_GRID,
GTK_ACCESSIBLE_ROLE_TREE_ITEM,
GTK_ACCESSIBLE_ROLE_WIDGET,
GTK_ACCESSIBLE_ROLE_WINDOW
GTK_ACCESSIBLE_ROLE_WINDOW,
GTK_ACCESSIBLE_ROLE_TOGGLE_BUTTON
} GtkAccessibleRole;
/**

View File

@ -67,6 +67,10 @@
* `GtkToggleButton` has a single CSS node with name button. To differentiate
* it from a plain `GtkButton`, it gets the `.toggle` style class.
*
* ## Accessibility
*
* `GtkToggleButton` uses the %GTK_ACCESSIBLE_ROLE_TOGGLE_BUTTON role.
*
* ## Creating two `GtkToggleButton` widgets.
*
* ```c
@ -311,6 +315,8 @@ gtk_toggle_button_class_init (GtkToggleButtonClass *class)
G_TYPE_NONE, 0);
gtk_widget_class_set_css_name (widget_class, I_("button"));
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_TOGGLE_BUTTON);
}
static void