mutter/tests/test-script.c
Emmanuele Bassi 991562f536 2007-10-08 Emmanuele Bassi <ebassi@openedhand.com>
Initial implementation of the UI definition files. (#424)

	* clutter/json/Makefile.am:
	* clutter/json/*.[ch]: In-tree copy of JSON-GLib, a GLib-based
	JSON parser/generator library. We use it in-tree because we might
	need to change the API. Ideally, we'd depend on it.

	* clutter/clutter.h:
	* clutter/clutter-script-private.h:
	* clutter/clutter-script.[ch]: ClutterScript, the scenegraph
	generator class. It parses JSON streams in form of buffers and
	files and builds the scene.

	* clutter/clutter-debug.h:
	* clutter/clutter-main.c: Add a "script" debug flag

	* clutter/Makefile.am: Build glue.

	* tests/Makefile.am:
	* tests/test-script.c: Add a test case for the ClutterScript.

	* configure.ac: Depend on GLib 2.14, so we can use the
	g_hash_table_get_key() and g_hash_table_get_values() functions
	for the time being; we can probably reimplement those, but we
	are going to need 2.14 anyway if we are going to implement a
	list model using GSequence.
2007-10-08 15:03:22 +00:00

82 lines
1.8 KiB
C

#include <stdlib.h>
#include <stdio.h>
#include <glib.h>
#include <clutter/clutter.h>
static const gchar *test_ui =
"{"
" \"Scene\" : {"
" \"id\" : \"main-stage\","
" \"type\" : \"ClutterStage\","
" \"color\" : \"white\","
" \"width\" : 500,"
" \"height\" : 200,"
" \"children\" : ["
" {"
" \"id\" : \"red-button\","
" \"type\" : \"ClutterRectangle\","
" \"color\" : \"#ff0000ff\","
" \"x\" : 50,"
" \"y\" : 50,"
" \"width\" : 100,"
" \"height\" : 100,"
" \"visible\" : true,"
" },"
" {"
" \"id\" : \"green-button\","
" \"type\" : \"ClutterRectangle\","
" \"color\" : \"#00ff00ff\","
" \"x\" : 200,"
" \"y\" : 50,"
" \"width\" : 100,"
" \"height\" : 100,"
" \"visible\" : true,"
" },"
" {"
" \"id\" : \"blue-button\","
" \"type\" : \"ClutterRectangle\","
" \"color\" : \"#0000ffff\","
" \"x\" : 350,"
" \"y\" : 50,"
" \"width\" : 100,"
" \"height\" : 100,"
" \"visible\" : true,"
" }"
" ]"
" }"
"}";
int
main (int argc, char *argv[])
{
ClutterActor *stage;
ClutterActor *rect;
ClutterScript *script;
GError *error;
clutter_init (&argc, &argv);
script = clutter_script_new ();
error = NULL;
clutter_script_load_from_data (script, test_ui, -1, &error);
if (error)
{
g_print ("*** Error:\n"
"*** %s\n", error->message);
g_error_free (error);
g_object_unref (script);
return EXIT_FAILURE;
}
stage = CLUTTER_ACTOR (clutter_script_get_object (script, "main-stage"));
clutter_actor_show (stage);
clutter_main ();
g_object_unref (script);
return EXIT_SUCCESS;
}