[gnome-shell/wip/exalm/dark-1: 46/46] status/a11y: Use the new high-contrast gsettings key
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/exalm/dark-1: 46/46] status/a11y: Use the new high-contrast gsettings key
- Date: Wed, 5 Jan 2022 18:20:24 +0000 (UTC)
commit 601ac5ade0db28915ad0256f5c641b17e0bc72e0
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sun Dec 19 21:30:00 2021 +0500
status/a11y: Use the new high-contrast gsettings key
With the new boolean setting, the "High Contrast" toggle can now
simply toggle the setting instead of the current gtk/icon-theme
shenanigans.
This isn't only much simpler, but will also make switching between
high-contrast and a non-default theme reliable at last.
js/ui/status/accessibility.js | 51 +++----------------------------------------
1 file changed, 3 insertions(+), 48 deletions(-)
---
diff --git a/js/ui/status/accessibility.js b/js/ui/status/accessibility.js
index a0513f68c8..47a8d33fc1 100644
--- a/js/ui/status/accessibility.js
+++ b/js/ui/status/accessibility.js
@@ -23,11 +23,10 @@ const WM_SCHEMA = 'org.gnome.desktop.wm.preferences';
const KEY_VISUAL_BELL = 'visual-bell';
const DESKTOP_INTERFACE_SCHEMA = 'org.gnome.desktop.interface';
-const KEY_GTK_THEME = 'gtk-theme';
-const KEY_ICON_THEME = 'icon-theme';
const KEY_TEXT_SCALING_FACTOR = 'text-scaling-factor';
-const HIGH_CONTRAST_THEME = 'HighContrast';
+const A11Y_INTERFACE_SCHEMA = 'org.gnome.desktop.a11y.interface';
+const KEY_HIGH_CONTRAST = 'high-contrast';
var ATIndicator = GObject.registerClass(
class ATIndicator extends PanelMenu.Button {
@@ -42,7 +41,7 @@ class ATIndicator extends PanelMenu.Button {
this._a11ySettings = new Gio.Settings({ schema_id: A11Y_SCHEMA });
this._a11ySettings.connect('changed::%s'.format(KEY_ALWAYS_SHOW),
this._queueSyncMenuVisibility.bind(this));
- let highContrast = this._buildHCItem();
+ let highContrast = this._buildItem(_('High Contrast'), A11Y_INTERFACE_SCHEMA, KEY_HIGH_CONTRAST);
this.menu.addMenuItem(highContrast);
let magnifier = this._buildItem(_("Zoom"), APPLICATIONS_SCHEMA,
@@ -125,50 +124,6 @@ class ATIndicator extends PanelMenu.Button {
return widget;
}
- _buildHCItem() {
- let interfaceSettings = new Gio.Settings({ schema_id: DESKTOP_INTERFACE_SCHEMA });
- let gtkTheme = interfaceSettings.get_string(KEY_GTK_THEME);
- let iconTheme = interfaceSettings.get_string(KEY_ICON_THEME);
- let hasHC = gtkTheme == HIGH_CONTRAST_THEME;
- let highContrast = this._buildItemExtended(
- _("High Contrast"),
- hasHC,
- interfaceSettings.is_writable(KEY_GTK_THEME) &&
- interfaceSettings.is_writable(KEY_ICON_THEME),
- enabled => {
- if (enabled) {
- interfaceSettings.set_string(KEY_ICON_THEME, HIGH_CONTRAST_THEME);
- interfaceSettings.set_string(KEY_GTK_THEME, HIGH_CONTRAST_THEME);
- } else if (!hasHC) {
- interfaceSettings.set_string(KEY_ICON_THEME, iconTheme);
- interfaceSettings.set_string(KEY_GTK_THEME, gtkTheme);
- } else {
- interfaceSettings.reset(KEY_ICON_THEME);
- interfaceSettings.reset(KEY_GTK_THEME);
- }
- });
-
- interfaceSettings.connect('changed::%s'.format(KEY_GTK_THEME), () => {
- let value = interfaceSettings.get_string(KEY_GTK_THEME);
- if (value == HIGH_CONTRAST_THEME) {
- highContrast.setToggleState(true);
- } else {
- highContrast.setToggleState(false);
- gtkTheme = value;
- }
-
- this._queueSyncMenuVisibility();
- });
-
- interfaceSettings.connect('changed::%s'.format(KEY_ICON_THEME), () => {
- let value = interfaceSettings.get_string(KEY_ICON_THEME);
- if (value != HIGH_CONTRAST_THEME)
- iconTheme = value;
- });
-
- return highContrast;
- }
-
_buildFontItem() {
let settings = new Gio.Settings({ schema_id: DESKTOP_INTERFACE_SCHEMA });
let factor = settings.get_double(KEY_TEXT_SCALING_FACTOR);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]