コード例 #1
0
ファイル: test-clip.c プロジェクト: ChrisCummins/clutter
G_MODULE_EXPORT int
test_clip_main (int argc, char **argv)
{
  CallbackData data;
  ClutterActor *stub_actor, *label;
  gchar *file;

  if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
    return 1;

  data.current_clip.type = CLIP_NONE;
  data.clips = NULL;

  data.stage = clutter_stage_new ();
  clutter_stage_set_title (CLUTTER_STAGE (data.stage), "Clipping");
  g_signal_connect (data.stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  stub_actor = clutter_rectangle_new ();
  clutter_container_add (CLUTTER_CONTAINER (data.stage), stub_actor, NULL);

  file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
  data.hand = cogl_texture_new_from_file (file,
                                          COGL_TEXTURE_NONE,
                                          COGL_PIXEL_FORMAT_ANY,
                                          NULL);
  g_free (file);

  label = clutter_text_new_with_text ("Sans 12px", instructions);
  clutter_text_set_line_wrap (CLUTTER_TEXT (label), TRUE);
  clutter_actor_set_width (label, clutter_actor_get_width (data.stage) - 310);
  clutter_actor_set_y (label,
                       clutter_actor_get_height (data.stage)
                       - clutter_actor_get_height (label));
  clutter_container_add (CLUTTER_CONTAINER (data.stage), label, NULL);

  g_signal_connect (stub_actor, "paint", G_CALLBACK (on_paint), &data);

  g_signal_connect (data.stage, "button-press-event",
                    G_CALLBACK (on_button_press), &data);
  g_signal_connect (data.stage, "button-release-event",
                    G_CALLBACK (on_button_release), &data);
  g_signal_connect (data.stage, "motion-event",
                    G_CALLBACK (on_motion), &data);
  g_signal_connect (data.stage, "key-press-event",
                    G_CALLBACK (on_key_press), &data);

  clutter_actor_show (data.stage);

  clutter_main ();

  cogl_handle_unref (data.hand);

  free_clips (&data);

  return 0;
}
コード例 #2
0
int
main (int argc, char *argv[])
{
	ClutterActor *stage;

  	g_type_init ();
	g_thread_init (NULL);
	if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
	  return 1;
	clutter_threads_init ();
	GMainLoop *loop;
	loop = g_main_loop_new (NULL, FALSE);

	stage = clutter_stage_new ();
	clutter_stage_set_title (CLUTTER_STAGE (stage), "message test");
	clutter_actor_set_size (stage, 400, 600);
	clutter_actor_show_all (stage);
#if 1
	ClutterActor *message;
	GnomeAppStore *store;

	store = gnome_app_store_get_default ();
	gnome_app_store_set_lock_function (store, clutter_threads_enter);
	gnome_app_store_set_unlock_function (store, clutter_threads_leave);

	message = CLUTTER_ACTOR (gnome_app_message_new ());
	clutter_container_add (CLUTTER_CONTAINER (stage), message, NULL);
#else
	ClutterActor *page, *actor;
	ClutterScript *script;
	GError *error;

	script = clutter_script_new ();
	error = NULL;
	clutter_script_load_from_file (script, "/home/dliang/gnome-app-store/ui/message-info-page.json", &error);
//	clutter_script_load_from_file (script, "/home/dliang/gnome-app-store/ui/test.json", &error);
	if (error)
		printf ("error in load %s\n", error->message);
        clutter_script_get_objects (script, "message-info-page", &page, "sender_label", &actor, NULL);
	ClutterLayoutManager *layout;
	layout = clutter_box_get_layout_manager (page);
	gint col, row;
	clutter_layout_manager_child_get (layout, page, actor, "column", &col, "row", &row, NULL);
	printf ("col %d %d\n", col, row);
	clutter_layout_manager_child_set (layout, page, actor, "column", 2, "row", 1, NULL);
	clutter_container_add (CLUTTER_CONTAINER (stage), page, NULL);
#endif
	g_main_loop_run (loop);
  	g_main_loop_unref (loop);

	return EXIT_SUCCESS;
}
コード例 #3
0
static void
stop_fullscreen (RBVisualizerPage *page)
{
    if (page->fullscreen != NULL) {
        ClutterActor *stage;

        rb_debug ("stopping fullscreen display");

        g_object_ref (page->texture);
        stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (page->fullscreen_embed));
        rb_visualizer_fullscreen_stop (stage);
        clutter_container_remove_actor (CLUTTER_CONTAINER (stage), page->texture);

        stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (page->embed));
        clutter_container_add (CLUTTER_CONTAINER (stage), page->texture, NULL);

        g_object_unref (page->texture);

        gtk_widget_destroy (GTK_WIDGET (page->fullscreen));
        page->fullscreen = NULL;

        page->fullscreen_embed = NULL;
    }

    set_action_state (page, FALSE);
}
コード例 #4
0
static void
mex_queue_button_init (MexQueueButton *self)
{
  ClutterActor *temp_text;

  self->priv = QUEUE_BUTTON_PRIVATE (self);

  self->priv->inner_box = mx_box_layout_new ();
  self->priv->icon = mx_icon_new ();
  self->priv->label = mx_label_new_with_text ("Unknown queue state");
  self->priv->spinner = mx_spinner_new ();
  self->priv->queue_model = mex_queue_model_dup_singleton ();

  g_signal_connect (self->priv->spinner,
                    "looped",
                    (GCallback)_spinner_looped_cb,
                    self);

  clutter_container_add (CLUTTER_CONTAINER (self->priv->inner_box),
                         self->priv->label,
                         self->priv->icon,
                         self->priv->spinner,
                         NULL);

  clutter_container_child_set (CLUTTER_CONTAINER (self->priv->inner_box),
                               self->priv->label,
                               "expand", TRUE,
                               "y-align", MX_ALIGN_MIDDLE,
                               "y-fill", FALSE,
                               NULL);

  clutter_container_child_set (CLUTTER_CONTAINER (self->priv->inner_box),
                               self->priv->icon,
                               "y-align", MX_ALIGN_MIDDLE,
                               "y-fill", FALSE,
                               "x-align", MX_ALIGN_END,
                               NULL);

  clutter_container_child_set (CLUTTER_CONTAINER (self->priv->inner_box),
                               self->priv->spinner,
                               "y-align", MX_ALIGN_MIDDLE,
                               "y-fill", FALSE,
                               "x-align", MX_ALIGN_END,
                               NULL);

  clutter_actor_hide (self->priv->spinner);

  mx_bin_set_child (MX_BIN (self), self->priv->inner_box);
  mx_bin_set_fill (MX_BIN (self), TRUE, FALSE);

  temp_text = mx_label_get_clutter_text (MX_LABEL (self->priv->label));
  clutter_text_set_ellipsize (CLUTTER_TEXT (temp_text), PANGO_ELLIPSIZE_NONE);

  g_signal_connect (self,
                    "notify::toggled",
                    (GCallback)_queue_button_notify_toggled_cb,
                    self);

  mx_button_set_is_toggle (MX_BUTTON (self), TRUE);
}
コード例 #5
0
ファイル: desktop.c プロジェクト: tommed/tuxwm-sandbox
//
// redraw stack
//
void redraw_stack()
{
	if (stage == NULL) {
		fprintf(stderr, "stage cannot be drawn upon\n");
		return;
	}
	
	// clear stage
	ClutterColor stage_bg_color;
	clutter_color_parse("#fff", &stage_bg_color);
  clutter_stage_set_color(CLUTTER_STAGE(stage), &stage_bg_color);
  
  int width=256, /*height=256, */padding=5;
  
  // loop through all windows and draw an item on the grid
  WindowStack *sitem = stack;
  int i=0;
  while (sitem != NULL) {
  	printf( "drawing stack item %d\n", (i+1) );
  	int x = (i*width) + ( (i+1)*padding );
  	int y = padding;
  	ClutterActor *actor = clutter_texture_new_from_file("/home/Downloads/window.png", NULL);
  	clutter_container_add(CLUTTER_CONTAINER(stage), actor, NULL);
	  clutter_actor_set_position(actor, x, y);
	  sitem = sitem->next;
	  i++;
  }
  
  clutter_actor_show(CLUTTER_ACTOR(stage));  
  clutter_color_free(&stage_bg_color);
}
コード例 #6
0
static void
mex_telepathy_channel_create_incoming_video (MexTelepathyChannel *self)
{
  MexTelepathyChannelPrivate *priv = MEX_TELEPATHY_CHANNEL (self)->priv;

  ClutterActor *video_incoming_area;

  /* Setup the incoming surface to draw to */
  priv->incoming_texture = clutter_texture_new ();
  clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (priv->incoming_texture),
                                         TRUE);

  video_incoming_area = mx_stack_new ();

  clutter_container_add (CLUTTER_CONTAINER (video_incoming_area),
                         mex_telepathy_channel_create_static_image(),
                         priv->incoming_texture,
                         NULL);

  /* Create a frame for it with a styled border */
  priv->full_frame = mx_frame_new();
  clutter_actor_set_name (priv->full_frame, "Incoming Frame");
  mx_bin_set_fill (MX_BIN (priv->full_frame), TRUE, TRUE);
  mx_stylable_set_style_class (MX_STYLABLE (priv->full_frame),
                               "CallWindow");
  clutter_actor_add_effect (priv->full_frame,
                            CLUTTER_EFFECT (
                              mex_telepathy_channel_create_shadow ()));
  clutter_container_add_actor (CLUTTER_CONTAINER (priv->full_frame),
                               video_incoming_area);

  priv->incoming_sink =
    clutter_gst_video_sink_new (CLUTTER_TEXTURE (priv->incoming_texture));
}
コード例 #7
0
static void
mex_telepathy_channel_create_preview (MexTelepathyChannel *self)
{
  MexTelepathyChannelPrivate *priv = MEX_TELEPATHY_CHANNEL (self)->priv;

  ClutterActor *video_preview_area;

  priv->video_outgoing = clutter_texture_new ();
  clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (priv->video_outgoing),
                                         TRUE);

  priv->outgoing_sink =
    clutter_gst_video_sink_new (CLUTTER_TEXTURE (priv->video_outgoing));

  video_preview_area = mx_stack_new ();

  clutter_container_add (CLUTTER_CONTAINER (video_preview_area),
                         mex_telepathy_channel_create_static_image(),
                         priv->video_outgoing,
                         NULL);

  mx_stylable_set_style_class (MX_STYLABLE (video_preview_area),
                               "PreviewStack");

  clutter_actor_set_height (video_preview_area, 150.0);
  clutter_actor_add_effect (video_preview_area,
                            CLUTTER_EFFECT (
                              mex_telepathy_channel_create_shadow ()));

  priv->preview_area = mx_frame_new ();
  mx_stylable_set_style_class (MX_STYLABLE (priv->preview_area),
                               "PreviewPadding");
  mx_bin_set_child (MX_BIN (priv->preview_area), video_preview_area);
}
コード例 #8
0
G_MODULE_EXPORT gint
test_texture_quality_main (int argc, char *argv[])
{
  ClutterTimeline  *timeline;
  ClutterAlpha     *alpha;
  ClutterBehaviour *depth_behavior;
  ClutterActor     *stage;
  ClutterActor     *image;
  ClutterColor      stage_color = { 0x12, 0x34, 0x56, 0xff };
  ClutterFog        stage_fog = { 10.0, -50.0 };
  GError           *error;

  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
  clutter_stage_set_use_fog (CLUTTER_STAGE (stage), TRUE);
  clutter_stage_set_fog (CLUTTER_STAGE (stage), &stage_fog);

  g_signal_connect (stage,
                    "button-press-event", G_CALLBACK (clutter_main_quit),
                    NULL);

  error = NULL;
  image = clutter_texture_new_from_file (argv[1]?argv[1]:"redhand.png", &error);
  if (error)
    g_error ("Unable to load image: %s", error->message);

  if (!argv[1])
    g_print ("Hint: the redhand.png isn't a good test image for this test.\n"
             "This test can take any clutter loadable image as an argument\n");

  /* center the image */
  clutter_actor_set_position (image, 
    (clutter_actor_get_width (stage) - clutter_actor_get_width (image))/2,
    (clutter_actor_get_height (stage) - clutter_actor_get_height (image))/2);
  clutter_container_add (CLUTTER_CONTAINER (stage), image, NULL);

  timeline = clutter_timeline_new (5000);
  g_signal_connect (timeline,
                    "completed", G_CALLBACK (timeline_completed),
                    NULL);

  alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR);
  depth_behavior = clutter_behaviour_depth_new (alpha, -2500, 400);
  clutter_behaviour_apply (depth_behavior, image);

  clutter_actor_show (stage);
  clutter_timeline_start (timeline);

  g_timeout_add (10000, change_filter, image);

  clutter_main ();

  g_object_unref (depth_behavior);
  g_object_unref (timeline);

  return EXIT_SUCCESS;
}
コード例 #9
0
ファイル: textures-sub-texture.c プロジェクト: rib/clutter
int
main (int argc, char **argv)
{
  ClutterActor *stage, *image, *sub_image;
  CoglHandle texture, sub_texture;
  gfloat image_width, image_height;

  /* Initialize Clutter */
  if (clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
    return 1;

  /* Get the default stage */
  stage = clutter_stage_get_default ();
  clutter_stage_set_title (CLUTTER_STAGE (stage), "Sub-texture");

  /* Create a new ClutterTexture that shows smiley.png */
  image = clutter_texture_new_from_file ("smiley.png", NULL);
  clutter_actor_get_size (image, &image_width, &image_height);
  clutter_actor_set_size (stage,
                          image_width * 3 / 2 + 30,
                          image_height + 20);

  /* Grab the CoglHandle of the underlying Cogl texture */
  texture = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (image));

  /* Create a new Cogl texture from the handle above. That new texture is a
   * rectangular region from image, more precisely the north ouest corner
   * of the image */
  sub_texture = cogl_texture_new_from_sub_texture (texture,
                                                   0, 0,
                                                   image_width / 2,
                                                   image_height / 2);

  /* Finally, use the newly created Cogl texture to feed a new ClutterTexture
   * and thus create a new actor that displays sub_texture */
   sub_image = clutter_texture_new ();
   clutter_texture_set_cogl_texture (CLUTTER_TEXTURE (sub_image), sub_texture);

  /*
   * You could have used the more straightforward g_object_new() function that
   * can create an object and set some properties on it at the same time:
   * sub_image = g_object_new (CLUTTER_TYPE_TEXTURE,
   *                           "cogl-texture", sub_texture,
   *                           NULL);
   */

  /* Put the original image at (10,10) and the new sub image next to it */
  clutter_actor_set_position (image, 10, 10);
  clutter_actor_set_position (sub_image, 20 + image_width, 10);

  /* Add both ClutterTexture to the stage */
  clutter_container_add (CLUTTER_CONTAINER (stage), image, sub_image, NULL);

  clutter_actor_show_all (stage);

  clutter_main ();

  return 0;
}
コード例 #10
0
ファイル: mex-tile.c プロジェクト: frankopt/media-explorer
static void
mex_tile_init (MexTile *self)
{
  MexTilePrivate *priv = self->priv = TILE_PRIVATE (self);
  const ClutterColor opaque = { 0x00, 0x00, 0x00, 0x00 };
  ClutterEffect *fade;

  /* create a template material for the header background from which cheap
   * copies can be made for each instance */
  if (G_UNLIKELY (!template_material))
    template_material = cogl_material_new ();

  priv->material = cogl_material_copy (template_material);


  /* layout for primary and secondary labels */
  priv->box_layout = mx_box_layout_new ();
  mx_box_layout_set_spacing (MX_BOX_LAYOUT (priv->box_layout), 12);

  /* add fade effect to the box layout */
  fade = (ClutterEffect*) mx_fade_effect_new ();
  mx_fade_effect_set_border (MX_FADE_EFFECT (fade), 0, 50, 0, 0);
  mx_fade_effect_set_color (MX_FADE_EFFECT (fade), &opaque);
  clutter_actor_add_effect_with_name (priv->box_layout, "fade", fade);
  clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (fade), TRUE);

  clutter_actor_push_internal (CLUTTER_ACTOR (self));
  clutter_actor_set_parent (priv->box_layout, CLUTTER_ACTOR (self));
  clutter_actor_pop_internal (CLUTTER_ACTOR (self));


  priv->label = clutter_text_new ();
  priv->secondary_label = clutter_text_new ();
  clutter_actor_set_opacity (priv->secondary_label, 128);

  clutter_container_add (CLUTTER_CONTAINER (priv->box_layout), priv->label,
                         priv->secondary_label, NULL);

  priv->header_visible = TRUE;

  priv->timeline = clutter_timeline_new (DURATION);
  priv->important_alpha =
    clutter_alpha_new_full (priv->timeline, CLUTTER_EASE_OUT_QUAD);
  g_signal_connect_object (priv->timeline, "new-frame",
                           G_CALLBACK (mex_tile_important_new_frame_cb), self,
                           0);
  g_signal_connect_object (priv->timeline, "completed",
                           G_CALLBACK (mex_tile_timeline_completed_cb), self,
                           0);

  g_signal_connect (self, "style-changed",
                    G_CALLBACK (mex_tile_style_changed_cb), NULL);

  g_signal_connect (self, "actor-added",
                    G_CALLBACK (mex_tile_actor_added), NULL);
  g_signal_connect (self, "actor-removed",
                    G_CALLBACK (mex_tile_actor_removed), NULL);
}
コード例 #11
0
static void
mex_telepathy_channel_create_busy_box (MexTelepathyChannel *self)
{
  MexTelepathyChannelPrivate *priv = MEX_TELEPATHY_CHANNEL (self)->priv;

  ClutterActor *calling_padding;
  ClutterActor *calling_box;
  ClutterActor *spinner;
  ClutterActor *stack;

  priv->busy_label = mx_label_new();
  mx_label_set_y_align (MX_LABEL (priv->busy_label), MX_ALIGN_MIDDLE);
  mx_label_set_x_align (MX_LABEL (priv->busy_label), MX_ALIGN_MIDDLE);

  spinner = mx_spinner_new ();

  calling_box = mx_box_layout_new ();

  mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (calling_box),
                                           priv->busy_label,
                                           0,
                                           "expand",
                                           TRUE,
                                           "x-align",
                                           MX_ALIGN_START,
                                           "x-fill",
                                           TRUE,
                                           NULL);

  mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (calling_box),
                                           spinner,
                                           1,
                                           "expand",
                                           TRUE,
                                           "x-align",
                                           MX_ALIGN_END,
                                           "x-fill",
                                           FALSE,
                                           NULL);

  priv->busy_box = mx_frame_new ();
  clutter_actor_set_width (CLUTTER_ACTOR (priv->busy_box), 475);
  mx_stylable_set_style_class (MX_STYLABLE (priv->busy_box),
                               "CallingFrameBorder");
  calling_padding = mx_frame_new ();
  mx_stylable_set_style_class (MX_STYLABLE (calling_padding),
                               "CallingFrame");
  mx_bin_set_child (MX_BIN (priv->busy_box), calling_padding);
  mx_bin_set_fill (MX_BIN (priv->busy_box), TRUE, TRUE);
  mx_bin_set_child (MX_BIN (calling_padding), calling_box);
  mx_bin_set_fill (MX_BIN (calling_padding), TRUE, TRUE);

  stack = mx_window_get_child (mex_get_main_window ());
  clutter_container_add (CLUTTER_CONTAINER (stack), priv->busy_box, NULL);
  mx_stack_child_set_x_fill (MX_STACK (stack), priv->busy_box, FALSE);
  mx_stack_child_set_y_fill (MX_STACK (stack), priv->busy_box, FALSE);
}
コード例 #12
0
ファイル: events-buttons.c プロジェクト: ChrisCummins/clutter
int
main (int   argc,
      char *argv[])
{
  ClutterActor *stage;
  ClutterActor *red;
  ClutterActor *green;

  if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
    return 1;

  stage = clutter_stage_new ();
  clutter_actor_set_size (stage, 400, 400);
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  red = clutter_rectangle_new_with_color (&red_color);
  clutter_actor_set_size (red, 100, 100);
  clutter_actor_set_position (red, 50, 150);
  clutter_actor_set_reactive (red, TRUE);

  green = clutter_rectangle_new_with_color (&green_color);
  clutter_actor_set_size (green, 100, 100);
  clutter_actor_set_position (green, 250, 150);
  clutter_actor_set_reactive (green, TRUE);

  g_signal_connect (red,
                    "button-press-event",
                    G_CALLBACK (button_event_cb),
                    NULL);

  g_signal_connect (red,
                    "button-release-event",
                    G_CALLBACK (button_event_cb),
                    NULL);

  g_signal_connect (green,
                    "button-press-event",
                    G_CALLBACK (button_event_cb),
                    NULL);

  g_signal_connect (green,
                    "button-release-event",
                    G_CALLBACK (button_event_cb),
                    NULL);

  clutter_container_add (CLUTTER_CONTAINER (stage),
                         red,
                         green,
                         NULL);

  clutter_actor_show (stage);

  clutter_main ();

  return EXIT_SUCCESS;
}
コード例 #13
0
static void
mex_content_box_init (MexContentBox *self)
{
  MexContentBoxPrivate *priv = self->priv = CONTENT_BOX_PRIVATE (self);
  ClutterActor *hline, *box;

  priv->thumb_width = 426;
  priv->thumb_height = 240;

  /* Create description panel */
  box = mx_box_layout_new ();
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_VERTICAL);

  hline = clutter_rectangle_new_with_color (&hline_color);
  clutter_actor_set_height (hline, 1);

  priv->panel = mex_info_panel_new (MEX_INFO_PANEL_MODE_SIMPLE);

  clutter_container_add (CLUTTER_CONTAINER (box), hline, priv->panel, NULL);


  /* monitor key press events */
  g_signal_connect (self, "key-press-event",
                    G_CALLBACK (mex_content_box_key_press_event_cb), self);

  /* Create tile */
  priv->tile = mex_content_tile_new ();
  g_object_set (G_OBJECT (priv->tile),
                "thumb-width", priv->thumb_width,
                "thumb-height", priv->thumb_height,
                NULL);
  mx_bin_set_fill (MX_BIN (priv->tile), TRUE, TRUE);

  clutter_actor_set_reactive (priv->tile, TRUE);
  g_signal_connect (priv->tile, "button-release-event",
                    G_CALLBACK (mex_content_box_tile_clicked_cb), self);

  /* Create secondary box for tile/menu */
  priv->box = mex_expander_box_new ();
  mex_expander_box_set_important (MEX_EXPANDER_BOX (priv->box), TRUE);
  mex_expander_box_set_grow_direction (MEX_EXPANDER_BOX (priv->box),
                                      MEX_EXPANDER_BOX_RIGHT);
  mex_expander_box_set_primary_child (MEX_EXPANDER_BOX (priv->box), priv->tile);

  /* Pack box and panel into self */
  mex_expander_box_set_primary_child (MEX_EXPANDER_BOX (self), priv->box);
  mex_expander_box_set_secondary_child (MEX_EXPANDER_BOX (self), box);

  /* Create the action list */
  priv->action_list = mex_action_list_new ();
  mex_expander_box_set_secondary_child (MEX_EXPANDER_BOX (priv->box),
                                        priv->action_list);

  /* Connect to the open notify signal */
  g_signal_connect (self, "notify::open",
                    G_CALLBACK (mex_content_box_notify_open_cb), NULL);
}
コード例 #14
0
ファイル: test-text.c プロジェクト: nobled/clutter
G_MODULE_EXPORT gint
test_text_main (gint    argc,
                gchar **argv)
{
  ClutterActor *stage;
  ClutterActor *text;
  ClutterColor  text_color       = { 0x33, 0xff, 0x33, 0xff };
  ClutterColor  cursor_color     = { 0xff, 0x33, 0x33, 0xff };
  ClutterColor  background_color = { 0x00, 0x00, 0x00, 0xff };

  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();
  clutter_stage_set_color (CLUTTER_STAGE (stage), &background_color);

  text = clutter_text_new_full (FONT, "·", &text_color);

  clutter_container_add (CLUTTER_CONTAINER (stage), text, NULL);
  clutter_actor_set_position (text, 40, 30);
  clutter_actor_set_width (text, 1024);
  clutter_text_set_line_wrap (CLUTTER_TEXT (text), TRUE);

  clutter_actor_set_reactive (text, TRUE);
  clutter_stage_set_key_focus (CLUTTER_STAGE (stage), text);

  clutter_text_set_editable (CLUTTER_TEXT (text), TRUE);
  clutter_text_set_selectable (CLUTTER_TEXT (text), TRUE);
  clutter_text_set_cursor_color (CLUTTER_TEXT (text), &cursor_color);

  if (argv[1])
    {
      GError *error = NULL;
      gchar *utf8;

      g_file_get_contents (argv[1], &utf8, NULL, &error);
      if (error)
        {
          utf8 = g_strconcat ("Unable to open '", argv[1], "':\n",
                              error->message,
                              NULL);
          g_error_free (error);
        }

      clutter_text_set_text (CLUTTER_TEXT (text), utf8);
    }
  else
    clutter_text_set_text (CLUTTER_TEXT (text), runes);

  clutter_actor_set_size (stage, 1024, 768);
  clutter_actor_show (stage);

  clutter_main ();

  return EXIT_SUCCESS;
}
コード例 #15
0
int
main (int argc, char *argv[])
{
  ClutterActor *stage;
  ClutterActor *r1, *r2, *r3;

  if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
    return 1;

  stage = clutter_stage_new ();
  clutter_actor_set_size (stage, 300, 300);
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  r1 = clutter_rectangle_new_with_color (&red);
  clutter_actor_set_size (r1, 150, 150);
  clutter_actor_add_constraint (r1, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.25));
  clutter_actor_add_constraint (r1, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.25));
  clutter_actor_set_reactive (r1, TRUE);
  clutter_actor_set_name (r1, "red");

  r2 = clutter_rectangle_new_with_color (&green);
  clutter_actor_set_size (r2, 150, 150);
  clutter_actor_add_constraint (r2, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.5));
  clutter_actor_add_constraint (r2, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.5));
  clutter_actor_set_reactive (r2, TRUE);
  clutter_actor_set_depth (r2, -100);
  clutter_actor_set_name (r2, "green");

  r3 = clutter_rectangle_new_with_color (&blue);
  clutter_actor_set_size (r3, 150, 150);
  clutter_actor_add_constraint (r3, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.75));
  clutter_actor_add_constraint (r3, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.75));
  clutter_actor_set_opacity (r3, 125);
  clutter_actor_set_name (r3, "blue");

  clutter_container_add (CLUTTER_CONTAINER (stage), r1, r2, r3, NULL);

  g_signal_connect (r1, "motion-event", G_CALLBACK (_pointer_motion_cb), NULL);
  g_signal_connect (r2, "motion-event", G_CALLBACK (_pointer_motion_cb), NULL);

  clutter_actor_show (stage);

  clutter_main ();

  return 0;
}
コード例 #16
0
static void
start_fullscreen (RBVisualizerPage *page)
{
    if (page->fullscreen == NULL) {
        ClutterActor *stage;
        GtkWindow *main_window;
        RBShell *shell;
        int x, y;

        rb_debug ("starting fullscreen display");
        g_object_get (page, "shell", &shell, NULL);
        g_object_get (shell, "window", &main_window, NULL);

        page->fullscreen = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_window_set_skip_taskbar_hint (GTK_WINDOW (page->fullscreen), TRUE);

        /* move the texture from the page embed to the new fullscreen embed */

        g_object_ref (page->texture);

        stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (page->embed));
        clutter_container_remove_actor (CLUTTER_CONTAINER (stage), page->texture);

        page->fullscreen_embed = create_embed (page);
        stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (page->fullscreen_embed));
        clutter_container_add (CLUTTER_CONTAINER (stage), page->texture, NULL);
        g_object_unref (page->texture);

        gtk_container_add (GTK_CONTAINER (page->fullscreen), page->fullscreen_embed);
        gtk_widget_show_all (GTK_WIDGET (page->fullscreen));

        gtk_window_get_position (main_window, &x, &y);
        gtk_window_move (GTK_WINDOW (page->fullscreen), x, y);

        gtk_window_fullscreen (GTK_WINDOW (page->fullscreen));
        gtk_window_set_transient_for (GTK_WINDOW (page->fullscreen), main_window);
        g_object_unref (main_window);

        rb_visualizer_fullscreen_add_widgets (page->fullscreen, stage, shell);
        g_object_unref (shell);
    }

    set_action_state (page, TRUE);
}
コード例 #17
0
ファイル: test-pick.c プロジェクト: Docworld/chromiumos
void
test_pick (TestConformSimpleFixture *fixture,
	   gconstpointer data)
{
  int y, x;
  State state;
  
  state.pass = TRUE;

  state.stage = clutter_stage_get_default ();

  clutter_actor_set_size (state.stage, STAGE_WIDTH, STAGE_HEIGHT);
  state.actor_width = STAGE_WIDTH / ACTORS_X;
  state.actor_height = STAGE_HEIGHT / ACTORS_Y;

  for (y = 0; y < ACTORS_Y; y++)
    for (x = 0; x < ACTORS_X; x++)
      {
	ClutterColor color = { x * 255 / (ACTORS_X - 1),
			       y * 255 / (ACTORS_Y - 1),
			       128, 255 };
	ClutterGeometry geom = { x * state.actor_width, y * state.actor_height,
				 state.actor_width, state.actor_height };
	ClutterActor *rect = clutter_rectangle_new_with_color (&color);

	clutter_actor_set_geometry (rect, &geom);

	clutter_container_add (CLUTTER_CONTAINER (state.stage), rect, NULL);

	state.gids[y * ACTORS_X + x] = clutter_actor_get_gid (rect);
      }

  clutter_actor_show (state.stage);

  g_timeout_add (250, (GSourceFunc) on_timeout, &state);

  clutter_main ();


  if (g_test_verbose ())
    g_print ("end result: %s\n", state.pass ? "pass" : "FAIL");

  g_assert (state.pass);
}
コード例 #18
0
ファイル: opengl.c プロジェクト: tommed/tuxwm-sandbox
void show_image(XImage *img)
{
	ClutterActor *stage, *actor;
	
	// init stage
	clutter_init(0, NULL);
	stage = clutter_stage_get_default(); // XX TODO: use root window?
	
	// init actor
	actor = clutter_texture_new();
	clutter_texture_set_from_rgb_data(CLUTTER_TEXTURE(actor), img->data, False, img->width, img->height, img->bytes_per_line, 4, (ClutterTextureFlags)0, NULL);
	clutter_container_add(CLUTTER_CONTAINER(stage), actor, NULL);
  clutter_actor_set_position(actor, 10, 10);
  
  g_signal_connect(stage, "button-press-event", clutter_main_quit, NULL);
  
  // show and wait for exit
  clutter_actor_show(stage);
  clutter_main();
}
コード例 #19
0
int
main (int argc, char *argv[])
{
  ClutterActor *stage;
  ClutterActor *texture;
  GError *error = NULL;
  ClutterActor *clone;
  gfloat y_offset;

  if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
    return 1;

  stage = clutter_stage_new ();
  clutter_stage_set_title (CLUTTER_STAGE (stage), "Reflection");
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  texture = clutter_texture_new ();
  clutter_texture_set_from_file (CLUTTER_TEXTURE (texture),
                                 "redhand.png",
                                 &error);
  clutter_actor_add_constraint (texture, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.5));
  clutter_actor_add_constraint (texture, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.2));

  y_offset = clutter_actor_get_height (texture) + V_PADDING;

  clone = clutter_clone_new (texture);
  clutter_actor_add_constraint (clone, clutter_bind_constraint_new (texture, CLUTTER_BIND_X, 0.0));
  clutter_actor_add_constraint (clone, clutter_bind_constraint_new (texture, CLUTTER_BIND_Y, y_offset));
  g_signal_connect (clone,
                    "paint",
                    G_CALLBACK (_clone_paint_cb),
                    NULL);

  clutter_container_add (CLUTTER_CONTAINER (stage), texture, clone, NULL);

  clutter_actor_show (stage);

  clutter_main ();

  return EXIT_SUCCESS;
}
コード例 #20
0
int
main (int argc, char *argv[])
{
  ClutterActor *stage;
  ClutterActor *actor;
  ClutterActor *overlay;

  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();
  clutter_actor_set_size (stage, 400, 400);
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  actor = clutter_rectangle_new_with_color (&red);
  clutter_actor_set_size (actor, 100, 100);
  clutter_actor_set_position (actor, 150, 150);

  overlay = clutter_rectangle_new_with_color (&blue);

  g_signal_connect (actor,
                    "allocation-changed",
                    G_CALLBACK (allocation_changed_cb),
                    overlay);

  clutter_container_add (CLUTTER_CONTAINER (stage), actor, overlay, NULL);

  clutter_actor_animate (actor, CLUTTER_LINEAR, 2000,
                         "width", 300.0,
                         "height", 300.0,
                         "x", 50.0,
                         "y", 50.0,
                         NULL);

  clutter_actor_show (stage);

  clutter_main ();

  return EXIT_SUCCESS;
}
コード例 #21
0
static void
impl_selected (RBDisplayPage *bpage)
{
    RBVisualizerPage *page = RB_VISUALIZER_PAGE (bpage);

    RB_DISPLAY_PAGE_CLASS (rb_visualizer_page_parent_class)->selected (bpage);

    if (page->embed == NULL) {
        ClutterActor *stage;

        page->embed = create_embed (page);

        stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (page->embed));

        clutter_container_add (CLUTTER_CONTAINER (stage), page->texture, NULL);

        gtk_box_pack_start (GTK_BOX (page), page->embed, TRUE, TRUE, 0);
        gtk_widget_show_all (GTK_WIDGET (page));
    }

    g_signal_emit (page, signals[START], 0);
}
コード例 #22
0
ファイル: test-egl-image.c プロジェクト: Docworld/chromiumos
G_MODULE_EXPORT int
test_egl_image_main (int argc, char **argv)
{
  static const ClutterColor stage_color = { 0x1f, 0x84, 0x56, 0xff };
  ClutterActor *stage;
  ClutterActor *texture;
  ClutterX11TexturePixmap *x11_texture;
  Window window;

  clutter_init (&argc, &argv);

  if (argc != 2)
    {
      g_printerr ("usage: clutter-test xid\n");
      return EXIT_FAILURE;
    }

  window = (Window)strtol (argv[1], NULL, 0);
  g_print ("Attempting to redirect window 0x%08x\n", (guint)window);

  stage = clutter_stage_get_default ();
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);

  texture = clutter_eglx_egl_image_new_with_window (window);
  x11_texture = CLUTTER_X11_TEXTURE_PIXMAP (texture);
  clutter_x11_texture_pixmap_set_automatic (x11_texture, TRUE);

  clutter_actor_set_name (texture, "EGL Image");
  clutter_container_add (CLUTTER_CONTAINER (stage), texture, NULL);

  clutter_actor_set_size (stage, 512, 512);
  clutter_actor_show (stage);

  clutter_main ();

  return EXIT_SUCCESS;
}
コード例 #23
0
ファイル: test-text-cache.c プロジェクト: Docworld/chromiumos
void
test_text_cache (TestConformSimpleFixture *fixture,
                 gconstpointer _data)
{
  CallbackData data;

  memset (&data, 0, sizeof (data));

  data.stage = clutter_stage_get_default ();

  data.label = clutter_text_new_with_text (TEST_FONT, "");

  data.test_layout = make_layout_like_label (CLUTTER_TEXT (data.label));

  g_signal_connect (data.label, "paint", G_CALLBACK (on_paint), &data);

  clutter_container_add (CLUTTER_CONTAINER (data.stage), data.label, NULL);

  clutter_actor_show (data.stage);

  clutter_threads_add_idle ((GSourceFunc) do_tests, &data);

  clutter_main ();

  if (g_test_verbose ())
    g_print ("\nOverall result: ");

  if (g_test_verbose ())
    {
      if (data.test_failed)
        g_print ("FAIL\n");
      else
        g_print ("pass\n");
    }
  else
    g_assert (data.test_failed != TRUE);
}
コード例 #24
0
ファイル: test-state.c プロジェクト: nobled/clutter
static ClutterActor *new_rect (gint r,
                               gint g,
                               gint b,
                               gint a)
{
  GError *error = NULL;
  ClutterColor *color = clutter_color_new (r, g, b, a);
  ClutterActor *group = clutter_group_new ();
  ClutterActor *rectangle = clutter_rectangle_new_with_color (color);
  ClutterActor *hand = NULL;

  gchar *file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);

  hand = clutter_texture_new_from_file (file, &error);
  if (rectangle == NULL)
    g_error ("image load failed: %s", error->message);
  g_free (file);
  clutter_actor_set_size (hand, ACTOR_WIDTH,ACTOR_HEIGHT);

  clutter_actor_set_size (rectangle, ACTOR_WIDTH,ACTOR_HEIGHT);
  clutter_color_free (color);
  clutter_container_add (CLUTTER_CONTAINER (group), rectangle, hand, NULL);
  return group;
}
コード例 #25
0
int
main (int argc, char **argv)
{
  const ClutterColor red = { 0xff, 0x00, 0x00, 0xff };
  ClutterActor *stage, *box, *tile, *rectangle;

  clutter_init (&argc, &argv);

  mex_style_load_default ();

  stage = clutter_stage_get_default ();
  clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);

  tile = mex_tile_new_with_label ("Red rectangle");
  mex_tile_set_important (MEX_TILE (tile), TRUE);
  rectangle = clutter_rectangle_new_with_color (&red);
  clutter_actor_set_size (rectangle, 300, 300);
  mx_bin_set_child (MX_BIN (tile), rectangle);

  box = mex_expander_box_new ();
  clutter_container_add (CLUTTER_CONTAINER (box), tile,
                         clutter_text_new_with_text ("Sans 16", "Hello"),
                         NULL);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), box);

  clutter_actor_set_reactive (rectangle, TRUE);
  g_signal_connect_swapped (rectangle, "enter-event",
                            G_CALLBACK (toggle_important), box);

  clutter_actor_show (stage);

  clutter_main ();

  return 0;
}
コード例 #26
0
ファイル: test-texture-fbo.c プロジェクト: gramozeka/GSB-NEW
static ClutterActor *
create_source (void)
{
  int x, y;
  ClutterActor *group = clutter_group_new ();

  /* Create a group with a different coloured rectangle at each
     corner */
  for (y = 0; y < SOURCE_DIVISIONS_Y; y++)
    for (x = 0; x < SOURCE_DIVISIONS_X; x++)
      {
        ClutterActor *rect = clutter_rectangle_new ();
        clutter_actor_set_size (rect, DIVISION_WIDTH, DIVISION_HEIGHT);
        clutter_actor_set_position (rect,
                                    DIVISION_WIDTH * x,
                                    DIVISION_HEIGHT * y);
        clutter_rectangle_set_color (CLUTTER_RECTANGLE (rect),
                                     corner_colors +
                                     (y * SOURCE_DIVISIONS_X + x));
        clutter_container_add (CLUTTER_CONTAINER (group), rect, NULL);
      }

  return group;
}
コード例 #27
0
static void
contact_widget_location_update (EmpathyContactWidget *information)
{
  GHashTable *location;
  GValue *value;
  gdouble lat = 0.0, lon = 0.0;
  gboolean has_position = TRUE;
  GtkWidget *label;
  guint row = 0;
  GHashTableIter iter;
  gpointer key, pvalue;

  if (!(information->flags & EMPATHY_CONTACT_WIDGET_SHOW_LOCATION))
    {
      gtk_widget_hide (information->vbox_location);
      return;
    }

  location = empathy_contact_get_location (information->contact);
  if (location == NULL || g_hash_table_size (location) == 0)
    {
      gtk_widget_hide (information->vbox_location);
      return;
    }

  value = g_hash_table_lookup (location, EMPATHY_LOCATION_LAT);
  if (value == NULL)
      has_position = FALSE;
  else
      lat = g_value_get_double (value);

  value = g_hash_table_lookup (location, EMPATHY_LOCATION_LON);
  if (value == NULL)
      has_position = FALSE;
  else
      lon = g_value_get_double (value);

  value = g_hash_table_lookup (location, EMPATHY_LOCATION_TIMESTAMP);
  if (value == NULL)
    gtk_label_set_markup (GTK_LABEL (information->label_location), _("<b>Location</b>"));
  else
    {
      gchar *user_date;
      gchar *text;
      gint64 stamp;
      time_t time;

      stamp = g_value_get_int64 (value);
      time = stamp;

      user_date = empathy_time_to_string_relative (time);

      text = g_strconcat ( _("<b>Location</b>, "), user_date, NULL);
      gtk_label_set_markup (GTK_LABEL (information->label_location), text);
      g_free (text);
    }


  /* Prepare the location information table */
  if (information->table_location != NULL)
    {
      gtk_widget_destroy (information->table_location);
    }

  information->table_location = gtk_table_new (1, 2, FALSE);
  gtk_box_pack_start (GTK_BOX (information->subvbox_location),
      information->table_location, FALSE, FALSE, 5);

  g_hash_table_iter_init (&iter, location);
  while (g_hash_table_iter_next (&iter, &key, &pvalue))
    {
      const gchar *skey;
      const gchar* user_label;
      GValue *gvalue;
      char *svalue = NULL;

      skey = (const gchar *) key;

      user_label = location_key_to_label (skey);
      gvalue = (GValue *) pvalue;

      label = gtk_label_new (user_label);
      gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
      gtk_table_attach (GTK_TABLE (information->table_location),
          label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 10, 0);
      gtk_widget_show (label);

      if (G_VALUE_TYPE (gvalue) == G_TYPE_DOUBLE)
        {
          gdouble dvalue;
          dvalue = g_value_get_double (gvalue);
          svalue = g_strdup_printf ("%f", dvalue);
        }
      else if (G_VALUE_TYPE (gvalue) == G_TYPE_STRING)
        {
          svalue = g_value_dup_string (gvalue);
        }
      else if (G_VALUE_TYPE (gvalue) == G_TYPE_INT64)
        {
          time_t time;

          time = g_value_get_int64 (value);
          svalue = empathy_time_to_string_utc (time, _("%B %e, %Y at %R UTC"));
        }

      if (svalue != NULL)
        {
          label = gtk_label_new (svalue);
          gtk_table_attach_defaults (GTK_TABLE (information->table_location),
              label, 1, 2, row, row + 1);
          gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
          gtk_widget_show (label);
        }

      g_free (svalue);
      row++;
    }

  gtk_widget_show (information->table_location);

#if HAVE_LIBCHAMPLAIN
  /* Cannot be displayed in tooltips until Clutter-Gtk can deal with such
   * windows
   */
  if (has_position &&
      !(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP))
    {
      ClutterActor *marker;
      ChamplainLayer *layer;

      information->map_view_embed = gtk_champlain_embed_new ();
      information->map_view = gtk_champlain_embed_get_view (
          GTK_CHAMPLAIN_EMBED (information->map_view_embed));

      gtk_container_add (GTK_CONTAINER (information->viewport_map),
          information->map_view_embed);
      g_object_set (G_OBJECT (information->map_view), "show-license", FALSE,
          "scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC,
          NULL);

      layer = champlain_layer_new ();
      champlain_view_add_layer (information->map_view, layer);

      marker = champlain_marker_new_with_text (
          empathy_contact_get_name (information->contact), NULL, NULL, NULL);
      champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), lat, lon);
      clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);

      champlain_view_center_on (information->map_view, lat, lon);
      gtk_widget_show_all (information->viewport_map);
    }
