[libhandy] stackable-box: Switch to the new HdySwipeTracker API



commit ffbc4a4050a60b500ad5942094cfd9c92c87e9b3
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Sat Jun 20 15:55:19 2020 +0500

    stackable-box: Switch to the new HdySwipeTracker API
    
    Connect to HdySwipeTracker signals instead of implementing interface
    functions.
    
    Signed-off-by: Alexander Mikhaylenko <alexm gnome org>

 debian/libhandy-1-0.symbols     |  3 ---
 src/hdy-deck.c                  | 26 --------------------------
 src/hdy-leaflet.c               | 26 --------------------------
 src/hdy-stackable-box-private.h |  9 +--------
 src/hdy-stackable-box.c         | 31 +++++++++++++++++++------------
 5 files changed, 20 insertions(+), 75 deletions(-)
---
diff --git a/debian/libhandy-1-0.symbols b/debian/libhandy-1-0.symbols
index 924c48f6..0caba5fe 100644
--- a/debian/libhandy-1-0.symbols
+++ b/debian/libhandy-1-0.symbols
@@ -270,10 +270,8 @@ libhandy-1.so.0 libhandy-1-0 #MINVER#
  hdy_squeezer_set_transition_type@LIBHANDY_1_0 0.0.10
  hdy_squeezer_transition_type_get_type@LIBHANDY_1_0 0.0.10
  hdy_stackable_box_add@LIBHANDY_1_0 0.80.0
- hdy_stackable_box_begin_swipe@LIBHANDY_1_0 0.80.0
  hdy_stackable_box_direction_changed@LIBHANDY_1_0 0.80.0
  hdy_stackable_box_draw@LIBHANDY_1_0 0.80.0
- hdy_stackable_box_end_swipe@LIBHANDY_1_0 0.80.0
  hdy_stackable_box_forall@LIBHANDY_1_0 0.80.0
  hdy_stackable_box_get_adjacent_child@LIBHANDY_1_0 0.81.0
  hdy_stackable_box_get_can_swipe_back@LIBHANDY_1_0 0.80.0
@@ -318,7 +316,6 @@ libhandy-1.so.0 libhandy-1-0 #MINVER#
  hdy_stackable_box_transition_type_get_type@LIBHANDY_1_0 0.80.0
  hdy_stackable_box_unmap@LIBHANDY_1_0 0.80.0
  hdy_stackable_box_unrealize@LIBHANDY_1_0 0.80.0
- hdy_stackable_box_update_swipe@LIBHANDY_1_0 0.80.0
  hdy_swipe_group_add_swipeable@LIBHANDY_1_0 0.0.12
  hdy_swipe_group_get_swipeables@LIBHANDY_1_0 0.0.12
  hdy_swipe_group_get_type@LIBHANDY_1_0 0.0.12
diff --git a/src/hdy-deck.c b/src/hdy-deck.c
index 00217b8d..7de3ec1a 100644
--- a/src/hdy-deck.c
+++ b/src/hdy-deck.c
@@ -769,29 +769,6 @@ hdy_deck_switch_child (HdySwipeable *swipeable,
   hdy_stackable_box_switch_child (HDY_GET_HELPER (swipeable), index, duration);
 }
 
