2008-08-01 Neil Roberts <neil@o-hand.com>
+ Bug 1071 - clutter_timeline_get_duration doesn't always work
+
+ * clutter/clutter-timeline.c: Calculate the 'duration' property
+ on-demand instead of storing it as a member variable. Notify
+ duration property changes whenever the fps or num_frames changes.
+
+2008-08-01 Neil Roberts <neil@o-hand.com>
+
Bug 1069 - Warnings with ClutterScore
* clutter/clutter-score.c (clutter_score_is_playing): Check
guint fps;
guint n_frames;
guint delay;
- guint duration;
gint skipped_frames;
clutter_timeline_set_speed (timeline, g_value_get_uint (value));
break;
case PROP_NUM_FRAMES:
- priv->n_frames = g_value_get_uint (value);
+ clutter_timeline_set_n_frames (timeline, g_value_get_uint (value));
break;
case PROP_LOOP:
priv->loop = g_value_get_boolean (value);
g_value_set_uint (value, priv->delay);
break;
case PROP_DURATION:
- g_value_set_uint (value, priv->duration);
+ g_value_set_uint (value, clutter_timeline_get_duration (timeline));
break;
case PROP_DIRECTION:
g_value_set_enum (value, priv->direction);
if (priv->n_frames != n_frames)
{
+ g_object_ref (timeline);
+
+ g_object_freeze_notify (G_OBJECT (timeline));
+
priv->n_frames = n_frames;
g_object_notify (G_OBJECT (timeline), "num-frames");
+ g_object_notify (G_OBJECT (timeline), "duration");
+
+ g_object_thaw_notify (G_OBJECT (timeline));
+ g_object_unref (timeline);
}
}
timeline, NULL);
}
+ g_object_freeze_notify (G_OBJECT (timeline));
+
+ g_object_notify (G_OBJECT (timeline), "duration");
g_object_notify (G_OBJECT (timeline), "fps");
+
+ g_object_thaw_notify (G_OBJECT (timeline));
+
g_object_unref (timeline);
}
}
guint
clutter_timeline_get_duration (ClutterTimeline *timeline)
{
+ ClutterTimelinePrivate *priv;
+
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0);
- return timeline->priv->duration;
+ priv = timeline->priv;
+
+ return priv->n_frames * 1000 / priv->fps;
}
/**
guint msecs)
{
ClutterTimelinePrivate *priv;
+ guint n_frames;
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
priv = timeline->priv;
- if (priv->duration != msecs)
- {
- g_object_ref (timeline);
-
- g_object_freeze_notify (G_OBJECT (timeline));
-
- priv->duration = msecs;
-
- priv->n_frames = priv->duration * priv->fps / 1000;
-
- g_object_notify (G_OBJECT (timeline), "num-frames");
- g_object_notify (G_OBJECT (timeline), "duration");
+ n_frames = msecs * priv->fps / 1000;
+ if (n_frames < 1)
+ n_frames = 1;
- g_object_thaw_notify (G_OBJECT (timeline));
- g_object_unref (timeline);
- }
+ clutter_timeline_set_n_frames (timeline, n_frames);
}
/**