[gnome-shell/wip/exalm/dark-1: 110/112] st/settings: Use the new high-contrast gsettings key




commit 7fe31ddfba5221a115d798f3aec6830bfa5c86df
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Sun Dec 19 21:29:51 2021 +0500

    st/settings: Use the new high-contrast gsettings key
    
    We now have a dedicated "high-contrast" setting that we can
    use instead of a "magic" theme name.

 js/ui/main.js        |  7 +++---
 src/st/st-settings.c | 71 ++++++++++++++++++++++++++++++----------------------
 2 files changed, 44 insertions(+), 34 deletions(-)
---
diff --git a/js/ui/main.js b/js/ui/main.js
index 6ed34a7cd5..ee7cdedcac 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -156,7 +156,7 @@ function start() {
     sessionMode = new SessionMode.SessionMode();
     sessionMode.connect('updated', _sessionUpdated);
 
-    St.Settings.get().connect('notify::gtk-theme', _loadDefaultStylesheet);
+    St.Settings.get().connect('notify::high-contrast', _loadDefaultStylesheet);
 
     // Initialize ParentalControlsManager before the UI
     ParentalControlsManager.getDefault();
@@ -389,9 +389,8 @@ function _getDefaultStylesheet() {
     let stylesheet = null;
     let name = sessionMode.stylesheetName;
 
-    // Look for a high-contrast variant first when using GTK+'s HighContrast
-    // theme
-    if (St.Settings.get().gtk_theme == 'HighContrast')
+    // Look for a high-contrast variant first
+    if (St.Settings.get().high_contrast)
         stylesheet = _getStylesheet(name.replace('.css', '-high-contrast.css'));
 
     if (stylesheet == null)
diff --git a/src/st/st-settings.c b/src/st/st-settings.c
index f4ca4a5a68..0d5ca8616a 100644
--- a/src/st/st-settings.c
+++ b/src/st/st-settings.c
@@ -31,7 +31,7 @@
 #define KEY_PRIMARY_PASTE         "gtk-enable-primary-paste"
 #define KEY_DRAG_THRESHOLD        "drag-threshold"
 #define KEY_FONT_NAME             "font-name"
-#define KEY_GTK_THEME             "gtk-theme"
+#define KEY_HIGH_CONTRAST         "high-contrast"
 #define KEY_GTK_ICON_THEME        "icon-theme"
 #define KEY_MAGNIFIER_ACTIVE      "screen-magnifier-enabled"
 #define KEY_DISABLE_SHOW_PASSWORD "disable-show-password"
@@ -42,7 +42,7 @@ enum {
   PROP_PRIMARY_PASTE,
   PROP_DRAG_THRESHOLD,
   PROP_FONT_NAME,
-  PROP_GTK_THEME,
+  PROP_HIGH_CONTRAST,
   PROP_GTK_ICON_THEME,
   PROP_MAGNIFIER_ACTIVE,
   PROP_SLOW_DOWN_FACTOR,
@@ -57,11 +57,12 @@ struct _StSettings
   GObject parent_object;
   GSettings *interface_settings;
   GSettings *mouse_settings;
-  GSettings *a11y_settings;
+  GSettings *a11y_applications_settings;
+  GSettings *a11y_interface_settings;
   GSettings *lockdown_settings;
 
   gchar *font_name;
-  gchar *gtk_theme;
+  gboolean high_contrast;
   gchar *gtk_icon_theme;
   int inhibit_animations_count;
   gboolean enable_animations;
@@ -129,10 +130,10 @@ st_settings_finalize (GObject *object)
 
   g_object_unref (settings->interface_settings);
   g_object_unref (settings->mouse_settings);
-  g_object_unref (settings->a11y_settings);
+  g_object_unref (settings->a11y_applications_settings);
+  g_object_unref (settings->a11y_interface_settings);
   g_object_unref (settings->lockdown_settings);
   g_free (settings->font_name);
-  g_free (settings->gtk_theme);
   g_free (settings->gtk_icon_theme);
 
   G_OBJECT_CLASS (st_settings_parent_class)->finalize (object);
@@ -178,8 +179,8 @@ st_settings_get_property (GObject    *object,
     case PROP_FONT_NAME:
       g_value_set_string (value, settings->font_name);
       break;
-    case PROP_GTK_THEME:
-      g_value_set_string (value, settings->gtk_theme);
+    case PROP_HIGH_CONTRAST:
+      g_value_set_boolean (value, settings->high_contrast);
       break;
     case PROP_GTK_ICON_THEME:
       g_value_set_string (value, settings->gtk_icon_theme);
@@ -253,15 +254,15 @@ st_settings_class_init (StSettingsClass *klass)
                                                ST_PARAM_READABLE);
 
   /**
-   * StSettings:gtk-theme:
+   * StSettings:high-contrast:
    *
-   * The current GTK theme.
+   * Whether the accessibility high contrast mode is enabled.
    */
-  props[PROP_GTK_THEME] = g_param_spec_string ("gtk-theme",
-                                               "GTK Theme",
-                                               "GTK Theme",
-                                               "",
-                                               ST_PARAM_READABLE);
+  props[PROP_HIGH_CONTRAST] = g_param_spec_boolean ("high-contrast",
+                                                    "High contrast",
+                                                    "High contrast",
+                                                    FALSE,
+                                                    ST_PARAM_READABLE);
 
   /**
    * StSettings:gtk-icon-theme:
@@ -331,12 +332,6 @@ on_interface_settings_changed (GSettings   *g_settings,
       settings->font_name = g_settings_get_string (g_settings, key);
       g_object_notify_by_pspec (G_OBJECT (settings), props[PROP_FONT_NAME]);
     }
-  else if (g_str_equal (key, KEY_GTK_THEME))
-    {
-      g_free (settings->gtk_theme);
-      settings->gtk_theme = g_settings_get_string (g_settings, key);
-      g_object_notify_by_pspec (G_OBJECT (settings), props[PROP_GTK_THEME]);
-    }
   else if (g_str_equal (key, KEY_GTK_ICON_THEME))
     {
       g_free (settings->gtk_icon_theme);
@@ -359,9 +354,9 @@ on_mouse_settings_changed (GSettings   *g_settings,
 }
 
 static void
-on_a11y_settings_changed (GSettings   *g_settings,
-                          const gchar *key,
-                          StSettings  *settings)
+on_a11y_applications_settings_changed (GSettings   *g_settings,
+                                       const gchar *key,
+                                       StSettings  *settings)
 {
   if (g_str_equal (key, KEY_MAGNIFIER_ACTIVE))
     {
@@ -370,6 +365,18 @@ on_a11y_settings_changed (GSettings   *g_settings,
     }
 }
 
+static void
+on_a11y_interface_settings_changed (GSettings   *g_settings,
+                                    const gchar *key,
+                                    StSettings  *settings)
+{
+  if (g_str_equal (key, KEY_HIGH_CONTRAST))
+    {
+      settings->high_contrast = g_settings_get_boolean (g_settings, key);
+      g_object_notify_by_pspec (G_OBJECT (settings), props[PROP_HIGH_CONTRAST]);
+    }
+}
+
 static void
 on_lockdown_settings_changed (GSettings   *g_settings,
                               const gchar *key,
@@ -393,9 +400,13 @@ st_settings_init (StSettings *settings)
   g_signal_connect (settings->interface_settings, "changed",
                     G_CALLBACK (on_mouse_settings_changed), settings);
 
-  settings->a11y_settings = g_settings_new ("org.gnome.desktop.a11y.applications");
-  g_signal_connect (settings->a11y_settings, "changed",
-                    G_CALLBACK (on_a11y_settings_changed), settings);
+  settings->a11y_applications_settings = g_settings_new ("org.gnome.desktop.a11y.applications");
+  g_signal_connect (settings->a11y_applications_settings, "changed",
+                    G_CALLBACK (on_a11y_applications_settings_changed), settings);
+
+  settings->a11y_interface_settings = g_settings_new ("org.gnome.desktop.a11y.interface");
+  g_signal_connect (settings->a11y_interface_settings, "changed",
+                    G_CALLBACK (on_a11y_interface_settings_changed), settings);
 
   settings->lockdown_settings = g_settings_new ("org.gnome.desktop.lockdown");
   g_signal_connect (settings->lockdown_settings, "changed",
@@ -407,14 +418,14 @@ st_settings_init (StSettings *settings)
                                                     KEY_PRIMARY_PASTE);
   settings->font_name = g_settings_get_string (settings->interface_settings,
                                                KEY_FONT_NAME);
-  settings->gtk_theme = g_settings_get_string (settings->interface_settings,
-                                               KEY_GTK_THEME);
   settings->gtk_icon_theme = g_settings_get_string (settings->interface_settings,
                                                     KEY_GTK_ICON_THEME);
   settings->drag_threshold = g_settings_get_int (settings->mouse_settings,
                                                  KEY_DRAG_THRESHOLD);
-  settings->magnifier_active = g_settings_get_boolean (settings->a11y_settings,
+  settings->magnifier_active = g_settings_get_boolean (settings->a11y_applications_settings,
                                                        KEY_MAGNIFIER_ACTIVE);
+  settings->high_contrast = g_settings_get_boolean (settings->a11y_interface_settings,
+                                                    KEY_HIGH_CONTRAST);
   settings->slow_down_factor = 1.;
   settings->disable_show_password = g_settings_get_boolean (settings->lockdown_settings, 
KEY_DISABLE_SHOW_PASSWORD);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]