[libadwaita] animation: Overhaul the playback API



commit f7e808b2a8f8f1892ec540580321651978c49045
Author: Manuel Genovés <manuel genoves gmail com>
Date:   Tue Nov 16 04:56:23 2021 +0500

    animation: Overhaul the playback API

 src/adw-animation-private.h        |  17 +--
 src/adw-animation.c                | 238 ++++++++++++++++++++++++++++---------
 src/adw-carousel-indicator-dots.c  |   6 +-
 src/adw-carousel-indicator-lines.c |   6 +-
 src/adw-carousel.c                 |  10 +-
 src/adw-flap.c                     |  10 +-
 src/adw-tab-box.c                  |  50 ++++----
 src/adw-tab.c                      |   4 +-
 src/adw-toast-overlay.c            |   4 +-
 9 files changed, 236 insertions(+), 109 deletions(-)
---
diff --git a/src/adw-animation-private.h b/src/adw-animation-private.h
index 73d89580..9d608ebb 100644
--- a/src/adw-animation-private.h
+++ b/src/adw-animation-private.h
@@ -20,6 +20,8 @@
 
 G_BEGIN_DECLS
 
+#define ADW_DURATION_INFINITE G_MAXUINT
+
 #define ADW_TYPE_ANIMATION (adw_animation_get_type())
 
 G_DECLARE_DERIVABLE_TYPE (AdwAnimation, adw_animation, ADW, ANIMATION, GObject)
@@ -34,12 +36,10 @@ typedef enum {
 } AdwAnimationInterpolator;
 
 typedef enum {
-  ADW_ANIMATION_NONE,
-  ADW_ANIMATION_RUNNING,
+  ADW_ANIMATION_IDLE,
   ADW_ANIMATION_PAUSED,
-  ADW_ANIMATION_COMPLETED,
-  ADW_ANIMATION_CANCELED,
-  ADW_ANIMATION_STOPPED,
+  ADW_ANIMATION_PLAYING,
+  ADW_ANIMATION_FINISHED,
 } AdwAnimationState;
 
 /**
@@ -68,8 +68,11 @@ double adw_animation_get_value (AdwAnimation *self);
 
 AdwAnimationState adw_animation_get_state (AdwAnimation *self);
 
-void adw_animation_start (AdwAnimation *self);
-void adw_animation_stop  (AdwAnimation *self);
+void adw_animation_play   (AdwAnimation *self);
+void adw_animation_pause  (AdwAnimation *self);
+void adw_animation_resume (AdwAnimation *self);
+void adw_animation_reset  (AdwAnimation *self);
+void adw_animation_skip   (AdwAnimation *self);
 
 double adw_animation_get_value_from (AdwAnimation *self);
 void   adw_animation_set_value_from (AdwAnimation *self,
diff --git a/src/adw-animation.c b/src/adw-animation.c
index 11205534..724baadf 100644
--- a/src/adw-animation.c
+++ b/src/adw-animation.c
@@ -21,6 +21,7 @@ typedef struct
   gint64 duration; /* ms */
 
   gint64 start_time; /* ms */
+  gint64 paused_time;
   guint tick_cb_id;
   gulong unmap_cb_id;
 
@@ -86,6 +87,34 @@ set_widget (AdwAnimation *self,
                        self);
 }
 
+static double
+calculate_value (AdwAnimation *self,
+                 gint64        t)
+{
+  AdwAnimationPrivate *priv = adw_animation_get_instance_private (self);
+  double value;
+
+  if (priv->duration > 0) {
+    switch (priv->interpolator) {
+      case ADW_ANIMATION_INTERPOLATOR_EASE_IN:
+        value = adw_ease_in_cubic ((double) t / priv->duration);
+        break;
+      case ADW_ANIMATION_INTERPOLATOR_EASE_OUT:
+        value = adw_ease_out_cubic ((double) t / priv->duration);
+        break;
+      case ADW_ANIMATION_INTERPOLATOR_EASE_IN_OUT:
+        value = adw_ease_in_out_cubic ((double) t / priv->duration);
+        break;
+      default:
+        g_assert_not_reached ();
+    }
+  } else {
+    value = 1;
+  }
+
+  return adw_lerp (priv->value_from, priv->value_to, value);
+}
+
 static void
 set_value (AdwAnimation *self,
            double        value)
