2 #include <clutter/clutter.h>
4 #include <clutter-gtk/clutter-gtk.h>
7 on_stage2_allocation_changed (ClutterActor *stage_2,
8 const ClutterActorBox *allocation,
9 ClutterAllocationFlags flags,
10 ClutterActor *texture_2)
12 clutter_actor_set_position (texture_2,
13 (allocation->x2 - allocation->x1) / 2,
14 (allocation->y2 - allocation->y1) / 2);
18 main (int argc, char *argv[])
20 ClutterActor *stage0, *stage1, *stage2, *tex1, *tex2;
21 GtkWidget *window, *clutter0, *clutter1, *clutter2;
22 GtkWidget *notebook, *vbox;
23 ClutterColor col0 = { 0xdd, 0xff, 0xdd, 0xff };
24 ClutterColor col1 = { 0xff, 0xff, 0xff, 0xff };
25 ClutterColor col2 = { 0, 0, 0, 0xff };
27 if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
28 g_error ("Unable to initialize GtkClutter");
30 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
31 g_signal_connect (window, "destroy",
32 G_CALLBACK (gtk_main_quit), NULL);
34 notebook = gtk_notebook_new ();
35 gtk_container_add (GTK_CONTAINER (window), notebook);
37 clutter0 = gtk_clutter_embed_new ();
38 gtk_widget_set_size_request (clutter0, 320, 320);
39 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), clutter0,
40 gtk_label_new ("One stage"));
41 stage0 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter0));
42 clutter_stage_set_color (CLUTTER_STAGE (stage0), &col0);
44 vbox = gtk_vbox_new (FALSE, 6);
45 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox,
46 gtk_label_new ("Two stages"));
48 clutter1 = gtk_clutter_embed_new ();
49 gtk_widget_set_size_request (clutter1, 320, 240);
50 stage1 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter1));
51 clutter_stage_set_color (CLUTTER_STAGE(stage1), &col1);
52 tex1 = gtk_clutter_texture_new_from_stock (clutter1,
53 GTK_STOCK_DIALOG_INFO,
54 GTK_ICON_SIZE_DIALOG);
55 clutter_actor_set_anchor_point (tex1,
56 clutter_actor_get_width (tex1) / 2,
57 clutter_actor_get_height (tex1) / 2);
58 clutter_actor_set_position (tex1, 160, 120);
59 clutter_stage_add (stage1, tex1);
60 clutter_actor_show (tex1);
62 gtk_container_add (GTK_CONTAINER (vbox), clutter1);
64 clutter2 = gtk_clutter_embed_new ();
65 gtk_widget_set_size_request (clutter2, 320, 120);
66 stage2 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter2));
67 clutter_stage_set_color (CLUTTER_STAGE(stage2), &col2);
68 tex2 = gtk_clutter_texture_new_from_icon_name (clutter1,
70 GTK_ICON_SIZE_BUTTON);
71 clutter_actor_set_anchor_point (tex2,
72 clutter_actor_get_width (tex2) / 2,
73 clutter_actor_get_height (tex2) / 2);
74 clutter_actor_set_position (tex2, 160, 60);
75 clutter_stage_add (stage2, tex2);
77 gtk_container_add (GTK_CONTAINER (vbox), clutter2);
79 g_signal_connect (stage2, "allocation-changed",
80 G_CALLBACK (on_stage2_allocation_changed),
83 gtk_widget_show_all (window);