summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2023-04-28 22:57:10 +0000
committerMatthias Clasen <mclasen@redhat.com>2023-04-28 22:57:10 +0000
commit8b816d3b0385c7d7f4ea284eafe98bc97534cc3b (patch)
tree6d966b545a2174fdc8981de2bd498c535a1df3c6
parent63b50f48a946e6b1889b116013ef3f3e54e6c867 (diff)
parent33e5d2c307a7634a31d617675e98b010864e65b2 (diff)
downloadgtk+-8b816d3b0385c7d7f4ea284eafe98bc97534cc3b.tar.gz
Merge branch 'gtkshortcutswindow_a11y' into 'main'
GtkShortcutsWindow: Allow a screen reader user to browse the available shortcuts See merge request GNOME/gtk!5042
-rw-r--r--gtk/gtkshortcutlabel.c20
-rw-r--r--gtk/gtkshortcutsshortcut.c13
2 files changed, 32 insertions, 1 deletions
diff --git a/gtk/gtkshortcutlabel.c b/gtk/gtkshortcutlabel.c
index 47bcd905fa..87bb504823 100644
--- a/gtk/gtkshortcutlabel.c
+++ b/gtk/gtkshortcutlabel.c
@@ -362,6 +362,9 @@ parse_range (GtkShortcutLabel *self,
static void
clear_children (GtkShortcutLabel *self)
{
+ gtk_accessible_reset_relation (GTK_ACCESSIBLE (self),
+ GTK_ACCESSIBLE_RELATION_LABELLED_BY);
+
GtkWidget *child;
child = gtk_widget_get_first_child (GTK_WIDGET (self));
@@ -381,6 +384,10 @@ gtk_shortcut_label_rebuild (GtkShortcutLabel *self)
{
char **accels;
int k;
+ GtkAccessibleRelation relation = GTK_ACCESSIBLE_RELATION_LABELLED_BY;
+ GValue value = G_VALUE_INIT;
+ GList *parts = NULL;
+ GtkWidget *child;
clear_children (self);
@@ -407,6 +414,19 @@ gtk_shortcut_label_rebuild (GtkShortcutLabel *self)
}
}
g_strfreev (accels);
+
+ /* All of the child labels are a part of our a11y label */
+ for(child = gtk_widget_get_last_child (GTK_WIDGET (self));
+ child != NULL;
+ child = gtk_widget_get_prev_sibling (child))
+ {
+ parts = g_list_prepend (parts, child);
+ }
+ gtk_accessible_relation_init_value (relation, &value);
+ g_value_set_pointer (&value, parts);
+ gtk_accessible_update_relation_value (GTK_ACCESSIBLE (self),
+ 1, &relation, &value);
+
}
static void
diff --git a/gtk/gtkshortcutsshortcut.c b/gtk/gtkshortcutsshortcut.c
index 9c1cd8ca47..287bc7af12 100644
--- a/gtk/gtkshortcutsshortcut.c
+++ b/gtk/gtkshortcutsshortcut.c
@@ -706,12 +706,18 @@ gtk_shortcuts_shortcut_class_init (GtkShortcutsShortcutClass *klass)
g_object_class_install_properties (object_class, LAST_PROP, properties);
gtk_widget_class_set_css_name (widget_class, I_("shortcut"));
- gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_GROUP);
+ /* It is semantically a label, but the label role has such specific meaning in Orca
+ * as to be unusable in this context.
+ */
+ gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_WIDGET);
}
static void
gtk_shortcuts_shortcut_init (GtkShortcutsShortcut *self)
{
+ gtk_widget_set_focusable (GTK_WIDGET (self), TRUE);
+
+
self->box = g_object_new (GTK_TYPE_BOX,
"orientation", GTK_ORIENTATION_HORIZONTAL,
"spacing", 12,
@@ -754,4 +760,9 @@ gtk_shortcuts_shortcut_init (GtkShortcutsShortcut *self)
NULL);
gtk_widget_add_css_class (GTK_WIDGET (self->subtitle), "dim-label");
gtk_box_append (GTK_BOX (self->title_box), GTK_WIDGET (self->subtitle));
+
+ gtk_accessible_update_relation (GTK_ACCESSIBLE (self),
+ GTK_ACCESSIBLE_RELATION_LABELLED_BY, self->title, NULL,
+ GTK_ACCESSIBLE_RELATION_DESCRIBED_BY, self->accelerator, NULL,
+ -1);
}