[gtk: 1/5] Set correct accessible relations for GtkMenuButton
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 1/5] Set correct accessible relations for GtkMenuButton
- Date: Fri, 17 Sep 2021 16:51:53 +0000 (UTC)
commit b664b2d1fd6779cc10b4759bc797f04da41a1146
Author: Lukáš Tyrychtr <lukastyrychtr gmail com>
Date: Tue Sep 14 14:26:18 2021 +0200
Set correct accessible relations for GtkMenuButton
Up until now, as the focus was moved to the inner button, it was not possible for
assistive technologies to determine the correct labels and descriptions
because developers could set them only for the parent widget.
Now, the proper relations are added so the labels should be picked up properly.
Fixes #4254
gtk/gtkmenubutton.c | 10 ++++++++++
1 file changed, 10 insertions(+)
---
diff --git a/gtk/gtkmenubutton.c b/gtk/gtkmenubutton.c
index 02eb13b4a0..6552165824 100644
--- a/gtk/gtkmenubutton.c
+++ b/gtk/gtkmenubutton.c
@@ -669,6 +669,10 @@ gtk_menu_button_init (GtkMenuButton *self)
gtk_widget_set_sensitive (self->button, FALSE);
gtk_widget_add_css_class (GTK_WIDGET (self), "popup");
+
+ gtk_accessible_update_relation (GTK_ACCESSIBLE (self->button), GTK_ACCESSIBLE_RELATION_LABELLED_BY, self,
NULL,
+ GTK_ACCESSIBLE_RELATION_DESCRIBED_BY, self, NULL,
+ -1);
}
static GtkBuildableIface *parent_buildable_iface;
@@ -1017,6 +1021,9 @@ gtk_menu_button_set_icon_name (GtkMenuButton *menu_button,
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_halign (box, GTK_ALIGN_CENTER);
+ // Because we are setting only an icon, let the inner button be labeled by us, so the accessible label can
be overridden
+ gtk_accessible_update_relation (GTK_ACCESSIBLE (menu_button->button), GTK_ACCESSIBLE_RELATION_LABELLED_BY,
menu_button, NULL, -1);
+
image_widget = g_object_new (GTK_TYPE_IMAGE,
"accessible-role", GTK_ACCESSIBLE_ROLE_PRESENTATION,
"icon-name", icon_name,
@@ -1149,6 +1156,9 @@ gtk_menu_button_set_label (GtkMenuButton *menu_button,
gtk_button_set_child (GTK_BUTTON (menu_button->button), box);
menu_button->label_widget = label_widget;
+ // When the user explicitly set a label assume that it should be announced by assistive technologies as
well
+ gtk_accessible_update_relation (GTK_ACCESSIBLE (menu_button->button), GTK_ACCESSIBLE_RELATION_LABELLED_BY,
menu_button->label_widget, NULL, -1);
+
menu_button->image_widget = NULL;
menu_button->child = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]