[gnome-initial-setup/wip/pwithnall/misc-fixes: 48/70] account: Check configuration to hide password switch if needed




commit 499d7574f12ef7f4ed93e20fa90388865047786c
Author: Joaquim Rocha <jrocha endlessm com>
Date:   Fri Jul 20 18:21:14 2018 +0200

    account: Check configuration to hide password switch if needed
    
    If a vendor wants to have passwordless accounts by default, then they
    should be able to set that in the vendor configuration file.
    This patch allows that by using the "show-password-switch" option in the
    "page.account" group.
    
    https://phabricator.endlessm.com/T23326

 .../pages/account/gis-account-page-local.c           |  8 ++++++++
 .../pages/account/gis-account-page-local.h           |  2 ++
 gnome-initial-setup/pages/account/gis-account-page.c | 20 ++++++++++++++++++++
 3 files changed, 30 insertions(+)
---
diff --git a/gnome-initial-setup/pages/account/gis-account-page-local.c 
b/gnome-initial-setup/pages/account/gis-account-page-local.c
index 0a552d57..98a81dba 100644
--- a/gnome-initial-setup/pages/account/gis-account-page-local.c
+++ b/gnome-initial-setup/pages/account/gis-account-page-local.c
@@ -763,3 +763,11 @@ gis_account_page_local_shown (GisAccountPageLocal *local)
   GisAccountPageLocalPrivate *priv = gis_account_page_local_get_instance_private (local);
   gtk_widget_grab_focus (priv->fullname_entry);
 }
+
+void
+gis_account_page_local_show_password_toggle (GisAccountPageLocal *local,
+                                             gboolean show_password_toggle)
+{
+  GisAccountPageLocalPrivate *priv = gis_account_page_local_get_instance_private (local);
+  gtk_widget_set_visible (priv->password_toggle, show_password_toggle);
+}
diff --git a/gnome-initial-setup/pages/account/gis-account-page-local.h 
b/gnome-initial-setup/pages/account/gis-account-page-local.h
index 1674ad88..715a48e4 100644
--- a/gnome-initial-setup/pages/account/gis-account-page-local.h
+++ b/gnome-initial-setup/pages/account/gis-account-page-local.h
@@ -54,6 +54,8 @@ gboolean gis_account_page_local_create_user (GisAccountPageLocal  *local,
                                              GisPage              *page,
                                              GError              **error);
 void gis_account_page_local_shown (GisAccountPageLocal *local);
+void gis_account_page_local_show_password_toggle (GisAccountPageLocal *local,
+                                                  gboolean show_password_toggle);
 
 G_END_DECLS
 
diff --git a/gnome-initial-setup/pages/account/gis-account-page.c 
b/gnome-initial-setup/pages/account/gis-account-page.c
index 93d9e81a..70ad959e 100644
--- a/gnome-initial-setup/pages/account/gis-account-page.c
+++ b/gnome-initial-setup/pages/account/gis-account-page.c
@@ -32,6 +32,9 @@
 #include <glib/gi18n.h>
 #include <gio/gio.h>
 
+#define CONFIG_ACCOUNT_GROUP "page.account"
+#define CONFIG_ACCOUNT_SHOW_PASSWORD_SWITCH_KEY "show-password-switch"
+
 struct _GisAccountPagePrivate
 {
   GtkWidget *page_local;
@@ -86,6 +89,22 @@ on_validation_changed (gpointer        page_area,
   update_page_validation (page);
 }
 
+
+static void
+hide_password_toggle_if_needed (GisAccountPage *page)
+{
+  GisAccountPagePrivate *priv = gis_account_page_get_instance_private (page);
+  gboolean show_password_toggle;
+
+  /* check the conf file to see if the password toggle should be shown/hidden */
+  show_password_toggle = gis_driver_conf_get_boolean (GIS_PAGE (page)->driver,
+                                                      CONFIG_ACCOUNT_GROUP,
+                                                      CONFIG_ACCOUNT_SHOW_PASSWORD_SWITCH_KEY,
+                                                      TRUE);
+  gis_account_page_local_show_password_toggle (GIS_ACCOUNT_PAGE_LOCAL (priv->page_local),
+                                               show_password_toggle);
+}
+
 static void
 set_mode (GisAccountPage *page,
           UmAccountMode   mode)
@@ -103,6 +122,7 @@ set_mode (GisAccountPage *page,
     case UM_LOCAL:
       gtk_stack_set_visible_child (GTK_STACK (priv->stack), priv->page_local);
       gis_account_page_local_shown (GIS_ACCOUNT_PAGE_LOCAL (priv->page_local));
+      hide_password_toggle_if_needed (page);
       break;
     case UM_ENTERPRISE:
       gtk_stack_set_visible_child (GTK_STACK (priv->stack), priv->page_enterprise);


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