From ca9b06878d406841e8aa8df3a7da53c653c1276b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 21 Oct 2020 14:55:13 -0400 Subject: switch: Hide internal structure from a11y According to section 7.1 of WAI-ARIA, the switch role has the "Children presentational" characteristic, which indicates that children should not be represented in the a11y tree. --- gtk/gtkswitch.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c index a178672595..bb681d9123 100644 --- a/gtk/gtkswitch.c +++ b/gtk/gtkswitch.c @@ -651,13 +651,21 @@ gtk_switch_init (GtkSwitch *self) gtk_switch_allocate); gtk_widget_set_layout_manager (GTK_WIDGET (self), layout); - self->on_image = gtk_image_new_from_icon_name ("switch-on-symbolic"); + self->on_image = g_object_new (GTK_TYPE_IMAGE, + "accessible-role", GTK_ACCESSIBLE_ROLE_NONE, + "icon-name", "switch-on-symbolic", + NULL); gtk_widget_set_parent (self->on_image, GTK_WIDGET (self)); - self->off_image = gtk_image_new_from_icon_name ("switch-off-symbolic"); + self->off_image = g_object_new (GTK_TYPE_IMAGE, + "accessible-role", GTK_ACCESSIBLE_ROLE_NONE, + "icon-name", "switch-off-symbolic", + NULL); gtk_widget_set_parent (self->off_image, GTK_WIDGET (self)); - self->slider = gtk_gizmo_new ("slider", NULL, NULL, NULL, NULL, NULL, NULL); + self->slider = gtk_gizmo_new_with_role ("slider", + GTK_ACCESSIBLE_ROLE_NONE, + NULL, NULL, NULL, NULL, NULL, NULL); gtk_widget_set_parent (self->slider, GTK_WIDGET (self)); gtk_accessible_update_state (GTK_ACCESSIBLE (self), -- cgit v1.2.1