static gboolean start_search (MnpWorldClock *area) { MnpWorldClockPrivate *priv = GET_PRIVATE (area); priv->completion_timeout = 0; if (!priv->completion_inited) { priv->completion_inited = TRUE; construct_completion (area); } priv->search_text = mx_entry_get_text (priv->search_location); if (!priv->search_text || (strlen(priv->search_text) < 3)) clutter_actor_hide(priv->completion); if (priv->search_text && (strlen(priv->search_text) > 2)) g_signal_emit_by_name (priv->zones_model, "filter-changed"); if (priv->search_text && (strlen(priv->search_text) > 2) && (clutter_model_get_n_rows(priv->zones_model) > 0)) { clutter_actor_show(priv->completion); clutter_actor_raise_top (priv->completion); } else { clutter_actor_hide(priv->completion); } return FALSE; }
static void fade_transition_frame_cb (OptTransition *trans, gint frame_num, gpointer data) { OptSlide *from, *to; OptTransitionPrivate *priv; gint opacity; priv = trans->priv; from = opt_transition_get_from (trans); to = opt_transition_get_to (trans); if (frame_num == 1) { clutter_actor_show_all (CLUTTER_ACTOR(to)); clutter_actor_raise_top (CLUTTER_ACTOR(to)); } opacity = (frame_num * 255 ) / clutter_timeline_get_n_frames (CLUTTER_TIMELINE(trans)); clutter_actor_set_opacity (CLUTTER_ACTOR(to), opacity); /* clutter_actor_set_depth (CLUTTER_ACTOR(from), - opacity/10 ); */ }
static void mex_telepathy_channel_conference_added (TfChannel *channel, GstElement *conference, gpointer user_data) { MexTelepathyChannel *self = MEX_TELEPATHY_CHANNEL (user_data); MexTelepathyChannelPrivate *priv = self->priv; GKeyFile *keyfile; MEX_INFO ("Conference added"); /* Add notifier to set the various element properties as needed */ keyfile = fs_utils_get_default_element_properties (conference); if (keyfile != NULL) { FsElementAddedNotifier *notifier; MEX_INFO ("Loaded default codecs for %s", GST_ELEMENT_NAME (conference)); notifier = fs_element_added_notifier_new (); fs_element_added_notifier_set_properties_from_keyfile (notifier, keyfile); fs_element_added_notifier_add (notifier, GST_BIN (priv->pipeline)); priv->notifiers = g_list_prepend (priv->notifiers, notifier); } gst_bin_add (GST_BIN (priv->pipeline), conference); gst_element_set_state (conference, GST_STATE_PLAYING); if (CLUTTER_IS_ACTOR (priv->video_call_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); } else priv->show_page = TRUE; }
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; } }
static void switch_workspace (MetaPlugin *plugin, gint from, gint to, MetaMotionDirection direction) { MetaScreen *screen; MetaDefaultPluginPrivate *priv = META_DEFAULT_PLUGIN (plugin)->priv; GList *l; ClutterActor *workspace0 = clutter_group_new (); ClutterActor *workspace1 = clutter_group_new (); ClutterActor *stage; int screen_width, screen_height; ClutterAnimation *animation; screen = meta_plugin_get_screen (plugin); stage = meta_get_stage_for_screen (screen); meta_screen_get_size (screen, &screen_width, &screen_height); clutter_actor_set_anchor_point (workspace1, screen_width, screen_height); clutter_actor_set_position (workspace1, screen_width, screen_height); clutter_actor_set_scale (workspace1, 0.0, 0.0); clutter_container_add_actor (CLUTTER_CONTAINER (stage), workspace1); clutter_container_add_actor (CLUTTER_CONTAINER (stage), workspace0); if (from == to) { meta_plugin_switch_workspace_completed (plugin); return; } l = g_list_last (meta_get_window_actors (screen)); while (l) { MetaWindowActor *window_actor = l->data; MetaWindow *window = meta_window_actor_get_meta_window (window_actor); MetaWorkspace *workspace; ActorPrivate *apriv = get_actor_private (window_actor); ClutterActor *actor = CLUTTER_ACTOR (window_actor); gint win_workspace; workspace = meta_window_get_workspace (window); win_workspace = meta_workspace_index (workspace); if (win_workspace == to || win_workspace == from) { apriv->orig_parent = clutter_actor_get_parent (actor); clutter_actor_reparent (actor, win_workspace == to ? workspace1 : workspace0); clutter_actor_show_all (actor); clutter_actor_raise_top (actor); } else if (win_workspace < 0) { /* Sticky window */ apriv->orig_parent = NULL; } else { /* Window on some other desktop */ clutter_actor_hide (actor); apriv->orig_parent = NULL; } l = l->prev; } priv->desktop1 = workspace0; priv->desktop2 = workspace1; animation = clutter_actor_animate (workspace0, CLUTTER_EASE_IN_SINE, SWITCH_TIMEOUT, "scale-x", 1.0, "scale-y", 1.0, NULL); priv->tml_switch_workspace1 = clutter_animation_get_timeline (animation); g_signal_connect (priv->tml_switch_workspace1, "completed", G_CALLBACK (on_switch_workspace_effect_complete), plugin); animation = clutter_actor_animate (workspace1, CLUTTER_EASE_IN_SINE, SWITCH_TIMEOUT, "scale-x", 0.0, "scale-y", 0.0, NULL); priv->tml_switch_workspace2 = clutter_animation_get_timeline (animation); }
G_MODULE_EXPORT int test_bin_layout_main (int argc, char *argv[]) { ClutterActor *stage, *box, *rect; ClutterLayoutManager *layout; ClutterColor stage_color = { 0xe0, 0xf2, 0xfc, 0xff }; ClutterColor bg_color = { 0xcc, 0xcc, 0xcc, 0x99 }; ClutterColor *color; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Box test"); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_actor_set_size (stage, 640, 480); layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); box = clutter_box_new (layout); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); clutter_actor_set_anchor_point_from_gravity (box, CLUTTER_GRAVITY_CENTER); clutter_actor_set_position (box, 320, 240); clutter_actor_set_reactive (box, TRUE); clutter_actor_set_name (box, "box"); rect = make_background (&bg_color, 200, 200); /* first method: use clutter_box_pack() */ clutter_box_pack (CLUTTER_BOX (box), rect, "x-align", CLUTTER_BIN_ALIGNMENT_FILL, "y-align", CLUTTER_BIN_ALIGNMENT_FILL, NULL); clutter_actor_lower_bottom (rect); clutter_actor_set_name (rect, "background"); { ClutterActor *tex; GError *error; gchar *file; error = NULL; file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); tex = clutter_texture_new_from_file (file, &error); if (error) g_error ("Unable to create texture: %s", error->message); clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (tex), TRUE); /* second method: use clutter_bin_layout_add() */ clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (layout), tex, CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); clutter_actor_raise (tex, rect); clutter_actor_set_width (tex, 175); clutter_actor_set_name (tex, "texture"); g_free (file); } color = clutter_color_new (g_random_int_range (0, 255), g_random_int_range (0, 255), g_random_int_range (0, 255), 224); rect = clutter_rectangle_new_with_color (color); /* third method: container_add() and set_alignment() */ clutter_container_add_actor (CLUTTER_CONTAINER (box), rect); clutter_bin_layout_set_alignment (CLUTTER_BIN_LAYOUT (layout), rect, CLUTTER_BIN_ALIGNMENT_END, CLUTTER_BIN_ALIGNMENT_END); clutter_actor_set_size (rect, 50, 50); clutter_actor_set_opacity (rect, 0); clutter_actor_raise_top (rect); clutter_actor_set_name (rect, "emblem"); g_signal_connect (box, "enter-event", G_CALLBACK (on_box_enter), rect); g_signal_connect (box, "leave-event", G_CALLBACK (on_box_leave), rect); clutter_actor_show_all (stage); clutter_main (); clutter_color_free (color); return EXIT_SUCCESS; }
IO_METHOD(IoClutterActor, raiseToTop) { clutter_actor_raise_top(IOCACTOR(self)); return self; }
void clutter_dominatrix_handle_event (ClutterDominatrix *dominatrix, ClutterEvent *event) { ClutterDominatrixPrivate * priv = dominatrix->priv; switch (event->type) { case CLUTTER_BUTTON_PRESS: { gint x, y; ClutterActor * actor = priv->slave; ClutterVertex v[4]; ClutterVertex v1, v2; ClutterFixed xp, yp; ClutterFixed zang; gint32 xmin, xmax, ymin, ymax; gint i; gint width, height; gint mhandle_width = priv->mhandle_width; gint mhandle_height = priv->mhandle_height; gint rhandle_width = priv->rhandle_width; gint rhandle_height = priv->rhandle_height; if (((ClutterButtonEvent *)event)->click_count == 2) { clutter_dominatrix_restore (dominatrix); break; } clutter_event_get_coords (event, &x, &y); clutter_actor_raise_top (priv->slave); priv->old_opacity = clutter_actor_get_opacity (priv->slave); g_signal_emit (dominatrix, dmx_signals[MANIPULATION_STARTED], 0); priv->prev_x = x; priv->prev_y = y; /* Check that the handle size are sensible in relationship to the * projected size of our slave, otherwise if the user reduces the size * of the slave too much, s/he will not be able to expand it again * -- we practice safe bondage only in this house ;). * * Allow the movement handle to be at most half of the width/height * and the rotation handles to be at most a quarter of width/height. */ clutter_actor_get_vertices (actor, v); xmin = xmax = v[0].x; ymin = ymax = v[0].y; for (i = 1; i < 4; ++i) { if (xmin > v[i].x) xmin = v[i].x; if (xmax < v[i].x) xmax = v[i].x; if (ymin > v[i].y) ymin = v[i].y; if (ymax < v[i].y) ymax = v[i].y; } width = CLUTTER_FIXED_INT (xmax - xmin); height = CLUTTER_FIXED_INT (ymax - ymin); /* FIXME -- make this work when the actor is rotated */ if (width < 2 * mhandle_width) { mhandle_width = width >> 1; g_debug ("Adjusted mhandle width to %d", mhandle_width); } if (height < 2 * mhandle_height) { mhandle_height = height >> 1; g_debug ("Adjusted mhandle height to %d", mhandle_height); } if (width < 4 * rhandle_width) { rhandle_width = width >> 2; g_debug ("Adjusted rhandle width to %d", rhandle_width); }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterActor *texture; ClutterActor *overlay; ClutterAction *click; GError *error = NULL; const gchar *filename = "redhand.png"; if (argc > 1) filename = argv[1]; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_new (); clutter_actor_set_size (stage, STAGE_SIDE, STAGE_SIDE); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); texture = clutter_texture_new (); clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (texture), TRUE); clutter_actor_set_reactive (texture, TRUE); clutter_actor_set_size (texture, RECTANGLE_SIDE, RECTANGLE_SIDE); 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.5)); clutter_texture_set_from_file (CLUTTER_TEXTURE (texture), filename, &error); if (error != NULL) { g_warning ("Error loading %s\n%s", filename, error->message); g_error_free (error); exit (EXIT_FAILURE); } /* overlay is 10px wider and taller than the texture, and centered on it; * initially, it is transparent; but it is made semi-opaque when the * texture is clicked */ overlay = clutter_rectangle_new_with_color (&overlay_color); clutter_actor_set_opacity (overlay, OVERLAY_OPACITY_OFF); clutter_actor_add_constraint (overlay, clutter_bind_constraint_new (texture, CLUTTER_BIND_WIDTH, 10)); clutter_actor_add_constraint (overlay, clutter_bind_constraint_new (texture, CLUTTER_BIND_HEIGHT, 10)); clutter_actor_add_constraint (overlay, clutter_align_constraint_new (texture, CLUTTER_ALIGN_X_AXIS, 0.5)); clutter_actor_add_constraint (overlay, clutter_align_constraint_new (texture, CLUTTER_ALIGN_Y_AXIS, 0.5)); click = clutter_click_action_new (); clutter_actor_add_action (texture, click); clutter_container_add (CLUTTER_CONTAINER (stage), texture, overlay, NULL); clutter_actor_raise_top (overlay); g_signal_connect (click, "clicked", G_CALLBACK (click_cb), overlay); g_signal_connect (stage, "key-press-event", G_CALLBACK (key_press_cb), texture); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
static void construct_completion (MnpWorldClock *world_clock) { const ClutterColor transparent = { 0x00, 0x00, 0x00, 0x00 }; ClutterActor *frame, *scroll, *view, *stage; MnpWorldClockPrivate *priv = GET_PRIVATE (world_clock); ClutterModel *model; MnpButtonItem *button_item; stage = priv->stage; /* Create an event-box to capture input when the completion list * displays. */ priv->event_box = clutter_rectangle_new_with_color (&transparent); clutter_actor_set_size (priv->event_box, clutter_actor_get_width (stage), clutter_actor_get_height (stage)); clutter_container_add_actor (CLUTTER_CONTAINER (stage), priv->event_box); clutter_actor_set_reactive (priv->event_box, TRUE); clutter_actor_hide (priv->event_box); g_signal_connect (priv->event_box, "button-press-event", G_CALLBACK (event_box_clicked_cb), world_clock); if (!priv->zones_model) { model = mnp_get_world_timezones (); priv->zones_model = model; } else model = priv->zones_model; clutter_model_set_filter (model, filter_zone, world_clock, NULL); priv->search_text = "asd"; frame = mx_frame_new (); clutter_actor_set_name (frame, "CompletionFrame"); mx_bin_set_fill (MX_BIN (frame), TRUE, TRUE); scroll = mx_scroll_view_new (); clutter_actor_set_name (scroll, "CompletionScrollView"); g_object_set (G_OBJECT (scroll), "clip-to-allocation", TRUE, NULL); clutter_actor_set_size (scroll, -1, 300); mx_bin_set_child (MX_BIN (frame), scroll); clutter_container_add_actor ((ClutterContainer *)stage, frame); clutter_actor_raise_top((ClutterActor *) frame); clutter_actor_set_position (frame, 14, 167); clutter_actor_hide (frame); priv->completion = frame; g_signal_connect (priv->completion, "show", G_CALLBACK (completion_show_cb), world_clock); g_signal_connect (priv->completion, "hide", G_CALLBACK (completion_hide_cb), world_clock); view = mx_list_view_new (); clutter_actor_set_name (view, "CompletionListView"); priv->zones_list = (MxListView *)view; clutter_container_add_actor (CLUTTER_CONTAINER (scroll), view); mx_list_view_set_model (MX_LIST_VIEW (view), model); button_item = mnp_button_item_new ((gpointer)world_clock, mnp_completion_done); mx_list_view_set_factory (MX_LIST_VIEW (view), (MxItemFactory *)button_item); mx_list_view_add_attribute (MX_LIST_VIEW (view), "label", 0); }
int main(int argc, char **argv) { GtkWidget *window; GtkWidget *stage; ClutterColor stage_color = { 0xff, 0xff, 0xff, 0xff }; ClutterTimeline *timeline, *clock; GError *error = NULL; HandCar *all; clutter_init(&argc, &argv); clutter_gst_init(&argc, &argv); gst_init(&argc, &argv); gtk_init(&argc, &argv); all = handcar_new (); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW(window), "Clutter Player"); g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(gtk_main_quit), NULL); stage = gtk_clutter_embed_new(); gtk_widget_set_size_request(stage, STAGE_WIDTH, STAGE_HEIGHT); gtk_container_add(GTK_CONTAINER(window), stage); all->stage_actor = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(stage)); clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->rect1); clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->rect2); clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->rect3); clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->btn_actor_play); clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->btn_actor_previous); clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->btn_actor_next); clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->label_actor); clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->label_time); clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->video); clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->entry_actor); clutter_stage_set_color(CLUTTER_STAGE(all->stage_actor), &stage_color); timeline = clutter_timeline_new (100, 5); g_signal_connect(G_OBJECT(timeline), "new-frame", G_CALLBACK(on_timeline_new_frame), (gpointer)all); clutter_timeline_set_loop(timeline, TRUE); clutter_timeline_start(timeline); clock = clutter_timeline_new (60, 2); g_signal_connect(G_OBJECT(clock), "new-frame", G_CALLBACK(on_update_clock), (gpointer)all); clutter_timeline_set_loop(clock, TRUE); clutter_timeline_start(clock); g_signal_connect (all->stage_actor, "motion-event", G_CALLBACK(mouse_over_lighten), (gpointer) all); g_signal_connect (all->stage_actor, "button-press-event", G_CALLBACK(on_click), (gpointer) all); clutter_actor_raise_top (all->entry_actor); gtk_widget_show_all(window); gtk_main(); return 0; }