docs: Use symbolic constants for sources and events

This commit is contained in:
Emmanuele Bassi 2012-01-25 23:09:03 +00:00
parent 71323b8bfc
commit b2bf2dbb08
2 changed files with 24 additions and 24 deletions

View File

@ -35,7 +35,7 @@ go_away (gpointer data)
"y", +context->image_height, "y", +context->image_height,
"rotation-angle-z", 2000., "rotation-angle-z", 2000.,
NULL); NULL);
return FALSE; /* remove the timeout source */ return G_SOURCE_REMOVE; /* remove the timeout source */
} }
/* We split the four sub-textures faking to be the big texture, moving them /* We split the four sub-textures faking to be the big texture, moving them
@ -68,9 +68,9 @@ split (gpointer data)
NULL); NULL);
/* In 500ms the textures will flee! */ /* In 500ms the textures will flee! */
g_timeout_add (500, go_away, context); clutter_threads_add_timeout (500, go_away, context);
return FALSE; /* remove the timeout source */ return G_SOURCE_REMOVE; /* remove the timeout source */
} }
static ClutterActor * static ClutterActor *
@ -178,7 +178,7 @@ main (int argc,
context.image_height = image_height; context.image_height = image_height;
/* In two seconds, we'll split the texture! */ /* In two seconds, we'll split the texture! */
g_timeout_add_seconds (2, split, &context); clutter_threads_add_timeout (2000, split, &context);
clutter_main (); clutter_main ();

View File

@ -32,9 +32,9 @@
<title>Basic Animations</title> <title>Basic Animations</title>
<para>The most basic way to create animations with Clutter is via the use <para>The most basic way to create animations with Clutter is via the use
of g_timeout_add(). This enables a callback function to be called at a of clutter_threads_add_timeout(). This enables a callback function to be
defined interval. The callback function can then modify actors visual called at a defined interval. The callback function can then modify actors
properties as to produce an animation.</para> visual properties as to produce an animation.</para>
<example id="clutter-timeout-example"> <example id="clutter-timeout-example">
<title>Simple timeout example</title> <title>Simple timeout example</title>
@ -57,10 +57,11 @@ rotate_actor (gpointer data)
/* add one degree */ /* add one degree */
clos-&gt;current_angle += 1.0 clos-&gt;current_angle += 1.0
/* if we reached the target angle, stop */
if (clos-&gt;current_angle == clos-&gt;final_angle) if (clos-&gt;current_angle == clos-&gt;final_angle)
return FALSE; return G_SOURCE_REMOVE;
return TRUE; return G_SOURCE_CONTINUE;
} }
static void static void
@ -80,27 +81,28 @@ rotate_actor_cleanup (gpointer data)
clos-&gt;final_angle = 360.0; clos-&gt;final_angle = 360.0;
clos-&gt;current_angle = 0; clos-&gt;current_angle = 0;
g_timeout_add_full (1000 / 360, /* 360 updates in one second */ clutter_threads_add_timeout_full (G_PRIORITY_DEFAULT,
rotate_actor, 1000 / 360, /* 360 updates in one second */
clos, rotate_actor,
rotate_actor_cleanup); clos,
rotate_actor_cleanup);
</programlisting> </programlisting>
</example> </example>
<note> <note>
<title>Priorities</title> <title>Priorities</title>
<para>%G_PRIORITY_DEFAULT should always be used as the timeouts priority <para>%G_PRIORITY_DEFAULT should always be used as the timeouts priority
(in case of g_timeout_add_full()) as not to intefere with Clutter's (in case of clutter_threads_add_timeout_full()) as not to intefere with
scheduling of repaints and input event handling.</para> Clutter's scheduling of repaints and input event handling.</para>
</note> </note>
</section> </section>
<section id="clutter-animation-timelines"> <section id="clutter-animation-timelines">
<title>Timelines</title> <title>Timelines</title>
<para>Using g_timeout_add() to control an animation is complicated <para>Using clutter_threads_add_timeout() to control an animation is
and does not work in concert with the rest of the operations Clutter complicated and does not work in concert with the rest of the operations
must perform for each redraw cycle.</para> Clutter must perform for each redraw cycle.</para>
<para>For this reason, Clutter provides #ClutterTimeline, a class that <para>For this reason, Clutter provides #ClutterTimeline, a class that
allows scheduling animations with a definite duration. Timelines are allows scheduling animations with a definite duration. Timelines are
@ -113,7 +115,7 @@ rotate_actor_cleanup (gpointer data)
<para>A Timeline is created with:</para> <para>A Timeline is created with:</para>
<programlisting> <programlisting>
clutter_timeline_new (duration_in_milliseconds); ClutterTimeline *timeline = clutter_timeline_new (duration_in_milliseconds);
</programlisting> </programlisting>
<para>The duration of the timeline then be modifed via the <para>The duration of the timeline then be modifed via the
@ -161,7 +163,7 @@ on_new_frame (ClutterTimeline *timeline,
<example id="clutter-timeline-example"> <example id="clutter-timeline-example">
<title>Using a Timeline to drive an animation</title> <title>Using a Timeline to drive an animation</title>
<para>Rewrite the example above with a #ClutterTimeline instead of <para>Rewrite the example above with a #ClutterTimeline instead of
using g_timeout_add()</para> using clutter_threads_add_timeout()</para>
<programlisting> <programlisting>
#include &lt;clutter/clutter.h&gt; #include &lt;clutter/clutter.h&gt;
@ -189,12 +191,9 @@ on_new_frame (ClutterTimeline *timeline,
clutter_timeline_start (timeline); clutter_timeline_start (timeline);
</programlisting> </programlisting>
</example> </example>
<note><para>Multiple timelines can be sequenced in order by using a
#ClutterScore. See the #ClutterScore documentation for more details on
using this.</para></note>
</section> </section>
<!-- XXX - Behaviours are deprecated
<section id="clutter-animation-behaviours"> <section id="clutter-animation-behaviours">
<title>Behaviours</title> <title>Behaviours</title>
<para>With a large application containing many animations, the use of <para>With a large application containing many animations, the use of
@ -364,6 +363,7 @@ main (int argc, char *argv[])
linkend="creating-your-own-behaviours">here</link>.</para></note> linkend="creating-your-own-behaviours">here</link>.</para></note>
</section> </section>
-->
<section id="clutter-animation-implicit"> <section id="clutter-animation-implicit">
<title>Implicit Animations</title> <title>Implicit Animations</title>