diff --git a/icons/scalable/eye-not-looking-symbolic.svg b/icons/scalable/eye-not-looking-symbolic.svg new file mode 100644 index 0000000..792a22a --- /dev/null +++ b/icons/scalable/eye-not-looking-symbolic.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/icons/scalable/eye-open-negative-filled-symbolic.svg b/icons/scalable/eye-open-negative-filled-symbolic.svg new file mode 100644 index 0000000..f4e133a --- /dev/null +++ b/icons/scalable/eye-open-negative-filled-symbolic.svg @@ -0,0 +1,26 @@ + + + + + + image/svg+xml + + Gnome Symbolic Icon Theme + + + + Gnome Symbolic Icon Theme + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/resources/ui/virt-viewer-auth.ui b/src/resources/ui/virt-viewer-auth.ui index 350a30a..0309724 100644 --- a/src/resources/ui/virt-viewer-auth.ui +++ b/src/resources/ui/virt-viewer-auth.ui @@ -130,24 +130,6 @@ 2 - - - Show password - True - True - False - False - - - 1 - 2 - 2 - 3 - - - - - False diff --git a/src/resources/virt-viewer.gresource.xml b/src/resources/virt-viewer.gresource.xml index 6cb2082..ef1da7b 100644 --- a/src/resources/virt-viewer.gresource.xml +++ b/src/resources/virt-viewer.gresource.xml @@ -18,5 +18,7 @@ ../../icons/32x32/virt-viewer.png ../../icons/48x48/virt-viewer.png ../../icons/256x256/virt-viewer.png + ../../icons/scalable/eye-not-looking-symbolic.svg + ../../icons/scalable/eye-open-negative-filled-symbolic.svg diff --git a/src/virt-viewer-auth.c b/src/virt-viewer-auth.c index ccd85ac..c285531 100644 --- a/src/virt-viewer-auth.c +++ b/src/virt-viewer-auth.c @@ -34,10 +34,17 @@ #include "virt-viewer-util.h" static void -show_password(GtkCheckButton *check_button G_GNUC_UNUSED, - GtkEntry *entry) +show_password(GtkEntry *entry, + GtkEntryIconPosition pos G_GNUC_UNUSED, + GdkEvent event G_GNUC_UNUSED) { - gtk_entry_set_visibility(entry, !gtk_entry_get_visibility(entry)); + gboolean visible = gtk_entry_get_visibility(entry); + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(entry), + GTK_ENTRY_ICON_SECONDARY, + visible ? + "eye-not-looking-symbolic" : + "eye-open-negative-filled-symbolic"); + gtk_entry_set_visibility(entry, !visible); } /* NOTE: if username is provided, and *username is non-NULL, the user input @@ -58,7 +65,6 @@ virt_viewer_auth_collect_credentials(GtkWindow *window, GtkWidget *promptUsername; GtkWidget *promptPassword; GtkWidget *labelMessage; - GtkWidget *checkPassword; int response; char *message; @@ -71,7 +77,6 @@ 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) { @@ -83,7 +88,20 @@ 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); + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(credPassword), + GTK_ENTRY_ICON_SECONDARY, + "eye-not-looking-symbolic"); + gtk_entry_set_icon_sensitive(GTK_ENTRY(credPassword), + GTK_ENTRY_ICON_SECONDARY, + TRUE); + gtk_entry_set_icon_activatable(GTK_ENTRY(credPassword), + GTK_ENTRY_ICON_SECONDARY, + TRUE); + gtk_entry_set_icon_tooltip_text(GTK_ENTRY(credPassword), + GTK_ENTRY_ICON_SECONDARY, + _("Show / hide password text")); + + g_signal_connect(credPassword, "icon-press", G_CALLBACK(show_password), credPassword); if (address) { message = g_strdup_printf(_("Authentication is required for the %s connection to:\n\n%s\n\n"),