quickSettings: Set Atk checked state

Make sure that we update the accessibility state of a quick settings
toggle button appropriately to its actual state, as a screen reader has
no way of knowing otherwise whether it's actually checked or not.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7048
This commit is contained in:
Niels De Graef 2023-09-26 14:42:20 +02:00
parent b1a27d6086
commit 26f8bf1cad

View file

@ -128,6 +128,9 @@ export const QuickToggle = GObject.registerClass({
GObject.BindingFlags.SYNC_CREATE,
(bind, source) => [true, source !== null],
null);
this.connect('notify::checked', () => this._updateAccessibleState());
this._updateAccessibleState();
}
get label() {
@ -139,6 +142,13 @@ export const QuickToggle = GObject.registerClass({
console.warn('Trying to set label on QuickToggle. Use title instead.');
this.title = label;
}
_updateAccessibleState() {
if (this.checked)
this.add_accessible_state(Atk.StateType.CHECKED);
else
this.remove_accessible_state(Atk.StateType.CHECKED);
}
});
export const QuickMenuToggle = GObject.registerClass({