[gnome-games/wip/exalm/libhandy: 4/8] preferences-window: Enable swipe gesture for leaflet
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/libhandy: 4/8] preferences-window: Enable swipe gesture for leaflet
- Date: Wed, 26 Feb 2020 19:14:25 +0000 (UTC)
commit 45ba20ba7e510eca3058d520bc37f7821d4d966e
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Feb 25 22:56:08 2020 +0500
preferences-window: Enable swipe gesture for leaflet
data/ui/preferences-window.ui | 16 ++++++++++++++--
src/ui/preferences-window.vala | 17 +++--------------
2 files changed, 17 insertions(+), 16 deletions(-)
---
diff --git a/data/ui/preferences-window.ui b/data/ui/preferences-window.ui
index 5722830b..6bfefa1f 100644
--- a/data/ui/preferences-window.ui
+++ b/data/ui/preferences-window.ui
@@ -17,7 +17,7 @@
<child>
<object class="HdyLeaflet" id="titlebar_box">
<property name="visible">True</property>
- <property name="transition-type">slide</property>
+ <signal name="notify::visible-child" handler="update_header_group"/>
<child>
<object class="GtkHeaderBar" id="left_header_bar">
<property name="name">left_header_bar</property>
@@ -58,6 +58,9 @@
<class name="sidebar"/>
</style>
</object>
+ <packing>
+ <property name="allow-visible">False</property>
+ </packing>
</child>
<child>
<object class="GtkHeaderBar" id="right_header_bar">
@@ -106,7 +109,7 @@
<child>
<object class="HdyLeaflet" id="content_box">
<property name="visible">True</property>
- <property name="transition-type">slide</property>
+ <property name="can-swipe-back">True</property>
<signal name="notify::folded" handler="on_folded_changed" after="yes"/>
<child>
<object class="GamesPreferencesSidebar" id="sidebar">
@@ -125,6 +128,9 @@
<class name="sidebar"/>
</style>
</object>
+ <packing>
+ <property name="allow-visible">False</property>
+ </packing>
</child>
<child>
<object class="GtkStack" id="stack">
@@ -180,4 +186,10 @@
<headerbar name="right_header_bar"/>
</headerbars>
</object>
+ <object class="HdySwipeGroup">
+ <swipeables>
+ <swipeable name="titlebar_box"/>
+ <swipeable name="content_box"/>
+ </swipeables>
+ </object>
</interface>
diff --git a/src/ui/preferences-window.vala b/src/ui/preferences-window.vala
index c9083d37..ccda289d 100644
--- a/src/ui/preferences-window.vala
+++ b/src/ui/preferences-window.vala
@@ -9,8 +9,6 @@ private class Games.PreferencesWindow : Gtk.Window {
[GtkChild]
private Hdy.Leaflet titlebar_box;
[GtkChild]
- private Gtk.HeaderBar left_header_bar;
- [GtkChild]
private Gtk.HeaderBar right_header_bar;
[GtkChild]
private Gtk.Stack main_stack;
@@ -54,8 +52,7 @@ private class Games.PreferencesWindow : Gtk.Window {
titlebar_stack.add (header_bar);
titlebar_stack.visible_child = header_bar;
- content_box.visible_child = stack;
- titlebar_box.visible_child = right_header_bar;
+ content_box.navigate (Hdy.NavigationDirection.FORWARD);
}
_subpage = value;
@@ -74,9 +71,7 @@ private class Games.PreferencesWindow : Gtk.Window {
[GtkCallback]
private void sidebar_row_selected () {
- content_box.visible_child = stack;
- titlebar_box.visible_child = right_header_bar;
- update_header_group ();
+ content_box.navigate (Hdy.NavigationDirection.FORWARD);
update_ui ();
}
@@ -108,14 +103,8 @@ private class Games.PreferencesWindow : Gtk.Window {
[GtkCallback]
private void on_back_clicked () {
- if (content_box.visible_child == sidebar) {
+ if (!content_box.navigate (Hdy.NavigationDirection.BACK))
close ();
- return;
- }
-
- content_box.visible_child = sidebar;
- titlebar_box.visible_child = left_header_bar;
- update_header_group ();
}
[GtkCallback]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]