[libadwaita] Use guint for duration across the board



commit 57e1955143d030c10a9111039af7f67e317153af
Author: Manuel Genovés <manuel genoves gmail com>
Date:   Tue Nov 16 12:00:10 2021 +0500

    Use guint for duration across the board
    
    Update migration guides.

 doc/migrating-between-development-versions.md |  8 ++++++
 doc/migrating-libhandy-1-4-to-libadwaita.md   |  8 ++++++
 src/adw-animation-private.h                   | 12 ++++-----
 src/adw-animation.c                           | 36 +++++++++++++--------------
 src/adw-carousel.c                            |  9 +++----
 src/adw-carousel.h                            |  2 +-
 src/adw-flap.c                                |  6 ++---
 src/adw-leaflet.c                             |  2 +-
 src/adw-swipe-tracker.c                       |  6 ++---
 src/adw-tab-box.c                             | 10 ++++----
 10 files changed, 57 insertions(+), 42 deletions(-)
---
diff --git a/doc/migrating-between-development-versions.md b/doc/migrating-between-development-versions.md
index 5a24ba4c..faee4532 100644
--- a/doc/migrating-between-development-versions.md
+++ b/doc/migrating-between-development-versions.md
@@ -271,6 +271,9 @@ before the swipe starts, after the drag threshold has been reached, and it has
 lost its `direction` parameter. The new [signal@Adw.SwipeTracker::prepare]
 signal behaves exactly like `begin-swipe` was, and can be used instead of it.
 
+The type of the `duration` parameter in [signal@Adw.SwipeTracker::end-swipe] has
+changed from `gint64` to `guint`.
+
 ### Adapt to [class@Adw.TabView] API changes
 
 The `HdyTabVoew:shortcut-widget` property has been removed with no replacement;
@@ -296,6 +299,11 @@ The `can-swipe-back` property have been renamed to
 The new properties also handle keyboard and mouse shortcuts in addition to
 swipes.
 
+### Adapt to [class@Adw.Carousel] API changes
+
+The type of the `duration` parameter in [method@Adw.Carousel.scroll_to_full] has
+changed from `gint64` to `guint`.
+
 ### Adapt to Stylesheet Changes
 
 ### Adapt to the `button.outline` style removal
diff --git a/doc/migrating-libhandy-1-4-to-libadwaita.md b/doc/migrating-libhandy-1-4-to-libadwaita.md
index 6efdcc66..6d4fb98a 100644
--- a/doc/migrating-libhandy-1-4-to-libadwaita.md
+++ b/doc/migrating-libhandy-1-4-to-libadwaita.md
@@ -334,6 +334,9 @@ before the swipe starts, after the drag threshold has been reached, and it has
 lost its `direction` parameter. The new [signal@Adw.SwipeTracker::prepare]
 signal behaves exactly like `begin-swipe` was, and can be used instead of it.
 
+The type of the `duration` parameter in [signal@Adw.SwipeTracker::end-swipe] has
+changed from `gint64` to `guint`.
+
 ### Adapt to [class@Adw.TabView] API changes
 
 The `HdyTabVoew:shortcut-widget` property has been removed with no replacement;
@@ -352,6 +355,11 @@ The `can-swipe-back` property have been renamed to
 The new properties also handle keyboard and mouse shortcuts in addition to
 swipes.
 
+### Adapt to [class@Adw.Carousel] API changes
+
+The type of the `duration` parameter in [method@Adw.Carousel.scroll_to_full] has
+changed from `gint64` to `guint`.
+
 ### Adapt to Stylesheet Changes
 
 Most widgets don't have a backdrop state anymore, and the following public
