From 98841e2be820db144b47180776268cb850e87d12 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 8 Oct 2007 16:48:22 +0000 Subject: [PATCH] 2007-10-08 Emmanuele Bassi * clutter/clutter-script.c: Parse ClutterMargin and ClutterPadding properties from arrays or integers (assume pixels). --- ChangeLog | 5 +++ clutter/clutter-script.c | 68 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3b7c3f4bd..32a6fa4e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-10-08 Emmanuele Bassi + + * clutter/clutter-script.c: Parse ClutterMargin and ClutterPadding + properties from arrays or integers (assume pixels). + 2007-10-08 Emmanuele Bassi * clutter/clutter-script-private.h: diff --git a/clutter/clutter-script.c b/clutter/clutter-script.c index b68b0e694..4fa30ec96 100644 --- a/clutter/clutter-script.c +++ b/clutter/clutter-script.c @@ -156,7 +156,73 @@ parse_member_to_property (ClutterScript *script, break; case JSON_NODE_ARRAY: - if (strcmp (name, "clip") == 0) + if (strcmp (name, "margin") == 0) + { + JsonArray *array = json_node_get_array (node); + JsonNode *val; + gint i; + ClutterMargin margin = { 0, }; + + /* this is quite evil indeed */ + for (i = 0; i < json_array_get_length (array); i++) + { + val = json_array_get_element (array, i); + switch (i) + { + case 0: + margin.top = CLUTTER_UNITS_FROM_INT (json_node_get_int (val)); + break; + case 1: + margin.right = CLUTTER_UNITS_FROM_INT (json_node_get_int (val)); + break; + case 2: + margin.bottom = CLUTTER_UNITS_FROM_INT (json_node_get_int (val)); + break; + case 3: + margin.left = CLUTTER_UNITS_FROM_INT (json_node_get_int (val)); + break; + } + } + + retval = g_slice_new (PropertyInfo); + retval->property_name = g_strdup (name); + g_value_init (&retval->value, CLUTTER_TYPE_MARGIN); + g_value_set_boxed (&retval->value, &margin); + } + else if (strcmp (name, "padding") == 0) + { + JsonArray *array = json_node_get_array (node); + JsonNode *val; + gint i; + ClutterPadding padding = { 0, }; + + /* this is quite evil indeed */ + for (i = 0; i < json_array_get_length (array); i++) + { + val = json_array_get_element (array, i); + switch (i) + { + case 0: + padding.top = CLUTTER_UNITS_FROM_INT (json_node_get_int (val)); + break; + case 1: + padding.right = CLUTTER_UNITS_FROM_INT (json_node_get_int (val)); + break; + case 2: + padding.bottom = CLUTTER_UNITS_FROM_INT (json_node_get_int (val)); + break; + case 3: + padding.left = CLUTTER_UNITS_FROM_INT (json_node_get_int (val)); + break; + } + } + + retval = g_slice_new (PropertyInfo); + retval->property_name = g_strdup (name); + g_value_init (&retval->value, CLUTTER_TYPE_PADDING); + g_value_set_boxed (&retval->value, &padding); + } + else if (strcmp (name, "clip") == 0) { JsonArray *array = json_node_get_array (node); JsonNode *val;