From 276ca0f7537cbf4ba77d42e53286e8c19fb076c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Mon, 15 Sep 2014 16:09:52 +0200 Subject: [PATCH] Add support to view the password entry content 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 | 10 ++++++++++ src/virt-viewer-auth.xml | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/virt-viewer-auth.c b/src/virt-viewer-auth.c index 230d720..d08f2c0 100644 --- a/src/virt-viewer-auth.c +++ b/src/virt-viewer-auth.c @@ -32,6 +32,12 @@ #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 +57,7 @@ virt_viewer_auth_collect_credentials(GtkWindow *window, GtkWidget *promptUsername; GtkWidget *promptPassword; GtkWidget *labelMessage; + GtkWidget *checkPassword; int response; char *message; @@ -63,6 +70,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 +82,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%s\n\n"), type, diff --git a/src/virt-viewer-auth.xml b/src/virt-viewer-auth.xml index 0da1181..d307754 100644 --- a/src/virt-viewer-auth.xml +++ b/src/virt-viewer-auth.xml @@ -129,6 +129,20 @@ 2 + + + True + True + False + Show password + + + 1 + 2 + 2 + 3 + + False