mirror of
https://github.com/brl/mutter.git
synced 2025-06-14 01:09:30 +00:00
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:
@ -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 ();
|
||||
|
Reference in New Issue
Block a user