talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit a4d228e4cb9b02f7895032aada6988dc85413dc5
parent 453c7a867e0eda3b9e1381d669bebfa0044c5294
Author: Paul <paul@claws-mail.org>
Date:   Thu, 15 May 2025 12:02:53 +0100

replace 'Show password' checkboxes with an in-entry secondary icon to toggle hide/show password instead

Diffstat:
Msrc/editldap.c | 45+++++++++++++++++++++++++++++++--------------
Msrc/prefs_account.c | 128++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Msrc/prefs_proxy.c | 47++++++++++++++++++++++++++++++++---------------
3 files changed, 134 insertions(+), 86 deletions(-)

diff --git a/src/editldap.c b/src/editldap.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 2001-2022 the Claws Mail team and Match Grun + * Copyright (C) 2001-2025 the Claws Mail team and Match Grun * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -655,13 +655,27 @@ static void addressbook_edit_ldap_page_search( gint pageNum, gchar *pageLbl ) { ldapedit.check_matchoption = check_matchoption; } -static void showpwd_checkbtn_toggled(GtkToggleButton *button, - gpointer user_data) +static void showpwd_toggled(GtkEntry *entry, gpointer user_data) { - gboolean active = gtk_toggle_button_get_active(button); - GtkWidget *entry = GTK_WIDGET(user_data); - - gtk_entry_set_visibility(GTK_ENTRY(entry), active); + gboolean visible = gtk_entry_get_visibility(GTK_ENTRY(entry)); + + if (visible) { + gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(entry), + GTK_ENTRY_ICON_SECONDARY, + "view-reveal-symbolic"); + gtk_entry_set_icon_tooltip_text(GTK_ENTRY(entry), + GTK_ENTRY_ICON_SECONDARY, + _("Show password")); + } else { + gtk_entry_set_visibility(GTK_ENTRY(entry), TRUE); + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(entry), + GTK_ENTRY_ICON_SECONDARY, + "view-conceal-symbolic"); + gtk_entry_set_icon_tooltip_text(GTK_ENTRY(entry), + GTK_ENTRY_ICON_SECONDARY, + _("Hide password")); + } } static void addressbook_edit_ldap_page_extended( gint pageNum, gchar *pageLbl ) { @@ -670,7 +684,6 @@ static void addressbook_edit_ldap_page_extended( gint pageNum, gchar *pageLbl ) GtkWidget *label; GtkWidget *entry_bindDN; GtkWidget *entry_bindPW; - GtkWidget *showpwd_checkbtn; GtkWidget *hbox_spin; GtkAdjustment *spinbtn_timeout_adj; GtkWidget *spinbtn_timeout; @@ -716,6 +729,16 @@ static void addressbook_edit_ldap_page_extended( gint pageNum, gchar *pageLbl ) entry_bindPW = gtk_entry_new(); gtk_entry_set_visibility(GTK_ENTRY(entry_bindPW), FALSE); + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(entry_bindPW), + GTK_ENTRY_ICON_SECONDARY, + "view-reveal-symbolic"); + gtk_entry_set_icon_activatable(GTK_ENTRY(entry_bindPW), + GTK_ENTRY_ICON_SECONDARY, TRUE); + gtk_entry_set_icon_tooltip_text(GTK_ENTRY(entry_bindPW), + GTK_ENTRY_ICON_SECONDARY, _("Show password")); + g_signal_connect(entry_bindPW, "icon-press", + G_CALLBACK(showpwd_toggled), NULL); + gtk_grid_attach(GTK_GRID(table), entry_bindPW, 1, 1, 1, 1); gtk_widget_set_hexpand(entry_bindPW, TRUE); gtk_widget_set_halign(entry_bindPW, GTK_ALIGN_FILL); @@ -724,12 +747,6 @@ static void addressbook_edit_ldap_page_extended( gint pageNum, gchar *pageLbl ) "The password to be used when connecting as the \"Bind DN\" " \ "user." )); - showpwd_checkbtn = gtk_check_button_new_with_label (_("Show password")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showpwd_checkbtn), FALSE); - g_signal_connect(G_OBJECT(showpwd_checkbtn), "toggled", - G_CALLBACK(showpwd_checkbtn_toggled), entry_bindPW); - gtk_grid_attach(GTK_GRID(table), showpwd_checkbtn, 2, 1, 1, 1); - /* Next row */ label = gtk_label_new(_("Timeout (secs)")); gtk_label_set_xalign(GTK_LABEL(label), 0.0); diff --git a/src/prefs_account.c b/src/prefs_account.c @@ -144,7 +144,6 @@ typedef struct BasicPage GtkWidget *pass_label; GtkWidget *uid_entry; GtkWidget *pass_entry; - GtkWidget *showpwd_checkbtn; GtkWidget *auto_configure_btn; GtkWidget *auto_configure_cancel_btn; GtkWidget *auto_configure_lbl; @@ -464,7 +463,7 @@ static void prefs_account_crosspost_set_colormenu(PrefParam *pparam); static void prefs_account_nntpauth_toggled(GtkToggleButton *button, gpointer user_data); static void prefs_account_mailcmd_toggled(GtkToggleButton *button, gpointer user_data); -static void prefs_account_showpwd_checkbtn_toggled(GtkToggleButton *button, gpointer user_data); +static void prefs_account_showpwd_toggled(GtkEntry *entry, gpointer user_data); static void prefs_account_entry_changed_newline_check_cb(GtkWidget *entry, gpointer user_data); static void prefs_account_filter_on_recv_toggled(GtkToggleButton *button, gpointer user_data); @@ -1215,7 +1214,6 @@ static void basic_create_widget_func(PrefsPage * _page, GtkWidget *auto_configure_btn; GtkWidget *auto_configure_cancel_btn; GtkWidget *auto_configure_lbl; - GtkWidget *showpwd_checkbtn; GtkListStore *menu; GtkTreeIter iter; gchar *buf; @@ -1423,6 +1421,16 @@ static void basic_create_widget_func(PrefsPage * _page, gtk_widget_set_hexpand(pass_entry, TRUE); gtk_widget_set_halign(pass_entry, GTK_ALIGN_FILL); gtk_entry_set_visibility (GTK_ENTRY (pass_entry), FALSE); + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(pass_entry), + GTK_ENTRY_ICON_SECONDARY, + "view-reveal-symbolic"); + gtk_entry_set_icon_activatable(GTK_ENTRY(pass_entry), + GTK_ENTRY_ICON_SECONDARY, TRUE); + gtk_entry_set_icon_tooltip_text(GTK_ENTRY(pass_entry), + GTK_ENTRY_ICON_SECONDARY, _("Show password")); + g_signal_connect(pass_entry, "icon-press", + G_CALLBACK(prefs_account_showpwd_toggled), NULL); + g_signal_connect(G_OBJECT(pass_entry), "changed", G_CALLBACK(prefs_account_entry_changed_newline_check_cb), GINT_TO_POINTER(ac_prefs->protocol)); @@ -1473,18 +1481,10 @@ static void basic_create_widget_func(PrefsPage * _page, #endif gtk_grid_attach(GTK_GRID(serv_table), pass_label, 0, 8, 1, 1); - showpwd_checkbtn = gtk_check_button_new_with_label (_("Show password")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showpwd_checkbtn), FALSE); - gtk_widget_show(showpwd_checkbtn); - gtk_grid_attach(GTK_GRID(serv_table), showpwd_checkbtn, 2, 8, 1, 1); - g_signal_connect(G_OBJECT(showpwd_checkbtn), "toggled", - G_CALLBACK(prefs_account_showpwd_checkbtn_toggled), pass_entry); - SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, uid_label); SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, pass_label); SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, uid_entry); SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, pass_entry); - SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, showpwd_checkbtn); SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, nntpauth_onconnect_checkbtn); page->acname_entry = acname_entry; @@ -1514,7 +1514,6 @@ static void basic_create_widget_func(PrefsPage * _page, page->pass_label = pass_label; page->uid_entry = uid_entry; page->pass_entry = pass_entry; - page->showpwd_checkbtn = showpwd_checkbtn; page->auto_configure_btn = auto_configure_btn; page->auto_configure_cancel_btn = auto_configure_cancel_btn; page->auto_configure_lbl = auto_configure_lbl; @@ -1997,7 +1996,6 @@ static void send_create_widget_func(PrefsPage * _page, GtkWidget *checkbtn_msgid_with_addr; GtkWidget *vbox3; GtkWidget *smtp_auth_checkbtn; - GtkWidget *showpwd_checkbtn; GtkWidget *optmenu; GtkListStore *menu; GtkTreeIter iter; @@ -2128,17 +2126,20 @@ static void send_create_widget_func(PrefsPage * _page, gtk_widget_set_size_request (smtp_pass_entry, DEFAULT_ENTRY_WIDTH, -1); gtk_box_pack_start (GTK_BOX (hbox), smtp_pass_entry, TRUE, TRUE, 0); gtk_entry_set_visibility (GTK_ENTRY (smtp_pass_entry), FALSE); + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(smtp_pass_entry), + GTK_ENTRY_ICON_SECONDARY, + "view-reveal-symbolic"); + gtk_entry_set_icon_activatable(GTK_ENTRY(smtp_pass_entry), + GTK_ENTRY_ICON_SECONDARY, TRUE); + gtk_entry_set_icon_tooltip_text(GTK_ENTRY(smtp_pass_entry), + GTK_ENTRY_ICON_SECONDARY, _("Show password")); + g_signal_connect(smtp_pass_entry, "icon-press", + G_CALLBACK(prefs_account_showpwd_toggled), NULL); + g_signal_connect(G_OBJECT(smtp_pass_entry), "changed", G_CALLBACK(prefs_account_entry_changed_newline_check_cb), GINT_TO_POINTER(ac_prefs->protocol)); - showpwd_checkbtn = gtk_check_button_new_with_label (_("Show password")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showpwd_checkbtn), FALSE); - gtk_widget_show(showpwd_checkbtn); - gtk_box_pack_start(GTK_BOX (hbox), showpwd_checkbtn, FALSE, FALSE, 0); - g_signal_connect(G_OBJECT(showpwd_checkbtn), "toggled", - G_CALLBACK(prefs_account_showpwd_checkbtn_toggled), smtp_pass_entry); - PACK_SPACER(vbox4, vbox_spc, VSPACING_NARROW_2); hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8); @@ -2963,7 +2964,6 @@ static void ssl_create_widget_func(PrefsPage * _page, GtkWidget *cert_table; GtkWidget *entry_in_cert_pass; GtkWidget *entry_out_cert_pass; - GtkWidget *showpwd_checkbtn; GtkWidget *vbox7; GtkWidget *ssl_certs_auto_accept_checkbtn; @@ -3064,15 +3064,20 @@ static void ssl_create_widget_func(PrefsPage * _page, gtk_label_set_xalign(GTK_LABEL(label), 1.0); entry_in_cert_pass = gtk_entry_new(); gtk_entry_set_visibility(GTK_ENTRY(entry_in_cert_pass), FALSE); - showpwd_checkbtn = gtk_check_button_new_with_label (_("Show password")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showpwd_checkbtn), FALSE); - g_signal_connect(G_OBJECT(showpwd_checkbtn), "toggled", - G_CALLBACK(prefs_account_showpwd_checkbtn_toggled), entry_in_cert_pass); + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(entry_in_cert_pass), + GTK_ENTRY_ICON_SECONDARY, + "view-reveal-symbolic"); + gtk_entry_set_icon_activatable(GTK_ENTRY(entry_in_cert_pass), + GTK_ENTRY_ICON_SECONDARY, TRUE); + gtk_entry_set_icon_tooltip_text(GTK_ENTRY(entry_in_cert_pass), + GTK_ENTRY_ICON_SECONDARY, _("Show password")); + g_signal_connect(entry_in_cert_pass, "icon-press", + G_CALLBACK(prefs_account_showpwd_toggled), NULL); + gtk_grid_attach(GTK_GRID(cert_table), label, 0, 1, 1, 1); gtk_grid_attach(GTK_GRID(cert_table), entry_in_cert_pass, 1, 1, 1, 1); gtk_widget_set_hexpand(entry_in_cert_pass, TRUE); gtk_widget_set_halign(entry_in_cert_pass, GTK_ALIGN_FILL); - gtk_grid_attach(GTK_GRID(cert_table), showpwd_checkbtn, 2, 1, 1, 1); label = gtk_label_new(_("Certificate for sending")); gtk_label_set_xalign(GTK_LABEL(label), 1.0); @@ -3092,15 +3097,20 @@ static void ssl_create_widget_func(PrefsPage * _page, gtk_label_set_xalign(GTK_LABEL(label), 1.0); entry_out_cert_pass = gtk_entry_new(); gtk_entry_set_visibility(GTK_ENTRY(entry_out_cert_pass), FALSE); - showpwd_checkbtn = gtk_check_button_new_with_label (_("Show password")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(showpwd_checkbtn), FALSE); - g_signal_connect(G_OBJECT(showpwd_checkbtn), "toggled", - G_CALLBACK(prefs_account_showpwd_checkbtn_toggled), entry_out_cert_pass); + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(entry_out_cert_pass), + GTK_ENTRY_ICON_SECONDARY, + "view-reveal-symbolic"); + gtk_entry_set_icon_activatable(GTK_ENTRY(entry_out_cert_pass), + GTK_ENTRY_ICON_SECONDARY, TRUE); + gtk_entry_set_icon_tooltip_text(GTK_ENTRY(entry_out_cert_pass), + GTK_ENTRY_ICON_SECONDARY, _("Show password")); + g_signal_connect(entry_out_cert_pass, "icon-press", + G_CALLBACK(prefs_account_showpwd_toggled), NULL); + gtk_grid_attach(GTK_GRID(cert_table), label, 0, 3, 1, 1); gtk_grid_attach(GTK_GRID(cert_table), entry_out_cert_pass, 1, 3, 1, 1); gtk_widget_set_hexpand(entry_out_cert_pass, TRUE); gtk_widget_set_halign(entry_out_cert_pass, GTK_ALIGN_FILL); - gtk_grid_attach(GTK_GRID(cert_table), showpwd_checkbtn, 2, 3, 1, 1); gtk_widget_show_all(cert_table); @@ -3215,7 +3225,6 @@ static void proxy_create_widget_func(PrefsPage * _page, GtkWidget *proxy_pass_entry; GtkWidget *proxy_send_checkbtn; GtkWidget *table; - GtkWidget *button; gchar *buf; vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING); @@ -3289,17 +3298,19 @@ static void proxy_create_widget_func(PrefsPage * _page, proxy_pass_entry = gtk_entry_new(); gtk_widget_set_size_request(proxy_pass_entry, DEFAULT_ENTRY_WIDTH, -1); gtk_entry_set_visibility(GTK_ENTRY(proxy_pass_entry), FALSE); + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(proxy_pass_entry), + GTK_ENTRY_ICON_SECONDARY, + "view-reveal-symbolic"); + gtk_entry_set_icon_activatable(GTK_ENTRY(proxy_pass_entry), + GTK_ENTRY_ICON_SECONDARY, TRUE); + gtk_entry_set_icon_tooltip_text(GTK_ENTRY(proxy_pass_entry), + GTK_ENTRY_ICON_SECONDARY, _("Show password")); + g_signal_connect(proxy_pass_entry, "icon-press", + G_CALLBACK(prefs_account_showpwd_toggled), NULL); gtk_grid_attach(GTK_GRID(table), proxy_pass_entry, 3, 0, 1, 1); gtk_widget_set_hexpand(proxy_pass_entry, TRUE); gtk_widget_set_halign(proxy_pass_entry, GTK_ALIGN_FILL); - button = gtk_check_button_new_with_label(_("Show password")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); - gtk_grid_attach(GTK_GRID(table), button, 3, 1, 1, 1); - - g_signal_connect(G_OBJECT(button), "toggled", - G_CALLBACK(prefs_account_showpwd_checkbtn_toggled), proxy_pass_entry); - gtk_box_pack_start(GTK_BOX(vbox2), gtk_separator_new(GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 0); PACK_CHECK_BUTTON(vbox2, proxy_send_checkbtn, @@ -5451,13 +5462,11 @@ static void prefs_account_protocol_changed(GtkComboBox *combobox, gpointer data) gtk_widget_show(basic_page.pass_label); gtk_widget_show(basic_page.uid_entry); gtk_widget_show(basic_page.pass_entry); - gtk_widget_show(basic_page.showpwd_checkbtn); gtk_widget_set_sensitive(basic_page.uid_label, TRUE); gtk_widget_set_sensitive(basic_page.pass_label, TRUE); gtk_widget_set_sensitive(basic_page.uid_entry, TRUE); gtk_widget_set_sensitive(basic_page.pass_entry, TRUE); - gtk_widget_set_sensitive(basic_page.showpwd_checkbtn, TRUE); /* update userid/passwd sensitive state */ @@ -5537,13 +5546,11 @@ static void prefs_account_protocol_changed(GtkComboBox *combobox, gpointer data) gtk_widget_hide(basic_page.pass_label); gtk_widget_hide(basic_page.uid_entry); gtk_widget_hide(basic_page.pass_entry); - gtk_widget_hide(basic_page.showpwd_checkbtn); gtk_widget_set_sensitive(basic_page.uid_label, TRUE); gtk_widget_set_sensitive(basic_page.pass_label, TRUE); gtk_widget_set_sensitive(basic_page.uid_entry, TRUE); gtk_widget_set_sensitive(basic_page.pass_entry, TRUE); - gtk_widget_set_sensitive(basic_page.showpwd_checkbtn, TRUE); gtk_widget_hide(receive_page.pop3_frame); gtk_widget_hide(receive_page.imap_frame); gtk_widget_show(receive_page.local_frame); @@ -5630,13 +5637,11 @@ static void prefs_account_protocol_changed(GtkComboBox *combobox, gpointer data) gtk_widget_show(basic_page.pass_label); gtk_widget_show(basic_page.uid_entry); gtk_widget_show(basic_page.pass_entry); - gtk_widget_show(basic_page.showpwd_checkbtn); - + gtk_widget_set_sensitive(basic_page.uid_label, TRUE); gtk_widget_set_sensitive(basic_page.pass_label, TRUE); gtk_widget_set_sensitive(basic_page.uid_entry, TRUE); gtk_widget_set_sensitive(basic_page.pass_entry, TRUE); - gtk_widget_set_sensitive(basic_page.showpwd_checkbtn, TRUE); gtk_widget_hide(receive_page.pop3_frame); gtk_widget_show(receive_page.imap_frame); gtk_widget_hide(receive_page.local_frame); @@ -5717,13 +5722,11 @@ static void prefs_account_protocol_changed(GtkComboBox *combobox, gpointer data) gtk_widget_hide(basic_page.pass_label); gtk_widget_hide(basic_page.uid_entry); gtk_widget_hide(basic_page.pass_entry); - gtk_widget_hide(basic_page.showpwd_checkbtn); gtk_widget_set_sensitive(basic_page.uid_label, FALSE); gtk_widget_set_sensitive(basic_page.pass_label, FALSE); gtk_widget_set_sensitive(basic_page.uid_entry, FALSE); gtk_widget_set_sensitive(basic_page.pass_entry, FALSE); - gtk_widget_set_sensitive(basic_page.showpwd_checkbtn, FALSE); gtk_widget_set_sensitive(receive_page.pop3_frame, FALSE); gtk_widget_hide(receive_page.pop3_frame); gtk_widget_hide(receive_page.imap_frame); @@ -5801,13 +5804,11 @@ static void prefs_account_protocol_changed(GtkComboBox *combobox, gpointer data) gtk_widget_show(basic_page.pass_label); gtk_widget_show(basic_page.uid_entry); gtk_widget_show(basic_page.pass_entry); - gtk_widget_show(basic_page.showpwd_checkbtn); gtk_widget_set_sensitive(basic_page.uid_label, TRUE); gtk_widget_set_sensitive(basic_page.pass_label, TRUE); gtk_widget_set_sensitive(basic_page.uid_entry, TRUE); gtk_widget_set_sensitive(basic_page.pass_entry, TRUE); - gtk_widget_set_sensitive(basic_page.showpwd_checkbtn, TRUE); gtk_widget_set_sensitive(receive_page.pop3_frame, TRUE); gtk_widget_show(receive_page.pop3_frame); gtk_widget_hide(receive_page.imap_frame); @@ -5876,7 +5877,6 @@ static void prefs_account_nntpauth_toggled(GtkToggleButton *button, gtk_widget_set_sensitive(basic_page.pass_label, auth); gtk_widget_set_sensitive(basic_page.uid_entry, auth); gtk_widget_set_sensitive(basic_page.pass_entry, auth); - gtk_widget_set_sensitive(basic_page.showpwd_checkbtn, auth); gtk_widget_set_sensitive(basic_page.nntpauth_onconnect_checkbtn, auth); } @@ -5893,16 +5893,30 @@ static void prefs_account_mailcmd_toggled(GtkToggleButton *button, gtk_widget_set_sensitive(basic_page.smtpserv_label, !use_mailcmd); gtk_widget_set_sensitive(basic_page.uid_entry, !use_mailcmd); gtk_widget_set_sensitive(basic_page.pass_entry, !use_mailcmd); - gtk_widget_set_sensitive(basic_page.showpwd_checkbtn, !use_mailcmd); } -static void prefs_account_showpwd_checkbtn_toggled(GtkToggleButton *button, - gpointer user_data) +static void prefs_account_showpwd_toggled(GtkEntry *entry, + gpointer user_data) { - gboolean active = gtk_toggle_button_get_active(button); - GtkWidget *entry = GTK_WIDGET(user_data); + gboolean visible = gtk_entry_get_visibility(GTK_ENTRY(entry)); - gtk_entry_set_visibility(GTK_ENTRY(entry), active); + if (visible) { + gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(entry), + GTK_ENTRY_ICON_SECONDARY, + "view-reveal-symbolic"); + gtk_entry_set_icon_tooltip_text(GTK_ENTRY(entry), + GTK_ENTRY_ICON_SECONDARY, + _("Show password")); + } else { + gtk_entry_set_visibility(GTK_ENTRY(entry), TRUE); + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(entry), + GTK_ENTRY_ICON_SECONDARY, + "view-conceal-symbolic"); + gtk_entry_set_icon_tooltip_text(GTK_ENTRY(entry), + GTK_ENTRY_ICON_SECONDARY, + _("Hide password")); + } } static void prefs_account_entry_changed_newline_check_cb(GtkWidget *entry, diff --git a/src/prefs_proxy.c b/src/prefs_proxy.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 2018-2019 the Claws Mail team + * Copyright (C) 2018-2025 the Claws Mail team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,8 +46,7 @@ typedef struct _ProxyPage GtkWidget *proxy_pass_entry; } ProxyPage; -static void showpwd_checkbtn_toggled(GtkToggleButton *button, - gpointer user_data); +static void showpwd_toggled(GtkEntry *entry, gpointer user_data); static void prefs_proxy_create_widget(PrefsPage *_page, GtkWindow *window, gpointer data) @@ -137,16 +136,20 @@ static void prefs_proxy_create_widget(PrefsPage *_page, GtkWindow *window, proxy_pass_entry = gtk_entry_new(); gtk_widget_set_size_request(proxy_pass_entry, DEFAULT_ENTRY_WIDTH, -1); gtk_entry_set_visibility(GTK_ENTRY(proxy_pass_entry), FALSE); + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(proxy_pass_entry), + GTK_ENTRY_ICON_SECONDARY, + "view-reveal-symbolic"); + gtk_entry_set_icon_activatable(GTK_ENTRY(proxy_pass_entry), + GTK_ENTRY_ICON_SECONDARY, TRUE); + gtk_entry_set_icon_tooltip_text(GTK_ENTRY(proxy_pass_entry), + GTK_ENTRY_ICON_SECONDARY, _("Show password")); + g_signal_connect(proxy_pass_entry, "icon-press", + G_CALLBACK(showpwd_toggled), NULL); + gtk_grid_attach(GTK_GRID(table), proxy_pass_entry, 3, 0, 1, 1); gtk_widget_set_hexpand(proxy_pass_entry, TRUE); gtk_widget_set_halign(proxy_pass_entry, GTK_ALIGN_FILL); - button = gtk_check_button_new_with_label(_("Show password")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); - gtk_grid_attach(GTK_GRID(table), button, 3, 1, 1, 1); - g_signal_connect(G_OBJECT(button), "toggled", - G_CALLBACK(showpwd_checkbtn_toggled), proxy_pass_entry); - gtk_widget_show_all(vbox0); SET_TOGGLE_SENSITIVITY(proxy_checkbtn, vbox1); @@ -254,11 +257,25 @@ void prefs_proxy_done(void) g_free(prefs_proxy); } -static void showpwd_checkbtn_toggled(GtkToggleButton *button, - gpointer user_data) +static void showpwd_toggled(GtkEntry *entry, gpointer user_data) { - gboolean active = gtk_toggle_button_get_active(button); - GtkWidget *entry = GTK_WIDGET(user_data); - - gtk_entry_set_visibility(GTK_ENTRY(entry), active); + gboolean visible = gtk_entry_get_visibility(GTK_ENTRY(entry)); + + if (visible) { + gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(entry), + GTK_ENTRY_ICON_SECONDARY, + "view-reveal-symbolic"); + gtk_entry_set_icon_tooltip_text(GTK_ENTRY(entry), + GTK_ENTRY_ICON_SECONDARY, + _("Show password")); + } else { + gtk_entry_set_visibility(GTK_ENTRY(entry), TRUE); + gtk_entry_set_icon_from_icon_name(GTK_ENTRY(entry), + GTK_ENTRY_ICON_SECONDARY, + "view-conceal-symbolic"); + gtk_entry_set_icon_tooltip_text(GTK_ENTRY(entry), + GTK_ENTRY_ICON_SECONDARY, + _("Hide password")); + } }