[libhandy] swipe-tracker: Add begin-swipe signal
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy] swipe-tracker: Add begin-swipe signal
- Date: Fri, 26 Jun 2020 12:11:02 +0000 (UTC)
commit 58a6ac89ab81a2e99e1606ac64b9013c1d19100f
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sat Jun 20 16:48:58 2020 +0500
swipe-tracker: Add begin-swipe signal
This will replace HdySwipeable's signal and at the same time allow
swipeables to connect to it instead of overriding begin_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 | 4 ++++
src/hdy-swipe-tracker.c | 42 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
---
diff --git a/src/hdy-swipe-tracker-private.h b/src/hdy-swipe-tracker-private.h
index ee4891dd..8d364a0d 100644
--- a/src/hdy-swipe-tracker-private.h
+++ b/src/hdy-swipe-tracker-private.h
@@ -38,4 +38,8 @@ void hdy_swipe_tracker_set_allow_mouse_drag (HdySwipeTracker *self,
void hdy_swipe_tracker_shift_position (HdySwipeTracker *self,
gdouble delta);
+void hdy_swipe_tracker_emit_begin_swipe (HdySwipeTracker *self,
+ HdyNavigationDirection direction,
+ gboolean direct);
+
G_END_DECLS
diff --git a/src/hdy-swipe-tracker.c b/src/hdy-swipe-tracker.c
index 6895cb0c..f704ac73 100644
--- a/src/hdy-swipe-tracker.c
+++ b/src/hdy-swipe-tracker.c
@@ -90,6 +90,13 @@ enum {
static GParamSpec *props[LAST_PROP];
+enum {
+ SIGNAL_BEGIN_SWIPE,
+ SIGNAL_LAST_SIGNAL,
+};
+
+static guint signals[SIGNAL_LAST_SIGNAL];
+
static void
reset (HdySwipeTracker *self)
{
@@ -117,6 +124,7 @@ gesture_prepare (HdySwipeTracker *self,
return;
hdy_swipeable_begin_swipe (self->swipeable, direction, TRUE);
+ hdy_swipe_tracker_emit_begin_swipe (self, direction, TRUE);
self->initial_progress = hdy_swipeable_get_progress (self->swipeable);
self->progress = self->initial_progress;
@@ -739,6 +747,30 @@ hdy_swipe_tracker_class_init (HdySwipeTrackerClass *klass)
"orientation");
g_object_class_install_properties (object_class, LAST_PROP, props);
+
+ /**
+ * HdySwipeTracker::begin-swipe:
+ * @self: The #HdySwipeTracker instance
+ * @direction: The direction of the swipe
+ * @direct: %TRUE if the swipe is directly triggered by a gesture,
+ * %FALSE if it's triggered via a #HdySwipeGroup
+ *
+ * This signal is emitted when a possible swipe is detected.
+ *
+ * The @direction value can be used to restrict the swipe to a certain
+ * direction.
+ *
+ * Since: 1.0
+ */
+ signals[SIGNAL_BEGIN_SWIPE] =
+ g_signal_new ("begin-swipe",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 2,
+ HDY_TYPE_NAVIGATION_DIRECTION, G_TYPE_BOOLEAN);
}
static void
@@ -944,3 +976,13 @@ hdy_swipe_tracker_shift_position (HdySwipeTracker *self,
self->progress += delta;
self->initial_progress += delta;
}
+
+void
+hdy_swipe_tracker_emit_begin_swipe (HdySwipeTracker *self,
+ HdyNavigationDirection direction,
+ gboolean direct)
+{
+ g_return_if_fail (HDY_IS_SWIPE_TRACKER (self));
+
+ g_signal_emit (self, signals[SIGNAL_BEGIN_SWIPE], 0, direction, direct);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]