[virt-tools-list] [PATCH 2/2] Add support to view the password entry content
Fabiano Fidêncio
fidencio at redhat.com
Fri Sep 12 13:04:10 UTC 2014
Allow users to check the if the entered password is right and/or modify
the password easily in case it's wrong.
This piece of code was taken from File Roller
(https://wiki.gnome.org/Apps/FileRoller), written by Paolo Bacchilega
<paobac at src.gnome.org> and pushed as
bcaf181fba2f0265cb109c53968694d00b5cc74d
---
src/virt-viewer-auth.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/src/virt-viewer-auth.c b/src/virt-viewer-auth.c
index 230d720..c732a88 100644
--- a/src/virt-viewer-auth.c
+++ b/src/virt-viewer-auth.c
@@ -32,6 +32,27 @@
#include "virt-viewer-auth.h"
+static void
+virt_viewer_password_entry_icon_press_cb(GtkEntry *entry,
+ GtkEntryIconPosition icon_pos G_GNUC_UNUSED,
+ GdkEvent *event G_GNUC_UNUSED,
+ gpointer user_data G_GNUC_UNUSED)
+{
+ gtk_entry_set_visibility(entry, !gtk_entry_get_visibility(entry));
+}
+
+static void
+virt_viewer_use_entry_as_password_entry(GtkEntry *entry)
+{
+ g_return_if_fail (GTK_IS_ENTRY(entry));
+
+ gtk_entry_set_visibility(entry, FALSE);
+ gtk_entry_set_icon_from_icon_name(entry, GTK_ENTRY_ICON_SECONDARY, "security-medium-symbolic");
+ gtk_entry_set_icon_activatable(entry, GTK_ENTRY_ICON_SECONDARY, TRUE);
+ gtk_entry_set_icon_tooltip_text(entry, GTK_ENTRY_ICON_SECONDARY, _("Change password visibility"));
+
+ g_signal_connect(entry, "icon-press", G_CALLBACK(virt_viewer_password_entry_icon_press_cb), NULL);
+}
/* 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
@@ -74,6 +95,8 @@ virt_viewer_auth_collect_credentials(GtkWindow *window,
gtk_widget_set_sensitive(credPassword, password != NULL);
gtk_widget_set_sensitive(promptPassword, password != NULL);
+ virt_viewer_use_entry_as_password_entry(GTK_ENTRY(credPassword));
+
if (address) {
message = g_strdup_printf(_("Authentication is required for the %s connection to:\n\n<b>%s</b>\n\n"),
type,
--
1.9.3
More information about the virt-tools-list
mailing list