[gnome-disk-utility] Hints for passphrase fields



commit 847d6d25113d854030f31c406961bffdd18261c7
Author: Kai Lüke <kailueke riseup net>
Date:   Sun Apr 9 17:28:24 2017 +0200

    Hints for passphrase fields
    
    The format and passphrase dialogs don't let proceed for insufficient
    field input like e.g. a missmatch in the confirmed passphrase.
    
    Now also add an icon hint which field needs a correction.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=689360

 src/disks/gduchangepassphrasedialog.c |   32 ++++++++++++++++++++++++++++++++
 src/disks/gducreatefilesystemwidget.c |   16 ++++++++++++++++
 2 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/src/disks/gduchangepassphrasedialog.c b/src/disks/gduchangepassphrasedialog.c
index cb432a5..f7c965e 100644
--- a/src/disks/gduchangepassphrasedialog.c
+++ b/src/disks/gduchangepassphrasedialog.c
@@ -94,9 +94,41 @@ update (ChangePassphraseData *data)
   passphrase = gtk_entry_get_text (GTK_ENTRY (data->passphrase_entry));
   confirm_passphrase = gtk_entry_get_text (GTK_ENTRY (data->confirm_passphrase_entry));
 
+  gtk_entry_set_icon_from_icon_name (GTK_ENTRY (data->confirm_passphrase_entry),
+                                     GTK_ENTRY_ICON_SECONDARY,
+                                     NULL);
+  gtk_entry_set_icon_tooltip_text (GTK_ENTRY (data->confirm_passphrase_entry),
+                                   GTK_ENTRY_ICON_SECONDARY,
+                                   NULL);
+  gtk_entry_set_icon_from_icon_name (GTK_ENTRY (data->passphrase_entry),
+                                     GTK_ENTRY_ICON_SECONDARY,
+                                     NULL);
+  gtk_entry_set_icon_tooltip_text (GTK_ENTRY (data->passphrase_entry),
+                                   GTK_ENTRY_ICON_SECONDARY,
+                                   NULL);
+
   gdu_password_strength_widget_set_password (GDU_PASSWORD_STRENGTH_WIDGET (data->passphrase_strengh_widget),
                                              passphrase);
 
+  if (strlen (passphrase) > 0 && strlen (confirm_passphrase) > 0 && g_strcmp0 (passphrase, 
confirm_passphrase) != 0)
+    {
+      gtk_entry_set_icon_from_icon_name (GTK_ENTRY (data->confirm_passphrase_entry),
+                                         GTK_ENTRY_ICON_SECONDARY,
+                                         "dialog-warning-symbolic");
+      gtk_entry_set_icon_tooltip_text (GTK_ENTRY (data->confirm_passphrase_entry),
+                                       GTK_ENTRY_ICON_SECONDARY,
+                                       _("The passphrases do not match"));
+    }
+  if (strlen (existing_passphrase) > 0 && strlen (passphrase) > 0 && g_strcmp0 (passphrase, 
existing_passphrase) == 0)
+    {
+      gtk_entry_set_icon_from_icon_name (GTK_ENTRY (data->passphrase_entry),
+                                         GTK_ENTRY_ICON_SECONDARY,
+                                         "dialog-warning-symbolic");
+      gtk_entry_set_icon_tooltip_text (GTK_ENTRY (data->passphrase_entry),
+                                       GTK_ENTRY_ICON_SECONDARY,
+                                       _("The passphrase matches the existing passphrase"));
+    }
+
   if (strlen (existing_passphrase) > 0 && strlen (passphrase) > 0 &&
       g_strcmp0 (passphrase, confirm_passphrase) == 0 &&
       g_strcmp0 (passphrase, existing_passphrase) != 0)
diff --git a/src/disks/gducreatefilesystemwidget.c b/src/disks/gducreatefilesystemwidget.c
index 5c00384..55803e6 100644
--- a/src/disks/gducreatefilesystemwidget.c
+++ b/src/disks/gducreatefilesystemwidget.c
@@ -187,6 +187,13 @@ update (GduCreateFilesystemWidget *widget)
   const gchar *passphrase = NULL;
   const gchar *id;
 
+  gtk_entry_set_icon_from_icon_name (GTK_ENTRY (widget->confirm_passphrase_entry),
+                                     GTK_ENTRY_ICON_SECONDARY,
+                                     NULL);
+  gtk_entry_set_icon_tooltip_text (GTK_ENTRY (widget->confirm_passphrase_entry),
+                                   GTK_ENTRY_ICON_SECONDARY,
+                                   NULL);
+
   name = gtk_entry_get_text (GTK_ENTRY (widget->name_entry));
   passphrase = gtk_entry_get_text (GTK_ENTRY (widget->passphrase_entry));
 
@@ -219,6 +226,15 @@ update (GduCreateFilesystemWidget *widget)
             {
               has_info = TRUE;
             }
+          else if (strlen (gtk_entry_get_text (GTK_ENTRY (widget->confirm_passphrase_entry))) > 0)
+            {
+              gtk_entry_set_icon_from_icon_name (GTK_ENTRY (widget->confirm_passphrase_entry),
+                                                 GTK_ENTRY_ICON_SECONDARY,
+                                                 "dialog-warning-symbolic");
+              gtk_entry_set_icon_tooltip_text (GTK_ENTRY (widget->confirm_passphrase_entry),
+                                               GTK_ENTRY_ICON_SECONDARY,
+                                               _("The passphrases do not match"));
+            }
         }
       gdu_password_strength_widget_set_password (GDU_PASSWORD_STRENGTH_WIDGET 
(widget->passphrase_strengh_widget),
                                                  gtk_entry_get_text (GTK_ENTRY (widget->passphrase_entry)));


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