[animation] add varargs support for signal::completed

Added support for registering a handler for the completed signal
directly amongst the varargs making it easier to attach code
to be executed when animations complete.
This commit is contained in:
Øyvind Kolås 2009-03-30 12:10:41 +01:00
parent a1a8193179
commit f6d938a0db

View File

@ -1421,6 +1421,15 @@ clutter_animation_setup_valist (ClutterAnimation *animation,
GValue final = { 0, }; GValue final = { 0, };
gchar *error = NULL; gchar *error = NULL;
if (G_UNLIKELY (g_str_equal (property_name, "signal::completed")))
{
GCallback callback = va_arg (var_args, GCallback);
gpointer userdata = va_arg (var_args, gpointer);
g_signal_connect (animation, "completed", callback, userdata);
}
else
{
if (g_str_has_prefix (property_name, "fixed::")) if (g_str_has_prefix (property_name, "fixed::"))
property_name += 7; /* strlen("fixed::") */ property_name += 7; /* strlen("fixed::") */
@ -1446,6 +1455,7 @@ clutter_animation_setup_valist (ClutterAnimation *animation,
clutter_animation_setup_property (animation, property_name, clutter_animation_setup_property (animation, property_name,
&final, &final,
pspec); pspec);
}
property_name = va_arg (var_args, gchar*); property_name = va_arg (var_args, gchar*);
} }
@ -1627,6 +1637,26 @@ clutter_actor_animate_with_timeline (ClutterActor *actor,
* to control the animation or to know when the animation has been * to control the animation or to know when the animation has been
* completed. * completed.
* *
* If a name argument starts with "signal::" the two following arguments are
* used as callback function and userdata for a signal handler installed on the
* #ClutterAnimation object, for instance:
*
* |[
*
* static void
* on_animation_completed (ClutterAnimation *animation,
* ClutterActor *actor)
* {
* clutter_actor_hide (actor);
* }
*
* clutter_actor_animate (actor, CLUTTER_EASE_IN, 100,
* "opacity", 0,
* "signal::completed", on_animation_completed, actor,
* NULL);
* ]|
*
*
* Calling this function on an actor that is already being animated * Calling this function on an actor that is already being animated
* will cause the current animation to change with the new final values, * will cause the current animation to change with the new final values,
* the new easing mode and the new duration - that is, this code: * the new easing mode and the new duration - that is, this code: