status/a11y: Block 'toggled' signal when manually toggling

When the 'text-scaling-factor' key changes and it's set bigger than 1.0,
the corresponding switch is activated in the a11y menu. However, since
commit 946ee936926a0e14fa5f86f62da757bcb581a147, setting the state using
`setToggleState()` also fires the 'toggled' signal, which is I think
correct and intended.

However, that means the GSettings handler for 'text-scaling-factor'
should block that 'toggled' handler when it sets the switch active, as
otherwise the 'text-scaling-factor' is always set to 1.25 when it is
first made bigger than 1.0.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3574>
This commit is contained in:
Matthijs Velsink 2024-12-15 21:53:06 +01:00
parent 5057a7fe0e
commit 1e6c92a083

View File

@ -122,7 +122,7 @@ class ATIndicator extends PanelMenu.Button {
const widget =
new PopupMenu.PopupSwitchMenuItem(_('Large Text'), factor > 1.0);
widget.connect('toggled', item => {
const toggledId = widget.connect('toggled', item => {
if (item.state)
settings.set_double(KEY_TEXT_SCALING_FACTOR, DPI_FACTOR_LARGE);
else
@ -132,7 +132,10 @@ class ATIndicator extends PanelMenu.Button {
settings.connect(`changed::${KEY_TEXT_SCALING_FACTOR}`, () => {
factor = settings.get_double(KEY_TEXT_SCALING_FACTOR);
let active = factor > 1.0;
widget.block_signal_handler(toggledId);
widget.setToggleState(active);
widget.unblock_signal_handler(toggledId);
this._queueSyncMenuVisibility();
});