Commit 0b09c4dc authored by Alexander Mikhaylenko's avatar Alexander Mikhaylenko

example: Enable back swipe in the leaflet

Set can-swipe-back=true on the content leaflet, allow-visible=false for
separators and use HdySwipeGroup for syncing leaflets rather than binding
visible child name.
Signed-off-by: Alexander Mikhaylenko's avatarAlexander Mikhaylenko <alexm@gnome.org>
parent 6c949864
Pipeline #48798 passed with stages
in 15 minutes and 9 seconds
......@@ -96,6 +96,17 @@ hdy_demo_window_notify_fold_cb (GObject *sender,
update (self);
}
static void
update_leaflet_swipe (HdyDemoWindow *self)
{
gboolean first_page = (hdy_paginator_get_position (self->paginator) <= 0);
gboolean paginator_visible =
(gtk_stack_get_visible_child (self->stack) == GTK_WIDGET (self->paginator));
hdy_leaflet_set_can_swipe_back (self->content_box,
!paginator_visible || first_page);
}
static void
hdy_demo_window_notify_visible_child_cb (GObject *sender,
GParamSpec *pspec,
......@@ -103,6 +114,7 @@ hdy_demo_window_notify_visible_child_cb (GObject *sender,
{
hdy_leaflet_set_visible_child_name (self->content_box, "content");
update_header_bar (self);
update_leaflet_swipe (self);
}
static void
......@@ -303,6 +315,14 @@ paginator_orientation_name (HdyEnumValueObject *value,
}
}
static void
notify_paginator_position_cb (GObject *sender,
GParamSpec *pspec,
HdyDemoWindow *self)
{
update_leaflet_swipe (self);
}
static void
notify_paginator_orientation_cb (GObject *sender,
GParamSpec *pspec,
......@@ -439,6 +459,7 @@ hdy_demo_window_class_init (HdyDemoWindowClass *klass)
gtk_widget_class_bind_template_callback_full (widget_class, "dialog_action_clicked_cb", G_CALLBACK(dialog_action_clicked_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "dialog_complex_clicked_cb", G_CALLBACK(dialog_complex_clicked_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "view_switcher_demo_clicked_cb", G_CALLBACK(view_switcher_demo_clicked_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "notify_paginator_position_cb", G_CALLBACK(notify_paginator_position_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "notify_paginator_orientation_cb", G_CALLBACK(notify_paginator_orientation_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "notify_paginator_indicator_style_cb", G_CALLBACK(notify_paginator_indicator_style_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "paginator_return_clicked_cb", G_CALLBACK(paginator_return_clicked_cb));
......
......@@ -35,7 +35,6 @@
<object class="HdyLeaflet" id="header_box">
<property name="transition-type" bind-source="content_box" bind-property="transition-type" bind-flags="sync-create"/>
<property name="visible">True</property>
<property name="visible-child-name" bind-source="content_box" bind-property="visible-child-name" bind-flags="sync-create"/>
<signal name="notify::visible-child" handler="notify_header_visible_child_cb" swapped="no"/>
<signal name="notify::fold" handler="notify_fold_cb" after="yes" swapped="no"/>
<child>
......@@ -76,6 +75,9 @@
<class name="sidebar"/>
</style>
</object>
<packing>
<property name="allow-visible">False</property>
</packing>
</child>
<child>
<object class="GtkHeaderBar" id="sub_header_bar">
......@@ -149,6 +151,7 @@
<object class="HdyLeaflet" id="content_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-swipe-back">True</property>
<child>
<object class="GtkStackSidebar" id="sidebar">
<property name="width_request">270</property>
......@@ -169,6 +172,9 @@
<class name="sidebar"/>
</style>
</object>
<packing>
<property name="allow-visible">False</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolled_window">
......@@ -1471,6 +1477,7 @@
<property name="visible">True</property>
<property name="center_content">True</property>
<property name="indicator_spacing">6</property>
<signal name="notify::position" handler="notify_paginator_position_cb"/>
<child>
<object class="GtkBox">
<property name="visible">True</property>
......@@ -1642,6 +1649,12 @@
<headerbar name="sub_header_bar"/>
</headerbars>
</object>
<object class="HdySwipeGroup" id="swipe_group">
<swipeables>
<swipeable name="header_box"/>
<swipeable name="content_box"/>
</swipeables>
</object>
<object class="GtkAdjustment" id="column_width_adjustment">
<property name="lower">0</property>
<property name="upper">10000</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