[gnome-control-center/mwleeds/allow-empty-password: 4/4] user-accounts: Allow to change the password mode for oneself
- From: Phaedrus Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/mwleeds/allow-empty-password: 4/4] user-accounts: Allow to change the password mode for oneself
- Date: Wed, 26 Aug 2020 23:46:28 +0000 (UTC)
commit 61149a221ee9d7fcabc85e7d787a7890d2e7aa6e
Author: Joaquim Rocha <jrocha endlessm com>
Date: Fri Jun 9 17:40:14 2017 +0200
user-accounts: Allow to change the password mode for oneself
This patch modifies the password change dialog in order to allow users
to change their own password mode (i.e. remove or reinstate a password).
Unlike when changing the password for other users, when changing it for
oneself, if a password is currently set, the password change dialog will
require the user to authenticate before modifying the mode or password.
panels/user-accounts/cc-password-dialog.c | 16 +++++++++++-----
panels/user-accounts/cc-password-dialog.ui | 12 +++++-------
2 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/panels/user-accounts/cc-password-dialog.c b/panels/user-accounts/cc-password-dialog.c
index c170e118c..38b188780 100644
--- a/panels/user-accounts/cc-password-dialog.c
+++ b/panels/user-accounts/cc-password-dialog.c
@@ -209,7 +209,7 @@ static void
update_sensitivity (CcPasswordDialog *self)
{
const gchar *password, *verify;
- gboolean can_change;
+ gboolean can_change = TRUE;
int strength;
password = gtk_entry_get_text (self->password_entry);
@@ -220,8 +220,8 @@ update_sensitivity (CcPasswordDialog *self)
can_change = strength > 1 && strcmp (password, verify) == 0 &&
(self->old_password_ok || !gtk_widget_get_visible (GTK_WIDGET
(self->old_password_entry)));
}
- else {
- can_change = TRUE;
+ else if (self->password_mode == ACT_USER_PASSWORD_MODE_NONE) {
+ can_change = self->old_password_ok || !gtk_widget_get_visible (GTK_WIDGET
(self->old_password_entry));
}
gtk_widget_set_sensitive (GTK_WIDGET (self->ok_button), can_change);
@@ -232,11 +232,11 @@ mode_change (CcPasswordDialog *self,
ActUserPasswordMode mode)
{
gboolean active;
+ gboolean user_is_self = (act_user_get_uid (self->user) == getuid ());
active = (mode == ACT_USER_PASSWORD_MODE_REGULAR);
gtk_widget_set_sensitive (GTK_WIDGET (self->password_entry), active);
gtk_widget_set_sensitive (GTK_WIDGET (self->verify_entry), active);
- 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),
@@ -244,6 +244,11 @@ mode_change (CcPasswordDialog *self,
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->action_no_password_radio),
(mode == ACT_USER_PASSWORD_MODE_NONE));
+ if (user_is_self) {
+ gtk_widget_set_sensitive (GTK_WIDGET (self->old_password_entry),
+ act_user_get_password_mode (self->user) ==
ACT_USER_PASSWORD_MODE_REGULAR);
+ }
+
self->password_mode = mode;
update_sensitivity (self);
}
@@ -541,6 +546,7 @@ cc_password_dialog_new (ActUser *user)
NULL);
self->user = g_object_ref (user);
+ gtk_widget_show_all (GTK_WIDGET (self->action_radio_box));
if (act_user_get_uid (self->user) == getuid ()) {
gboolean visible;
@@ -548,6 +554,7 @@ cc_password_dialog_new (ActUser *user)
mode_change (self, ACT_USER_PASSWORD_MODE_REGULAR);
visible = (act_user_get_password_mode (user) != ACT_USER_PASSWORD_MODE_NONE);
+ gtk_widget_hide (GTK_WIDGET (self->action_login_radio));
gtk_widget_set_visible (GTK_WIDGET (self->old_password_label), visible);
gtk_widget_set_visible (GTK_WIDGET (self->old_password_entry), visible);
self->old_password_ok = !visible;
@@ -556,7 +563,6 @@ cc_password_dialog_new (ActUser *user)
}
else {
mode_change (self, act_user_get_password_mode (user));
- gtk_widget_show (GTK_WIDGET (self->action_radio_box));
gtk_widget_hide (GTK_WIDGET (self->old_password_label));
gtk_widget_hide (GTK_WIDGET (self->old_password_entry));
diff --git a/panels/user-accounts/cc-password-dialog.ui b/panels/user-accounts/cc-password-dialog.ui
index 88481a9ac..d96999fad 100644
--- a/panels/user-accounts/cc-password-dialog.ui
+++ b/panels/user-accounts/cc-password-dialog.ui
@@ -218,13 +218,10 @@
<property name="mnemonic_widget">old_password_entry</property>
<property name="margin_start">25</property>
<property name="margin_bottom">12</property>
- <style>
- <class name="dim-label"/>
- </style>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">1</property>
</packing>
</child>
<child>
@@ -242,7 +239,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">1</property>
</packing>
</child>
<child>
@@ -282,13 +279,14 @@
</child>
<child>
<object class="GtkRadioButton" id="action_now_radio">
- <property name="label" translatable="yes">Set a password now</property>
+ <property name="label" translatable="yes">Set a password _now</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="password_now_radio_toggled_cb"
object="CcPasswordDialog" swapped="no"/>
</object>
<packing>
@@ -298,7 +296,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">1</property>
+ <property name="top_attach">3</property>
<property name="width">3</property>
</packing>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]