-static void
-hdy_deck_begin_swipe (HdySwipeable           *swipeable,
-                      HdyNavigationDirection  direction,
-                      gboolean                direct)
-{
-  hdy_stackable_box_begin_swipe (HDY_GET_HELPER (swipeable), direction, direct);
-}
-
-static void
-hdy_deck_update_swipe (HdySwipeable *swipeable,
-                       gdouble       value)
-{
-  hdy_stackable_box_update_swipe (HDY_GET_HELPER (swipeable), value);
-}
-
-static void
-hdy_deck_end_swipe (HdySwipeable *swipeable,
-                    gint64        duration,
-                    gdouble       to)
-{
-  hdy_stackable_box_end_swipe (HDY_GET_HELPER (swipeable), duration, to);
-}
-
 static gdouble
 hdy_deck_get_distance (HdySwipeable *swipeable)
 {
@@ -1069,9 +1046,6 @@ static void
 hdy_deck_swipeable_init (HdySwipeableInterface *iface)
 {
   iface->switch_child = hdy_deck_switch_child;
-  iface->begin_swipe = hdy_deck_begin_swipe;
-  iface->update_swipe = hdy_deck_update_swipe;
-  iface->end_swipe = hdy_deck_end_swipe;
   iface->get_distance = hdy_deck_get_distance;
   iface->get_range = hdy_deck_get_range;
   iface->get_progress = hdy_deck_get_progress;
diff --git a/src/hdy-leaflet.c b/src/hdy-leaflet.c
index e3db1eb8..eea2fc45 100644
--- a/src/hdy-leaflet.c
+++ b/src/hdy-leaflet.c
@@ -842,29 +842,6 @@ hdy_leaflet_switch_child (HdySwipeable *swipeable,
   hdy_stackable_box_switch_child (HDY_GET_HELPER (swipeable), index, duration);
 }
 
-static void
-hdy_leaflet_begin_swipe (HdySwipeable           *swipeable,
-                         HdyNavigationDirection  direction,
-                         gboolean                direct)
-{
-  hdy_stackable_box_begin_swipe (HDY_GET_HELPER (swipeable), direction, direct);
-}
-
-static void
-hdy_leaflet_update_swipe (HdySwipeable *swipeable,
-                          gdouble       value)
-{
-  hdy_stackable_box_update_swipe (HDY_GET_HELPER (swipeable), value);
-}
-
-static void
-hdy_leaflet_end_swipe (HdySwipeable    *swipeable,
-                       gint64           duration,
-                       gdouble          to)
-{
-  hdy_stackable_box_end_swipe (HDY_GET_HELPER (swipeable), duration, to);
-}
-
 static gdouble
 hdy_leaflet_get_distance (HdySwipeable *swipeable)
 {
@@ -1174,9 +1151,6 @@ static void
 hdy_leaflet_swipeable_init (HdySwipeableInterface *iface)
 {
   iface->switch_child = hdy_leaflet_switch_child;
-  iface->begin_swipe = hdy_leaflet_begin_swipe;
-  iface->update_swipe = hdy_leaflet_update_swipe;
-  iface->end_swipe = hdy_leaflet_end_swipe;
   iface->get_distance = hdy_leaflet_get_distance;
   iface->get_range = hdy_leaflet_get_range;
   iface->get_progress = hdy_leaflet_get_progress;
diff --git a/src/hdy-stackable-box-private.h b/src/hdy-stackable-box-private.h
index 30ef1be9..688630ae 100644
--- a/src/hdy-stackable-box-private.h
+++ b/src/hdy-stackable-box-private.h
@@ -87,14 +87,7 @@ void             hdy_stackable_box_set_child_allow_visible (HdyStackableBox *sel
 void             hdy_stackable_box_switch_child (HdyStackableBox *self,
                                                  guint            index,
                                                  gint64           duration);
-void             hdy_stackable_box_begin_swipe (HdyStackableBox        *self,
-                                                HdyNavigationDirection  direction,
-                                                gboolean                direct);
-void             hdy_stackable_box_update_swipe (HdyStackableBox *self,
-                                                 gdouble          value);
-void             hdy_stackable_box_end_swipe (HdyStackableBox *self,
-                                              gint64           duration,
-                                              gdouble          to);
+
 gdouble          hdy_stackable_box_get_distance (HdyStackableBox *self);
 void             hdy_stackable_box_get_range (HdyStackableBox *self,
                                               gdouble         *lower,
diff --git a/src/hdy-stackable-box.c b/src/hdy-stackable-box.c
index 4a0be770..211442e8 100644
--- a/src/hdy-stackable-box.c
+++ b/src/hdy-stackable-box.c
@@ -2669,10 +2669,11 @@ hdy_stackable_box_switch_child (HdyStackableBox *self,
                           duration, FALSE);
 }
 
-void
-hdy_stackable_box_begin_swipe (HdyStackableBox        *self,
-                               HdyNavigationDirection  direction,
-                               gboolean                direct)
+static void
+begin_swipe_cb (HdySwipeTracker        *tracker,
+                HdyNavigationDirection  direction,
+                gboolean                direct,
+                HdyStackableBox        *self)
 {
   self->child_transition.is_direct_swipe = direct;
   self->child_transition.swipe_direction = direction;
@@ -2701,18 +2702,20 @@ hdy_stackable_box_begin_swipe (HdyStackableBox        *self,
   }
 }
 
-void
-hdy_stackable_box_update_swipe (HdyStackableBox *self,
-                                gdouble          value)
+static void
+update_swipe_cb (HdySwipeTracker *tracker,
+                 gdouble          progress,
+                 HdyStackableBox *self)
 {
-  self->child_transition.progress = ABS (value);
+  self->child_transition.progress = ABS (progress);
   hdy_stackable_box_child_progress_updated (self);
 }
 
-void
-hdy_stackable_box_end_swipe (HdyStackableBox *self,
-                             gint64           duration,
-                             gdouble          to)
+static void
+end_swipe_cb (HdySwipeTracker *tracker,
+              gint64           duration,
+              gdouble          to,
+              HdyStackableBox *self)
 {
  if (!self->child_transition.is_gesture_active)
     return;
@@ -3054,6 +3057,10 @@ hdy_stackable_box_new (GtkContainer      *container,
 
   g_object_set (self->tracker, "orientation", self->orientation, "enabled", FALSE, NULL);
 
+  g_signal_connect_object (self->tracker, "begin-swipe", G_CALLBACK (begin_swipe_cb), self, 0);
+  g_signal_connect_object (self->tracker, "update-swipe", G_CALLBACK (update_swipe_cb), self, 0);
+  g_signal_connect_object (self->tracker, "end-swipe", G_CALLBACK (end_swipe_cb), self, 0);
+
   self->shadow_helper = hdy_shadow_helper_new (widget);
 
   gtk_widget_set_has_window (widget, FALSE);


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