[gnome-contacts] window: Add a "back" gesture



commit 88e741e74edda25e1cf9a3d7e960fec9a4f1fcb3
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Tue Dec 10 13:09:39 2019 +0100

    window: Add a "back" gesture
    
    This makes moving back to the contacts list more comfortable on a phone.

 data/ui/contacts-window.ui | 14 +++++++++++++-
 src/contacts-window.vala   |  5 +++++
 2 files changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/data/ui/contacts-window.ui b/data/ui/contacts-window.ui
index 73c4a8e..e203f73 100644
--- a/data/ui/contacts-window.ui
+++ b/data/ui/contacts-window.ui
@@ -112,7 +112,6 @@
             <property name="mode-transition-duration" bind-source="content_box" 
bind-property="mode-transition-duration" bind-flags="bidirectional|sync-create"/>
             <property name="child-transition-duration" bind-source="content_box" 
bind-property="child-transition-duration" bind-flags="bidirectional|sync-create"/>
             <property name="transition-type" bind-source="content_box" bind-property="transition-type" 
bind-flags="bidirectional|sync-create"/>
-            <property name="visible-child-name" bind-source="content_box" bind-property="visible-child-name" 
bind-flags="bidirectional|sync-create"/>
             <child>
               <object class="GtkHeaderBar" id="left_header">
                 <property name="visible">True</property>
@@ -188,6 +187,9 @@
                   <class name="sidebar"/>
                 </style>
               </object>
+              <packing>
+                <property name="allow-visible">False</property>
+              </packing>
             </child>
             <child>
               <object class="GtkHeaderBar" id="right_header">
@@ -316,6 +318,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>
             <property name="transition-type">over</property>
             <signal name="notify::fold" handler="on_fold" object="ContactsWindow" after="yes" swapped="no"/>
             <signal name="notify::child-transition-running" handler="on_child_transition_running" 
object="ContactsWindow" after="yes" swapped="no"/>
@@ -369,6 +372,9 @@
                   <class name="sidebar"/>
                 </style>
               </object>
+              <packing>
+                <property name="allow-visible">False</property>
+              </packing>
             </child>
             <child>
               <object class="GtkOverlay" id="contact_pane_container">
@@ -405,5 +411,11 @@
       <headerbar name="right_header"/>
     </headerbars>
   </object>
+  <object class="HdySwipeGroup" id="swipe_group">
+    <swipeables>
+      <swipeable name="header"/>
+      <swipeable name="content_box"/>
+    </swipeables>
+  </object>
 </interface>
 
diff --git a/src/contacts-window.vala b/src/contacts-window.vala
index e427a32..2b648f0 100644
--- a/src/contacts-window.vala
+++ b/src/contacts-window.vala
@@ -232,6 +232,11 @@ public class Contacts.Window : Gtk.ApplicationWindow {
     }
     // When selecting or editing, we get special headerbars
     this.titlebar.selection_mode = this.state == UiState.SELECTING || this.state.editing ();
+
+    // Allow the back gesture when not browsing
+    this.content_box.can_swipe_back = this.state == UiState.NORMAL ||
+                                      this.state == UiState.SHOWING ||
+                                      this.state == UiState.SELECTING;
   }
 
   [GtkCallback]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]