[gnome-control-center/mwleeds/allow-empty-password: 2/4] user-accounts: Allow to remove the password for a user
- From: Phaedrus Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/mwleeds/allow-empty-password: 2/4] user-accounts: Allow to remove the password for a user
- Date: Wed, 26 Aug 2020 23:46:28 +0000 (UTC)
commit 65c7b9569fa26fd90a0957fe17851b2a9797884a
Author: Joaquim Rocha <jrocha endlessm com>
Date: Fri Jun 9 17:40:14 2017 +0200
user-accounts: Allow to remove the password for a user
Since we now support users without passwords, admin users should be
able to set that option for existing users when changing their password.
panels/user-accounts/cc-password-dialog.c | 52 +++++++++++++++++++++++++-----
panels/user-accounts/cc-password-dialog.ui | 24 ++++++++++++--
2 files changed, 65 insertions(+), 11 deletions(-)
---
diff --git a/panels/user-accounts/cc-password-dialog.c b/panels/user-accounts/cc-password-dialog.c
index b199999c0..0212e121c 100644
--- a/panels/user-accounts/cc-password-dialog.c
+++ b/panels/user-accounts/cc-password-dialog.c
@@ -45,6 +45,7 @@ struct _CcPasswordDialog
GtkBox *action_radio_box;
GtkRadioButton *action_now_radio;
GtkRadioButton *action_login_radio;
+ GtkRadioButton *action_no_password_radio;
GtkButton *ok_button;
GtkLabel *old_password_label;
GtkEntry *old_password_entry;
@@ -188,6 +189,15 @@ ok_button_clicked_cb (CcPasswordDialog *self)
act_user_set_automatic_login (self->user, FALSE);
break;
+ case ACT_USER_PASSWORD_MODE_NONE:
+ /* When setting the user password mode to none, when it
+ * was previously set-at-login, we need to reset the password,
+ * otherwise the mode will be set back to set-at-login */
+ if (act_user_get_password_mode (self->user) == ACT_USER_PASSWORD_MODE_SET_AT_LOGIN)
+ act_user_set_password (self->user, "", "");
+ act_user_set_password_mode (self->user, self->password_mode);
+ break;
+
default:
g_assert_not_reached ();
}
@@ -229,23 +239,47 @@ mode_change (CcPasswordDialog *self,
gtk_widget_set_sensitive (GTK_WIDGET (self->old_password_entry), active);
gtk_widget_set_sensitive (GTK_WIDGET (self->password_hint_label), active);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->action_now_radio), active);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->action_login_radio), !active);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->action_login_radio),
+ (mode == ACT_USER_PASSWORD_MODE_SET_AT_LOGIN));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->action_no_password_radio),
+ (mode == ACT_USER_PASSWORD_MODE_NONE));
self->password_mode = mode;
update_sensitivity (self);
}
static void
-action_now_radio_toggled_cb (CcPasswordDialog *self)
+set_password_mode_from_radio_button (GtkRadioButton *radio,
+ CcPasswordDialog *self,
+ ActUserPasswordMode mode)
{
- gint active;
- ActUserPasswordMode mode;
+ if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio)))
+ return;
- active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->action_now_radio));
- mode = active ? ACT_USER_PASSWORD_MODE_REGULAR : ACT_USER_PASSWORD_MODE_SET_AT_LOGIN;
mode_change (self, mode);
}
+static void
+password_now_radio_toggled_cb (GtkRadioButton *radio,
+ CcPasswordDialog *self)
+{
+ set_password_mode_from_radio_button (radio, self, ACT_USER_PASSWORD_MODE_REGULAR);
+}
+
+static void
+no_password_radio_toggled_cb (GtkRadioButton *radio,
+ CcPasswordDialog *self)
+{
+ set_password_mode_from_radio_button (radio, self, ACT_USER_PASSWORD_MODE_NONE);
+}
+
+static void
+password_login_radio_toggled_cb (GtkRadioButton *radio,
+ CcPasswordDialog *self)
+{
+ set_password_mode_from_radio_button (radio, self, ACT_USER_PASSWORD_MODE_SET_AT_LOGIN);
+}
+
static void
update_password_match (CcPasswordDialog *self)
{
@@ -463,6 +497,7 @@ cc_password_dialog_class_init (CcPasswordDialogClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcPasswordDialog, action_radio_box);
gtk_widget_class_bind_template_child (widget_class, CcPasswordDialog, action_now_radio);
+ gtk_widget_class_bind_template_child (widget_class, CcPasswordDialog, action_no_password_radio);
gtk_widget_class_bind_template_child (widget_class, CcPasswordDialog, action_login_radio);
gtk_widget_class_bind_template_child (widget_class, CcPasswordDialog, ok_button);
gtk_widget_class_bind_template_child (widget_class, CcPasswordDialog, old_password_label);
@@ -473,7 +508,7 @@ cc_password_dialog_class_init (CcPasswordDialogClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcPasswordDialog, verify_entry);
gtk_widget_class_bind_template_child (widget_class, CcPasswordDialog, verify_hint_label);
- gtk_widget_class_bind_template_callback (widget_class, action_now_radio_toggled_cb);
+ gtk_widget_class_bind_template_callback (widget_class, no_password_radio_toggled_cb);
gtk_widget_class_bind_template_callback (widget_class, old_password_entry_changed);
gtk_widget_class_bind_template_callback (widget_class, old_password_entry_focus_out_cb);
gtk_widget_class_bind_template_callback (widget_class, ok_button_clicked_cb);
@@ -481,6 +516,8 @@ cc_password_dialog_class_init (CcPasswordDialogClass *klass)
gtk_widget_class_bind_template_callback (widget_class, password_entry_focus_out_cb);
gtk_widget_class_bind_template_callback (widget_class, password_entry_icon_press_cb);
gtk_widget_class_bind_template_callback (widget_class, password_entry_key_press_cb);
+ gtk_widget_class_bind_template_callback (widget_class, password_login_radio_toggled_cb);
+ gtk_widget_class_bind_template_callback (widget_class, password_now_radio_toggled_cb);
gtk_widget_class_bind_template_callback (widget_class, verify_entry_changed);
}
@@ -509,7 +546,6 @@ cc_password_dialog_new (ActUser *user)
gboolean visible;
mode_change (self, ACT_USER_PASSWORD_MODE_REGULAR);
- gtk_widget_hide (GTK_WIDGET (self->action_radio_box));
visible = (act_user_get_password_mode (user) != ACT_USER_PASSWORD_MODE_NONE);
gtk_widget_set_visible (GTK_WIDGET (self->old_password_label), visible);
diff --git a/panels/user-accounts/cc-password-dialog.ui b/panels/user-accounts/cc-password-dialog.ui
index bfcc7585b..88481a9ac 100644
--- a/panels/user-accounts/cc-password-dialog.ui
+++ b/panels/user-accounts/cc-password-dialog.ui
@@ -251,17 +251,35 @@
<property name="orientation">vertical</property>
<child>
<object class="GtkRadioButton" id="action_login_radio">
- <property name="label" translatable="yes">Allow user to change their password on
next login</property>
+ <property name="label" translatable="yes">Allow user to set a password when they
next _login</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="use_underline">True</property>
+ <signal name="toggled" handler="password_login_radio_toggled_cb"
object="CcPasswordDialog" swapped="no"/>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
+ <child>
+ <object class="GtkRadioButton" id="action_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">action_login_radio</property>
+ <property name="use_underline">True</property>
+ <signal name="toggled" handler="no_password_radio_toggled_cb"
object="CcPasswordDialog" swapped="no"/>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
<child>
<object class="GtkRadioButton" id="action_now_radio">
<property name="label" translatable="yes">Set a password now</property>
@@ -271,10 +289,10 @@
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">action_login_radio</property>
- <signal name="toggled" handler="action_now_radio_toggled_cb"
object="CcPasswordDialog" swapped="yes"/>
+ <signal name="toggled" handler="password_now_radio_toggled_cb"
object="CcPasswordDialog" swapped="no"/>
</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]