2008-05-09 Emmanuele Bassi <ebassi@openedhand.com>

* clutter/clutter-script-private.h: Add a flag for the
	default stage.

	* clutter/clutter-script.c:
	(json_object_end): If the "type" member is "ClutterStage"
	and we have a "is-default" member set to true then this
	is the default stage.

	(clutter_script_construct_object): Special case the default
	stage instead of each ClutterStage.
	
	(object_info_free): Ditto as above.

	* tests/test-script.json: Test the creation of a non-default
	stage and the ::destroy handler to quit.
This commit is contained in:
Emmanuele Bassi
2008-05-09 13:58:04 +00:00
parent 4f9738d3a3
commit d7a8fa8b53
4 changed files with 40 additions and 8 deletions

View File

@ -729,6 +729,17 @@ json_object_end (JsonParser *parser,
json_object_remove_member (object, "signals");
}
if (strcmp (oinfo->class_name, "ClutterStage") == 0 &&
json_object_has_member (object, "is-default"))
{
val = json_object_get_member (object, "is-default");
oinfo->is_stage_default = json_node_get_boolean (val);
json_object_remove_member (object, "is-default");
}
else
oinfo->is_stage_default = FALSE;
oinfo->is_toplevel = FALSE;
oinfo->is_unmerged = FALSE;
oinfo->has_unresolved = TRUE;
@ -1246,9 +1257,9 @@ clutter_script_construct_object (ClutterScript *script,
if (oinfo->object)
object = oinfo->object;
else if (oinfo->gtype == CLUTTER_TYPE_STAGE)
else if (oinfo->gtype == CLUTTER_TYPE_STAGE && oinfo->is_stage_default)
{
/* the stage is a complex beast: we cannot create it using
/* the default stage is a complex beast: we cannot create it using
* g_object_newv() but we need clutter_script_construct_parameters()
* to add the GParamSpec to the PropertyInfo pspec member, so
* that we don't have to implement every complex property (like
@ -1459,7 +1470,7 @@ object_info_free (gpointer data)
oinfo->object = NULL;
}
if (oinfo->is_unmerged && oinfo->object)
if (oinfo->is_unmerged && oinfo->object && !oinfo->is_stage_default)
{
clutter_actor_destroy (CLUTTER_ACTOR (oinfo->object));
oinfo->object = NULL;