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');
|
||||
}
|
||||
|
||||
_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) {
|
||||
const settings = new Gio.Settings({schema_id: schema});
|
||||
const widget = new PopupMenu.PopupSwitchMenuItem(string, false);
|
||||
@ -129,19 +117,16 @@ class ATIndicator extends PanelMenu.Button {
|
||||
}
|
||||
|
||||
_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 initialSetting = factor > 1.0;
|
||||
let widget = this._buildItemExtended(_('Large Text'),
|
||||
initialSetting,
|
||||
settings.is_writable(KEY_TEXT_SCALING_FACTOR),
|
||||
enabled => {
|
||||
if (enabled) {
|
||||
settings.set_double(
|
||||
KEY_TEXT_SCALING_FACTOR, DPI_FACTOR_LARGE);
|
||||
} else {
|
||||
const widget =
|
||||
new PopupMenu.PopupSwitchMenuItem(_('Large Text'), factor > 1.0);
|
||||
|
||||
widget.connect('toggled', item => {
|
||||
if (item.state)
|
||||
settings.set_double(KEY_TEXT_SCALING_FACTOR, DPI_FACTOR_LARGE);
|
||||
else
|
||||
settings.reset(KEY_TEXT_SCALING_FACTOR);
|
||||
}
|
||||
});
|
||||
|
||||
settings.connect(`changed::${KEY_TEXT_SCALING_FACTOR}`, () => {
|
||||
@ -151,6 +136,9 @@ class ATIndicator extends PanelMenu.Button {
|
||||
|
||||
this._queueSyncMenuVisibility();
|
||||
});
|
||||
settings.bind_writable(KEY_TEXT_SCALING_FACTOR,
|
||||
widget, 'sensitive',
|
||||
false);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user