mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 08:30:42 -05:00
[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:
parent
a1a8193179
commit
f6d938a0db
@ -1421,31 +1421,41 @@ clutter_animation_setup_valist (ClutterAnimation *animation,
|
||||
GValue final = { 0, };
|
||||
gchar *error = NULL;
|
||||
|
||||
if (g_str_has_prefix (property_name, "fixed::"))
|
||||
property_name += 7; /* strlen("fixed::") */
|
||||
|
||||
pspec = g_object_class_find_property (klass, property_name);
|
||||
if (!pspec)
|
||||
if (G_UNLIKELY (g_str_equal (property_name, "signal::completed")))
|
||||
{
|
||||
g_warning ("Cannot bind property '%s': objects of type '%s' do "
|
||||
"not have this property",
|
||||
property_name,
|
||||
g_type_name (G_OBJECT_TYPE (priv->object)));
|
||||
break;
|
||||
}
|
||||
GCallback callback = va_arg (var_args, GCallback);
|
||||
gpointer userdata = va_arg (var_args, gpointer);
|
||||
|
||||
g_value_init (&final, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||
G_VALUE_COLLECT (&final, var_args, 0, &error);
|
||||
if (error)
|
||||
g_signal_connect (animation, "completed", callback, userdata);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("%s: %s", G_STRLOC, error);
|
||||
g_free (error);
|
||||
break;
|
||||
}
|
||||
if (g_str_has_prefix (property_name, "fixed::"))
|
||||
property_name += 7; /* strlen("fixed::") */
|
||||
|
||||
clutter_animation_setup_property (animation, property_name,
|
||||
&final,
|
||||
pspec);
|
||||
pspec = g_object_class_find_property (klass, property_name);
|
||||
if (!pspec)
|
||||
{
|
||||
g_warning ("Cannot bind property '%s': objects of type '%s' do "
|
||||
"not have this property",
|
||||
property_name,
|
||||
g_type_name (G_OBJECT_TYPE (priv->object)));
|
||||
break;
|
||||
}
|
||||
|
||||
g_value_init (&final, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||
G_VALUE_COLLECT (&final, var_args, 0, &error);
|
||||
if (error)
|
||||
{
|
||||
g_warning ("%s: %s", G_STRLOC, error);
|
||||
g_free (error);
|
||||
break;
|
||||
}
|
||||
|
||||
clutter_animation_setup_property (animation, property_name,
|
||||
&final,
|
||||
pspec);
|
||||
}
|
||||
|
||||
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
|
||||
* 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
|
||||
* will cause the current animation to change with the new final values,
|
||||
* the new easing mode and the new duration - that is, this code:
|
||||
|
Loading…
Reference in New Issue
Block a user