a11y: Set an accessible role for GtkLabel

Use the label accessible role for GtkLabel. ARIA has some
ominous wording about it going way, but while we have it,
GtkLabel is the obvious candidate for carrying it.

Update the documentation and add a test.
This commit is contained in:
Matthias Clasen 2020-07-28 16:53:19 -04:00
parent cc35cc6c4e
commit 2040b7ecdf
4 changed files with 20 additions and 1 deletions

View File

@ -52,6 +52,7 @@ Each role name is part of the #GtkAccessibleRole enumeration.
| `COMBOBOX` | A control that can be expanded to show a list of possible values to select | #GtkComboBox |
| `DIALOG` | A dialog that prompts the user to enter information or require a response | #GtkDialog and subclasses |
| `IMG` | An image | #GtkImage, #GtkPicture |
| `LABEL` | A visible name or caption for a user interface component. | #GtkLabel |
| `PROGRESS_BAR` | An element that display progress | #GtkProgressBar |
| `RADIO` | A checkable input in a group of radio roles | #GtkRadioButton |
| `SCROLLBAR` | A graphical object controlling the scolling of content | #GtkScrollbar |

View File

@ -1183,7 +1183,7 @@ typedef enum {
* @GTK_ACCESSIBLE_ROLE_HEADING: Unused
* @GTK_ACCESSIBLE_ROLE_IMG: An image.
* @GTK_ACCESSIBLE_ROLE_INPUT: Unused
* @GTK_ACCESSIBLE_ROLE_LABEL: Unused
* @GTK_ACCESSIBLE_ROLE_LABEL: A visible name or caption for a user interface component.
* @GTK_ACCESSIBLE_ROLE_LANDMARK: Unused
* @GTK_ACCESSIBLE_ROLE_LEGEND: Unused
* @GTK_ACCESSIBLE_ROLE_LINK: Unused

View File

@ -114,6 +114,10 @@
* sense with translatable attributes. Use markup embedded in the translatable
* content instead.
*
* # Accessibility
*
* GtkLabel uses the #GTK_ACCESSIBLE_ROLE_LABEL role.
*
* # Mnemonics
*
* Labels may contain mnemonics. Mnemonics are
@ -1073,6 +1077,7 @@ gtk_label_class_init (GtkLabelClass *class)
NULL);
gtk_widget_class_set_css_name (widget_class, I_("label"));
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_LABEL);
quark_mnemonics_visible_connected = g_quark_from_static_string ("gtk-label-mnemonics-visible-connected");

View File

@ -1,5 +1,17 @@
#include <gtk/gtk.h>
static void
label_role (void)
{
GtkWidget *label = gtk_label_new ("a");
g_object_ref_sink (label);
gtk_test_accessible_assert_role (GTK_ACCESSIBLE (label), GTK_ACCESSIBLE_ROLE_LABEL);
g_object_unref (label);
}
static void
label_relations (void)
{
@ -37,6 +49,7 @@ main (int argc, char *argv[])
{
gtk_test_init (&argc, &argv, NULL);
g_test_add_func ("/a11y/label/role", label_role);
g_test_add_func ("/a11y/label/relations", label_relations);
return g_test_run ();