@@ -98,17 +127,19 @@ set_value (AdwAnimation *self,
 }
 
 static void
-done (AdwAnimation *self)
+stop_animation (AdwAnimation *self)
 {
   AdwAnimationPrivate *priv = adw_animation_get_instance_private (self);
 
-  if (priv->state == ADW_ANIMATION_COMPLETED)
-    return;
-
-  priv->state = ADW_ANIMATION_COMPLETED;
-  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_STATE]);
+  if (priv->tick_cb_id) {
+    gtk_widget_remove_tick_callback (priv->widget, priv->tick_cb_id);
+    priv->tick_cb_id = 0;
+  }
 
-  g_signal_emit (self, signals[SIGNAL_DONE], 0);
+  if (priv->unmap_cb_id) {
+    g_signal_handler_disconnect (priv->widget, priv->unmap_cb_id);
+    priv->unmap_cb_id = 0;
+  }
 }
 
 static gboolean
@@ -119,41 +150,53 @@ tick_cb (GtkWidget     *widget,
   AdwAnimationPrivate *priv = adw_animation_get_instance_private (self);
 
   gint64 frame_time = gdk_frame_clock_get_frame_time (frame_clock) / 1000; /* ms */
-  double t = (double) (frame_time - priv->start_time) / priv->duration;
-  double value;
+  gint64 t = (gint64) (frame_time - priv->start_time);
 
-  if (t >= 1) {
-    priv->tick_cb_id = 0;
+  if (t >= priv->duration && priv->duration != ADW_DURATION_INFINITE) {
+    adw_animation_skip (self);
 
-    set_value (self, priv->value_to);
+    return G_SOURCE_REMOVE;
+  }
 
-    if (priv->unmap_cb_id) {
-      g_signal_handler_disconnect (priv->widget, priv->unmap_cb_id);
-      priv->unmap_cb_id = 0;
-    }
+  set_value (self, calculate_value (self, t));
 
-    done (self);
+  return G_SOURCE_CONTINUE;
+}
 
-    return G_SOURCE_REMOVE;
+static void
+play (AdwAnimation *self)
+{
+
+  AdwAnimationPrivate *priv = adw_animation_get_instance_private (self);
+
+  if (priv->state == ADW_ANIMATION_PLAYING) {
+    g_critical ("Trying to play animation %p, but it's already playing", self);
+
+    return;
   }
 
-  switch (priv->interpolator) {
-    case ADW_ANIMATION_INTERPOLATOR_EASE_IN:
-      value = adw_ease_in_cubic (t);
-      break;
-    case ADW_ANIMATION_INTERPOLATOR_EASE_OUT:
-      value = adw_ease_out_cubic (t);
-      break;
-    case ADW_ANIMATION_INTERPOLATOR_EASE_IN_OUT:
-      value = adw_ease_in_out_cubic (t);
-      break;
-    default:
-      g_assert_not_reached ();
+  priv->state = ADW_ANIMATION_PLAYING;
+  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_STATE]);
+
+  if (!adw_get_enable_animations (priv->widget) ||
+      !gtk_widget_get_mapped (priv->widget)) {
+    adw_animation_skip (g_object_ref (self));
+
+    return;
   }
 
-  set_value (self, adw_lerp (priv->value_from, priv->value_to, value));
+  priv->start_time += gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (priv->widget)) / 1000;
+  priv->start_time -= priv->paused_time;
 
-  return G_SOURCE_CONTINUE;
+  if (priv->tick_cb_id)
+    return;
+
+  priv->unmap_cb_id =
+    g_signal_connect_swapped (priv->widget, "unmap",
+                              G_CALLBACK (adw_animation_skip), self);
+  priv->tick_cb_id = gtk_widget_add_tick_callback (priv->widget, (GtkTickCallback) tick_cb, self, NULL);
+
+  g_object_ref (self);
 }
 
 static void
@@ -174,7 +217,8 @@ adw_animation_dispose (GObject *object)
   AdwAnimation *self = ADW_ANIMATION (object);
   AdwAnimationPrivate *priv = adw_animation_get_instance_private (self);
 
-  adw_animation_stop (self);
+  if (priv->state == ADW_ANIMATION_PLAYING)
+    adw_animation_skip (self);
 
   g_clear_object (&priv->target);
 
@@ -341,7 +385,7 @@ adw_animation_class_init (AdwAnimationClass *klass)
                        "State",
                        "State of the animation",
                        ADW_TYPE_ANIMATION_STATE,
-                       ADW_ANIMATION_NONE,
+                       ADW_ANIMATION_IDLE,
                        G_PARAM_READABLE);
 
   g_object_class_install_properties (object_class, LAST_PROP, props);
@@ -359,6 +403,9 @@ adw_animation_class_init (AdwAnimationClass *klass)
 static void
 adw_animation_init (AdwAnimation *self)
 {
+  AdwAnimationPrivate *priv = adw_animation_get_instance_private (self);
+
+  priv->state = ADW_ANIMATION_IDLE;
 }
 
 AdwAnimation *
@@ -427,7 +474,7 @@ adw_animation_get_state (AdwAnimation *self)
 {
   AdwAnimationPrivate *priv;
 
-  g_return_val_if_fail (ADW_IS_ANIMATION (self), ADW_ANIMATION_NONE);
+  g_return_val_if_fail (ADW_IS_ANIMATION (self), ADW_ANIMATION_IDLE);
 
   priv = adw_animation_get_instance_private (self);
 
@@ -435,7 +482,7 @@ adw_animation_get_state (AdwAnimation *self)
 }
 
 void
-adw_animation_start (AdwAnimation *self)
+adw_animation_play (AdwAnimation *self)
 {
   AdwAnimationPrivate *priv;
 
@@ -443,47 +490,124 @@ adw_animation_start (AdwAnimation *self)
 
   priv = adw_animation_get_instance_private (self);
 
-  if (!adw_get_enable_animations (priv->widget) ||
-      !gtk_widget_get_mapped (priv->widget) ||
-      priv->duration <= 0) {
-    set_value (self, priv->value_to);
+  if (priv->state != ADW_ANIMATION_IDLE) {
+    priv->state = ADW_ANIMATION_IDLE;
+    priv->start_time = 0;
+    priv->paused_time = 0;
+  }
 
-    done (self);
+  play (self);
+}
+
+void
+adw_animation_pause (AdwAnimation *self)
+{
+  AdwAnimationPrivate *priv;
+
+  g_return_if_fail (ADW_IS_ANIMATION (self));
+
+  priv = adw_animation_get_instance_private (self);
+
+  if (priv->state != ADW_ANIMATION_PLAYING)
+    return;
+
+  g_object_freeze_notify (G_OBJECT (self));
+
+  priv->state = ADW_ANIMATION_PAUSED;
+  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_STATE]);
+
+  stop_animation (self);
+
+  priv->paused_time = gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (priv->widget)) / 1000;
+
+  g_object_thaw_notify (G_OBJECT (self));
+
+  g_object_unref (self);
+}
+
+void
+adw_animation_resume (AdwAnimation *self)
+{
+  AdwAnimationPrivate *priv;
+
+  g_return_if_fail (ADW_IS_ANIMATION (self));
+
+  priv = adw_animation_get_instance_private (self);
+
+  if (priv->state != ADW_ANIMATION_PAUSED) {
+    g_critical ("Trying to resume animation %p, but it's not paused", self);
 
     return;
   }
 
-  priv->start_time = gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (priv->widget)) / 1000;
+  play (self);
+}
 
