[timeline] Move a complex condition into its own function
The "is-timeline-complete" condition is pretty long, spanning four lines and four logical sub-conditions. It is possible to neatly move it into an is_complete() function and make the code more readable.
This commit is contained in:
parent
092db1098c
commit
f753847851
@ -626,6 +626,17 @@ emit_frame_signal (ClutterTimeline *timeline)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
is_complete (ClutterTimeline *timeline)
|
||||||
|
{
|
||||||
|
ClutterTimelinePrivate *priv = timeline->priv;
|
||||||
|
|
||||||
|
return ((priv->direction == CLUTTER_TIMELINE_FORWARD) &&
|
||||||
|
(priv->current_frame_num >= priv->n_frames)) ||
|
||||||
|
((priv->direction == CLUTTER_TIMELINE_BACKWARD) &&
|
||||||
|
(priv->current_frame_num <= 0));
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
timeline_timeout_func (gpointer data)
|
timeline_timeout_func (gpointer data)
|
||||||
{
|
{
|
||||||
@ -684,12 +695,7 @@ timeline_timeout_func (gpointer data)
|
|||||||
priv->current_frame_num -= n_frames;
|
priv->current_frame_num -= n_frames;
|
||||||
|
|
||||||
/* If we have not reached the end of the timeline: */
|
/* If we have not reached the end of the timeline: */
|
||||||
if (!(
|
if (!is_complete (timeline))
|
||||||
((priv->direction == CLUTTER_TIMELINE_FORWARD) &&
|
|
||||||
(priv->current_frame_num >= priv->n_frames)) ||
|
|
||||||
((priv->direction == CLUTTER_TIMELINE_BACKWARD) &&
|
|
||||||
(priv->current_frame_num <= 0))
|
|
||||||
))
|
|
||||||
{
|
{
|
||||||
/* Emit the signal */
|
/* Emit the signal */
|
||||||
emit_frame_signal (timeline);
|
emit_frame_signal (timeline);
|
||||||
@ -1097,8 +1103,6 @@ clutter_timeline_set_n_frames (ClutterTimeline *timeline,
|
|||||||
|
|
||||||
if (priv->n_frames != n_frames)
|
if (priv->n_frames != n_frames)
|
||||||
{
|
{
|
||||||
g_object_ref (timeline);
|
|
||||||
|
|
||||||
g_object_freeze_notify (G_OBJECT (timeline));
|
g_object_freeze_notify (G_OBJECT (timeline));
|
||||||
|
|
||||||
priv->n_frames = n_frames;
|
priv->n_frames = n_frames;
|
||||||
@ -1107,7 +1111,6 @@ clutter_timeline_set_n_frames (ClutterTimeline *timeline,
|
|||||||
g_object_notify (G_OBJECT (timeline), "duration");
|
g_object_notify (G_OBJECT (timeline), "duration");
|
||||||
|
|
||||||
g_object_thaw_notify (G_OBJECT (timeline));
|
g_object_thaw_notify (G_OBJECT (timeline));
|
||||||
g_object_unref (timeline);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user