2008-04-01 Matthew Allum <mallum@openedhand.com>
[clutter-gtk] / examples / gtk-clutter-multistage.c
1 #include <gtk/gtk.h>
2 #include <clutter/clutter.h>
3 #include <clutter-gtk/gtk-clutter-embed.h>
4
5 int
6 main (int argc, char *argv[])
7 {
8   ClutterTimeline *timeline;
9   ClutterActor    *stage1, *stage2, *tex1, *tex2;
10   ClutterColor     stage_color = { 0x61, 0x64, 0x8c, 0xff };
11   GtkWidget       *window, *clutter1, *clutter2;
12   GtkWidget       *label, *button, *vbox;
13   GdkPixbuf       *pixbuf;
14   gint             i;
15   ClutterColor     col1 = { 0xff, 0xff, 0xff, 0xff };
16   ClutterColor     col2 = { 0, 0, 0, 0xff };
17
18   gtk_init (&argc, &argv);
19   gtk_clutter_init (&argc, &argv);
20
21   pixbuf = gdk_pixbuf_new_from_file ("redhand.png", NULL);
22
23   if (!pixbuf)
24     g_error("pixbuf load failed");
25
26   tex1 = clutter_texture_new_from_pixbuf (pixbuf);
27   tex2 = clutter_clone_texture_new (tex1);
28
29   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
30   g_signal_connect (window, "destroy",
31                     G_CALLBACK (gtk_main_quit), NULL);
32
33   vbox = gtk_vbox_new (FALSE, 6);
34   gtk_container_add (GTK_CONTAINER (window), vbox);
35
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   clutter_stage_add (stage1, tex1); 
41
42   gtk_container_add (GTK_CONTAINER (vbox), clutter1);
43
44   clutter2 = gtk_clutter_embed_new ();
45   gtk_widget_set_size_request (clutter2, 320, 240);
46   stage2 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter2));
47
48   clutter_stage_set_color (CLUTTER_STAGE(stage2), &col2);
49   clutter_stage_add (stage2, tex2);
50
51   gtk_container_add (GTK_CONTAINER (vbox), clutter2);
52
53   gtk_widget_show_all (window);
54   clutter_actor_show_all (stage1); 
55   clutter_actor_show_all (stage2); 
56
57   gtk_main();
58
59   return 0;
60 }