-  if (priv->tick_cb_id)
+void
+adw_animation_skip (AdwAnimation *self)
+{
+  AdwAnimationPrivate *priv;
+  gboolean was_playing;
+
+  g_return_if_fail (ADW_IS_ANIMATION (self));
+
+  priv = adw_animation_get_instance_private (self);
+
+  if (priv->state == ADW_ANIMATION_FINISHED)
     return;
 
-  priv->unmap_cb_id =
-    g_signal_connect_swapped (priv->widget, "unmap",
-                              G_CALLBACK (adw_animation_stop), self);
-  priv->tick_cb_id = gtk_widget_add_tick_callback (priv->widget, (GtkTickCallback) tick_cb, self, NULL);
+  g_object_freeze_notify (G_OBJECT (self));
+
+  was_playing = priv->state == ADW_ANIMATION_PLAYING;
+
+  priv->state = ADW_ANIMATION_FINISHED;
+  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_STATE]);
+
+  stop_animation (self);
+
+  set_value (self, calculate_value (self, priv->duration));
+
+  priv->start_time = 0;
+  priv->paused_time = 0;
+
+  g_object_thaw_notify (G_OBJECT (self));
+
+  g_signal_emit (self, signals[SIGNAL_DONE], 0);
+
+  if (was_playing)
+    g_object_unref (self);
 }
 
 void
-adw_animation_stop (AdwAnimation *self)
+adw_animation_reset (AdwAnimation *self)
 {
   AdwAnimationPrivate *priv;
+  gboolean was_playing;
 
   g_return_if_fail (ADW_IS_ANIMATION (self));
 
   priv = adw_animation_get_instance_private (self);
 
-  if (priv->tick_cb_id) {
-    gtk_widget_remove_tick_callback (priv->widget, priv->tick_cb_id);
-    priv->tick_cb_id = 0;
-  }
+  if (priv->state == ADW_ANIMATION_IDLE)
+    return;
 
-  if (priv->unmap_cb_id) {
-    g_signal_handler_disconnect (priv->widget, priv->unmap_cb_id);
-    priv->unmap_cb_id = 0;
-  }
+  g_object_freeze_notify (G_OBJECT (self));
+
+  was_playing = priv->state == ADW_ANIMATION_PLAYING;
+
+  priv->state = ADW_ANIMATION_IDLE;
+  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_STATE]);
+
+  stop_animation (self);
+
+  set_value (self, calculate_value (self, 0));
+  priv->start_time = 0;
+  priv->paused_time = 0;
+
+  g_object_thaw_notify (G_OBJECT (self));
 
-  done (self);
+  if (was_playing)
+    g_object_unref (self);
 }
 
 double
