[libadwaita/wip/exalm/carousel-refactor: 31/31] carousel: Move swipeable implementation after init()
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/carousel-refactor: 31/31] carousel: Move swipeable implementation after init()
- Date: Fri, 2 Apr 2021 11:04:43 +0000 (UTC)
commit f6814ff8be60c95195acc0ae8c40a1081b453811
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sun Feb 21 21:01:06 2021 +0500
carousel: Move swipeable implementation after init()
That's where we usually keep interface implementations.
src/adw-carousel.c | 158 ++++++++++++++++++++++++++---------------------------
1 file changed, 79 insertions(+), 79 deletions(-)
---
diff --git a/src/adw-carousel.c b/src/adw-carousel.c
index cd815de..fd5e9e7 100644
--- a/src/adw-carousel.c
+++ b/src/adw-carousel.c
@@ -426,74 +426,6 @@ end_swipe_cb (AdwSwipeTracker *tracker,
scroll_to (self, child, duration);
}
-static void
-adw_carousel_switch_child (AdwSwipeable *swipeable,
- guint index,
- gint64 duration)
-{
- AdwCarousel *self = ADW_CAROUSEL (swipeable);
- GtkWidget *child = adw_carousel_get_nth_page (self, index);
-
- scroll_to (self, child, duration);
-}
-
-static AdwSwipeTracker *
-adw_carousel_get_swipe_tracker (AdwSwipeable *swipeable)
-{
- AdwCarousel *self = ADW_CAROUSEL (swipeable);
-
- return self->tracker;
-}
-
-static double
-adw_carousel_get_distance (AdwSwipeable *swipeable)
-{
- AdwCarousel *self = ADW_CAROUSEL (swipeable);
-
- return self->distance;
-}
-
-static double *
-adw_carousel_get_snap_points (AdwSwipeable *swipeable,
- int *n_snap_points)
-{
- AdwCarousel *self = ADW_CAROUSEL (swipeable);
- guint i, n_pages;
- double *points;
- GList *l;
-
- n_pages = MAX (g_list_length (self->children), 1);
- points = g_new0 (double, n_pages);
-
- i = 0;
- for (l = self->children; l; l = l->next) {
- ChildInfo *info = l->data;
-
- points[i++] = info->snap_point;
- }
-
- if (n_snap_points)
- *n_snap_points = n_pages;
-
- return points;
-}
-
-static double
-adw_carousel_get_progress (AdwSwipeable *swipeable)
-{
- AdwCarousel *self = ADW_CAROUSEL (swipeable);
-
- return adw_carousel_get_position (self);
-}
-
-static double
-adw_carousel_get_cancel_progress (AdwSwipeable *swipeable)
-{
- AdwCarousel *self = ADW_CAROUSEL (swipeable);
-
- return get_closest_snap_point (self);
-}
-
/* Copied from GtkOrientable. Orientable widgets are supposed
* to do this manually via a private GTK function. */
static void
@@ -906,17 +838,6 @@ adw_carousel_set_property (GObject *object,
}
}
-static void
-adw_carousel_swipeable_init (AdwSwipeableInterface *iface)
-{
- iface->switch_child = adw_carousel_switch_child;
- iface->get_swipe_tracker = adw_carousel_get_swipe_tracker;
- iface->get_distance = adw_carousel_get_distance;
- iface->get_snap_points = adw_carousel_get_snap_points;
- iface->get_progress = adw_carousel_get_progress;
- iface->get_cancel_progress = adw_carousel_get_cancel_progress;
-}
-
static void
adw_carousel_class_init (AdwCarouselClass *klass)
{
@@ -1131,6 +1052,85 @@ adw_carousel_buildable_init (GtkBuildableIface *iface)
iface->add_child = adw_carousel_buildable_add_child;
}
+static void
+adw_carousel_switch_child (AdwSwipeable *swipeable,
+ guint index,
+ gint64 duration)
+{
+ AdwCarousel *self = ADW_CAROUSEL (swipeable);
+ GtkWidget *child = adw_carousel_get_nth_page (self, index);
+
+ scroll_to (self, child, duration);
+}
+
+static AdwSwipeTracker *
+adw_carousel_get_swipe_tracker (AdwSwipeable *swipeable)
+{
+ AdwCarousel *self = ADW_CAROUSEL (swipeable);
+
+ return self->tracker;
+}
+
+static double
+adw_carousel_get_distance (AdwSwipeable *swipeable)
+{
+ AdwCarousel *self = ADW_CAROUSEL (swipeable);
+
+ return self->distance;
+}
+
+static double *
+adw_carousel_get_snap_points (AdwSwipeable *swipeable,
+ int *n_snap_points)
+{
+ AdwCarousel *self = ADW_CAROUSEL (swipeable);
+ guint i, n_pages;
+ double *points;
+ GList *l;
+
+ n_pages = MAX (g_list_length (self->children), 1);
+ points = g_new0 (double, n_pages);
+
+ i = 0;
+ for (l = self->children; l; l = l->next) {
+ ChildInfo *info = l->data;
+
+ points[i++] = info->snap_point;
+ }
+
+ if (n_snap_points)
+ *n_snap_points = n_pages;
+
+ return points;
+}
+
+static double
+adw_carousel_get_progress (AdwSwipeable *swipeable)
+{
+ AdwCarousel *self = ADW_CAROUSEL (swipeable);
+
+ return adw_carousel_get_position (self);
+}
+
+static double
+adw_carousel_get_cancel_progress (AdwSwipeable *swipeable)
+{
+ AdwCarousel *self = ADW_CAROUSEL (swipeable);
+
+ return get_closest_snap_point (self);
+}
+
+static void
+adw_carousel_swipeable_init (AdwSwipeableInterface *iface)
+{
+ iface->switch_child = adw_carousel_switch_child;
+ iface->get_swipe_tracker = adw_carousel_get_swipe_tracker;
+ iface->get_distance = adw_carousel_get_distance;
+ iface->get_snap_points = adw_carousel_get_snap_points;
+ iface->get_progress = adw_carousel_get_progress;
+ iface->get_cancel_progress = adw_carousel_get_cancel_progress;
+}
+
/**
* adw_carousel_new:
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]