[gtk/ebassi/new-a11y: 58/63] a11y: Implement role and state change in GtkSwitch



commit 09f7ee5344c3fba5dcc01060005c686eb56f373a
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Fri Jul 17 14:31:02 2020 +0100

    a11y: Implement role and state change in GtkSwitch
    
    Set the "switch" role, and update the "checked" state when the :active
    property is toggled.

 gtk/gtkswitch.c | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c
index 7563c5b099..bca74e7b27 100644
--- a/gtk/gtkswitch.c
+++ b/gtk/gtkswitch.c
@@ -605,6 +605,8 @@ gtk_switch_class_init (GtkSwitchClass *klass)
   g_object_class_override_property (gobject_class, PROP_ACTION_TARGET, "action-target");
 
   gtk_widget_class_set_css_name (widget_class, I_("switch"));
+
+  gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_SWITCH);
 }
 
 static void
@@ -699,6 +701,10 @@ gtk_switch_set_active (GtkSwitch *self,
 
       g_object_notify_by_pspec (G_OBJECT (self), switch_props[PROP_ACTIVE]);
 
+      gtk_accessible_update_state (GTK_ACCESSIBLE (self),
+                                   GTK_ACCESSIBLE_STATE_CHECKED, is_active,
+                                   -1);
+
       gtk_widget_queue_allocate (GTK_WIDGET (self));
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]