[gnome-shell/wip/lockdown-show-password: 9/11] st/settings: Add new disable-show-password setting




commit 95a57bd79da8770f0ce23fd5b6da5671792972f6
Author: Ray Strode <rstrode redhat com>
Date:   Wed Jul 21 13:51:53 2021 -0400

    st/settings: Add new disable-show-password setting
    
    There's now a setting
    
    org.gnome.desktop.lockdown disable-show-password
    
    that ostensibly lets admins prevent from users from
    showing their password in password dialogs.
    
    gnome-shell currently ignores this key.
    
    As a first step, this commit adds the setting to StSettings.
    
    Future commits will use the new setting.

 meson.build          |  2 +-
 src/st/st-settings.c | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)
---
diff --git a/meson.build b/meson.build
index 82d4ad8e06..26ca245d53 100644
--- a/meson.build
+++ b/meson.build
@@ -28,7 +28,7 @@ gjs_req = '>= 1.68.1'
 gtk_req = '>= 3.15.0'
 mutter_req = '>= 41.alpha'
 polkit_req = '>= 0.100'
-schemas_req = '>= 3.33.1'
+schemas_req = '>= 41.alpha'
 startup_req = '>= 0.11'
 ibus_req = '>= 1.5.2'
 gnome_desktop_req = '>= 3.35.90'
diff --git a/src/st/st-settings.c b/src/st/st-settings.c
index 994893acb8..f4ca4a5a68 100644
--- a/src/st/st-settings.c
+++ b/src/st/st-settings.c
@@ -34,6 +34,7 @@
 #define KEY_GTK_THEME             "gtk-theme"
 #define KEY_GTK_ICON_THEME        "icon-theme"
 #define KEY_MAGNIFIER_ACTIVE      "screen-magnifier-enabled"
+#define KEY_DISABLE_SHOW_PASSWORD "disable-show-password"
 
 enum {
   PROP_0,
@@ -45,6 +46,7 @@ enum {
   PROP_GTK_ICON_THEME,
   PROP_MAGNIFIER_ACTIVE,
   PROP_SLOW_DOWN_FACTOR,
+  PROP_DISABLE_SHOW_PASSWORD,
   N_PROPS
 };
 
@@ -56,6 +58,7 @@ struct _StSettings
   GSettings *interface_settings;
   GSettings *mouse_settings;
   GSettings *a11y_settings;
+  GSettings *lockdown_settings;
 
   gchar *font_name;
   gchar *gtk_theme;
@@ -64,6 +67,7 @@ struct _StSettings
   gboolean enable_animations;
   gboolean primary_paste;
   gboolean magnifier_active;
+  gboolean disable_show_password;
   gint drag_threshold;
   double slow_down_factor;
 };
@@ -126,6 +130,7 @@ 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->lockdown_settings);
   g_free (settings->font_name);
   g_free (settings->gtk_theme);
   g_free (settings->gtk_icon_theme);
@@ -185,6 +190,9 @@ st_settings_get_property (GObject    *object,
     case PROP_SLOW_DOWN_FACTOR:
       g_value_set_double (value, settings->slow_down_factor);
       break;
+    case PROP_DISABLE_SHOW_PASSWORD:
+      g_value_set_boolean (value, settings->disable_show_password);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -288,6 +296,17 @@ st_settings_class_init (StSettingsClass *klass)
                                                       EPSILON, G_MAXDOUBLE, 1.0,
                                                       ST_PARAM_READWRITE);
 
+  /**
+   * StSettings:disable-show-password:
+   *
+   *  Whether password showing can be locked down
+   */
+  props[PROP_DISABLE_SHOW_PASSWORD] = g_param_spec_boolean("disable-show-password",
+                                                           "'Show Password' is disabled",
+                                                           "Whether user can request to see their password",
+                                                           FALSE,
+                                                           ST_PARAM_READABLE);
+
   g_object_class_install_properties (object_class, N_PROPS, props);
 }
 
@@ -351,6 +370,18 @@ on_a11y_settings_changed (GSettings   *g_settings,
     }
 }
 
+static void
+on_lockdown_settings_changed (GSettings   *g_settings,
+                              const gchar *key,
+                              StSettings  *settings)
+{
+  if (g_str_equal (key, KEY_DISABLE_SHOW_PASSWORD))
+    {
+      settings->disable_show_password = g_settings_get_boolean (g_settings, key);
+      g_object_notify_by_pspec (G_OBJECT (settings), props[PROP_DISABLE_SHOW_PASSWORD]);
+    }
+}
+
 static void
 st_settings_init (StSettings *settings)
 {
@@ -366,6 +397,10 @@ st_settings_init (StSettings *settings)
   g_signal_connect (settings->a11y_settings, "changed",
                     G_CALLBACK (on_a11y_settings_changed), settings);
 
+  settings->lockdown_settings = g_settings_new ("org.gnome.desktop.lockdown");
+  g_signal_connect (settings->lockdown_settings, "changed",
+                    G_CALLBACK (on_lockdown_settings_changed), settings);
+
   settings->enable_animations = g_settings_get_boolean (settings->interface_settings,
                                                         KEY_ENABLE_ANIMATIONS);
   settings->primary_paste = g_settings_get_boolean (settings->interface_settings,
@@ -381,6 +416,7 @@ st_settings_init (StSettings *settings)
   settings->magnifier_active = g_settings_get_boolean (settings->a11y_settings,
                                                        KEY_MAGNIFIER_ACTIVE);
   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]