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

@ -1,3 +1,21 @@
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.
2008-05-09 Emmanuele Bassi <ebassi@openedhand.com> 2008-05-09 Emmanuele Bassi <ebassi@openedhand.com>
Bug #908 - Support transform from G_TYPE_INT to ClutterUnit Bug #908 - Support transform from G_TYPE_INT to ClutterUnit

View File

@ -50,9 +50,10 @@ typedef struct {
guint merge_id; guint merge_id;
guint is_toplevel : 1; guint is_stage_default : 1;
guint has_unresolved : 1; guint is_toplevel : 1;
guint is_unmerged : 1; guint has_unresolved : 1;
guint is_unmerged : 1;
} ObjectInfo; } ObjectInfo;
void object_info_free (gpointer data); void object_info_free (gpointer data);

View File

@ -729,6 +729,17 @@ json_object_end (JsonParser *parser,
json_object_remove_member (object, "signals"); 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_toplevel = FALSE;
oinfo->is_unmerged = FALSE; oinfo->is_unmerged = FALSE;
oinfo->has_unresolved = TRUE; oinfo->has_unresolved = TRUE;
@ -1246,9 +1257,9 @@ clutter_script_construct_object (ClutterScript *script,
if (oinfo->object) if (oinfo->object)
object = 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() * g_object_newv() but we need clutter_script_construct_parameters()
* to add the GParamSpec to the PropertyInfo pspec member, so * to add the GParamSpec to the PropertyInfo pspec member, so
* that we don't have to implement every complex property (like * that we don't have to implement every complex property (like
@ -1459,7 +1470,7 @@ object_info_free (gpointer data)
oinfo->object = NULL; 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)); clutter_actor_destroy (CLUTTER_ACTOR (oinfo->object));
oinfo->object = NULL; oinfo->object = NULL;

View File

@ -2,9 +2,11 @@
"My Scene" : { "My Scene" : {
"id" : "main-stage", "id" : "main-stage",
"type" : "ClutterStage", "type" : "ClutterStage",
"title" : "ClutterScript test",
"color" : "white", "color" : "white",
"signals" : [ "signals" : [
{ "name" : "key-press-event", "handler" : "clutter_main_quit" } { "name" : "key-press-event", "handler" : "clutter_main_quit" },
{ "name" : "destroy", "handler" : "clutter_main_quit" }
], ],
"children" : [ "children" : [
{ {
@ -16,7 +18,7 @@
"rotation" : [ "rotation" : [
{ "z-axis" : [ 45.0, [ 75, 75 ] ] } { "z-axis" : [ 45.0, [ 75, 75 ] ] }
], ],
"behaviours" : [ "fade-behaviour", "path-behaviour" ], "behaviours" : [ "fade-behaviour", "path-behaviour" ]
}, },
{ {
"id" : "green-button", "id" : "green-button",