Advertisement
Guest User

clutter backend test

a guest
Sep 29th, 2011
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.45 KB | None | 0 0
  1. #include <clutter/clutter.h>
  2. #include <stdlib.h>
  3.  
  4. int
  5. main (int argc, char *argv[])
  6. {
  7.   if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
  8.     g_error ("*** Unable to initialize Clutter");
  9.  
  10.   const gchar *backend_str;
  11.  
  12. #if CLUTTER_WINDOWING_GDK
  13.   if (clutter_check_backend (CLUTTER_GDK_BACKEND))
  14.     backend_str = "Clutter is using the GDK backend";
  15.   else
  16. #endif
  17. #if CLUTTER_WINDOWING_X11
  18.   if (clutter_check_backend (CLUTTER_X11_BACKEND))
  19.     backend_str = "Clutter is using the X11 backend";
  20.   else
  21. #endif
  22. #if CLUTTER_WINDOWING_WAYLAND
  23.   if (clutter_check_backend (CLUTTER_WAYLAND_BACKEND))
  24.     backend_str = "Clutter is using the Wayland backend";
  25.   else
  26. #endif
  27. #if CLUTTER_WINDOWING_OSX
  28.   if (clutter_check_backend (CLUTTER_OSX_BACKEND))
  29.     backend_str = "Clutter is using the OS X backend";
  30.   else
  31. #endif
  32. #if CLUTTER_WINDOWING_WIN32
  33.   if (clutter_check_backend (CLUTTER_WIN32_BACKEND))
  34.     backend_str = "Clutter is using the Windows backend";
  35.   else
  36. #endif
  37.     g_error ("*** Unrecognized backend");
  38.  
  39.   gchar *label = g_strconcat ("<big><b>", backend_str, "</b></big>", NULL);
  40.  
  41.   ClutterActor *stage = clutter_stage_new ();
  42.   clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);
  43.   clutter_stage_set_title (CLUTTER_STAGE (stage), "Test Backends");
  44.   clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_LightSkyBlue);
  45.   g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
  46.   clutter_actor_show (stage);
  47.  
  48.   ClutterActor *text = clutter_text_new ();
  49.   clutter_text_set_markup (CLUTTER_TEXT (text), label);
  50.   clutter_actor_add_constraint (text, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.5));
  51.   clutter_actor_add_constraint (text, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.5));
  52.   clutter_container_add_actor (CLUTTER_CONTAINER (stage), text);
  53.  
  54.   ClutterVertex center = {
  55.     .x = clutter_actor_get_width (text) / 2.0,
  56.     .y = clutter_actor_get_height (text) / 2.0,
  57.     .z = 0.f
  58.   };
  59.  
  60.   ClutterAnimation *animation = clutter_actor_animate (text, CLUTTER_LINEAR, 6000,
  61.                                                        "fixed::rotation-center-y", &center,
  62.                                                        "rotation-angle-y", 360.0,
  63.                                                        NULL);
  64.   clutter_timeline_set_loop (clutter_animation_get_timeline (animation), TRUE);
  65.  
  66.   clutter_main ();
  67.  
  68.   g_free (label);
  69.  
  70.   return EXIT_SUCCESS;
  71. }
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement