a11y: Set accessible roles for GtkImage and GtkPicture

Use the img accessible role for these.
Also update the documentation and add tests.
This commit is contained in:
Matthias Clasen 2020-07-28 15:44:12 -04:00
parent cc50be971d
commit efd4169fa2
6 changed files with 48 additions and 1 deletions

View File

@ -51,6 +51,7 @@ Each role name is part of the #GtkAccessibleRole enumeration.
| `COLUMNHEADER` | The header of a column in a list or grid | - |
| `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 |
| `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

@ -1181,7 +1181,7 @@ typedef enum {
* @GTK_ACCESSIBLE_ROLE_GRID_CELL: Unused
* @GTK_ACCESSIBLE_ROLE_GROUP: Unused
* @GTK_ACCESSIBLE_ROLE_HEADING: Unused
* @GTK_ACCESSIBLE_ROLE_IMG: Unused
* @GTK_ACCESSIBLE_ROLE_IMG: An image.
* @GTK_ACCESSIBLE_ROLE_INPUT: Unused
* @GTK_ACCESSIBLE_ROLE_LABEL: Unused
* @GTK_ACCESSIBLE_ROLE_LANDMARK: Unused

View File

@ -72,6 +72,10 @@
* GtkImage has a single CSS node with the name image. The style classes
* .normal-icons or .large-icons may appear, depending on the #GtkImage:icon-size
* property.
*
* # Accessibility
*
* GtkImage uses the #GTK_ACCESSIBLE_ROLE_IMG role.
*/
typedef struct _GtkImageClass GtkImageClass;
@ -261,6 +265,8 @@ gtk_image_class_init (GtkImageClass *class)
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, image_props);
gtk_widget_class_set_css_name (widget_class, I_("image"));
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_IMG);
}
static void

View File

@ -59,6 +59,10 @@
* # CSS nodes
*
* GtkPicture has a single CSS node with the name picture.
*
* # Accessibility
*
* GtkImage uses the #GTK_ACCESSIBLE_ROLE_IMG role.
*/
enum
@ -365,6 +369,7 @@ gtk_picture_class_init (GtkPictureClass *class)
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, properties);
gtk_widget_class_set_css_name (widget_class, I_("picture"));
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_IMG);
}
static void

34
testsuite/a11y/image.c Normal file
View File

@ -0,0 +1,34 @@
#include <gtk/gtk.h>
static void
image_role (void)
{
GtkWidget *widget = gtk_image_new ();
g_object_ref_sink (widget);
gtk_test_accessible_assert_role (widget, GTK_ACCESSIBLE_ROLE_IMG);
g_object_unref (widget);
}
static void
picture_role (void)
{
GtkWidget *widget = gtk_picture_new ();
g_object_ref_sink (widget);
gtk_test_accessible_assert_role (widget, GTK_ACCESSIBLE_ROLE_IMG);
g_object_unref (widget);
}
int
main (int argc, char *argv[])
{
gtk_test_init (&argc, &argv, NULL);
g_test_add_func ("/a11y/image/role", image_role);
g_test_add_func ("/a11y/picture/role", picture_role);
return g_test_run ();
}

View File

@ -14,6 +14,7 @@ tests = [
{ 'name': 'button' },
{ 'name': 'checkbutton' },
{ 'name': 'dialog' },
{ 'name': 'image' },
{ 'name': 'progressbar' },
{ 'name': 'scrollbar' },
{ 'name': 'separator' },