cookbook: Simplified ClutterScript example

There was too much in the example code to cover in a single
recipe, so I trimmed it down to demonstrate simple
UI building (no constraints, effects, animations, or signals).
This commit is contained in:
Elliot Smith
2010-08-26 10:52:12 +01:00
parent 4cba0cf3e8
commit 27d9825abe
2 changed files with 8 additions and 112 deletions

View File

@ -1,44 +1,12 @@
#include <stdlib.h>
#include <clutter/clutter.h>
gboolean
_pointer_motion_cb (ClutterActor *actor,
ClutterEvent *event,
gpointer user_data)
{
g_debug ("Pointer movement");
return TRUE;
}
void
_button_clicked_cb (ClutterClickAction *action,
ClutterActor *actor,
gpointer user_data)
{
/* get the UI definition passed to the handler */
ClutterScript *ui = CLUTTER_SCRIPT (user_data);
ClutterState *transitions;
clutter_script_get_objects (ui,
"transitions", &transitions,
NULL);
clutter_state_set_state (transitions, "faded-in");
}
int
main (int argc, char *argv[])
{
g_thread_init (NULL);
clutter_init (&argc, &argv);
/* path to the directory containing assets (e.g. images) for the script to load */
const gchar *paths[] = { TESTS_DATA_DIR };
ClutterScript *ui = clutter_script_new ();
clutter_script_add_search_paths (ui, paths, 1);
gchar *filename = "script-ui.json";
GError *error = NULL;
@ -58,9 +26,6 @@ main (int argc, char *argv[])
"stage", &stage,
NULL);
/* make the objects in the script available to all signals */
clutter_script_connect_signals (ui, ui);
clutter_actor_show (stage);
clutter_main ();