Fri, 26 Aug 2022 00:57:06 -0500
Use GtkPasswordEntry for passwords
This assumes that entries in a `PurpleRequest` that are masked really mean they are asking for passwords.
Testing Done:
Added a new account so that it prompted for password, checked proxy settings in Preferences, as well as in account settings.
Reviewed at https://reviews.imfreedom.org/r/1656/
--- a/pidgin/gtkrequest.c Fri Aug 26 00:40:48 2022 -0500 +++ b/pidgin/gtkrequest.c Fri Aug 26 00:57:06 2022 -0500 @@ -611,19 +611,23 @@ data->u.input.entry = input; } else { - GtkWidget *entry = gtk_entry_new(); - - gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); + GtkWidget *entry = NULL; + + if(masked) { + entry = gtk_password_entry_new(); + g_object_set(entry, "activates-default", TRUE, + "show-peek-icon", TRUE, NULL); + } else { + entry = gtk_entry_new(); + gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); + } + gtk_box_append(GTK_BOX(vbox), entry); if(default_value != NULL) { gtk_editable_set_text(GTK_EDITABLE(entry), default_value); } - if(masked) { - gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); - } - data->u.input.entry = entry; } @@ -1093,7 +1097,7 @@ { const char *type_hint; - gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); + g_object_set(entry, "activates-default", TRUE, NULL); g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(req_entry_field_changed_cb), field); @@ -1190,7 +1194,13 @@ { GtkEventController *controller = NULL; - widget = gtk_entry_new(); + if (purple_request_field_string_is_masked(field)) { + widget = gtk_password_entry_new(); + gtk_password_entry_set_show_peek_icon(GTK_PASSWORD_ENTRY(widget), + TRUE); + } else { + widget = gtk_entry_new(); + } setup_entry_field(widget, field); @@ -1200,11 +1210,6 @@ gtk_widget_set_tooltip_text(widget, purple_request_field_get_tooltip(field)); - if (purple_request_field_string_is_masked(field)) - { - gtk_entry_set_visibility(GTK_ENTRY(widget), FALSE); - } - gtk_editable_set_editable(GTK_EDITABLE(widget), is_editable); controller = gtk_event_controller_focus_new();
--- a/pidgin/resources/Prefs/network.ui Fri Aug 26 00:40:48 2022 -0500 +++ b/pidgin/resources/Prefs/network.ui Fri Aug 26 00:57:06 2022 -0500 @@ -257,11 +257,9 @@ </object> </child> <child> - <object class="GtkEntry" id="turn_password"> + <object class="GtkPasswordEntry" id="turn_password"> <property name="focusable">1</property> - <property name="visibility">0</property> - <property name="invisible-char">●</property> - <property name="input-purpose">password</property> + <property name="show-peek-icon">1</property> </object> </child> </object>
--- a/pidgin/resources/Prefs/proxy.ui Fri Aug 26 00:40:48 2022 -0500 +++ b/pidgin/resources/Prefs/proxy.ui Fri Aug 26 00:57:06 2022 -0500 @@ -239,11 +239,9 @@ </object> </child> <child> - <object class="GtkEntry" id="password"> + <object class="GtkPasswordEntry" id="password"> <property name="focusable">1</property> - <property name="visibility">0</property> - <property name="invisible-char">●</property> - <property name="input-purpose">password</property> + <property name="show-peek-icon">1</property> <signal name="changed" handler="proxy_print_option" object="PidginProxyPrefs" swapped="no"/> <accessibility> <relation name="labelled-by">password-label</relation>
--- a/pidgin/resources/proxyoptions.ui Fri Aug 26 00:40:48 2022 -0500 +++ b/pidgin/resources/proxyoptions.ui Fri Aug 26 00:57:06 2022 -0500 @@ -180,10 +180,11 @@ </object> </child> <child> - <object class="GtkEntry" id="password"> + <object class="GtkPasswordEntry" id="password"> <property name="hexpand">1</property> <property name="halign">fill</property> <property name="focusable">1</property> + <property name="show-peek-icon">1</property> </object> </child> </object>