[virt-tools-list] [PATCH 2/2] Add support to view the password entry content
Christophe Fergeau
cfergeau at redhat.com
Mon Sep 15 11:25:40 UTC 2014
Hey,
Why not if we want to let the user unobscure the password. The icon is a
bit weird though, I would not know what it's about without clicking on
it.
Code looks good.
Christophe
On Fri, Sep 12, 2014 at 03:04:10PM +0200, Fabiano Fidêncio wrote:
> 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
>
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20140915/0f96864b/attachment.sig>
More information about the virt-tools-list
mailing list