[gnome-control-center/mwleeds/add-password-reminder] user-accounts: Allow to set up a password reminder
- From: Phaedrus Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/mwleeds/add-password-reminder] user-accounts: Allow to set up a password reminder
- Date: Wed, 26 Aug 2020 22:54:36 +0000 (UTC)
commit e70ce77445935b2761ee5ad87e76a4e57c1ba185
Author: Cosimo Cecchi <cosimo endlessm com>
Date: Mon Mar 28 12:18:39 2016 -0700
user-accounts: Allow to set up a password reminder
When setting up user password, allow to set up also a password reminder phrase,
that can be used to remind the user what is the password.
Note 2020-08-26: This patch has been in Endless OS since 2016; proposing
it upstream with some minor changes to e.g. variable names. - mwleeds
panels/user-accounts/cc-add-user-dialog.c | 25 ++++++++++++++++---------
panels/user-accounts/cc-add-user-dialog.ui | 27 +++++++++++++++++++++++++++
panels/user-accounts/cc-password-dialog.c | 18 ++++++++++++++++--
panels/user-accounts/cc-password-dialog.ui | 28 ++++++++++++++++++++++++++++
4 files changed, 87 insertions(+), 11 deletions(-)
---
diff --git a/panels/user-accounts/cc-add-user-dialog.c b/panels/user-accounts/cc-add-user-dialog.c
index 7a99b09dd..eb4f4d255 100644
--- a/panels/user-accounts/cc-add-user-dialog.c
+++ b/panels/user-accounts/cc-add-user-dialog.c
@@ -75,6 +75,7 @@ struct _CcAddUserDialog {
GtkListStore *local_username_model;
GtkEntry *local_password_entry;
GtkRadioButton *local_password_radio;
+ GtkWidget *local_password_reminder;
GtkEntry *local_username_entry;
GtkLabel *local_username_hint_label;
GtkLevelBar *local_strength_indicator;
@@ -171,18 +172,22 @@ user_loaded_cb (CcAddUserDialog *self,
GParamSpec *pspec,
ActUser *user)
{
- const gchar *password;
+ const gchar *password;
+ const gchar *reminder;
+
+ finish_action (self);
- finish_action (self);
+ password = gtk_entry_get_text (GTK_ENTRY (self->local_password_entry));
+ reminder = gtk_entry_get_text (GTK_ENTRY (self->local_password_reminder));
+ act_user_set_password_mode (user, self->local_password_mode);
- /* Set a password for the user */
- password = gtk_entry_get_text (self->local_password_entry);
- act_user_set_password_mode (user, self->local_password_mode);
- if (self->local_password_mode == ACT_USER_PASSWORD_MODE_REGULAR)
- act_user_set_password (user, password, "");
+ if (self->local_password_mode == ACT_USER_PASSWORD_MODE_REGULAR) {
+ g_autofree gchar *sanitized_reminder = g_strstrip (g_strdup (reminder));
+ act_user_set_password (user, password, sanitized_reminder);
+ }
- self->user = g_object_ref (user);
- gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_CLOSE);
+ self->user = g_object_ref (user);
+ gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_CLOSE);
}
static void
@@ -781,6 +786,7 @@ local_password_radio_changed_cb (CcAddUserDialog *self)
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);
+ gtk_widget_set_sensitive (self->local_password_reminder, active);
dialog_validate (self);
}
@@ -1723,6 +1729,7 @@ cc_add_user_dialog_class_init (CcAddUserDialogClass *klass)
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_radio);
+ gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_password_reminder);
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);
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_strength_indicator);
diff --git a/panels/user-accounts/cc-add-user-dialog.ui b/panels/user-accounts/cc-add-user-dialog.ui
index 12a253ac4..8d7af78f1 100644
--- a/panels/user-accounts/cc-add-user-dialog.ui
+++ b/panels/user-accounts/cc-add-user-dialog.ui
@@ -464,6 +464,33 @@
<property name="height">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="label11">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Password _Reminder</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">local_reminder</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">11</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="local_reminder">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">11</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="name">_local</property>
diff --git a/panels/user-accounts/cc-password-dialog.c b/panels/user-accounts/cc-password-dialog.c
index b199999c0..4bee01cef 100644
--- a/panels/user-accounts/cc-password-dialog.c
+++ b/panels/user-accounts/cc-password-dialog.c
@@ -50,6 +50,7 @@ struct _CcPasswordDialog
GtkEntry *old_password_entry;
GtkEntry *password_entry;
GtkLabel *password_hint_label;
+ GtkEntry *password_reminder_entry;
GtkLevelBar *strength_indicator;
GtkEntry *verify_entry;
GtkLabel *verify_hint_label;
@@ -116,6 +117,12 @@ password_changed_cb (PasswdHandler *handler,
gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (self)), NULL);
if (!error) {
+ g_autofree gchar *sanitized_reminder = NULL;
+ const gchar *reminder;
+
+ reminder = gtk_entry_get_text (GTK_ENTRY (self->password_reminder_entry));
+ sanitized_reminder = g_strstrip (g_strdup (reminder));
+ act_user_set_password_hint (self->user, sanitized_reminder);
gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_ACCEPT);
return;
}
@@ -155,7 +162,8 @@ password_changed_cb (PasswdHandler *handler,
static void
ok_button_clicked_cb (CcPasswordDialog *self)
{
- const gchar *password;
+ const gchar *password, *reminder;
+ g_autofree char *sanitized_reminder = NULL;
password = gtk_entry_get_text (self->password_entry);
@@ -179,8 +187,10 @@ ok_button_clicked_cb (CcPasswordDialog *self)
return;
}
+ reminder = gtk_entry_get_text (GTK_ENTRY (self->password_reminder_entry));
+ sanitized_reminder = g_strstrip (g_strdup (reminder));
act_user_set_password_mode (self->user, ACT_USER_PASSWORD_MODE_REGULAR);
- act_user_set_password (self->user, password, "");
+ act_user_set_password (self->user, password, sanitized_reminder);
break;
case ACT_USER_PASSWORD_MODE_SET_AT_LOGIN:
@@ -228,6 +238,7 @@ mode_change (CcPasswordDialog *self,
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_widget_set_sensitive (GTK_WIDGET (self->password_reminder_entry), 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);
@@ -467,6 +478,7 @@ cc_password_dialog_class_init (CcPasswordDialogClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcPasswordDialog, ok_button);
gtk_widget_class_bind_template_child (widget_class, CcPasswordDialog, old_password_label);
gtk_widget_class_bind_template_child (widget_class, CcPasswordDialog, old_password_entry);
+ gtk_widget_class_bind_template_child (widget_class, CcPasswordDialog, password_reminder_entry);
gtk_widget_class_bind_template_child (widget_class, CcPasswordDialog, password_entry);
gtk_widget_class_bind_template_child (widget_class, CcPasswordDialog, password_hint_label);
gtk_widget_class_bind_template_child (widget_class, CcPasswordDialog, strength_indicator);
@@ -504,6 +516,7 @@ cc_password_dialog_new (ActUser *user)
NULL);
self->user = g_object_ref (user);
+ gtk_entry_set_text (GTK_ENTRY (self->password_reminder_entry), "");
if (act_user_get_uid (self->user) == getuid ()) {
gboolean visible;
@@ -514,6 +527,7 @@ cc_password_dialog_new (ActUser *user)
visible = (act_user_get_password_mode (user) != ACT_USER_PASSWORD_MODE_NONE);
gtk_widget_set_visible (GTK_WIDGET (self->old_password_label), visible);
gtk_widget_set_visible (GTK_WIDGET (self->old_password_entry), visible);
+ gtk_entry_set_text (GTK_ENTRY (self->password_reminder_entry), act_user_get_password_hint
(user));
self->old_password_ok = !visible;
self->passwd_handler = passwd_init ();
diff --git a/panels/user-accounts/cc-password-dialog.ui b/panels/user-accounts/cc-password-dialog.ui
index bfcc7585b..e2b9c3c04 100644
--- a/panels/user-accounts/cc-password-dialog.ui
+++ b/panels/user-accounts/cc-password-dialog.ui
@@ -284,6 +284,34 @@
<property name="width">3</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="password_reminder_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Password _Reminder</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">password_reminder_entry</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">9</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="password_reminder_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="activates_default">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">9</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="position">0</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]