1
0
mirror of https://gitlab.gnome.org/GNOME/evince synced 2024-06-30 22:54:23 +00:00

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
This commit is contained in:
Nelson Benítez León 2021-04-21 21:20:13 -04:00 committed by Germán Poo-Caamaño
parent b13a169756
commit d4ab3574d1
3 changed files with 21 additions and 3 deletions

View File

@ -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,

View File

@ -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",

View File

@ -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;