#include <clutter/clutter.h>

static void
_completed (ClutterTimeline *timeline, ClutterActor *actor)
{
  clutter_actor_remove_child (clutter_actor_get_parent (actor), actor);
}

static void
_timeout_cb (ClutterActor *actor)
{
  ClutterTimeline *timeline;

  clutter_actor_save_easing_state (actor);
  clutter_actor_set_easing_duration (actor, 300);
  clutter_actor_set_easing_mode (actor, CLUTTER_LINEAR);
  clutter_actor_set_scale (actor, 0, 0);
  clutter_actor_restore_easing_state (actor);

  timeline = (ClutterTimeline *) clutter_actor_get_transition (actor, "scale-x");
  g_signal_connect (timeline, "completed", G_CALLBACK (_completed), actor);
}

int
main (int argc, char *argv[])
{
  ClutterActor *stage, *actor;

  clutter_init (&argc, &argv);

  stage = g_object_new (CLUTTER_TYPE_STAGE,
                        "width", 200.0,
                        "height", 200.0,
                        NULL);
  actor = g_object_new (CLUTTER_TYPE_ACTOR,
                        "width", 200.0,
                        "height", 200.0,
                        "background-color", clutter_color_new (0xff, 0, 0, 0xff),
                        NULL);
  clutter_actor_add_child (stage, actor);

  g_timeout_add (2000, (GSourceFunc) _timeout_cb, actor);

  clutter_actor_show (stage);
  clutter_main ();

  return 0;
}
