[virt-tools-list] [virt-viewer: PATCH v2] Add support to view the password entry content

Fabiano Fidêncio fidencio at redhat.com
Mon Sep 15 14:13:52 UTC 2014


Allow users to check if the entered password is right and/org modify
the password easily in case it's wrong.
---
 src/virt-viewer-auth.c   | 11 +++++++++++
 src/virt-viewer-auth.xml | 13 +++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/src/virt-viewer-auth.c b/src/virt-viewer-auth.c
index 230d720..fb8fafe 100644
--- a/src/virt-viewer-auth.c
+++ b/src/virt-viewer-auth.c
@@ -32,6 +32,13 @@
 
 #include "virt-viewer-auth.h"
 
+static void
+show_password(GtkCheckButton *check_button G_GNUC_UNUSED,
+              GtkEntry *entry)
+{
+    gtk_entry_set_visibility(entry, !gtk_entry_get_visibility(entry));
+}
+
 
 /* NOTE: if username is provided, and *username is non-NULL, the user input
  * field will be pre-filled with this value. The existing string will be freed
@@ -51,6 +58,7 @@ virt_viewer_auth_collect_credentials(GtkWindow *window,
     GtkWidget *promptUsername;
     GtkWidget *promptPassword;
     GtkWidget *labelMessage;
+    GtkWidget *checkPassword;
     int response;
     char *message;
 
@@ -63,6 +71,7 @@ virt_viewer_auth_collect_credentials(GtkWindow *window,
     promptUsername = GTK_WIDGET(gtk_builder_get_object(creds, "prompt-username"));
     credPassword = GTK_WIDGET(gtk_builder_get_object(creds, "cred-password"));
     promptPassword = GTK_WIDGET(gtk_builder_get_object(creds, "prompt-password"));
+    checkPassword = GTK_WIDGET(gtk_builder_get_object(creds, "show-password"));
 
     gtk_widget_set_sensitive(credUsername, username != NULL);
     if (username && *username) {
@@ -74,6 +83,8 @@ virt_viewer_auth_collect_credentials(GtkWindow *window,
     gtk_widget_set_sensitive(credPassword, password != NULL);
     gtk_widget_set_sensitive(promptPassword, password != NULL);
 
+    g_signal_connect(checkPassword, "clicked", G_CALLBACK(show_password), credPassword);
+
     if (address) {
         message = g_strdup_printf(_("Authentication is required for the %s connection to:\n\n<b>%s</b>\n\n"),
                                   type,
diff --git a/src/virt-viewer-auth.xml b/src/virt-viewer-auth.xml
index 0da1181..2da315c 100644
--- a/src/virt-viewer-auth.xml
+++ b/src/virt-viewer-auth.xml
@@ -129,6 +129,19 @@
                 <property name="bottom_attach">2</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkCheckButton" id="show-password">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="label" translatable="yes">Show my password</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="expand">False</property>
-- 
1.9.3




More information about the virt-tools-list mailing list