From 07d55757219e25f32e3ce0802d7fe4c5fca6df1a Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 16 Sep 2015 17:02:28 +0100 Subject: [PATCH] kinetic-scroll-view: Handle ClutterTimeline:stopped not :completed The former is always emitted when the timeline stops (either due to reaching its duration, or due to clutter_timeline_stop() being called); the latter is only emitted in the first case. Changing signals means we can eliminate manual cleanup code after calls to clutter_timeline_stop(). https://github.com/clutter-project/mx/pull/98 --- mx/mx-kinetic-scroll-view.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/mx/mx-kinetic-scroll-view.c b/mx/mx-kinetic-scroll-view.c index 76d11163..18ae2758 100644 --- a/mx/mx-kinetic-scroll-view.c +++ b/mx/mx-kinetic-scroll-view.c @@ -1087,8 +1087,9 @@ clamp_adjustments (MxKineticScrollView *scroll, } static void -deceleration_completed_cb (ClutterTimeline *timeline, - MxKineticScrollView *scroll) +deceleration_stopped_cb (ClutterTimeline *timeline, + gboolean is_finished, + MxKineticScrollView *scroll) { MxKineticScrollViewPrivate *priv = scroll->priv; guint duration; @@ -1096,8 +1097,7 @@ deceleration_completed_cb (ClutterTimeline *timeline, duration = (priv->overshoot > 0.0) ? priv->clamp_duration : 10; clamp_adjustments (scroll, duration, priv->hmoving, priv->vmoving); - g_object_unref (timeline); - priv->deceleration_timeline = NULL; + g_clear_object (&priv->deceleration_timeline); } static void @@ -1201,7 +1201,6 @@ deceleration_new_frame_cb (ClutterTimeline *timeline, if (stop) { clutter_timeline_stop (timeline); - deceleration_completed_cb (timeline, scroll); } } } @@ -1464,8 +1463,8 @@ release_event (MxKineticScrollView *scroll, g_signal_connect (priv->deceleration_timeline, "new_frame", G_CALLBACK (deceleration_new_frame_cb), scroll); - g_signal_connect (priv->deceleration_timeline, "completed", - G_CALLBACK (deceleration_completed_cb), scroll); + g_signal_connect (priv->deceleration_timeline, "stopped", + G_CALLBACK (deceleration_stopped_cb), scroll); priv->accumulated_delta = 0; priv->hmoving = priv->vmoving = TRUE; clutter_timeline_start (priv->deceleration_timeline); @@ -1530,9 +1529,6 @@ press_event (MxKineticScrollView *scroll, clutter_timeline_stop (priv->deceleration_timeline); g_object_unref (priv->deceleration_timeline); priv->deceleration_timeline = NULL; - - clamp_adjustments (scroll, priv->clamp_duration, priv->hmoving, - priv->vmoving); } if (priv->use_captured)