2007-10-08 Emmanuele Bassi <ebassi@openedhand.com>

* clutter/clutter-script.c: Parse ClutterMargin and ClutterPadding
	properties from arrays or integers (assume pixels).
This commit is contained in:
Emmanuele Bassi 2007-10-08 16:48:22 +00:00
parent 76dd06bc7b
commit 98841e2be8
2 changed files with 72 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2007-10-08 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-script.c: Parse ClutterMargin and ClutterPadding
properties from arrays or integers (assume pixels).
2007-10-08 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-script-private.h:

View File

@ -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;