[libshumate] view: Add API to set the go-to animation duration



commit c912fc9acce442f4bf4c841d67473dcdda4fcc9f
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Mar 4 21:43:33 2021 -0300

    view: Add API to set the go-to animation duration
    
    Fixes https://gitlab.gnome.org/GNOME/libshumate/-/issues/10

 shumate/shumate-view.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
 shumate/shumate-view.h |  4 ++++
 2 files changed, 46 insertions(+), 2 deletions(-)
---
diff --git a/shumate/shumate-view.c b/shumate/shumate-view.c
index 4aa480f..338ccb7 100644
--- a/shumate/shumate-view.c
+++ b/shumate/shumate-view.c
@@ -454,7 +454,6 @@ shumate_view_set_property (GObject *object,
     GParamSpec *pspec)
 {
   ShumateView *view = SHUMATE_VIEW (object);
-  ShumateViewPrivate *priv = shumate_view_get_instance_private (view);
 
   switch (prop_id)
     {
@@ -475,7 +474,7 @@ shumate_view_set_property (GObject *object,
       break;
 
     case PROP_GOTO_ANIMATION_DURATION:
-      priv->goto_duration = g_value_get_uint (value);
+      shumate_view_set_go_to_duration (view, g_value_get_uint (value));
       break;
 
     default:
@@ -906,6 +905,47 @@ shumate_view_go_to_with_duration (ShumateView *view,
   //clutter_timeline_start (ctx->timeline);
 }
 
+/**
+ * shumate_view_get_go_to_duration:
+ * @self: a #ShumateView
+ *
+ * Get the 'goto-animation-duration' property.
+ *
+ * Returns: the animation duration when calling shumate_view_go_to(),
+ *   in milliseconds.
+ */
+guint
+shumate_view_get_go_to_duration (ShumateView *self)
+{
+  ShumateViewPrivate *priv = shumate_view_get_instance_private (self);
+
+  g_return_val_if_fail (SHUMATE_IS_VIEW (self), 0);
+
+  return priv->goto_duration;
+}
+
+/**
+ * shumate_view_set_go_to_duration:
+ * @self: a #ShumateView
+ * @duration: the animation duration, in milliseconds
+ *
+ * Set the duration of the transition of shumate_view_go_to().
+ */
+void
+shumate_view_set_go_to_duration (ShumateView *self,
+                                 guint        duration)
+{
+  ShumateViewPrivate *priv = shumate_view_get_instance_private (self);
+
+  g_return_if_fail (SHUMATE_IS_VIEW (self));
+
+  if (priv->goto_duration == duration)
+    return;
+
+  priv->goto_duration = duration;
+  g_object_notify_by_pspec (G_OBJECT (self), obj_properties[PROP_GOTO_ANIMATION_DURATION]);
+}
+
 /**
  * shumate_view_add_layer:
  * @view: a #ShumateView
diff --git a/shumate/shumate-view.h b/shumate/shumate-view.h
index 01589dd..5e553b6 100644
--- a/shumate/shumate-view.h
+++ b/shumate/shumate-view.h
@@ -65,6 +65,10 @@ void shumate_view_go_to (ShumateView *view,
     double longitude);
 void shumate_view_stop_go_to (ShumateView *view);
 
+guint shumate_view_get_go_to_duration (ShumateView *self);
+void shumate_view_set_go_to_duration (ShumateView *self,
+                                      guint        duration);
+
 void shumate_view_set_map_source (ShumateView *view,
     ShumateMapSource *map_source);
 void shumate_view_add_overlay_source (ShumateView *view,


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