[gnome-control-center/mwleeds/allow-empty-password: 1/4] user-accounts: Allow to create a user without a password
- From: Phaedrus Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/mwleeds/allow-empty-password: 1/4] user-accounts: Allow to create a user without a password
- Date: Wed, 26 Aug 2020 23:46:28 +0000 (UTC)
commit b140bdc920cc564ca11bbbce4c60fc39c832f5b2
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.
panels/user-accounts/cc-add-user-dialog.c | 29 ++++++++++++++++++++++++++++-
panels/user-accounts/cc-add-user-dialog.ui | 20 +++++++++++++++++++-
2 files changed, 47 insertions(+), 2 deletions(-)
---
diff --git a/panels/user-accounts/cc-add-user-dialog.c b/panels/user-accounts/cc-add-user-dialog.c
index 7a99b09dd..8febfc411 100644
--- a/panels/user-accounts/cc-add-user-dialog.c
+++ b/panels/user-accounts/cc-add-user-dialog.c
@@ -72,6 +72,8 @@ struct _CcAddUserDialog {
GtkLabel *local_hint_label;
GtkEntry *local_name_entry;
GtkComboBoxText *local_username_combo;
+ GtkRadioButton *local_password_login_radio;
+ GtkRadioButton *local_no_password_radio;
GtkListStore *local_username_model;
GtkEntry *local_password_entry;
GtkRadioButton *local_password_radio;
@@ -775,13 +777,35 @@ local_password_radio_changed_cb (CcAddUserDialog *self)
gboolean active;
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->local_password_radio));
- self->local_password_mode = active ? ACT_USER_PASSWORD_MODE_REGULAR :
ACT_USER_PASSWORD_MODE_SET_AT_LOGIN;
gtk_widget_set_sensitive (GTK_WIDGET (self->local_password_entry), active);
gtk_widget_set_sensitive (GTK_WIDGET (self->local_verify_entry), active);
gtk_widget_set_sensitive (GTK_WIDGET (self->local_strength_indicator), active);
gtk_widget_set_sensitive (GTK_WIDGET (self->local_hint_label), active);
+ if (!active)
+ return;
+
+ self->local_password_mode = ACT_USER_PASSWORD_MODE_REGULAR;
+ dialog_validate (self);
+}
+
+static void
+on_no_password_radio_changed_cb (GtkRadioButton *radio,
+ gpointer user_data)
+{
+ CcAddUserDialog *self = CC_ADD_USER_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);
}
@@ -1722,6 +1746,8 @@ cc_add_user_dialog_class_init (CcAddUserDialogClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_username_combo);
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_username_model);
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_password_entry);
+ gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_password_login_radio);
+ gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_no_password_radio);
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_password_radio);
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_username_entry);
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_username_hint_label);
@@ -1745,6 +1771,7 @@ cc_add_user_dialog_class_init (CcAddUserDialogClass *klass)
gtk_widget_class_bind_template_callback (widget_class, local_password_entry_icon_press_cb);
gtk_widget_class_bind_template_callback (widget_class, local_password_entry_key_press_event_cb);
gtk_widget_class_bind_template_callback (widget_class, local_password_radio_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, on_no_password_radio_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, local_username_combo_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, local_username_combo_focus_out_event_cb);
gtk_widget_class_bind_template_callback (widget_class, local_verify_entry_changed_cb);
diff --git a/panels/user-accounts/cc-add-user-dialog.ui b/panels/user-accounts/cc-add-user-dialog.ui
index 12a253ac4..7cf5a0690 100644
--- a/panels/user-accounts/cc-add-user-dialog.ui
+++ b/panels/user-accounts/cc-add-user-dialog.ui
@@ -273,11 +273,29 @@
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="use_underline">True</property>
+ <signal name="toggled" handler="on_no_password_radio_changed_cb"
object="CcAddUserDialog" swapped="no"/>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
+ <child>
+ <object class="GtkRadioButton" id="local_no_password_radio">
+ <property name="label" translatable="yes">Do not re_quire a password when logging
in</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>
+ <signal name="toggled" handler="on_no_password_radio_changed_cb"
object="CcAddUserDialog" swapped="no"/>
+ </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>
@@ -291,7 +309,7 @@
<signal name="toggled" handler="local_password_radio_changed_cb"
object="CcAddUserDialog" swapped="yes"/>
</object>
<packing>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]