Commit b20b15f9 authored by Guido Gunther's avatar Guido Gunther Committed by Sebastian Krzyszkowiak

network-auth-prompt: Allow to toggle password visibility

This makes entering wifi passwords a bit simpler. Inspired by
GTK4's GtkPasswordEntry.
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent f024226e
Pipeline #50645 passed with stages
in 11 minutes and 33 seconds
......@@ -57,6 +57,7 @@ struct _PhoshNetworkAuthPrompt
ShellNetworkAgent *agent;
gboolean done_emitted;
gboolean visible; /* is input visible */
};
G_DEFINE_TYPE(PhoshNetworkAuthPrompt, phosh_network_auth_prompt, PHOSH_TYPE_LAYER_SURFACE);
......@@ -305,6 +306,27 @@ network_prompt_wpa_password_changed_cb (PhoshNetworkAuthPrompt *self)
gtk_widget_set_sensitive (self->connect_button, valid);
}
static void
network_prompt_icon_press_cb (PhoshNetworkAuthPrompt *self,
GtkEntryIconPosition icon_pos,
GdkEvent *event,
GtkEntry *entry)
{
const char *icon_name = "eye-not-looking-symbolic";
g_return_if_fail (PHOSH_IS_NETWORK_AUTH_PROMPT (self));
g_return_if_fail (GTK_IS_ENTRY (entry));
g_return_if_fail (icon_pos == GTK_ENTRY_ICON_SECONDARY);
self->visible = !self->visible;
gtk_entry_set_visibility (entry, self->visible);
if (self->visible)
icon_name = "eye-open-negative-filled-symbolic";
gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY,
icon_name);
}
static void
phosh_network_auth_prompt_class_init (PhoshNetworkAuthPromptClass *klass)
{
......@@ -342,6 +364,7 @@ phosh_network_auth_prompt_class_init (PhoshNetworkAuthPromptClass *klass)
gtk_widget_class_bind_template_callback (widget_class, network_prompt_draw_cb);
gtk_widget_class_bind_template_callback (widget_class, network_prompt_key_press_event_cb);
gtk_widget_class_bind_template_callback (widget_class, network_prompt_wpa_password_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, network_prompt_icon_press_cb);
}
......
......@@ -143,7 +143,12 @@
<property name="activates-default">1</property>
<property name="input-purpose">password</property>
<property name="buffer">password_buffer</property>
<property name="primary_icon_sensitive">False</property>
<property name="secondary_icon_activatable">True</property>
<property name="secondary_icon_name">eye-not-looking-symbolic</property>
<property name="secondary_icon_sensitive">True</property>
<signal name="changed" handler="network_prompt_wpa_password_changed_cb" swapped="yes"/>
<signal name="icon-press" handler="network_prompt_icon_press_cb" swapped="yes"/>
</object>
<packing>
<property name="left-attach">1</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment