status/a11y: Simplify "Large Text" toggle
It is the last user of `_buildItemExtended()`, so merge it with `_buildFontItem()`. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3576>
This commit is contained in:
parent
6029380267
commit
3d87782a58
@ -105,18 +105,6 @@ class ATIndicator extends PanelMenu.Button {
|
|||||||
GLib.Source.set_name_by_id(this._syncMenuVisibilityIdle, '[gnome-shell] this._syncMenuVisibility');
|
GLib.Source.set_name_by_id(this._syncMenuVisibilityIdle, '[gnome-shell] this._syncMenuVisibility');
|
||||||
}
|
}
|
||||||
|
|
||||||
_buildItemExtended(string, initialValue, writable, onSet) {
|
|
||||||
let widget = new PopupMenu.PopupSwitchMenuItem(string, initialValue);
|
|
||||||
if (!writable) {
|
|
||||||
widget.reactive = false;
|
|
||||||
} else {
|
|
||||||
widget.connect('toggled', item => {
|
|
||||||
onSet(item.state);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
_buildItem(string, schema, key) {
|
_buildItem(string, schema, key) {
|
||||||
const settings = new Gio.Settings({schema_id: schema});
|
const settings = new Gio.Settings({schema_id: schema});
|
||||||
const widget = new PopupMenu.PopupSwitchMenuItem(string, false);
|
const widget = new PopupMenu.PopupSwitchMenuItem(string, false);
|
||||||
@ -129,20 +117,17 @@ class ATIndicator extends PanelMenu.Button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_buildFontItem() {
|
_buildFontItem() {
|
||||||
let settings = new Gio.Settings({schema_id: DESKTOP_INTERFACE_SCHEMA});
|
const settings = new Gio.Settings({schema_id: DESKTOP_INTERFACE_SCHEMA});
|
||||||
let factor = settings.get_double(KEY_TEXT_SCALING_FACTOR);
|
let factor = settings.get_double(KEY_TEXT_SCALING_FACTOR);
|
||||||
let initialSetting = factor > 1.0;
|
const widget =
|
||||||
let widget = this._buildItemExtended(_('Large Text'),
|
new PopupMenu.PopupSwitchMenuItem(_('Large Text'), factor > 1.0);
|
||||||
initialSetting,
|
|
||||||
settings.is_writable(KEY_TEXT_SCALING_FACTOR),
|
widget.connect('toggled', item => {
|
||||||
enabled => {
|
if (item.state)
|
||||||
if (enabled) {
|
settings.set_double(KEY_TEXT_SCALING_FACTOR, DPI_FACTOR_LARGE);
|
||||||
settings.set_double(
|
else
|
||||||
KEY_TEXT_SCALING_FACTOR, DPI_FACTOR_LARGE);
|
settings.reset(KEY_TEXT_SCALING_FACTOR);
|
||||||
} else {
|
});
|
||||||
settings.reset(KEY_TEXT_SCALING_FACTOR);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
settings.connect(`changed::${KEY_TEXT_SCALING_FACTOR}`, () => {
|
settings.connect(`changed::${KEY_TEXT_SCALING_FACTOR}`, () => {
|
||||||
factor = settings.get_double(KEY_TEXT_SCALING_FACTOR);
|
factor = settings.get_double(KEY_TEXT_SCALING_FACTOR);
|
||||||
@ -151,6 +136,9 @@ class ATIndicator extends PanelMenu.Button {
|
|||||||
|
|
||||||
this._queueSyncMenuVisibility();
|
this._queueSyncMenuVisibility();
|
||||||
});
|
});
|
||||||
|
settings.bind_writable(KEY_TEXT_SCALING_FACTOR,
|
||||||
|
widget, 'sensitive',
|
||||||
|
false);
|
||||||
|
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user