[evince/BUG_presentation_duration: 1/2] EvTransitionEffect: support duration in decimal value




commit 1de4c7f22c5302f889d03adda2895e18b0cc2625
Author: Nelson Benítez León <nbenitezl gmail com>
Date:   Wed Apr 21 21:20:13 2021 -0400

    EvTransitionEffect: support duration in decimal value
    
    Property 'duration' of EvTransitionEffect was of
    int type, so when passing a 0.5 value it would
    cast to zero.
    
    So let's add a new 'duration_real' property to hold
    the duration in decimal format, and use it for the
    effect's duration.
    
    Fixes #637

 backend/pdf/ev-poppler.cc          |  1 +
 libdocument/ev-transition-effect.c | 19 ++++++++++++++++++-
 libview/ev-transition-animation.c  |  4 ++--
 3 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc
index d5845e44..e35f45aa 100644
--- a/backend/pdf/ev-poppler.cc
+++ b/backend/pdf/ev-poppler.cc
@@ -2664,6 +2664,7 @@ pdf_document_get_effect (EvDocumentTransition *trans,
                                           "alignment", page_transition->alignment,
                                           "direction", page_transition->direction,
                                           "duration", page_transition->duration,
+                                          "duration-real", page_transition->duration_real,
                                           "angle", page_transition->angle,
                                           "scale", page_transition->scale,
                                           "rectangular", page_transition->rectangular,
diff --git a/libdocument/ev-transition-effect.c b/libdocument/ev-transition-effect.c
index 13370278..c9eea9ab 100644
--- a/libdocument/ev-transition-effect.c
+++ b/libdocument/ev-transition-effect.c
@@ -34,6 +34,7 @@ struct EvTransitionEffectPrivate {
        gint duration;
        gint angle;
        gdouble scale;
+       gdouble duration_real;
 
        guint rectangular : 1;
 };
@@ -44,6 +45,7 @@ enum {
        PROP_ALIGNMENT,
        PROP_DIRECTION,
        PROP_DURATION,
+       PROP_DURATION_REAL,
        PROP_ANGLE,
        PROP_SCALE,
        PROP_RECTANGULAR
@@ -74,6 +76,9 @@ ev_transition_effect_set_property (GObject    *object,
        case PROP_DURATION:
                priv->duration = g_value_get_int (value);
                break;
+       case PROP_DURATION_REAL:
+               priv->duration_real = g_value_get_double (value);
+               break;
        case PROP_ANGLE:
                priv->angle = g_value_get_int (value);
                break;
@@ -112,6 +117,9 @@ ev_transition_effect_get_property (GObject    *object,
        case PROP_DURATION:
                g_value_set_int (value, priv->duration);
                break;
+       case PROP_DURATION_REAL:
+               g_value_set_double (value, priv->duration_real);
+               break;
        case PROP_ANGLE:
                g_value_set_int (value, priv->angle);
                break;
@@ -179,7 +187,16 @@ ev_transition_effect_class_init (EvTransitionEffectClass *klass)
                                                           "Effect duration in seconds",
                                                           0, G_MAXINT, 0,
                                                           G_PARAM_READWRITE |
-                                                           G_PARAM_STATIC_STRINGS));
+                                                           G_PARAM_STATIC_STRINGS |
+                                                           G_PARAM_DEPRECATED));
+       g_object_class_install_property (object_class,
+                                        PROP_DURATION_REAL,
+                                        g_param_spec_double ("duration-real",
+                                                             "Effect duration in seconds (expressed as 
decimal number)",
+                                                             "Effect duration in seconds (expressed as 
decimal number)",
+                                                             0., 86400., 0., /* Arbitrary 1 day max value */
+                                                             G_PARAM_READWRITE |
+                                                             G_PARAM_STATIC_STRINGS));
        g_object_class_install_property (object_class,
                                         PROP_ANGLE,
                                         g_param_spec_int ("angle",
diff --git a/libview/ev-transition-animation.c b/libview/ev-transition-animation.c
index 7b52b70c..78b730b6 100644
--- a/libview/ev-transition-animation.c
+++ b/libview/ev-transition-animation.c
@@ -132,7 +132,7 @@ ev_transition_animation_constructor (GType                  type,
        GObject                      *object;
        EvTransitionAnimationPrivate *priv;
        EvTransitionEffect           *effect;
-       gint                          duration;
+       gdouble                       duration;
 
        object = G_OBJECT_CLASS (ev_transition_animation_parent_class)->constructor (type,
                                                                                     n_construct_properties,
@@ -141,7 +141,7 @@ ev_transition_animation_constructor (GType                  type,
        priv = ev_transition_animation_get_instance_private (EV_TRANSITION_ANIMATION (object));
        effect = priv->effect;
 
-       g_object_get (effect, "duration", &duration, NULL);
+       g_object_get (effect, "duration-real", &duration, NULL);
        ev_timeline_set_duration (EV_TIMELINE (object), duration * 1000);
 
        return object;


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