summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2016-10-04 16:48:17 +0100
committerPhilip Withnall <philip.withnall@collabora.co.uk>2016-11-21 20:43:16 +0000
commitc05dc54908d72c94511bc0c3c26aed1624840fe2 (patch)
treec575fa90d26fe1ad1caf1fef9080c6f5fd6b6165
parent7ab085c0864a0607bf602a48afa6f12e562c965f (diff)
downloadclutter-c05dc54908d72c94511bc0c3c26aed1624840fe2.tar.gz
clutter-script: Document support for top-level arrays
Despite being a widely-used feature, it doesn’t seem to be obvious from the documentation that the top-level node in a ClutterScript JSON file can be an object, or an array of objects. Try to clarify that in the documentation. https://bugzilla.gnome.org/show_bug.cgi?id=772412
-rw-r--r--clutter/clutter-script.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/clutter/clutter-script.c b/clutter/clutter-script.c
index 0550ceeb3..68f30c89f 100644
--- a/clutter/clutter-script.c
+++ b/clutter/clutter-script.c
@@ -33,8 +33,9 @@
*
* The UI definition format is JSON, the JavaScript Object Notation as
* described by RFC 4627. #ClutterScript can load a JSON data stream,
- * parse it and build all the objects defined into it. Each object must
- * have an "id" and a "type" properties defining the name to be used
+ * parse it and build all the objects defined into it. The top-level node
+ * in the JSON file can be a single object or an array of objects. Each object
+ * must have an "id" and a "type" properties defining the name to be used
* to retrieve it from #ClutterScript with clutter_script_get_object(),
* and the class type to be instanciated. Every other attribute will
* be mapped to the class properties.
@@ -70,6 +71,27 @@
* using ClutterScript it is possible to check the id by calling
* clutter_get_script_id().
*
+ * Multiple objects can be defined using an array:
+ *
+ * |[<!-- language="plain" -->
+ * [
+ * {
+ * "id" : "red-button",
+ * "type" : "ClutterRectangle",
+ * "width" : 100,
+ * "height" : 100,
+ * "color" : "&num;ff0000ff"
+ * },
+ * {
+ * "id" : "white-button",
+ * "type" : "ClutterRectangle",
+ * "width" : 100,
+ * "height" : 100,
+ * "color" : "&num;ffffffff"
+ * }
+ * ]
+ * ]|
+ *
* Packing can be represented using the "children" member, and passing an
* array of objects or ids of objects already defined (but not packed: the
* packing rules of Clutter still apply, and an actor cannot be packed