Verified Commit a4bbf20b authored by Ujjwal Kumar's avatar Ujjwal Kumar 😁
Browse files

example: Add Password entry

parent 7cd41434
Pipeline #54744 passed with stages
in 14 minutes and 10 seconds
......@@ -31,6 +31,7 @@ struct _HdyDemoWindow
HdyComboRow *carousel_indicator_style_row;
HdyAvatar *avatar;
GtkFileChooserButton *avatar_filechooser;
HdyPasswordEntry *password_entry;
};
G_DEFINE_TYPE (HdyDemoWindow, hdy_demo_window, HDY_TYPE_APPLICATION_WINDOW)
......@@ -329,6 +330,15 @@ avatar_file_remove_cb (HdyDemoWindow *self)
hdy_avatar_set_image_load_func (self->avatar, NULL, NULL, NULL);
}
static void
spin_button_value_changed_cb (HdyDemoWindow *self,
GtkSpinButton *spin_button)
{
gdouble peek_duration = gtk_spin_button_get_value (spin_button);
hdy_password_entry_set_peek_duration (self->password_entry, (guint) peek_duration);
}
static GdkPixbuf *
avatar_load_file (gint size, HdyDemoWindow *self)
{
......@@ -409,6 +419,7 @@ hdy_demo_window_class_init (HdyDemoWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, HdyDemoWindow, carousel_indicator_style_row);
gtk_widget_class_bind_template_child (widget_class, HdyDemoWindow, avatar);
gtk_widget_class_bind_template_child (widget_class, HdyDemoWindow, avatar_filechooser);
gtk_widget_class_bind_template_child (widget_class, HdyDemoWindow, password_entry);
gtk_widget_class_bind_template_callback_full (widget_class, "key_pressed_cb", G_CALLBACK(hdy_demo_window_key_pressed_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "notify_visible_child_cb", G_CALLBACK(hdy_demo_window_notify_visible_child_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "notify_deck_visible_child_cb", G_CALLBACK(hdy_demo_window_notify_deck_visible_child_cb));
......@@ -425,6 +436,7 @@ hdy_demo_window_class_init (HdyDemoWindowClass *klass)
gtk_widget_class_bind_template_callback_full (widget_class, "carousel_return_clicked_cb", G_CALLBACK(carousel_return_clicked_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "avatar_file_remove_cb", G_CALLBACK(avatar_file_remove_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "avatar_file_set_cb", G_CALLBACK(avatar_file_set_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "spin_button_value_changed_cb", G_CALLBACK(spin_button_value_changed_cb));
}
static void
......
......@@ -2120,6 +2120,131 @@
<property name="title">Window</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="expand">True</property>
<property name="margin-bottom">32</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="can_focus">False</property>
<property name="margin-bottom">32</property>
<property name="expand">True</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="opacity">0.5</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Password Entry</property>
<property name="justify">center</property>
<property name="use_markup">true</property>
<property name="wrap">True</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="2"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</object>
</child>
<child>
<object class="HdyColumn">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="maximum-width">400</property>
<property name="linear-growth-width">300</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkListBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="expand">True</property>
<property name="selection-mode">none</property>
<style>
<class name="preferences"/>
</style>
<child>
<object class="HdyActionRow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Password</property>
<property name="activatable">False</property>.
<child>
<object class="HdyPasswordEntry" id="password_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">center</property>
<property name="peek-duration">500</property>
<property name="show-peek-icon" bind-source="password_show_peek_icon" bind-property="state" bind-flags="sync-create"/>
</object>
</child>
</object>
</child>
<child>
<object class="HdyActionRow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Show peek icon</property>
<property name="activatable_widget">password_show_peek_icon</property>
<child>
<object class="GtkSwitch" id="password_show_peek_icon">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">center</property>
<property name="state">True</property>
</object>
</child>
</object>
</child>
<child>
<object class="HdyActionRow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Peek duration</property>
<property name="activatable">False</property>.
<child>
<object class="GtkSpinButton" id="peek_duration">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">center</property>
<property name="numeric">True</property>
<property name="update-policy">GTK_UPDATE_IF_VALID</property>
<property name="adjustment">peek_duration_adjustment</property>
<signal name="value-changed" swapped="yes" handler="spin_button_value_changed_cb"/>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="name">passwordentry</property>
<property name="title">Password Entry</property>
</packing>
</child>
</object>
</child>
</object>
......@@ -2184,4 +2309,11 @@
<mime-type>image/gif</mime-type>
</mime-types>
</object>
<object class="GtkAdjustment" id="peek_duration_adjustment">
<property name="lower">500</property>
<property name="upper">65000</property>
<property name="value">500</property>
<property name="page-increment">100</property>
<property name="step-increment">100</property>
</object>
</interface>
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