[libhandy] swipe-tracker: Add end-swipe signal



commit 7879ebd4867c27d30cc9d4abc7c3eb929f9c2118
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Sat Jun 20 16:53:44 2020 +0500

    swipe-tracker: Add end-swipe signal
    
    This will replace HdySwipeable's signal and at the same time allow
    swipeables to connect to it instead of overriding end_swipe() there,
    making it clear the 2 classes are closely related and are only meant to be
    used together.
    
    Signed-off-by: Alexander Mikhaylenko <alexm gnome org>

 src/hdy-swipe-tracker-private.h |  3 +++
 src/hdy-swipe-tracker.c         | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
---
diff --git a/src/hdy-swipe-tracker-private.h b/src/hdy-swipe-tracker-private.h
index 9faad4cf..6ec05f23 100644
--- a/src/hdy-swipe-tracker-private.h
+++ b/src/hdy-swipe-tracker-private.h
@@ -43,5 +43,8 @@ void             hdy_swipe_tracker_emit_begin_swipe (HdySwipeTracker        *sel
                                                      gboolean                direct);
 void             hdy_swipe_tracker_emit_update_swipe (HdySwipeTracker *self,
                                                       gdouble          progress);
+void             hdy_swipe_tracker_emit_end_swipe (HdySwipeTracker *self,
+                                                   gint64           duration,
+                                                   gdouble          to);
 
 G_END_DECLS
diff --git a/src/hdy-swipe-tracker.c b/src/hdy-swipe-tracker.c
index 7afee98e..3d370d3e 100644
--- a/src/hdy-swipe-tracker.c
+++ b/src/hdy-swipe-tracker.c
@@ -93,6 +93,7 @@ static GParamSpec *props[LAST_PROP];
 enum {
   SIGNAL_BEGIN_SWIPE,
   SIGNAL_UPDATE_SWIPE,
+  SIGNAL_END_SWIPE,
   SIGNAL_LAST_SIGNAL,
 };
 
@@ -252,6 +253,7 @@ gesture_end (HdySwipeTracker *self,
     duration = CLAMP (duration, MIN_ANIMATION_DURATION, MAX_ANIMATION_DURATION);
 
   hdy_swipeable_end_swipe (self->swipeable, duration, end_progress);
+  hdy_swipe_tracker_emit_end_swipe (self, duration, end_progress);
 
   if (self->cancelled)
     reset (self);
@@ -792,6 +794,26 @@ hdy_swipe_tracker_class_init (HdySwipeTrackerClass *klass)
                   G_TYPE_NONE,
                   1,
                   G_TYPE_DOUBLE);
+
+  /**
+   * HdySwipeTracker::end-swipe:
+   * @self: The #HdySwipeTracker instance
+   * @duration: Snap-back animation duration in milliseconds
+   * @to: The progress value to animate to
+   *
+   * This signal is emitted as soon as the gesture has stopped.
+   *
+   * Since: 1.0
+   */
+  signals[SIGNAL_END_SWIPE] =
+    g_signal_new ("end-swipe",
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_FIRST,
+                  0,
+                  NULL, NULL, NULL,
+                  G_TYPE_NONE,
+                  2,
+                  G_TYPE_INT64, G_TYPE_DOUBLE);
 }
 
 static void
@@ -1016,3 +1038,13 @@ hdy_swipe_tracker_emit_update_swipe (HdySwipeTracker *self,
 
   g_signal_emit (self, signals[SIGNAL_UPDATE_SWIPE], 0, progress);
 }
+
+void
+hdy_swipe_tracker_emit_end_swipe (HdySwipeTracker *self,
+                                  gint64           duration,
+                                  gdouble          to)
+{
+  g_return_if_fail (HDY_IS_SWIPE_TRACKER (self));
+
+  g_signal_emit (self, signals[SIGNAL_END_SWIPE], 0, duration, to);
+}


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