2008-04-21 Emmanuele Bassi <ebassi@openedhand.com>
[clutter-gtk] / examples / gtk-clutter-multistage.c
1 #include <gtk/gtk.h>
2 #include <clutter/clutter.h>
3
4 #include <clutter-gtk/gtk-clutter-embed.h>
5 #include <clutter-gtk/gtk-clutter-util.h>
6
7 int
8 main (int argc, char *argv[])
9 {
10   ClutterTimeline *timeline;
11   ClutterActor    *stage1, *stage2, *tex1, *tex2;
12   ClutterColor     stage_color = { 0x61, 0x64, 0x8c, 0xff };
13   GtkWidget       *window, *clutter1, *clutter2;
14   GtkWidget       *label, *button, *vbox;
15   GdkPixbuf       *pixbuf;
16   gint             i;
17   ClutterColor     col1 = { 0xff, 0xff, 0xff, 0xff };
18   ClutterColor     col2 = { 0, 0, 0, 0xff };
19
20   if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
21     g_error ("Unable to initialize GtkClutter");
22
23   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
24   g_signal_connect (window, "destroy",
25                     G_CALLBACK (gtk_main_quit), NULL);
26
27   vbox = gtk_vbox_new (FALSE, 6);
28   gtk_container_add (GTK_CONTAINER (window), vbox);
29
30   clutter1 = gtk_clutter_embed_new ();
31   gtk_widget_set_size_request (clutter1, 320, 240);
32   stage1 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter1));
33   clutter_stage_set_color (CLUTTER_STAGE(stage1), &col1);
34   tex1 = gtk_clutter_texture_new_from_stock (clutter1,
35                                              GTK_STOCK_DIALOG_INFO,
36                                              GTK_ICON_SIZE_DIALOG);
37   clutter_actor_set_anchor_point (tex1,
38                                   clutter_actor_get_width (tex1) / 2,
39                                   clutter_actor_get_height (tex1) / 2);
40   clutter_actor_set_position (tex1, 160, 120);
41   clutter_stage_add (stage1, tex1); 
42   clutter_actor_show (tex1);
43
44   gtk_container_add (GTK_CONTAINER (vbox), clutter1);
45
46   clutter2 = gtk_clutter_embed_new ();
47   gtk_widget_set_size_request (clutter2, 320, 240);
48   stage2 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter2));
49   clutter_stage_set_color (CLUTTER_STAGE(stage2), &col2);
50   tex2 = gtk_clutter_texture_new_from_icon_name (clutter1,
51                                                  "user-info",
52                                                  GTK_ICON_SIZE_BUTTON);
53   clutter_actor_set_anchor_point (tex2,
54                                   clutter_actor_get_width (tex2) / 2,
55                                   clutter_actor_get_height (tex2) / 2);
56   clutter_actor_set_position (tex2, 160, 120);
57   clutter_stage_add (stage2, tex2);
58
59   gtk_container_add (GTK_CONTAINER (vbox), clutter2);
60
61   gtk_widget_show_all (window);
62   clutter_actor_show_all (stage1); 
63   clutter_actor_show_all (stage2); 
64
65   gtk_main();
66
67   return 0;
68 }