2008-01-23 Emmanuele Bassi <ebassi@openedhand.com>
[clutter-gtk] / examples / gtk-clutter-test.c
index 1d14684..f80acf1 100644 (file)
@@ -2,7 +2,7 @@
 #include <clutter/clutter.h>
 #include <math.h>
 
-#include <clutter-gtk/gtk-clutter.h>
+#include <clutter-gtk/gtk-clutter-embed.h>
 
 #define TRAILS 0
 #define NHANDS  2
@@ -28,18 +28,14 @@ input_cb (ClutterStage *stage,
 {
   if (event->type == CLUTTER_BUTTON_PRESS)
     {
-      ClutterButtonEvent *bev = (ClutterButtonEvent *) event;
-      ClutterActor *e;
+      ClutterActor *actor;
+      gint x, y;
 
-      g_print ("*** button press event (button:%d) ***\n",
-              bev->button);
+      clutter_event_get_coords (event, &x, &y);
 
-      e = clutter_stage_get_actor_at_pos (stage, 
-                                           clutter_button_event_x (bev),
-                                           clutter_button_event_y (bev));
-
-      if (e)
-       clutter_actor_hide(e);
+      actor = clutter_stage_get_actor_at_pos (stage, x, y);
+      if (actor)
+       clutter_actor_hide (actor);
     }
   else if (event->type == CLUTTER_KEY_PRESS)
     {
@@ -74,23 +70,24 @@ frame_cb (ClutterTimeline *timeline,
 #endif
 
   /* Rotate everything clockwise about stage center*/
-  clutter_actor_rotate_z (CLUTTER_ACTOR(oh->group),
-                           frame_num,
-                           WINWIDTH/2,
-                           WINHEIGHT/2);
+  clutter_actor_set_rotation (CLUTTER_ACTOR (oh->group),
+                              CLUTTER_Z_AXIS,
+                              frame_num,
+                              WINWIDTH / 2, WINHEIGHT / 2, 0);
+
   for (i = 0; i < NHANDS; i++)
     {
       /* rotate each hand around there centers */
-      clutter_actor_rotate_z (oh->hand[i],
-                               - 6.0 * frame_num,
-                               clutter_actor_get_width (oh->hand[i])/2,
-                               clutter_actor_get_height (oh->hand[i])/2);
-      if (fade == TRUE) {
-              clutter_actor_set_opacity (oh->hand[i], (255 - (frame_num % 255)));
-      }
+      clutter_actor_set_rotation (oh->hand[i],
+                                  CLUTTER_Z_AXIS,
+                                  - 6.0 * frame_num,
+                                  clutter_actor_get_width (oh->hand[i]) / 2,
+                                  clutter_actor_get_height (oh->hand[i]) / 2,
+                                  0);
+      if (fade == TRUE)
+        clutter_actor_set_opacity (oh->hand[i], (255 - (frame_num % 255)));
     }
 
-          
   /*
   clutter_actor_rotate_x (CLUTTER_ACTOR(oh->group),
                            75.0,
@@ -109,9 +106,9 @@ int
 main (int argc, char *argv[])
 {
   ClutterTimeline *timeline;
-  ClutterActor  *stage;
+  ClutterActor    *stage;
   ClutterColor     stage_color = { 0x61, 0x64, 0x8c, 0xff };
-  GtkWidget       *window, *clutter;
+  GtkWidget       *window, *clutter, *socket_box;
   GtkWidget       *label, *button, *vbox;
   GdkPixbuf       *pixbuf;
   SuperOH         *oh;
@@ -120,7 +117,6 @@ main (int argc, char *argv[])
   clutter_init (&argc, &argv);
   gtk_init (&argc, &argv);
 
-
   pixbuf = gdk_pixbuf_new_from_file ("redhand.png", NULL);
 
   if (!pixbuf)
@@ -133,13 +129,11 @@ main (int argc, char *argv[])
   vbox = gtk_vbox_new (FALSE, 6);
   gtk_container_add (GTK_CONTAINER (window), vbox);
 
-  clutter = gtk_clutter_new ();
-  stage = gtk_clutter_get_stage (GTK_CLUTTER (clutter));
-  
+  clutter = gtk_clutter_embed_new ();
+
   gtk_container_add (GTK_CONTAINER (vbox), clutter);
 
-  /* Set our stage size */
-/*   clutter_actor_set_size (stage, WINWIDTH, WINHEIGHT); */
+  stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter));
 
   label = gtk_label_new ("This is a label");
   gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
@@ -148,6 +142,12 @@ main (int argc, char *argv[])
   g_signal_connect (button, "clicked",
                     G_CALLBACK (clickity), NULL);
   gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+
+  button = gtk_button_new_from_stock (GTK_STOCK_QUIT);
+  g_signal_connect_swapped (button, "clicked",
+                            G_CALLBACK (gtk_widget_destroy),
+                            window);
+  gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
   
   /* and its background color */
 
@@ -198,7 +198,7 @@ main (int argc, char *argv[])
   clutter_group_add (CLUTTER_GROUP (stage), CLUTTER_ACTOR(oh->group));
 
   /* Show everying ( and map window ) */
-  clutter_group_show_all (oh->group);
+  clutter_actor_show_all (CLUTTER_ACTOR (oh->group));
 
   g_signal_connect (stage, "button-press-event",
                    G_CALLBACK (input_cb),