a11y: Present the checked state on the list row itself

That allows the visually impaired user to get the information quicker,
and, as a result of that, we can simplify the focus chain as well.
This commit is contained in:
Lukáš Tyrychtr 2023-05-16 12:12:50 +02:00 committed by Felipe Borges
parent f9c75e6694
commit 41cb03db76
2 changed files with 13 additions and 0 deletions

View file

@ -61,6 +61,14 @@ enum {
static GParamSpec *properties[N_PROPS];
static void
update_checked_state (CcListRow *self)
{
gtk_accessible_update_state (GTK_ACCESSIBLE (self),
GTK_ACCESSIBLE_STATE_CHECKED, self->switch_active,
-1);
}
static void
cc_list_row_switch_active_cb (CcListRow *self)
{
@ -75,6 +83,7 @@ cc_list_row_switch_active_cb (CcListRow *self)
return;
self->switch_active = switch_active;
update_checked_state (self);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ACTIVE]);
}
@ -133,6 +142,7 @@ cc_list_row_set_property (GObject *object,
gtk_switch_set_active (self->enable_switch,
g_value_get_boolean (value));
self->switch_active = g_value_get_boolean (value);
update_checked_state (self);
g_signal_handlers_unblock_by_func (self->enable_switch,
cc_list_row_switch_active_cb, self);
break;
@ -228,6 +238,8 @@ cc_list_row_set_show_switch (CcListRow *self,
adw_action_row_set_activatable_widget (ADW_ACTION_ROW (self),
self->show_switch ? GTK_WIDGET (self->enable_switch) : NULL);
update_checked_state (self);
}
gboolean

View file

@ -24,6 +24,7 @@
<object class="GtkSwitch" id="enable_switch">
<property name="visible">False</property>
<property name="valign">center</property>
<property name="can-focus">false</property>
<signal name="notify::active" handler="cc_list_row_switch_active_cb" swapped="yes"/>
</object>
</child>