script: Support layout manager properties

Layout properties work similarly to child properties, with the added
headache that they require the 3-tuple:

  ( layout manager, container, actor )

to be valid in order to be inspected, parsed and applied. This means
using the newly added back-pointer from the container to the layout
manager and then rejigging a bit how the ScriptParser handles the
unresolved properties.

Similarly to the child properties, which use the "child::" prefix, the
layout manager properties use the "layout::" prefix and are defined with
the child of a container holding a layout manager.
This commit is contained in:
Emmanuele Bassi
2010-06-07 22:45:34 +01:00
parent ab76584965
commit 4c22f122e1
7 changed files with 225 additions and 6 deletions

View File

@ -336,3 +336,54 @@ test_script_animation (TestConformSimpleFixture *fixture,
g_object_unref (script);
g_free (test_file);
}
void
test_script_layout_property (TestConformSimpleFixture *fixture,
gconstpointer dummy G_GNUC_UNUSED)
{
ClutterScript *script = clutter_script_new ();
GObject *manager, *container, *actor;
GError *error = NULL;
gchar *test_file;
gboolean x_fill, expand;
ClutterBoxAlignment y_align;
test_file = clutter_test_get_data_file ("test-script-layout-property.json");
clutter_script_load_from_file (script, test_file, &error);
if (g_test_verbose () && error)
g_print ("Error: %s", error->message);
#if GLIB_CHECK_VERSION (2, 20, 0)
g_assert_no_error (error);
#else
g_assert (error == NULL);
#endif
manager = container = actor = NULL;
clutter_script_get_objects (script,
"manager", &manager,
"container", &container,
"actor", &actor,
NULL);
g_assert (CLUTTER_IS_LAYOUT_MANAGER (manager));
g_assert (CLUTTER_IS_CONTAINER (container));
g_assert (CLUTTER_IS_ACTOR (actor));
x_fill = FALSE;
y_align = CLUTTER_BOX_ALIGNMENT_START;
expand = FALSE;
clutter_layout_manager_child_get (CLUTTER_LAYOUT_MANAGER (manager),
CLUTTER_CONTAINER (container),
CLUTTER_ACTOR (actor),
"x-fill", &x_fill,
"y-align", &y_align,
"expand", &expand,
NULL);
g_assert (x_fill);
g_assert (y_align == CLUTTER_BOX_ALIGNMENT_CENTER);
g_assert (expand);
g_object_unref (script);
}