#endif

    gtk_widget_show (information->vbox_location);
}
コード例 #28
0
static void
mex_telepathy_channel_create_video_page (MexTelepathyChannel *self)
{
  MexTelepathyChannelPrivate *priv = MEX_TELEPATHY_CHANNEL (self)->priv;

  /* Create the widgets to place */
  mex_telepathy_channel_create_toolbar (self);
  mex_telepathy_channel_create_preview (self);
  mex_telepathy_channel_create_busy_box (self);
  mex_telepathy_channel_create_incoming_video (self);

  /* Top container */
  priv->video_call_page = mx_stack_new ();

  clutter_container_add (CLUTTER_CONTAINER (priv->video_call_page),
                         priv->full_frame,
                         priv->preview_area,
                         priv->toolbar_area,
                         NULL);

  /* Arrange the preview video area on the page */
  mx_stack_child_set_x_align (MX_STACK (priv->video_call_page),
                              priv->preview_area,
                              MX_ALIGN_END);

  mx_stack_child_set_y_align (MX_STACK (priv->video_call_page),
                              priv->preview_area,
                              MX_ALIGN_START);

  mx_stack_child_set_x_fill (MX_STACK (priv->video_call_page),
                             priv->preview_area,
                             FALSE);

  mx_stack_child_set_y_fill (MX_STACK (priv->video_call_page),
                             priv->preview_area,
                             FALSE);

  /* Arrange the incoming video area on the page */
  mx_stack_child_set_x_fill (MX_STACK (priv->video_call_page),
                             priv->full_frame,
                             FALSE);

  mx_stack_child_set_y_fill (MX_STACK (priv->video_call_page),
                             priv->full_frame,
                             FALSE);

  /* Arrange the toolbar area on the page */
  mx_stack_child_set_x_align (MX_STACK (priv->video_call_page),
                              priv->toolbar_area,
                              MX_ALIGN_MIDDLE);

  mx_stack_child_set_y_align (MX_STACK (priv->video_call_page),
                              priv->toolbar_area,
                              MX_ALIGN_END);

  mx_stack_child_set_x_fill (MX_STACK (priv->video_call_page),
                             priv->toolbar_area,
                             TRUE);

  mx_stack_child_set_y_fill (MX_STACK (priv->video_call_page),
                             priv->toolbar_area,
                             FALSE);

  /* Connect to hide signals. */
  g_signal_connect (priv->video_call_page,
                    "hide",
                    G_CALLBACK (mex_telepathy_channel_on_video_closed),
                    self);

  /* Connect to show signals. */
  g_signal_connect (priv->video_call_page,
                    "show",
                    G_CALLBACK (mex_telepathy_channel_on_video_shown),
                    self);

  if (priv->show_page)
    {
      g_signal_emit (self,
                     mex_telepathy_channel_signals[SHOW_ACTOR],
                     0,
                     g_object_ref (priv->video_call_page));
      clutter_actor_show (priv->busy_box);
      clutter_actor_raise_top (priv->busy_box);
      priv->show_page = FALSE;
    }
}
コード例 #29
0
int main(int argc, char *argv[])
{
    ClutterActor *stage;
    WebKitWebView *web_view;
    
    ClutterConstraint *width_binding;
    ClutterConstraint *height_binding;
    ClutterConstraint *web_view_height_binding;
    
    gfloat stageWidth, stageHeight;
    ClutterActorBox stageAllocation;
    
    ClutterLayoutManager  *mainLayout;
    ClutterActor          *mainLayoutContainer;
    ClutterLayoutManager  *toolbarLayout;
    ClutterActor          *toolbarContainer;
    ClutterLayoutManager  *toolbarBinLayout;
    ClutterActor          *toolbarBinContainer;
    ClutterActor          *toolbarBgr;
    ClutterActor          *statusBar;
    ClutterActor *backFwdBtns;
    ClutterActor *backBtn;
    ClutterActor *fwdBtn;
    ClutterActor *uriGroup;
    ClutterActor *uriBgr;
    ClutterActor *uriText;
    ClutterActor *spacer;
    
    GError *error = NULL;
    
    ClutterColor whiteColor = { 255, 255, 255, 255 };
    ClutterColor blackColor = { 0, 0, 0, 255 };
    ClutterColor grayColor =  { 200, 200, 200, 255 };
    ClutterColor transparentColor = { 0, 0, 0, 0 };
    
    gchar *toolbarBgrPath = clutter_launcher_file_path("toolbar_bgr.png");
    gchar *backBtnPath = clutter_launcher_file_path("back_btn.png");
    gchar *fwdBtnPath = clutter_launcher_file_path("fwd_btn.png");
    
    g_thread_init(NULL);
    clutter_threads_init();
    
    clutter_init(&argc, &argv);
    
    stage = clutter_stage_get_default();
    clutter_actor_set_size(stage, 1024, 768);
    clutter_stage_set_color(CLUTTER_STAGE(stage), &stage_color);
    g_signal_connect (stage, "destroy", G_CALLBACK(clutter_main_quit), NULL);
    
    /* make the stage resizable */
    clutter_stage_set_user_resizable(CLUTTER_STAGE(stage), TRUE);
    
    clutter_actor_show(stage);
    
    mainLayout = clutter_box_layout_new();
    clutter_box_layout_set_vertical(CLUTTER_BOX_LAYOUT(mainLayout), TRUE);
    
    
    clutter_actor_get_allocation_box(stage, &stageAllocation);
    stageWidth = stageAllocation.x2 - stageAllocation.x1;
    stageHeight = stageAllocation.y2 - stageAllocation.y1;
    
    web_view = WEBKIT_WEB_VIEW(webkit_web_view_new((guint)stageWidth, (guint)stageHeight - (toolbarHeight + statusBarHeight)));
    g_object_set(web_view, "reactive", TRUE, NULL);
    
    mainLayoutContainer = clutter_box_new(mainLayout);
    clutter_actor_set_size(mainLayoutContainer, stageWidth, stageHeight);
    
    width_binding = clutter_bind_constraint_new(stage, CLUTTER_BIND_WIDTH, 0);
    height_binding = clutter_bind_constraint_new(stage, CLUTTER_BIND_HEIGHT, 0);
/*    web_view_height_binding = clutter_bind_constraint_new(stage, CLUTTER_BIND_HEIGHT, -(toolbarHeight + statusBarHeight));
  */  
    clutter_actor_add_constraint(mainLayoutContainer, width_binding);
    clutter_actor_add_constraint(mainLayoutContainer, height_binding);
/*    clutter_actor_add_constraint(CLUTTER_ACTOR(web_view), web_view_height_binding);
  */  
    toolbarBinLayout = clutter_bin_layout_new(CLUTTER_BIN_ALIGNMENT_FILL, CLUTTER_BIN_ALIGNMENT_CENTER);
    toolbarBinContainer = clutter_box_new(toolbarBinLayout);
    
    toolbarBgr = clutter_texture_new_from_file(toolbarBgrPath, &error);
    if (toolbarBgr == NULL) {
      fprintf(stderr, "Can't load file: %s. Aborting...\n", toolbarBgrPath);
      exit(1);
    }
    clutter_actor_set_height(toolbarBgr, toolbarHeight);
    clutter_texture_set_repeat(CLUTTER_TEXTURE(toolbarBgr), TRUE, FALSE);
    clutter_box_pack(CLUTTER_BOX(toolbarBinContainer), toolbarBgr, NULL, NULL);
    
    toolbarLayout = clutter_box_layout_new();
    clutter_box_layout_set_vertical(CLUTTER_BOX_LAYOUT(toolbarLayout), FALSE);
    clutter_box_layout_set_spacing(CLUTTER_BOX_LAYOUT(toolbarLayout), 16);
    toolbarContainer = clutter_box_new(toolbarLayout);
    
    spacer = clutter_rectangle_new_with_color(&transparentColor);
    clutter_actor_set_size(spacer, 1, 1);
    clutter_box_pack(CLUTTER_BOX(toolbarContainer), spacer, NULL, NULL);
    
    backFwdBtns = clutter_group_new();
    
    backBtn = clutter_texture_new_from_file(backBtnPath, &error);
    if (backBtn == NULL) {
      fprintf(stderr, "Can't load file: %s. Aborting...\n", backBtnPath);
      exit(1);
    }
    clutter_actor_set_reactive(backBtn, TRUE);
    /* connect the release event */
    g_signal_connect (backBtn,
                      "button-release-event",
                      G_CALLBACK (on_back_release_cb),
                      web_view);
    
    fwdBtn = clutter_texture_new_from_file(fwdBtnPath, &error);
    if (fwdBtn == NULL) {
      fprintf(stderr, "Can't load file: %s. Aborting...\n", fwdBtnPath);
      exit(1);
    }
    clutter_actor_set_reactive(fwdBtn, TRUE);
    /* connect the release event */
    g_signal_connect (fwdBtn,
                      "button-release-event",
                      G_CALLBACK (on_fwd_release_cb),
                      web_view);
    
    clutter_actor_set_position(fwdBtn, 
                               clutter_actor_get_width(backBtn), 0);
    clutter_container_add(CLUTTER_CONTAINER(backFwdBtns), backBtn, fwdBtn, NULL);
    clutter_box_pack(CLUTTER_BOX(toolbarContainer), backFwdBtns, NULL, NULL);
    
    uriGroup = clutter_group_new();
    
    uriBgr = clutter_rectangle_new_with_color(&whiteColor);
    clutter_rectangle_set_border_color(CLUTTER_RECTANGLE(uriBgr), &blackColor);
    clutter_rectangle_set_border_width(CLUTTER_RECTANGLE(uriBgr), 1);
    clutter_actor_set_size(uriBgr, 400, 25);
    
    uriText = clutter_text_new_full("Helvetica 11px", "http://www.google.com", &blackColor);
    clutter_text_set_editable(CLUTTER_TEXT(uriText), TRUE);
    clutter_text_set_single_line_mode(CLUTTER_TEXT(uriText), TRUE);
    clutter_actor_set_position(uriText, 5, 7);
    clutter_actor_set_size(uriText, 390, 17);
    clutter_actor_set_reactive(uriText, TRUE);
    g_signal_connect(uriText, "activate", G_CALLBACK(on_uri_activate_cb), web_view);
    
    clutter_container_add(CLUTTER_CONTAINER(uriGroup), uriBgr, uriText, NULL);
    clutter_box_pack(CLUTTER_BOX(toolbarContainer), uriGroup, NULL, NULL);
    
    clutter_box_pack(CLUTTER_BOX(toolbarBinContainer), toolbarContainer, NULL, NULL);
    
    clutter_box_pack(CLUTTER_BOX(mainLayoutContainer), toolbarBinContainer, 
                     "y-align", CLUTTER_BOX_ALIGNMENT_START, NULL);
    clutter_box_layout_set_expand(CLUTTER_BOX_LAYOUT(mainLayout), toolbarBinContainer, TRUE);
    clutter_box_layout_set_fill(CLUTTER_BOX_LAYOUT(mainLayout), toolbarBinContainer, TRUE, FALSE);
    
    statusBar = clutter_rectangle_new_with_color(&grayColor);
    clutter_actor_set_height(statusBar, statusBarHeight);
    
    clutter_box_pack(CLUTTER_BOX(mainLayoutContainer), statusBar, 
                     "y-align", CLUTTER_BOX_ALIGNMENT_END, NULL);
    clutter_box_layout_set_expand(CLUTTER_BOX_LAYOUT(mainLayout), statusBar, TRUE);
    clutter_box_layout_set_fill(CLUTTER_BOX_LAYOUT(mainLayout), statusBar, TRUE, FALSE);
    
    clutter_box_pack_after(CLUTTER_BOX(mainLayoutContainer), CLUTTER_ACTOR(web_view), toolbarBinContainer, 
                           "y-align", CLUTTER_BOX_ALIGNMENT_START, NULL);
    clutter_box_layout_set_expand(CLUTTER_BOX_LAYOUT(mainLayout), CLUTTER_ACTOR(web_view), TRUE);
    clutter_box_layout_set_fill(CLUTTER_BOX_LAYOUT(mainLayout), CLUTTER_ACTOR(web_view), TRUE, TRUE);

    clutter_container_add(CLUTTER_CONTAINER(stage), mainLayoutContainer, NULL);
    
    g_signal_connect(web_view, "webkit-load-finished", G_CALLBACK(load_finished_cb), web_view);
    g_signal_connect(web_view, "notify::progress", G_CALLBACK (notify_progress_cb), web_view);
    /*    g_signal_connect(stage, "delete-event", G_CALLBACK(delete_cb), web_view);*/
    g_signal_connect(web_view, "notify::uri", G_CALLBACK(notify_uri_cb), uriText);
    
    gchar *uri = (gchar*) (argc > 1 ? argv[1] : "http://www.google.com/");
    gchar *fileURL = filenameToURL(uri);

    webkit_web_view_load_uri(web_view, fileURL ? fileURL : uri);
    printf("%s\n", fileURL ? fileURL : uri);
    g_free(fileURL);
        
    g_timeout_add_full(G_PRIORITY_DEFAULT, 3000, timeout_cb, web_view, 0);
    
    clutter_threads_enter ();
    clutter_main();
    clutter_threads_leave ();
    
    return EXIT_SUCCESS;
}
コード例 #30
0
int
main (int   argc,
      char *argv[])
{
  State *state = g_new0 (State, 1);

  ClutterActor *stage;
  ClutterAnimator *animator;

  clutter_init (&argc, &argv);

  stage = clutter_stage_new ();
  clutter_actor_set_size (stage, 400, 400);
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  state->red = clutter_rectangle_new_with_color (&red_color);
  clutter_actor_set_size (state->red, 100, 100);
  clutter_actor_set_position (state->red, 300, 300);

  state->green = clutter_rectangle_new_with_color (&green_color);
  clutter_actor_set_size (state->green, 100, 100);
  clutter_actor_set_position (state->green, 0, 0);

  animator = clutter_animator_new ();
  clutter_animator_set_duration (animator, 1000);

  clutter_animator_set (animator,
                        state->red, "x", CLUTTER_LINEAR, 0.0, 300.0,
                        state->red, "y", CLUTTER_LINEAR, 0.0, 300.0,
                        state->red, "x", CLUTTER_LINEAR, 1.0, 0.0,
                        state->red, "y", CLUTTER_EASE_IN_QUINT, 1.0, 0.0,
                        NULL);

  clutter_animator_set (animator,
                        state->green, "x", CLUTTER_LINEAR, 0.0, 0.0,
                        state->green, "y", CLUTTER_LINEAR, 0.0, 0.0,
                        state->green, "x", CLUTTER_LINEAR, 1.0, 300.0,
                        state->green, "y", CLUTTER_EASE_IN_QUINT, 1.0, 300.0,
                        NULL);

  state->timeline = clutter_animator_get_timeline (animator);

  clutter_timeline_set_auto_reverse (state->timeline, TRUE);

  g_signal_connect (stage,
                    "key-press-event",
                    G_CALLBACK (key_pressed_cb),
                    state);

  clutter_container_add (CLUTTER_CONTAINER (stage), state->red, state->green, NULL);

  clutter_actor_show (stage);

  clutter_main ();

  g_object_unref (animator);

  g_free (state);

  return EXIT_SUCCESS;
}