[gnome-control-center/T20771: 25/44] user-accounts: Allow to create a user without a password



commit 09fd7d0c6e80b805c18f4007ed80f7b2a8d451c0
Author: Joaquim Rocha <jrocha endlessm com>
Date:   Fri Jun 9 17:35:58 2017 +0200

    user-accounts: Allow to create a user without a password
    
    This is done by a new radio button reflecting that option.
    
    https://phabricator.endlessm.com/T17270

 panels/user-accounts/data/account-dialog.ui |   18 +++++++++++++++-
 panels/user-accounts/um-account-dialog.c    |   30 ++++++++++++++++++++++++++-
 2 files changed, 46 insertions(+), 2 deletions(-)
---
diff --git a/panels/user-accounts/data/account-dialog.ui b/panels/user-accounts/data/account-dialog.ui
index 18d0b80..56ec60a 100644
--- a/panels/user-accounts/data/account-dialog.ui
+++ b/panels/user-accounts/data/account-dialog.ui
@@ -270,6 +270,22 @@
                       </packing>
                     </child>
                     <child>
+                      <object class="GtkRadioButton" id="local_no_password_radio">
+                        <property name="label" translatable="yes">Allow user to log in _without a 
password</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">local_password_login_radio</property>
+                        <property name="use_underline">True</property>
+                        <property name="margin_start">12</property>
+                      </object>
+                      <packing>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
                       <object class="GtkRadioButton" id="local_password_radio">
                         <property name="label" translatable="yes">Set a password _now</property>
                         <property name="visible">True</property>
@@ -281,7 +297,7 @@
                         <property name="use_underline">True</property>
                       </object>
                       <packing>
-                        <property name="position">1</property>
+                        <property name="position">2</property>
                       </packing>
                     </child>
                   </object>
diff --git a/panels/user-accounts/um-account-dialog.c b/panels/user-accounts/um-account-dialog.c
index 06b4fc2..b2505d5 100644
--- a/panels/user-accounts/um-account-dialog.c
+++ b/panels/user-accounts/um-account-dialog.c
@@ -86,6 +86,8 @@ struct _UmAccountDialog {
         gint       local_username_timeout_id;
         GtkWidget *account_type_standard;
         ActUserPasswordMode local_password_mode;
+        GtkWidget *local_password_login_radio;
+        GtkWidget *local_no_password_radio;
         GtkWidget *local_password_radio;
         GtkWidget *local_password;
         GtkWidget *local_verify;
@@ -549,7 +551,6 @@ on_password_radio_changed (GtkRadioButton *radio,
         gboolean active;
 
         active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio));
-        self->local_password_mode = active ? ACT_USER_PASSWORD_MODE_REGULAR : 
ACT_USER_PASSWORD_MODE_SET_AT_LOGIN;
 
         gtk_widget_set_sensitive (self->local_password, active);
         gtk_widget_set_sensitive (self->local_verify, active);
@@ -557,6 +558,29 @@ on_password_radio_changed (GtkRadioButton *radio,
         gtk_widget_set_sensitive (self->local_hint, active);
         gtk_widget_set_sensitive (self->local_reminder, active);
 
+        if (!active)
+                return;
+
+        self->local_password_mode = ACT_USER_PASSWORD_MODE_REGULAR;
+        dialog_validate (self);
+}
+
+static void
+on_no_password_radio_changed (GtkRadioButton *radio,
+                              gpointer user_data)
+{
+        UmAccountDialog *self = UM_ACCOUNT_DIALOG (user_data);
+        gboolean active;
+
+        active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio));
+        if (!active)
+                return;
+
+        if (radio == GTK_RADIO_BUTTON (self->local_no_password_radio))
+                self->local_password_mode = ACT_USER_PASSWORD_MODE_NONE;
+        else
+                self->local_password_mode = ACT_USER_PASSWORD_MODE_SET_AT_LOGIN;
+
         dialog_validate (self);
 }
 
@@ -573,6 +597,8 @@ local_init (UmAccountDialog *self)
         g_signal_connect_after (self->local_name, "focus-out-event", G_CALLBACK (on_name_focus_out), self);
         g_signal_connect_swapped (self->local_name, "activate", G_CALLBACK (dialog_validate), self);
 
+        g_signal_connect (self->local_password_login_radio, "toggled", G_CALLBACK 
(on_no_password_radio_changed), self);
+        g_signal_connect (self->local_no_password_radio, "toggled", G_CALLBACK 
(on_no_password_radio_changed), self);
         g_signal_connect (self->local_password_radio, "toggled", G_CALLBACK (on_password_radio_changed), 
self);
 
         self->local_password_mode = ACT_USER_PASSWORD_MODE_SET_AT_LOGIN;
@@ -1574,6 +1600,8 @@ um_account_dialog_class_init (UmAccountDialogClass *klass)
         gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_name);
         gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_username_hint);
         gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, account_type_standard);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_password_login_radio);
+        gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_no_password_radio);
         gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_password_radio);
         gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_password);
         gtk_widget_class_bind_template_child (widget_class, UmAccountDialog, local_verify);


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