test-recorder: Create the recorder only after the stage is realized

The recorder needs the stage's XID so it can only be created after the
stage is realized.

https://bugzilla.gnome.org/show_bug.cgi?id=675301
This commit is contained in:
Rui Matos 2012-05-02 16:23:28 +02:00
parent cb5941ec55
commit d579cd1605

View File

@ -7,12 +7,19 @@
/* Very simple test of the ShellRecorder class; shows some text strings
* moving around and records it.
*/
static ShellRecorder *recorder;
static ShellRecorder *recorder = NULL;
static gboolean
stop_recording_timeout (gpointer data)
{
shell_recorder_close (recorder);
if (recorder)
{
shell_recorder_close (recorder);
g_object_unref (recorder);
}
clutter_main_quit ();
return FALSE;
}
@ -22,6 +29,15 @@ on_animation_completed (ClutterAnimation *animation)
g_timeout_add (1000, stop_recording_timeout, NULL);
}
static void
on_stage_realized (ClutterActor *stage,
gpointer data)
{
recorder = shell_recorder_new (CLUTTER_STAGE (stage));
shell_recorder_set_filename (recorder, "test-recorder.ogg");
shell_recorder_record (recorder);
}
int main (int argc, char **argv)
{
ClutterActor *stage;
@ -86,13 +102,14 @@ int main (int argc, char **argv)
"y", 240.0,
NULL);
recorder = shell_recorder_new (CLUTTER_STAGE (stage));
shell_recorder_set_filename (recorder, "test-recorder.ogg");
g_signal_connect_after (stage, "realize",
G_CALLBACK (on_stage_realized), NULL);
clutter_actor_show (stage);
shell_recorder_record (recorder);
clutter_main ();
g_object_unref (stage);
return 0;
}