[gnome-initial-setup/wip/pwithnall/misc-fixes: 46/70] password: Reset the password page whenever the password page gets hidden




commit e809bc633cc81636c82ee4198c884b984480d925
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Wed Apr 25 15:33:55 2018 +0100

    password: Reset the password page whenever the password page gets hidden
    
    This will be useful to prevent the password from being picked up at
    the end of the FBE process if someone decides that wants to use a
    password at first and sets one but then goes back to the "account"
    page and turns off the "Password protected" switch.
    
    https://phabricator.endlessm.com/T22042

 .../pages/password/gis-password-page.c             | 29 ++++++++++++++++++++++
 1 file changed, 29 insertions(+)
---
diff --git a/gnome-initial-setup/pages/password/gis-password-page.c 
b/gnome-initial-setup/pages/password/gis-password-page.c
index d12fba72..097befc4 100644
--- a/gnome-initial-setup/pages/password/gis-password-page.c
+++ b/gnome-initial-setup/pages/password/gis-password-page.c
@@ -284,6 +284,32 @@ validate (GisPasswordPage *page)
   return G_SOURCE_REMOVE;
 }
 
+static void
+page_visibility_changed (GtkWidget  *w,
+                         GParamSpec *pspec,
+                         gpointer    unused)
+{
+  /* Make sure to reset the password page in this case, to prevent situations
+   * where a previously introduced password, that is no longer required, would
+   * end up being used anyway when creating the user's account.
+   */
+  if (!gtk_widget_get_visible (w)) {
+    GisPasswordPage *page = GIS_PASSWORD_PAGE (w);
+    GisPasswordPagePrivate *priv = gis_password_page_get_instance_private (page);
+
+    gtk_entry_set_text (GTK_ENTRY (priv->password_entry), "");
+    gtk_entry_set_text (GTK_ENTRY (priv->confirm_entry), "");
+    gtk_entry_set_text (GTK_ENTRY (priv->reminder_entry), "");
+    gtk_entry_set_visibility (GTK_ENTRY (priv->password_entry), FALSE);
+    gtk_entry_set_icon_from_icon_name (GTK_ENTRY (priv->password_entry),
+                                       GTK_ENTRY_ICON_PRIMARY,
+                                       "eye-open-negative-filled-symbolic");
+    gtk_entry_set_icon_tooltip_text (GTK_ENTRY (priv->password_entry),
+                                     GTK_ENTRY_ICON_PRIMARY,
+                                     _("Show password"));
+  }
+}
+
 static gboolean
 on_focusout (GisPasswordPage *page)
 {
@@ -379,6 +405,9 @@ gis_password_page_constructed (GObject *object)
 
   G_OBJECT_CLASS (gis_password_page_parent_class)->constructed (object);
 
+  g_signal_connect (page, "notify::visible",
+                    G_CALLBACK (page_visibility_changed), NULL);
+
   g_signal_connect (priv->password_entry, "notify::text",
                     G_CALLBACK (password_changed), page);
   g_signal_connect_swapped (priv->password_entry, "focus-out-event",


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