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 *stage1, *stage2, *tex1, *tex2;
21 GtkWidget *window, *clutter1, *clutter2;
23 ClutterColor col1 = { 0xff, 0xff, 0xff, 0xff };
24 ClutterColor col2 = { 0, 0, 0, 0xff };
26 if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
27 g_error ("Unable to initialize GtkClutter");
29 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
30 g_signal_connect (window, "destroy",
31 G_CALLBACK (gtk_main_quit), NULL);
33 vbox = gtk_vbox_new (FALSE, 6);
34 gtk_container_add (GTK_CONTAINER (window), vbox);
36 clutter1 = gtk_clutter_embed_new ();
37 gtk_widget_set_size_request (clutter1, 320, 240);
38 stage1 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter1));
39 clutter_stage_set_color (CLUTTER_STAGE(stage1), &col1);
40 tex1 = gtk_clutter_texture_new_from_stock (clutter1,
41 GTK_STOCK_DIALOG_INFO,
42 GTK_ICON_SIZE_DIALOG);
43 clutter_actor_set_anchor_point (tex1,
44 clutter_actor_get_width (tex1) / 2,
45 clutter_actor_get_height (tex1) / 2);
46 clutter_actor_set_position (tex1, 160, 120);
47 clutter_stage_add (stage1, tex1);
48 clutter_actor_show (tex1);
50 gtk_container_add (GTK_CONTAINER (vbox), clutter1);
52 clutter2 = gtk_clutter_embed_new ();
53 gtk_widget_set_size_request (clutter2, 320, 120);
54 stage2 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter2));
55 clutter_stage_set_color (CLUTTER_STAGE(stage2), &col2);
56 tex2 = gtk_clutter_texture_new_from_icon_name (clutter1,
58 GTK_ICON_SIZE_BUTTON);
59 clutter_actor_set_anchor_point (tex2,
60 clutter_actor_get_width (tex2) / 2,
61 clutter_actor_get_height (tex2) / 2);
62 clutter_actor_set_position (tex2, 160, 60);
63 clutter_stage_add (stage2, tex2);
65 gtk_container_add (GTK_CONTAINER (vbox), clutter2);
67 g_signal_connect (stage2, "allocation-changed",
68 G_CALLBACK (on_stage2_allocation_changed),
71 gtk_widget_show_all (window);
72 clutter_actor_show_all (stage1);
73 clutter_actor_show_all (stage2);