Commit 9d3c4705 authored by Adrien Plazas's avatar Adrien Plazas
Browse files

example: Bind back and close buttons visibility to fold

Directly bind whether the back button and the close button are visible
to whether the headerbar is folded.
parent abdfd5f8
Pipeline #1140 passed with stage
in 2 minutes and 3 seconds
......@@ -38,23 +38,6 @@ example_window_key_pressed_cb (GtkWidget *sender,
return FALSE;
}
static void
update (ExampleWindow *self)
{
HdyFold fold = hdy_leaflet_get_fold (self->content_box);
gtk_header_bar_set_show_close_button (self->header_bar, fold == HDY_FOLD_FOLDED);
gtk_widget_set_visible (GTK_WIDGET (self->back), fold == HDY_FOLD_FOLDED);
}
static void
example_window_notify_fold_cb (GObject *sender,
GParamSpec *pspec,
ExampleWindow *self)
{
update (self);
}
static void
example_window_notify_visible_child_cb (GObject *sender,
GParamSpec *pspec,
......@@ -248,7 +231,6 @@ example_window_class_init (ExampleWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, adj_arrows_count);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, adj_arrows_duration);
gtk_widget_class_bind_template_callback_full (widget_class, "key_pressed_cb", G_CALLBACK(example_window_key_pressed_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "notify_fold_cb", G_CALLBACK(example_window_notify_fold_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "notify_visible_child_cb", G_CALLBACK(example_window_notify_visible_child_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "back_clicked_cb", G_CALLBACK(example_window_back_clicked_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "submitted_cb", G_CALLBACK(example_window_submitted_cb));
......@@ -268,6 +250,4 @@ example_window_init (ExampleWindow *self)
gtk_widget_init_template (GTK_WIDGET (self));
hdy_leaflet_set_visible_child (self->content_box, GTK_WIDGET (self->stack));
update (self);
}
......@@ -38,6 +38,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title">Handy Widget Factory</property>
<property name="show_close_button" bind-source="header_box" bind-property="folded" bind-flags="sync-create"/>
</object>
<packing>
<property name="name">sidebar</property>
......@@ -64,6 +65,7 @@
<property name="receives_default">False</property>
<property name="valign">center</property>
<property name="use-underline">True</property>
<property name="visible" bind-source="header_box" bind-property="folded" bind-flags="sync-create"/>
<signal name="clicked" handler="back_clicked_cb"/>
<style>
<class name="image-button"/>
......@@ -98,7 +100,6 @@
<property name="can_focus">False</property>
<property name="mode_transition_type">slide</property>
<property name="child_transition_type">slide</property>
<signal name="notify::fold" handler="notify_fold_cb" after="yes" swapped="no"/>
<child>
<object class="GtkStackSidebar" id="sidebar">
<property name="width_request">270</property>
......
Supports Markdown
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