mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 21:21:21 +00:00
a11y: Set an accessible role for GtkLevelBar
Use the 'meter' role for GtkLevelBar, and set the appropriate properties. Update the docs and add a test.
This commit is contained in:
parent
c0de580d46
commit
abf8cbeaea
@ -45,14 +45,13 @@ Each role name is part of the #GtkAccessibleRole enumeration.
|
||||
|
||||
| Role name | Description | Related GTK widget |
|
||||
|-----------|-------------|--------------------|
|
||||
| `ALERT` | A message with important information | - |
|
||||
| `BUTTON` | A control that performs an action when pressed | #GtkButton, #GtkLinkButton, #GtkExpander |
|
||||
| `CHECKBOX` | A control that has three possible value: `true`, `false`, or `undefined` | #GtkCheckButton |
|
||||
| `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 |
|
||||
| `LABEL` | A visible name or caption for a user interface component. | #GtkLabel |
|
||||
| `LABEL` | A visible name or caption for a user interface component | #GtkLabel |
|
||||
| `METER` | Represents a value within a known range | #GtkLevelBar |
|
||||
| `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 |
|
||||
|
@ -1194,7 +1194,7 @@ typedef enum {
|
||||
* @GTK_ACCESSIBLE_ROLE_MAIN: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_MARQUEE: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_MATH: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_METER: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_METER: An element that represents a value within a known range.
|
||||
* @GTK_ACCESSIBLE_ROLE_MENU: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_MENU_BAR: Unused
|
||||
* @GTK_ACCESSIBLE_ROLE_MENU_ITEM: Unused
|
||||
|
@ -116,6 +116,10 @@
|
||||
*
|
||||
* In horizontal orientation, the nodes are always arranged from left to right,
|
||||
* regardless of text direction.
|
||||
*
|
||||
* # Accessibility
|
||||
*
|
||||
* GtkLevelBar uses the #GTK_ACCESSIBLE_ROLE_METER role.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
@ -1007,6 +1011,7 @@ gtk_level_bar_class_init (GtkLevelBarClass *klass)
|
||||
|
||||
gtk_widget_class_set_layout_manager_type (wclass, GTK_TYPE_BIN_LAYOUT);
|
||||
gtk_widget_class_set_css_name (wclass, I_("levelbar"));
|
||||
gtk_widget_class_set_accessible_role (wclass, GTK_ACCESSIBLE_ROLE_METER);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1041,6 +1046,12 @@ gtk_level_bar_init (GtkLevelBar *self)
|
||||
update_mode_style_classes (self);
|
||||
update_block_nodes (self);
|
||||
update_level_style_classes (self);
|
||||
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (self),
|
||||
GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, 1.0,
|
||||
GTK_ACCESSIBLE_PROPERTY_VALUE_MIN, 0.0,
|
||||
GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, 0.0,
|
||||
-1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1163,6 +1174,12 @@ gtk_level_bar_set_min_value (GtkLevelBar *self,
|
||||
|
||||
update_block_nodes (self);
|
||||
update_level_style_classes (self);
|
||||
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (self),
|
||||
GTK_ACCESSIBLE_PROPERTY_VALUE_MIN, self->min_value,
|
||||
GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, self->cur_value,
|
||||
-1);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MIN_VALUE]);
|
||||
}
|
||||
|
||||
@ -1194,6 +1211,12 @@ gtk_level_bar_set_max_value (GtkLevelBar *self,
|
||||
gtk_level_bar_ensure_offsets_in_range (self);
|
||||
update_block_nodes (self);
|
||||
update_level_style_classes (self);
|
||||
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (self),
|
||||
GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, self->max_value,
|
||||
GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, self->cur_value,
|
||||
-1);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MAX_VALUE]);
|
||||
}
|
||||
|
||||
@ -1216,6 +1239,10 @@ gtk_level_bar_set_value (GtkLevelBar *self,
|
||||
|
||||
gtk_level_bar_set_value_internal (self, value);
|
||||
update_level_style_classes (self);
|
||||
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (self),
|
||||
GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, self->cur_value,
|
||||
-1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
50
testsuite/a11y/levelbar.c
Normal file
50
testsuite/a11y/levelbar.c
Normal file
@ -0,0 +1,50 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void
|
||||
level_bar_role (void)
|
||||
{
|
||||
GtkWidget *widget = gtk_level_bar_new ();
|
||||
g_object_ref_sink (widget);
|
||||
|
||||
gtk_test_accessible_assert_role (widget, GTK_ACCESSIBLE_ROLE_METER);
|
||||
|
||||
g_object_unref (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
level_bar_properties (void)
|
||||
{
|
||||
GtkWidget *widget = gtk_level_bar_new ();
|
||||
g_object_ref_sink (widget);
|
||||
|
||||
gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, 1.);
|
||||
gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_VALUE_MIN, 0.);
|
||||
gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, 0.);
|
||||
gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT, NULL);
|
||||
|
||||
gtk_level_bar_set_max_value (GTK_LEVEL_BAR (widget), 100.0);
|
||||
gtk_level_bar_set_min_value (GTK_LEVEL_BAR (widget), 10.0);
|
||||
|
||||
gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, 100.0);
|
||||
gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_VALUE_MIN, 10.0);
|
||||
gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, 10.0);
|
||||
|
||||
gtk_level_bar_set_value (GTK_LEVEL_BAR (widget), 40.0);
|
||||
|
||||
gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, 100.0);
|
||||
gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_VALUE_MIN, 10.0);
|
||||
gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, 40.0);
|
||||
|
||||
g_object_unref (widget);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gtk_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/a11y/levelbar/role", level_bar_role);
|
||||
g_test_add_func ("/a11y/levelbar/properties", level_bar_properties);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
@ -18,6 +18,7 @@ tests = [
|
||||
{ 'name': 'expander' },
|
||||
{ 'name': 'image' },
|
||||
{ 'name': 'label' },
|
||||
{ 'name': 'levelbar' },
|
||||
{ 'name': 'passwordentry' },
|
||||
{ 'name': 'progressbar' },
|
||||
{ 'name': 'scrollbar' },
|
||||
|
Loading…
Reference in New Issue
Block a user