diff --git a/src/adw-animation-private.h b/src/adw-animation-private.h
index 26216dd2..73467c1b 100644
--- a/src/adw-animation-private.h
+++ b/src/adw-animation-private.h
@@ -46,16 +46,16 @@ struct _AdwAnimationClass
 {
   GObjectClass parent_class;
 
-  gint64 (*estimate_duration) (AdwAnimation *self);
+  guint (*estimate_duration) (AdwAnimation *self);
 
   double (*calculate_value) (AdwAnimation *self,
-                             gint64        t);
+                             guint         t);
 };
 
 AdwAnimation *adw_animation_new (GtkWidget          *widget,
                                  double              from,
                                  double              to,
-                                 gint64              duration,
+                                 guint               duration,
                                  AdwAnimationTarget *target) G_GNUC_WARN_UNUSED_RESULT;
 
 GtkWidget *adw_animation_get_widget (AdwAnimation *self);
@@ -80,9 +80,9 @@ double adw_animation_get_value_to (AdwAnimation *self);
 void   adw_animation_set_value_to (AdwAnimation *self,
                                    double        value);
 
-gint64 adw_animation_get_duration (AdwAnimation *self);
-void   adw_animation_set_duration (AdwAnimation *self,
-                                   gint64        duration);
+guint adw_animation_get_duration (AdwAnimation *self);
+void  adw_animation_set_duration (AdwAnimation *self,
+                                  guint         duration);
 
 AdwAnimationInterpolator adw_animation_get_interpolator (AdwAnimation             *self);
 void                     adw_animation_set_interpolator (AdwAnimation             *self,
diff --git a/src/adw-animation.c b/src/adw-animation.c
index 98fdfad1..7d233501 100644
--- a/src/adw-animation.c
+++ b/src/adw-animation.c
@@ -18,7 +18,7 @@ typedef struct
 
   double value_from;
   double value_to;
-  gint64 duration; /* ms */
+  guint duration; /* ms */
 
   gint64 start_time; /* ms */
   gint64 paused_time;
@@ -89,7 +89,7 @@ set_widget (AdwAnimation *self,
 
 static void
 set_value (AdwAnimation *self,
-           gint64        t)
+           guint         t)
 {
   AdwAnimationPrivate *priv = adw_animation_get_instance_private (self);
 
@@ -124,8 +124,8 @@ 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 */
-  gint64 duration = ADW_ANIMATION_GET_CLASS (self)->estimate_duration (self);
-  gint64 t = (gint64) (frame_time - priv->start_time);
+  guint duration = ADW_ANIMATION_GET_CLASS (self)->estimate_duration (self);
+  guint t = (guint) (frame_time - priv->start_time);
 
   if (t >= duration && duration != ADW_DURATION_INFINITE) {
     adw_animation_skip (self);
@@ -138,7 +138,7 @@ tick_cb (GtkWidget     *widget,
   return G_SOURCE_CONTINUE;
 }
 
-static gint64
+static guint
 adw_animation_estimate_duration (AdwAnimation *animation)
 {
   AdwAnimationPrivate *priv = adw_animation_get_instance_private (animation);
@@ -148,7 +148,7 @@ adw_animation_estimate_duration (AdwAnimation *animation)
 
 static double
 adw_animation_calculate_value (AdwAnimation *animation,
-                               gint64        t)
+                               guint         t)
 {
   AdwAnimationPrivate *priv = adw_animation_get_instance_private (animation);
   double value;
@@ -264,7 +264,7 @@ adw_animation_get_property (GObject    *object,
     break;
 
   case PROP_DURATION:
-    g_value_set_int64 (value, adw_animation_get_duration (self));
+    g_value_set_uint (value, adw_animation_get_duration (self));
     break;
 
   case PROP_INTERPOLATOR:
@@ -307,7 +307,7 @@ adw_animation_set_property (GObject      *object,
     break;
 
   case PROP_DURATION:
-    adw_animation_set_duration (self, g_value_get_int64 (value));
+    adw_animation_set_duration (self, g_value_get_uint (value));
     break;
 
   case PROP_INTERPOLATOR:
@@ -371,13 +371,13 @@ adw_animation_class_init (AdwAnimationClass *klass)
                          G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
 
   props[PROP_DURATION] =
-    g_param_spec_int64 ("duration",
-                        "Duration",
-                        "Duration of the animation",
-                        0,
-                        G_MAXINT64,
-                        0,
-                        G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+    g_param_spec_uint ("duration",
+                       "Duration",
+                       "Duration of the animation",
+                       0,
+                       G_MAXUINT,
+                       0,
+                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
 
   props[PROP_INTERPOLATOR] =
     g_param_spec_enum ("interpolator",
@@ -426,7 +426,7 @@ AdwAnimation *
 adw_animation_new (GtkWidget          *widget,
                    double              from,
                    double              to,
-                   gint64              duration,
+                   guint               duration,
                    AdwAnimationTarget *target)
 {
   AdwAnimation *animation;
@@ -684,7 +684,7 @@ adw_animation_set_value_to (AdwAnimation *self,
   g_object_notify_by_pspec (G_OBJECT (self), props[PROP_VALUE_TO]);
 }
 
-gint64
+guint
 adw_animation_get_duration (AdwAnimation *self)
 {
   AdwAnimationPrivate *priv;
@@ -698,7 +698,7 @@ adw_animation_get_duration (AdwAnimation *self)
 
 void
 adw_animation_set_duration (AdwAnimation *self,
-                            gint64        duration)
+                            guint         duration)
 {
   AdwAnimationPrivate *priv;
 
diff --git a/src/adw-carousel.c b/src/adw-carousel.c
index fa30ab40..6abb5a72 100644
--- a/src/adw-carousel.c
+++ b/src/adw-carousel.c
@@ -316,7 +316,7 @@ static void
 animate_child_resize (AdwCarousel *self,
                       ChildInfo   *child,
                       double       value,
-                      gint64       duration)
+                      guint        duration)
 {
   AdwAnimationTarget *target;
   double old_size = child->size;
@@ -377,7 +377,7 @@ scroll_animation_done_cb (AdwCarousel *self)
 static void
 scroll_to (AdwCarousel *self,
            GtkWidget   *widget,
-           gint64       duration)
+           guint        duration)
 {
   self->animation_target_child = find_child_info (self, widget);
 
@@ -419,7 +419,7 @@ update_swipe_cb (AdwSwipeTracker *tracker,
 
 static void
 end_swipe_cb (AdwSwipeTracker *tracker,
-              gint64           duration,
+              guint            duration,
               double           to,
               AdwCarousel     *self)
 {
@@ -1391,11 +1391,10 @@ adw_carousel_scroll_to (AdwCarousel *self,
 void
 adw_carousel_scroll_to_full (AdwCarousel *self,
                              GtkWidget   *widget,
-                             gint64       duration)
+                             guint        duration)
 {
   g_return_if_fail (ADW_IS_CAROUSEL (self));
   g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (duration >= 0);
   g_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (self));
 
   scroll_to (self, widget, duration);
diff --git a/src/adw-carousel.h b/src/adw-carousel.h
index 72359509..15a4b8f3 100644
--- a/src/adw-carousel.h
+++ b/src/adw-carousel.h
@@ -50,7 +50,7 @@ void adw_carousel_scroll_to      (AdwCarousel *self,
 ADW_AVAILABLE_IN_ALL
 void adw_carousel_scroll_to_full (AdwCarousel *self,
                                   GtkWidget   *widget,
-                                  gint64       duration);
+                                  guint        duration);
 
 ADW_AVAILABLE_IN_ALL
 GtkWidget *adw_carousel_get_nth_page (AdwCarousel *self,
diff --git a/src/adw-flap.c b/src/adw-flap.c
index 33866432..34cea260 100644
--- a/src/adw-flap.c
+++ b/src/adw-flap.c
@@ -313,7 +313,7 @@ reveal_animation_done_cb (AdwFlap *self)
 static void
 animate_reveal (AdwFlap *self,
                 double   to,
-                gint64   duration)
+                guint    duration)
 {
   adw_animation_set_value_from (self->reveal_animation, self->reveal_progress);
   adw_animation_set_value_to (self->reveal_animation, to);
@@ -325,7 +325,7 @@ animate_reveal (AdwFlap *self,
 static void
 set_reveal_flap (AdwFlap  *self,
                  gboolean  reveal_flap,
-                 guint64   duration)
+                 guint     duration)
 {
   reveal_flap = !!reveal_flap;
 
@@ -414,7 +414,7 @@ update_swipe_cb (AdwSwipeTracker *tracker,
 
 static void
 end_swipe_cb (AdwSwipeTracker *tracker,
-              gint64           duration,
+              guint            duration,
               double           to,
               AdwFlap         *self)
 {
diff --git a/src/adw-leaflet.c b/src/adw-leaflet.c
index 72b20de1..36324258 100644
--- a/src/adw-leaflet.c
+++ b/src/adw-leaflet.c
@@ -1604,7 +1604,7 @@ update_swipe_cb (AdwSwipeTracker *tracker,
 
 static void
 end_swipe_cb (AdwSwipeTracker *tracker,
-              gint64           duration,
+              guint            duration,
               double           to,
               AdwLeaflet      *self)
 {
diff --git a/src/adw-swipe-tracker.c b/src/adw-swipe-tracker.c
index 459e0dc9..543e17c3 100644
--- a/src/adw-swipe-tracker.c
+++ b/src/adw-swipe-tracker.c
@@ -426,7 +426,7 @@ gesture_end (AdwSwipeTracker *self,
              gboolean         is_touchpad)
 {
   double end_progress, velocity;
-  gint64 duration, max_duration;
+  guint duration, max_duration;
 
   if (self->state == ADW_SWIPE_TRACKER_STATE_NONE)
     return;
@@ -1150,7 +1150,7 @@ adw_swipe_tracker_class_init (AdwSwipeTrackerClass *klass)
 
   /**
    * AdwSwipeTracker::end-swipe:
-   * @self: t`he `AdwSwipeTracker` instance
+   * @self: the `AdwSwipeTracker` instance
    * @duration: snap-back animation duration in milliseconds
    * @to: the progress value to animate to
    *
@@ -1166,7 +1166,7 @@ adw_swipe_tracker_class_init (AdwSwipeTrackerClass *klass)
                   NULL, NULL, NULL,
                   G_TYPE_NONE,
                   2,
-                  G_TYPE_INT64, G_TYPE_DOUBLE);
+                  G_TYPE_UINT, G_TYPE_DOUBLE);
 }
 
 static void
diff --git a/src/adw-tab-box.c b/src/adw-tab-box.c
index 62e2e33d..cb10f406 100644
--- a/src/adw-tab-box.c
+++ b/src/adw-tab-box.c
@@ -143,7 +143,7 @@ struct _AdwTabBox
   struct {
     TabInfo *info;
     int pos;
-    gint64 duration;
+    guint duration;
     gboolean keep_selected_visible;
   } scheduled_scroll;
 
@@ -760,7 +760,7 @@ static void
 animate_scroll (AdwTabBox *self,
                 TabInfo   *info,
                 double     offset,
-                gint64     duration)
+                guint      duration)
 {
   if (!self->adjustment)
     return;
@@ -779,7 +779,7 @@ animate_scroll (AdwTabBox *self,
 static void
 animate_scroll_relative (AdwTabBox *self,
                          double     delta,
-                         gint64     duration)
+                         guint      duration)
 {
   double current_value = gtk_adjustment_get_value (self->adjustment);
 
@@ -797,7 +797,7 @@ static void
 scroll_to_tab_full (AdwTabBox *self,
                     TabInfo   *info,
                     int        pos,
-                    gint64     duration,
+                    guint      duration,
                     gboolean   keep_selected_visible)
 {
   int tab_width;
@@ -839,7 +839,7 @@ scroll_to_tab_full (AdwTabBox *self,
 static void
 scroll_to_tab (AdwTabBox *self,
                TabInfo   *info,
-               gint64     duration)
+               guint      duration)
 {
   scroll_to_tab_full (self, info, -1, duration, FALSE);
 }


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