a11y: Implement role and state change in GtkSwitch

Set the "switch" role, and update the "checked" state when the :active
property is toggled.
This commit is contained in:
Emmanuele Bassi 2020-07-17 14:31:02 +01:00
parent 732578eb53
commit 52c1fb8dfe

View File

@ -606,6 +606,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
@ -700,6 +702,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));
}
}