diff --git a/src/adw-carousel-indicator-dots.c b/src/adw-carousel-indicator-dots.c
index e1be8a57..6c3aae4e 100644
--- a/src/adw-carousel-indicator-dots.c
+++ b/src/adw-carousel-indicator-dots.c
@@ -79,7 +79,7 @@ animate (AdwCarouselIndicatorDots *self,
   AdwAnimationTarget *target;
 
   if (self->animation)
-    adw_animation_stop (self->animation);
+    adw_animation_skip (self->animation);
 
   target = adw_callback_animation_target_new ((AdwAnimationTargetFunc)
                                               gtk_widget_queue_draw,
@@ -89,7 +89,7 @@ animate (AdwCarouselIndicatorDots *self,
 
   g_signal_connect_swapped (self->animation, "done", G_CALLBACK (done_cb), self);
 
-  adw_animation_start (self->animation);
+  adw_animation_play (self->animation);
 }
 
 static GdkRGBA
@@ -421,7 +421,7 @@ adw_carousel_indicator_dots_set_carousel (AdwCarouselIndicatorDots *self,
     return;
 
   if (self->animation)
-    adw_animation_stop (self->animation);
+    adw_animation_skip (self->animation);
 
   if (self->carousel) {
     g_signal_handlers_disconnect_by_func (self->carousel, gtk_widget_queue_draw, self);
diff --git a/src/adw-carousel-indicator-lines.c b/src/adw-carousel-indicator-lines.c
index d049ffd6..9ae8993b 100644
--- a/src/adw-carousel-indicator-lines.c
+++ b/src/adw-carousel-indicator-lines.c
@@ -77,7 +77,7 @@ animate (AdwCarouselIndicatorLines *self,
   AdwAnimationTarget *target;
 
   if (self->animation)
-    adw_animation_stop (self->animation);
+    adw_animation_skip (self->animation);
 
   target = adw_callback_animation_target_new ((AdwAnimationTargetFunc)
                                               gtk_widget_queue_draw,
@@ -87,7 +87,7 @@ animate (AdwCarouselIndicatorLines *self,
 
   g_signal_connect_swapped (self->animation, "done", G_CALLBACK (done_cb), self);
 
-  adw_animation_start (self->animation);
+  adw_animation_play (self->animation);
 }
 
 static GdkRGBA
@@ -406,7 +406,7 @@ adw_carousel_indicator_lines_set_carousel (AdwCarouselIndicatorLines *self,
     return;
 
   if (self->animation)
-    adw_animation_stop (self->animation);
+    adw_animation_skip (self->animation);
 
   if (self->carousel) {
     g_signal_handlers_disconnect_by_func (self->carousel, gtk_widget_queue_draw, self);
diff --git a/src/adw-carousel.c b/src/adw-carousel.c
index 31488006..848aabba 100644
--- a/src/adw-carousel.c
+++ b/src/adw-carousel.c
@@ -324,7 +324,7 @@ animate_child_resize (AdwCarousel *self,
   update_shift_position_flag (self, child);
 
   if (child->resize_animation)
-    adw_animation_stop (child->resize_animation);
+    adw_animation_skip (child->resize_animation);
 
   target = adw_callback_animation_target_new ((AdwAnimationTargetFunc)
                                               resize_animation_value_cb,
@@ -334,7 +334,7 @@ animate_child_resize (AdwCarousel *self,
 
   g_signal_connect_swapped (child->resize_animation, "done", G_CALLBACK (resize_animation_done_cb), child);
 
-  adw_animation_start (child->resize_animation);
+  adw_animation_play (child->resize_animation);
 }
 
 static void
@@ -382,7 +382,7 @@ scroll_to (AdwCarousel *self,
   AdwAnimationTarget *target;
 
   if (self->animation)
-    adw_animation_stop (self->animation);
+    adw_animation_skip (self->animation);
 
   self->animation_target_child = find_child_info (self, widget);
 
@@ -399,7 +399,7 @@ scroll_to (AdwCarousel *self,
 
   g_signal_connect_swapped (self->animation, "done", G_CALLBACK (scroll_animation_done_cb), self);
 
-  adw_animation_start (self->animation);
+  adw_animation_play (self->animation);
 }
 
 static inline double
@@ -419,7 +419,7 @@ begin_swipe_cb (AdwSwipeTracker *tracker,
                 AdwCarousel     *self)
 {
   if (self->animation)
-    adw_animation_stop (self->animation);
+    adw_animation_skip (self->animation);
 }
 
 static void
diff --git a/src/adw-flap.c b/src/adw-flap.c
index fed54d7e..e5a97ef4 100644
--- a/src/adw-flap.c
+++ b/src/adw-flap.c
@@ -297,7 +297,7 @@ animate_fold (AdwFlap *self)
   AdwAnimationTarget *target;
 
   if (self->fold_animation)
-    adw_animation_stop (self->fold_animation);
+    adw_animation_skip (self->fold_animation);
 
   target = adw_callback_animation_target_new ((AdwAnimationTargetFunc)
                                               fold_animation_value_cb,
@@ -312,7 +312,7 @@ animate_fold (AdwFlap *self)
 
   g_signal_connect_swapped (self->fold_animation, "done", G_CALLBACK (fold_animation_done_cb), self);
 
-  adw_animation_start (self->fold_animation);
+  adw_animation_play (self->fold_animation);
 }
 
 static void
@@ -337,7 +337,7 @@ animate_reveal (AdwFlap *self,
   AdwAnimationTarget *target;
 
   if (self->reveal_animation)
-    adw_animation_stop (self->reveal_animation);
+    adw_animation_skip (self->reveal_animation);
 
   target = adw_callback_animation_target_new ((AdwAnimationTargetFunc)
                                               set_reveal_progress,
@@ -348,7 +348,7 @@ animate_reveal (AdwFlap *self,
 
   g_signal_connect_swapped (self->reveal_animation, "done", G_CALLBACK (reveal_animation_done_cb), self);
 
-  adw_animation_start (self->reveal_animation);
+  adw_animation_play (self->reveal_animation);
 }
 
 static void
@@ -429,7 +429,7 @@ begin_swipe_cb (AdwSwipeTracker *tracker,
     return;
 
   if (self->reveal_animation)
-    adw_animation_stop (self->reveal_animation);
+    adw_animation_skip (self->reveal_animation);
 
   self->swipe_active = TRUE;
 }
diff --git a/src/adw-tab-box.c b/src/adw-tab-box.c
index f97d7b46..6d1f1fc1 100644
--- a/src/adw-tab-box.c
+++ b/src/adw-tab-box.c
@@ -473,7 +473,7 @@ set_tab_resize_mode (AdwTabBox     *self,
 
     g_signal_connect_swapped (self->resize_animation, "done", G_CALLBACK (resize_animation_done_cb), self);
 
-    adw_animation_start (self->resize_animation);
+    adw_animation_play (self->resize_animation);
   }
 
   notify = (self->tab_resize_mode == TAB_RESIZE_NORMAL) !=
@@ -765,7 +765,7 @@ adjustment_value_changed_cb (AdwTabBox *self)
       return;
 
   if (self->scroll_animation)
-    adw_animation_stop (self->scroll_animation);
+    adw_animation_skip (self->scroll_animation);
 
   gtk_widget_queue_allocate (GTK_WIDGET (self));
 }
@@ -791,7 +791,7 @@ animate_scroll (AdwTabBox *self,
   g_signal_emit (self, signals[SIGNAL_STOP_KINETIC_SCROLLING], 0);
 
   if (self->scroll_animation)
-    adw_animation_stop (self->scroll_animation);
+    adw_animation_skip (self->scroll_animation);
 
   g_clear_object (&self->scroll_animation);
   self->scroll_animation_done = FALSE;
@@ -812,7 +812,7 @@ animate_scroll (AdwTabBox *self,
 
   g_signal_connect_swapped (self->scroll_animation, "done", G_CALLBACK (scroll_animation_done_cb), self);
 
-  adw_animation_start (self->scroll_animation);
+  adw_animation_play (self->scroll_animation);
 }
 
 static void
@@ -927,13 +927,13 @@ force_end_reordering (AdwTabBox *self)
     return;
 
   if (self->reorder_animation)
-    adw_animation_stop (self->reorder_animation);
+    adw_animation_skip (self->reorder_animation);
 
   for (l = self->tabs; l; l = l->next) {
     TabInfo *info = l->data;
 
     if (info->reorder_animation)
-      adw_animation_stop (info->reorder_animation);
+      adw_animation_skip (info->reorder_animation);
   }
 }
 
@@ -1035,7 +1035,7 @@ animate_reordering (AdwTabBox *self,
   AdwAnimationTarget *target;
 
   if (self->reorder_animation)
-    adw_animation_stop (self->reorder_animation);
+    adw_animation_skip (self->reorder_animation);
 
   target = adw_callback_animation_target_new ((AdwAnimationTargetFunc)
                                               reorder_animation_value_cb,
@@ -1046,7 +1046,7 @@ animate_reordering (AdwTabBox *self,
 
   g_signal_connect_swapped (self->reorder_animation, "done", G_CALLBACK (reorder_animation_done_cb), 
dest_tab);
 
-  adw_animation_start (self->reorder_animation);
+  adw_animation_play (self->reorder_animation);
 
   check_end_reordering (self);
 }
@@ -1087,7 +1087,7 @@ animate_reorder_offset (AdwTabBox *self,
   info->end_reorder_offset = offset;
 
   if (info->reorder_animation)
-    adw_animation_stop (info->reorder_animation);
+    adw_animation_skip (info->reorder_animation);
 
   target = adw_callback_animation_target_new ((AdwAnimationTargetFunc)
                                               reorder_offset_animation_value_cb,
@@ -1098,7 +1098,7 @@ animate_reorder_offset (AdwTabBox *self,
 
   g_signal_connect_swapped (info->reorder_animation, "done", G_CALLBACK (reorder_offset_animation_done_cb), 
info);
 
-  adw_animation_start (info->reorder_animation);
+  adw_animation_play (info->reorder_animation);
 }
 
 static void
@@ -1361,7 +1361,7 @@ start_drag_reodering (AdwTabBox *self,
 
   if (self->continue_reorder) {
     if (self->reorder_animation)
-      adw_animation_stop (self->reorder_animation);
+      adw_animation_skip (self->reorder_animation);
 
     reset_reorder_animations (self);
 
@@ -1682,7 +1682,7 @@ page_attached_cb (AdwTabBox  *self,
 
   self->n_tabs++;
 
-  adw_animation_start (info->appear_animation);
+  adw_animation_play (info->appear_animation);
 
   if (page == adw_tab_view_get_selected_page (self->view))
     adw_tab_box_select_page (self, page);
@@ -1703,10 +1703,10 @@ close_animation_done_cb (TabInfo *info)
   self->tabs = g_list_remove (self->tabs, info);
 
   if (info->reorder_animation)
-    adw_animation_stop (info->reorder_animation);
+    adw_animation_skip (info->reorder_animation);
 
   if (self->reorder_animation)
-    adw_animation_stop (self->reorder_animation);
+    adw_animation_skip (self->reorder_animation);
 
   if (self->pressed_tab == info)
     self->pressed_tab = NULL;
@@ -1774,7 +1774,7 @@ page_detached_cb (AdwTabBox  *self,
   info->page = NULL;
 
   if (info->appear_animation)
-    adw_animation_stop (info->appear_animation);
+    adw_animation_skip (info->appear_animation);
 
   target = adw_callback_animation_target_new ((AdwAnimationTargetFunc)
                                               appear_animation_value_cb,
@@ -1785,7 +1785,7 @@ page_detached_cb (AdwTabBox  *self,
 
   g_signal_connect_swapped (info->appear_animation, "done", G_CALLBACK (close_animation_done_cb), info);
 
-  adw_animation_start (info->appear_animation);
+  adw_animation_play (info->appear_animation);
 }
 
 /* Tab DND */
@@ -1932,7 +1932,7 @@ insert_placeholder (AdwTabBox  *self,
     initial_progress = info->appear_progress;
 
     if (info->appear_animation)
-      adw_animation_stop (info->appear_animation);
+      adw_animation_skip (info->appear_animation);
   } else {
     int index;
 
@@ -1979,7 +1979,7 @@ insert_placeholder (AdwTabBox  *self,
 
   g_signal_connect_swapped (info->appear_animation, "done", G_CALLBACK (open_animation_done_cb), info);
 
-  adw_animation_start (info->appear_animation);
+  adw_animation_play (info->appear_animation);
 }
 
 static void
@@ -2018,7 +2018,7 @@ replace_placeholder (AdwTabBox  *self,
   adw_tab_set_page (info->tab, page);
   info->page = page;
 
-  adw_animation_stop (info->appear_animation);
+  adw_animation_skip (info->appear_animation);
 
   target = adw_callback_animation_target_new ((AdwAnimationTargetFunc)
                                               appear_animation_value_cb,
@@ -2029,7 +2029,7 @@ replace_placeholder (AdwTabBox  *self,
 
   g_signal_connect_swapped (info->appear_animation, "done", G_CALLBACK (replace_animation_done_cb), info);
 
-  adw_animation_start (info->appear_animation);
+  adw_animation_play (info->appear_animation);
 }
 
 static void
@@ -2051,7 +2051,7 @@ remove_animation_done_cb (TabInfo *info)
     force_end_reordering (self);
 
     if (self->reorder_animation)
-      adw_animation_stop (info->reorder_animation);
+      adw_animation_skip (info->reorder_animation);
 
     self->reordered_tab = NULL;
   }
@@ -2090,7 +2090,7 @@ remove_placeholder (AdwTabBox *self)
   info->page = NULL;
 
   if (info->appear_animation)
-    adw_animation_stop (info->appear_animation);
+    adw_animation_skip (info->appear_animation);
 
   g_idle_add ((GSourceFunc) remove_placeholder_scroll_cb, self);
 
@@ -2103,7 +2103,7 @@ remove_placeholder (AdwTabBox *self)
 
   g_signal_connect_swapped (info->appear_animation, "done", G_CALLBACK (remove_animation_done_cb), info);
 
-  adw_animation_start (info->appear_animation);
+  adw_animation_play (info->appear_animation);
 }
 
 static inline AdwTabBox *
@@ -2312,7 +2312,7 @@ resize_drag_icon (AdwTabBox *self,
     return;
 
   if (icon->resize_animation)
-    adw_animation_stop (icon->resize_animation);
+    adw_animation_skip (icon->resize_animation);
 
   icon->target_width = width;
 
@@ -2325,7 +2325,7 @@ resize_drag_icon (AdwTabBox *self,
 
   g_signal_connect_swapped (icon->resize_animation, "done", G_CALLBACK (icon_resize_animation_done_cb), 
icon);
 
-  adw_animation_start (icon->resize_animation);
+  adw_animation_play (icon->resize_animation);
 }
 
 static void
diff --git a/src/adw-tab.c b/src/adw-tab.c
index 5454cb0a..41c4f82f 100644
--- a/src/adw-tab.c
+++ b/src/adw-tab.c
@@ -125,7 +125,7 @@ update_state (AdwTab *self)
     double opacity = gtk_widget_get_opacity (self->close_btn);
 
     if (self->close_btn_animation)
-      adw_animation_stop (self->close_btn_animation);
+      adw_animation_skip (self->close_btn_animation);
 
     self->show_close = show_close;
 
@@ -144,7 +144,7 @@ update_state (AdwTab *self)
 
     g_signal_connect_swapped (self->close_btn_animation, "done", G_CALLBACK (close_btn_animation_done_cb), 
self);
 
-    adw_animation_start (self->close_btn_animation);
+    adw_animation_play (self->close_btn_animation);
   }
 }
 
diff --git a/src/adw-toast-overlay.c b/src/adw-toast-overlay.c
index 4c3b1120..0a9f9918 100644
--- a/src/adw-toast-overlay.c
+++ b/src/adw-toast-overlay.c
@@ -179,7 +179,7 @@ hide_current_toast (AdwToastOverlay *self)
   g_signal_connect_swapped (info->hide_animation, "done",
                             G_CALLBACK (hide_done_cb), info);
 
-  adw_animation_start (info->hide_animation);
+  adw_animation_play (info->hide_animation);
 }
 
 static void
@@ -237,7 +237,7 @@ show_toast (AdwToastOverlay *self,
   g_signal_connect_swapped (info->show_animation, "done",
                             G_CALLBACK (show_done_cb), info);
 
-  adw_animation_start (info->show_animation);
+  adw_animation_play (info->show_animation);
 }
 
 static gboolean


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