[gnome-initial-setup/wip/pwithnall/misc-fixes: 32/70] account-local: add toggle for passwordless accounts




commit 208a1791e5d5f386764a7512666a51a972ea0753
Author: Alessandro Puccetti <alessandro kinvolk io>
Date:   Wed Jun 7 10:41:00 2017 +0200

    account-local: add toggle for passwordless accounts
    
    (During the 3.36 rebase, I made the passwordless checkbox be above the
    new parental controls checkbox, with the hope that this avoids confusion
    about whether the child or parent account is the one being made
    passwordless; it's the child. -- Matthew Leeds)
    
    (Rebase 3.38: Fix minor rebase conflicts and squash in 3 fixups.)
    
    https://phabricator.endlessm.com/T17268

 gnome-initial-setup/pages/account/gis-account-page-local.c  | 10 ++++++++++
 gnome-initial-setup/pages/account/gis-account-page-local.ui | 13 ++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)
---
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 92e34c92..c6e54e79 100644
--- a/gnome-initial-setup/pages/account/gis-account-page-local.c
+++ b/gnome-initial-setup/pages/account/gis-account-page-local.c
@@ -54,6 +54,8 @@ struct _GisAccountPageLocalPrivate
   GtkWidget *enable_parental_controls_check_button;
   gboolean   has_custom_username;
   GtkWidget *username_explanation;
+  GtkWidget *password_toggle;
+  gboolean   passwordless;
   UmPhotoDialog *photo_dialog;
 
   gint timeout_id;
@@ -282,6 +284,8 @@ validate (GisAccountPageLocal *page)
 
   um_photo_dialog_generate_avatar (priv->photo_dialog, name);
 
+  priv->passwordless = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->password_toggle));
+
   validation_changed (page);
 
   return G_SOURCE_REMOVE;
@@ -438,6 +442,8 @@ gis_account_page_local_constructed (GObject *object)
                             "activate", G_CALLBACK (confirm), page);
   g_signal_connect_swapped (priv->fullname_entry, "activate",
                             G_CALLBACK (confirm), page);
+  g_signal_connect_swapped (priv->password_toggle, "notify::active",
+                            G_CALLBACK (validate), page);
   g_signal_connect (priv->enable_parental_controls_check_button, "toggled",
                     G_CALLBACK (enable_parental_controls_check_button_toggled_cb), page);
 
@@ -643,6 +649,9 @@ local_create_user (GisAccountPageLocal  *local,
 
   set_user_avatar (local, main_user);
 
+  if (priv->passwordless)
+    act_user_set_password_mode (main_user, ACT_USER_PASSWORD_MODE_NONE);
+
   g_signal_emit (local, signals[MAIN_USER_CREATED], 0, main_user, "");
 
   return create_shared_user (local, error);
@@ -661,6 +670,7 @@ gis_account_page_local_class_init (GisAccountPageLocalClass *klass)
   gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAccountPageLocal, 
fullname_entry);
   gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAccountPageLocal, 
username_combo);
   gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAccountPageLocal, 
username_explanation);
+  gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAccountPageLocal, 
password_toggle);
   gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAccountPageLocal, 
enable_parental_controls_box);
   gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAccountPageLocal, 
enable_parental_controls_check_button);
 
diff --git a/gnome-initial-setup/pages/account/gis-account-page-local.ui 
b/gnome-initial-setup/pages/account/gis-account-page-local.ui
index 489a3852..ccb40a6e 100644
--- a/gnome-initial-setup/pages/account/gis-account-page-local.ui
+++ b/gnome-initial-setup/pages/account/gis-account-page-local.ui
@@ -139,6 +139,17 @@
                 <property name="height">1</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkCheckButton" id="password_toggle">
+                <property name="label" translatable="yes">Set a password</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">6</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
             <child>
               <object class="GtkBox" id="enable_parental_controls_box">
                 <property name="visible">True</property>
@@ -168,7 +179,7 @@
               </object>
               <packing>
                 <property name="left_attach">1</property>
-                <property name="top_attach">6</property>
+                <property name="top_attach">7</property>
                 <property name="width">1</property>
                 <property name="height">1</property>
               </packing>


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