/** * mx_menu_add_action: * @menu: A #MxMenu * @action: A #MxAction * * Append @action to @menu. * */ void mx_menu_add_action (MxMenu *menu, MxAction *action) { MxMenuChild child; ClutterActor *button_child; g_return_if_fail (MX_IS_MENU (menu)); g_return_if_fail (MX_IS_ACTION (action)); MxMenuPrivate *priv = menu->priv; child.action = g_object_ref_sink (action); /* TODO: Connect to notify signals in case action properties change */ child.box = g_object_new (MX_TYPE_BUTTON, "action", child.action, NULL); mx_button_set_action (MX_BUTTON (child.box), child.action); /* align to the left */ button_child = clutter_actor_get_child_at_index ((ClutterActor*) child.box, 0); clutter_actor_set_x_align (button_child, CLUTTER_ACTOR_ALIGN_START); g_signal_connect (child.box, "clicked", G_CALLBACK (mx_menu_button_clicked_cb), action); g_signal_connect (child.box, "enter-event", G_CALLBACK (mx_menu_button_enter_event_cb), menu); clutter_actor_add_child (CLUTTER_ACTOR (menu), CLUTTER_ACTOR (child.box)); g_array_append_val (priv->children, child); clutter_actor_queue_relayout (CLUTTER_ACTOR (menu)); }
static void st_icon_finish_update (StIcon *icon) { StIconPrivate *priv = icon->priv; if (priv->icon_texture) { clutter_actor_destroy (priv->icon_texture); priv->icon_texture = NULL; } if (priv->pending_texture) { priv->icon_texture = priv->pending_texture; priv->pending_texture = NULL; clutter_actor_set_x_align (priv->icon_texture, CLUTTER_ACTOR_ALIGN_CENTER); clutter_actor_set_y_align (priv->icon_texture, CLUTTER_ACTOR_ALIGN_CENTER); clutter_actor_add_child (CLUTTER_ACTOR (icon), priv->icon_texture); /* Remove the temporary ref we added */ g_object_unref (priv->icon_texture); st_icon_update_shadow_pipeline (icon); /* "pixbuf-change" is actually a misnomer for "texture-changed" */ g_signal_connect_object (priv->icon_texture, "pixbuf-change", G_CALLBACK (on_pixbuf_changed), icon, 0); } }
static void plate1anim (ClutterTimeline *timeline, const gchar *marker_name, guint frame_num, ClutterActor *bg) { clutter_actor_set_easing_duration (bg, 750); clutter_actor_save_easing_state (bg); clutter_actor_set_easing_mode (bg, CLUTTER_EASE_OUT_CIRC); clutter_actor_set_x_align (bg, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_restore_easing_state (bg); }
int main (int argc, char *argv[]) { ClutterActor *stage, *box, *bg, *icon, *emblem, *label; ClutterLayoutManager *layout; ClutterContent *canvas, *image; ClutterColor *color; ClutterAction *action; GdkPixbuf *pixbuf; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; /* prepare the stage */ stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "BinLayout"); clutter_actor_set_background_color (stage, CLUTTER_COLOR_Aluminium2); clutter_actor_set_size (stage, 640, 480); clutter_actor_show (stage); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); /* this is our BinLayout, with its default alignments */ layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); /* the main container; this actor will use the BinLayout to lay * out its children; we use the anchor point to keep it centered * on the same position even when we change its size */ box = clutter_actor_new (); clutter_actor_set_layout_manager (box, layout); clutter_actor_add_constraint (box, clutter_align_constraint_new (stage, CLUTTER_ALIGN_BOTH, 0.5)); clutter_actor_set_position (box, 320, 240); clutter_actor_set_reactive (box, TRUE); clutter_actor_set_name (box, "box"); clutter_actor_add_child (stage, box); /* the background is drawn using a canvas content */ canvas = clutter_canvas_new (); g_signal_connect (canvas, "draw", G_CALLBACK (on_canvas_draw), NULL); clutter_canvas_set_size (CLUTTER_CANVAS (canvas), 200, 200); /* this is the background actor; we want it to fill the whole * of the allocation given to it by its parent */ bg = clutter_actor_new (); clutter_actor_set_name (bg, "background"); clutter_actor_set_size (bg, 200, 200); clutter_actor_set_content (bg, canvas); clutter_actor_set_x_expand (bg, TRUE); clutter_actor_set_y_expand (bg, TRUE); clutter_actor_set_x_align (bg, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_set_y_align (bg, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_add_child (box, bg); /* we use the ::transitions-completed signal to get notification * of the end of the sizing animation; this allows us to redraw * the canvas only once the animation has stopped */ g_signal_connect (box, "transitions-completed", G_CALLBACK (redraw_canvas), canvas); /* we use GdkPixbuf to load an image from our data directory */ pixbuf = gdk_pixbuf_new_from_file (TESTS_DATADIR G_DIR_SEPARATOR_S "redhand.png", NULL); image = clutter_image_new (); clutter_image_set_data (CLUTTER_IMAGE (image), gdk_pixbuf_get_pixels (pixbuf), gdk_pixbuf_get_has_alpha (pixbuf) ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), gdk_pixbuf_get_rowstride (pixbuf), NULL); g_object_unref (pixbuf); /* this is the icon; it's going to be centered inside the box actor. * we use the content gravity to keep the aspect ratio of the image, * and the scaling filters to get a better result when scaling the * image down. */ icon = clutter_actor_new (); clutter_actor_set_name (icon, "icon"); clutter_actor_set_size (icon, 196, 196); clutter_actor_set_x_expand (icon, TRUE); clutter_actor_set_y_expand (icon, TRUE); clutter_actor_set_x_align (icon, CLUTTER_ACTOR_ALIGN_CENTER); clutter_actor_set_y_align (icon, CLUTTER_ACTOR_ALIGN_CENTER); clutter_actor_set_content_gravity (icon, CLUTTER_CONTENT_GRAVITY_RESIZE_ASPECT); clutter_actor_set_content_scaling_filters (icon, CLUTTER_SCALING_FILTER_TRILINEAR, CLUTTER_SCALING_FILTER_LINEAR); clutter_actor_set_content (icon, image); clutter_actor_add_child (box, icon); color = clutter_color_new (g_random_int_range (0, 255), g_random_int_range (0, 255), g_random_int_range (0, 255), 224); /* this is the emblem: a small rectangle with a random color, that we * want to put in the bottom right corner */ emblem = clutter_actor_new (); clutter_actor_set_name (emblem, "emblem"); clutter_actor_set_size (emblem, 48, 48); clutter_actor_set_background_color (emblem, color); clutter_actor_set_x_expand (emblem, TRUE); clutter_actor_set_y_expand (emblem, TRUE); clutter_actor_set_x_align (emblem, CLUTTER_ACTOR_ALIGN_END); clutter_actor_set_y_align (emblem, CLUTTER_ACTOR_ALIGN_END); clutter_actor_set_reactive (emblem, TRUE); clutter_actor_set_opacity (emblem, 0); clutter_actor_add_child (box, emblem); clutter_color_free (color); /* when clicking on the emblem, we want to perform an action */ action = clutter_click_action_new (); clutter_actor_add_action (emblem, action); g_signal_connect (action, "clicked", G_CALLBACK (on_emblem_clicked), box); g_signal_connect (action, "long-press", G_CALLBACK (on_emblem_long_press), box); /* whenever the pointer enters the box, we show the emblem; we hide * the emblem when the pointer leaves the box */ g_signal_connect (box, "enter-event", G_CALLBACK (on_box_enter), emblem); g_signal_connect (box, "leave-event", G_CALLBACK (on_box_leave), emblem); /* a label, that we want to position at the top and center of the box */ label = clutter_text_new (); clutter_actor_set_name (label, "text"); clutter_text_set_text (CLUTTER_TEXT (label), "A simple test"); clutter_actor_set_x_expand (label, TRUE); clutter_actor_set_x_align (label, CLUTTER_ACTOR_ALIGN_CENTER); clutter_actor_set_y_expand (label, TRUE); clutter_actor_set_y_align (label, CLUTTER_ACTOR_ALIGN_START); clutter_actor_add_child (box, label); clutter_main (); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { ClutterActor *video; /* So we can fade out at the end. */ clutter_x11_set_use_argb_visual (TRUE); if (clutter_gst_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return EXIT_FAILURE; if (argc < 2) { g_print ("Usage: %s [OPTIONS] <video file>\n", argv[0]); return EXIT_FAILURE; } if (!clutter_color_from_string (&bg_color, BG_COLOR)) { g_warning ("Invalid BG_COLOR"); exit (1); } stage = clutter_stage_new (); /* Clutter's full-screening code does not allow us to * set both that and _NET_WM_STATE_ABOVE, so do the state * management ourselves for now. */ #if 0 clutter_stage_set_fullscreen (CLUTTER_STAGE (stage), TRUE); #endif /* Clutter will set maximum size restrictions (meaning not * full screen) unless I set this. */ clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE); clutter_stage_set_use_alpha (CLUTTER_STAGE (stage), TRUE); clutter_actor_set_background_color (stage, &bg_color); clutter_actor_set_layout_manager (stage, clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FIXED, CLUTTER_BIN_ALIGNMENT_FIXED)); clutter_actor_realize (stage); set_above_and_fullscreen (); video = clutter_gst_video_texture_new (); clutter_actor_set_x_expand (video, TRUE); clutter_actor_set_y_expand (video, TRUE); clutter_actor_set_x_align (video, CLUTTER_ACTOR_ALIGN_CENTER); clutter_actor_set_y_align (video, CLUTTER_ACTOR_ALIGN_CENTER); set_idle_material (CLUTTER_GST_VIDEO_TEXTURE (video)); g_signal_connect (video, "eos", G_CALLBACK (on_video_texture_eos), NULL); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); clutter_media_set_filename (CLUTTER_MEDIA (video), argv[1]); clutter_stage_hide_cursor (CLUTTER_STAGE (stage)); clutter_actor_add_child (stage, video); g_signal_connect (stage, "key-press-event", G_CALLBACK (key_press_cb), NULL); clutter_media_set_playing (CLUTTER_MEDIA (video), TRUE); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { ClutterActor *stage, *box, *bg, *bg2, *inset, *labelContainer, *contentContainer, *labelbg, *fixed, *upper, *lower, *lowerInner; ClutterLayoutManager *layout, *labelContainer_l, *layoutFixed; ClutterTimeline *timeline; ClutterContent *canvas, *canvas1; ClutterColor color_with_trans = {0,0,0,0}; clutter_x11_set_use_argb_visual (TRUE); if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return (1); /* prepare the stage */ stage = clutter_stage_new (); clutter_stage_set_use_alpha (CLUTTER_STAGE (stage), TRUE); clutter_stage_set_color (CLUTTER_STAGE (stage), &color_with_trans); clutter_stage_set_title (CLUTTER_STAGE (stage), "IPLocation Database"); clutter_actor_set_background_color (stage, CLUTTER_COLOR_WHITE); clutter_actor_set_size (stage, 648, 246); clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE); clutter_actor_show (stage); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); box = clutter_actor_new (); clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_SIZE, 0.0)); clutter_actor_set_background_color (box, CLUTTER_COLOR_WHITE); clutter_actor_set_layout_manager (box, layout); clutter_actor_add_constraint (box, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 1)); clutter_actor_set_name (box, "box"); clutter_actor_add_child (stage, box); bg = clutter_actor_new (); //clutter_actor_set_background_color (bg, clutter_color_new (50, 50, 50, 255)); clutter_actor_set_name (bg, "background"); clutter_actor_set_reactive (bg, TRUE); //clutter_actor_set_x_expand (bg, TRUE); //clutter_actor_set_y_expand (bg, TRUE); clutter_actor_set_x_align (bg, CLUTTER_ACTOR_ALIGN_END); clutter_actor_set_y_align (bg, CLUTTER_ACTOR_ALIGN_FILL); canvas1 = clutter_canvas_new (); clutter_canvas_set_size (CLUTTER_CANVAS (canvas1), 300, 300); clutter_actor_set_content (bg, canvas1); /*clutter_actor_set_content_scaling_filters (bg2, CLUTTER_SCALING_FILTER_TRILINEAR, CLUTTER_SCALING_FILTER_LINEAR);*/ g_object_unref (canvas1); clutter_actor_add_child (box, bg); bg2 = clutter_actor_new (); //clutter_actor_set_background_color (bg2, clutter_color_new (0, 100, 100, 255*.5)); clutter_actor_set_name (bg2, "background"); clutter_actor_set_reactive (bg2, TRUE); clutter_actor_set_size (bg2, 0, 0); //clutter_actor_set_x_expand (bg2, TRUE); //clutter_actor_set_y_expand (bg2, TRUE); clutter_actor_set_x_align (bg2, CLUTTER_ACTOR_ALIGN_END); clutter_actor_set_y_align (bg2, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_set_clip_to_allocation(bg2, TRUE); clutter_actor_add_child (box, bg2); clutter_actor_set_layout_manager (bg2, clutter_box_layout_new ()); canvas = clutter_canvas_new (); clutter_canvas_set_size (CLUTTER_CANVAS (canvas), 300, 300); clutter_actor_set_content (bg2, canvas); /*clutter_actor_set_content_scaling_filters (bg2, CLUTTER_SCALING_FILTER_TRILINEAR, CLUTTER_SCALING_FILTER_LINEAR);*/ g_object_unref (canvas); inset = clutter_actor_new (); //clutter_actor_set_background_color (inset, clutter_color_new (255, 0, 0, 255)); clutter_actor_set_name (inset, "inset"); clutter_actor_set_reactive (inset, TRUE); clutter_actor_set_margin_top (inset, 18); clutter_actor_set_margin_right (inset, 18); clutter_actor_set_margin_bottom (inset, 18); clutter_actor_set_margin_left (inset, 48); //clutter_actor_set_x_expand (inset, TRUE); //clutter_actor_set_y_expand (inset, TRUE); clutter_actor_set_x_align (inset, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_set_y_align (inset, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_set_clip_to_allocation(inset, TRUE); clutter_actor_add_child (bg2, inset); layout = clutter_box_layout_new (); clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (layout), TRUE); clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (layout), 5); clutter_actor_set_layout_manager (inset, layout); labelContainer = clutter_actor_new (); clutter_actor_set_size (labelContainer, 0, 35); //clutter_actor_set_background_color (labelContainer, clutter_color_new (34, 134, 158, 255)); clutter_actor_set_name (labelContainer, "labelContainer"); clutter_actor_set_reactive (labelContainer, TRUE); //clutter_actor_set_x_expand (labelContainer, TRUE); //clutter_actor_set_y_expand (labelContainer, TRUE); clutter_actor_add_child (inset, labelContainer); labelContainer_l = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); clutter_actor_set_layout_manager (labelContainer, labelContainer_l); labelbg = clutter_actor_new (); clutter_actor_set_background_color (labelbg, clutter_color_new (34, 134, 158, 255)); clutter_actor_set_name (labelbg, "labelbg"); //clutter_actor_set_x_expand (labelbg, TRUE); clutter_actor_set_size (labelbg, 0, 35); clutter_actor_set_x_align (labelbg, CLUTTER_ACTOR_ALIGN_START); clutter_actor_set_y_align (labelbg, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_add_child (labelContainer, labelbg); contentContainer = clutter_actor_new (); clutter_actor_set_size (contentContainer, 0, 0); clutter_actor_set_background_color (contentContainer, clutter_color_new (0.290196*255, 0.427451*255, 0.462745*255, 255)); clutter_actor_set_name (contentContainer, "labelContainer"); //clutter_actor_set_x_expand (contentContainer, TRUE); //clutter_actor_set_y_expand (contentContainer, TRUE); clutter_actor_set_layout_manager (contentContainer, clutter_fixed_layout_new ()); clutter_actor_add_child (inset, contentContainer); fixed = clutter_actor_new (); clutter_actor_set_background_color (fixed, clutter_color_new (9, 53, 71, 255)); clutter_actor_set_name (fixed, "fixed"); clutter_actor_set_size (fixed, 582, 210-40); clutter_actor_set_position (fixed, 582, 0); layoutFixed = clutter_box_layout_new (); clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (layoutFixed), TRUE); clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (layoutFixed), 8); clutter_actor_set_layout_manager (fixed, layoutFixed); clutter_actor_add_child (contentContainer, fixed); //------------------------------------------------------------------------// lower = clutter_actor_new (); clutter_actor_set_size (lower, 0, 0); clutter_actor_set_name (lower, "lower"); //clutter_actor_set_x_expand (lower, TRUE); //clutter_actor_set_y_expand (lower, TRUE); clutter_actor_set_margin_right (lower, 8); clutter_actor_set_margin_top (lower, 8); clutter_actor_set_margin_left (lower, 8); clutter_actor_set_layout_manager (lower, clutter_fixed_layout_new ()); clutter_actor_set_clip_to_allocation(lower, TRUE); clutter_actor_add_child (fixed, lower); lowerInner = clutter_actor_new (); clutter_actor_set_background_color (lowerInner, clutter_color_new (255, 255, 255, 30)); clutter_actor_set_name (lowerInner, "fixed"); clutter_actor_set_size (lowerInner, 566, 113); clutter_actor_set_position (lowerInner, 566, 0); clutter_actor_add_child (lower, lowerInner); upper = clutter_actor_new (); clutter_actor_set_size (upper, 0, 33); clutter_actor_set_name (upper, "upper"); clutter_actor_set_x_expand (upper, TRUE); //clutter_actor_set_y_expand (upper, TRUE); clutter_actor_set_margin_bottom (upper, 8); clutter_actor_set_margin_right (upper, 8); clutter_actor_set_margin_left (upper, 8); //clutter_actor_set_layout_manager (upper, clutter_fixed_layout_new ()); clutter_actor_add_child (fixed, upper); timeline = clutter_timeline_new (57/24.*1000); clutter_timeline_add_marker_at_time(timeline, "first", (40-35)/24.*1000); clutter_timeline_add_marker_at_time(timeline, "second", (46-35)/24.*1000); clutter_timeline_add_marker_at_time(timeline, "third", (51-35)/24.*1000); clutter_timeline_add_marker_at_time(timeline, "fourth", (52-35)/24.*1000); clutter_timeline_add_marker_at_time(timeline, "fifth", (58-35)/24.*1000); g_signal_connect (timeline, "marker-reached::first", G_CALLBACK (plate1anim), bg); g_signal_connect (timeline, "marker-reached::second", G_CALLBACK (plate2anim), bg2); g_signal_connect (timeline, "marker-reached::third", G_CALLBACK (plate3anim), labelbg); g_signal_connect (timeline, "marker-reached::fourth", G_CALLBACK (plate4anim), fixed); g_signal_connect (timeline, "marker-reached::fifth", G_CALLBACK (plate5anim), lowerInner); g_signal_connect (canvas1, "draw", G_CALLBACK (draw_1), NULL); g_signal_connect (bg, "paint", G_CALLBACK (on_actor_resize), canvas); g_signal_connect (canvas, "draw", G_CALLBACK (draw), NULL); g_signal_connect (bg2, "paint", G_CALLBACK (on_actor_resize), canvas); clutter_content_invalidate (canvas); clutter_timeline_start (timeline); clutter_main (); return (EXIT_SUCCESS); }
int main (int argc, char *argv[]) { GtkWidget *window; GtkWidget *widget, *vbox, *bbox, *button, *viewport, *image; ChamplainView *view; ChamplainMarkerLayer *layer; ClutterActor *scale; ChamplainLicense *license_actor; if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; /* create the main, top level, window */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); /* give the window a 10px wide border */ gtk_container_set_border_width (GTK_CONTAINER (window), 10); /* give it the title */ gtk_window_set_title (GTK_WINDOW (window), "libchamplain Gtk+ demo"); /* Connect the destroy event of the window with our on_destroy function * When the window is about to be destroyed we get a notificaiton and * stop the main GTK loop */ g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (on_destroy), NULL); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10); widget = gtk_champlain_embed_new (); view = gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (widget)); clutter_actor_set_reactive (CLUTTER_ACTOR (view), TRUE); g_signal_connect (view, "button-release-event", G_CALLBACK (mouse_click_cb), view); g_object_set (G_OBJECT (view), "kinetic-mode", TRUE, "zoom-level", 5, NULL); g_object_set_data (G_OBJECT (view), "window", window); scale = champlain_scale_new (); champlain_scale_connect_view (CHAMPLAIN_SCALE (scale), view); /* align to the bottom left */ clutter_actor_set_x_expand (scale, TRUE); clutter_actor_set_y_expand (scale, TRUE); clutter_actor_set_x_align (scale, CLUTTER_ACTOR_ALIGN_START); clutter_actor_set_y_align (scale, CLUTTER_ACTOR_ALIGN_END); clutter_actor_add_child (CLUTTER_ACTOR (view), scale); license_actor = champlain_view_get_license_actor (view); champlain_license_set_extra_text (license_actor, "Don't eat cereals with orange juice\nIt tastes bad"); champlain_view_center_on (CHAMPLAIN_VIEW (view), 45.466, -73.75); layer = create_marker_layer (view, &path); champlain_view_add_layer (view, CHAMPLAIN_LAYER (path)); champlain_view_add_layer (view, CHAMPLAIN_LAYER (layer)); path_layer = champlain_path_layer_new (); /* Cheap approx of Highway 10 */ append_point (path_layer, 45.4095, -73.3197); append_point (path_layer, 45.4104, -73.2846); append_point (path_layer, 45.4178, -73.2239); append_point (path_layer, 45.4176, -73.2181); append_point (path_layer, 45.4151, -73.2126); append_point (path_layer, 45.4016, -73.1926); append_point (path_layer, 45.3994, -73.1877); append_point (path_layer, 45.4000, -73.1815); append_point (path_layer, 45.4151, -73.1218); champlain_view_add_layer (view, CHAMPLAIN_LAYER (path_layer)); gtk_widget_set_size_request (widget, 640, 481); bbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); button = gtk_button_new (); image = gtk_image_new_from_icon_name ("zoom-in", GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (button), image); gtk_button_set_label (GTK_BUTTON (button), "Zoom In"); g_signal_connect (button, "clicked", G_CALLBACK (zoom_in), view); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_button_new (); image = gtk_image_new_from_icon_name ("zoom-out", GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (button), image); gtk_button_set_label (GTK_BUTTON (button), "Zoom Out"); g_signal_connect (button, "clicked", G_CALLBACK (zoom_out), view); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_toggle_button_new_with_label ("Markers"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); g_signal_connect (button, "toggled", G_CALLBACK (toggle_layer), layer); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_toggle_button_new_with_label ("Toggle wrap"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), champlain_view_get_horizontal_wrap (view)); g_signal_connect (button, "toggled", G_CALLBACK (toggle_wrap), view); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_combo_box_new (); build_combo_box (GTK_COMBO_BOX (button)); gtk_combo_box_set_active (GTK_COMBO_BOX (button), 0); g_signal_connect (button, "changed", G_CALLBACK (map_source_changed), view); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_spin_button_new_with_range (0, 20, 1); gtk_spin_button_set_value (GTK_SPIN_BUTTON (button), champlain_view_get_zoom_level (view)); g_signal_connect (button, "changed", G_CALLBACK (zoom_changed), view); g_signal_connect (view, "notify::zoom-level", G_CALLBACK (map_zoom_changed), button); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_button_new (); image = gtk_image_new_from_icon_name ("list-add", GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (button), image); g_signal_connect (button, "clicked", G_CALLBACK (add_clicked), view); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_button_new (); image = gtk_image_new_from_icon_name ("camera-photo-symbolic", GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (button), image); g_signal_connect (button, "clicked", G_CALLBACK (export_png), view); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_image_new (); gtk_widget_set_size_request (button, 22, -1); g_signal_connect (view, "notify::state", G_CALLBACK (view_state_changed), button); gtk_box_pack_end (GTK_BOX (bbox), button, FALSE, FALSE, 0); viewport = gtk_frame_new (NULL); gtk_container_add (GTK_CONTAINER (viewport), widget); gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (vbox), viewport); /* and insert it into the main window */ gtk_container_add (GTK_CONTAINER (window), vbox); /* make sure that everything, window and label, are visible */ gtk_widget_show_all (window); /* start the main loop */ gtk_main (); return 0; }
static void current_call_view_init(CurrentCallView *view) { gtk_widget_init_template(GTK_WIDGET(view)); CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); /* create video widget and overlay the call info and controls on it */ priv->video_widget = video_widget_new(); gtk_container_add(GTK_CONTAINER(priv->frame_video), priv->video_widget); gtk_widget_show_all(priv->frame_video); auto stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(priv->video_widget)); auto actor_info = gtk_clutter_actor_new_with_contents(priv->hbox_call_info); auto actor_controls = gtk_clutter_actor_new_with_contents(priv->hbox_call_controls); clutter_actor_add_child(stage, actor_info); clutter_actor_set_x_align(actor_info, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_set_y_align(actor_info, CLUTTER_ACTOR_ALIGN_START); clutter_actor_add_child(stage, actor_controls); clutter_actor_set_x_align(actor_controls, CLUTTER_ACTOR_ALIGN_CENTER); clutter_actor_set_y_align(actor_controls, CLUTTER_ACTOR_ALIGN_END); /* add fade in and out states to the info and controls */ priv->time_last_mouse_motion = g_get_monotonic_time(); priv->fade_info = create_fade_out_transition(); priv->fade_controls = create_fade_out_transition(); clutter_actor_add_transition(actor_info, "fade_info", priv->fade_info); clutter_actor_add_transition(actor_controls, "fade_controls", priv->fade_controls); clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_info), CLUTTER_TIMELINE_BACKWARD); clutter_timeline_set_direction(CLUTTER_TIMELINE(priv->fade_controls), CLUTTER_TIMELINE_BACKWARD); clutter_timeline_stop(CLUTTER_TIMELINE(priv->fade_info)); clutter_timeline_stop(CLUTTER_TIMELINE(priv->fade_controls)); /* have a timer check every 1 second if the controls should fade out */ priv->timer_fade = g_timeout_add(1000, (GSourceFunc)timeout_check_last_motion_event, view); /* connect to the mouse motion event to reset the last moved time */ g_signal_connect_swapped(priv->video_widget, "motion-notify-event", G_CALLBACK(mouse_moved), view); g_signal_connect_swapped(priv->video_widget, "button-press-event", G_CALLBACK(mouse_moved), view); g_signal_connect_swapped(priv->video_widget, "button-release-event", G_CALLBACK(mouse_moved), view); /* manually handle the focus of the video widget to be able to focus on the call controls */ g_signal_connect(priv->video_widget, "focus", G_CALLBACK(video_widget_focus), view); /* toggle whether or not the chat is displayed */ g_signal_connect(priv->togglebutton_chat, "toggled", G_CALLBACK(chat_toggled), view); /* bind the chat orientation to the gsetting */ priv->settings = g_settings_new_full(get_ring_schema(), NULL, NULL); g_settings_bind_with_mapping(priv->settings, "chat-pane-horizontal", priv->paned_call, "orientation", G_SETTINGS_BIND_GET, map_boolean_to_orientation, nullptr, nullptr, nullptr); g_signal_connect(priv->scalebutton_quality, "value-changed", G_CALLBACK(quality_changed), view); /* customize the quality button scale */ if (auto scale_box = gtk_scale_button_get_box(GTK_SCALE_BUTTON(priv->scalebutton_quality))) { priv->checkbutton_autoquality = gtk_check_button_new_with_label(C_("Enable automatic video quality", "Auto")); gtk_widget_show(priv->checkbutton_autoquality); gtk_box_pack_start(GTK_BOX(scale_box), priv->checkbutton_autoquality, FALSE, TRUE, 0); g_signal_connect(priv->checkbutton_autoquality, "toggled", G_CALLBACK(autoquality_toggled), view); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbutton_autoquality), TRUE); } if (auto scale = gtk_scale_button_get_scale(GTK_SCALE_BUTTON(priv->scalebutton_quality))) { g_signal_connect(scale, "button-press-event", G_CALLBACK(quality_button_pressed), view); g_signal_connect(scale, "button-release-event", G_CALLBACK(quality_button_released), view); } }
int main (int argc, char *argv[]) { ClutterActor *stage, *box, *instructions; ClutterLayoutManager *stage_layout, *grid_layout; GError *error = NULL; if (clutter_init_with_args (&argc, &argv, NULL, entries, NULL, &error) != CLUTTER_INIT_SUCCESS) { g_print ("Unable to run grid-layout: %s", error->message); g_error_free (error); return EXIT_FAILURE; } stage = clutter_stage_new (); clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE); stage_layout = clutter_box_layout_new (); clutter_box_layout_set_orientation (CLUTTER_BOX_LAYOUT (stage_layout), CLUTTER_ORIENTATION_VERTICAL); clutter_actor_set_layout_manager (stage, stage_layout); grid_layout = clutter_grid_layout_new (); if (is_vertical) clutter_grid_layout_set_orientation (CLUTTER_GRID_LAYOUT (grid_layout), CLUTTER_ORIENTATION_VERTICAL); box = clutter_actor_new (); clutter_actor_set_background_color (box, CLUTTER_COLOR_LightGray); clutter_actor_set_x_expand (box, TRUE); clutter_actor_set_y_expand (box, TRUE); clutter_actor_set_layout_manager (box, grid_layout); clutter_actor_add_child (stage, box); clutter_actor_set_x_align (box, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_set_y_align (box, CLUTTER_ACTOR_ALIGN_FILL); add_actor (box, 0, 0, 1, 1); add_actor (box, 1, 0, 1, 1); add_actor (box, 2, 0, 1, 1); add_actor (box, 0, 1, 1, 1); add_actor (box, 1, 1, 2, 1); add_actor (box, 0, 2, 3, 1); add_actor (box, 0, 3, 2, 2); add_actor (box, 2, 3, 1, 1); add_actor (box, 2, 4, 1, 1); instructions = clutter_text_new_with_text ("Sans 12px", INSTRUCTIONS); clutter_actor_set_margin_top (instructions, 4); clutter_actor_set_margin_left (instructions, 4); clutter_actor_set_margin_bottom (instructions, 4); clutter_actor_add_child (stage, instructions); clutter_actor_set_x_align (instructions, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_set_y_align (instructions, CLUTTER_ACTOR_ALIGN_CENTER); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); g_signal_connect (stage, "key-release-event", G_CALLBACK (key_release_cb), box); clutter_actor_show (stage); clutter_main (); return 0; }
static void add_actor (ClutterActor *box, gint left, gint top, gint width, gint height) { ClutterLayoutManager *layout; ClutterActor *rect, *text; ClutterColor color; clutter_color_from_hls (&color, g_random_double_range (0.0, 360.0), 0.5, 0.5); color.alpha = 255; rect = clutter_actor_new (); clutter_actor_set_layout_manager (rect, clutter_bin_layout_new ()); clutter_actor_set_background_color (rect, &color); clutter_actor_set_reactive (rect, TRUE); if (random_size) clutter_actor_set_size (rect, g_random_int_range (40, 80), g_random_int_range (40, 80)); else clutter_actor_set_size (rect, 60, 60); clutter_actor_set_x_expand (rect, default_expand); clutter_actor_set_y_expand (rect, default_expand); if (!default_expand) { clutter_actor_set_x_align (rect, CLUTTER_ACTOR_ALIGN_CENTER); clutter_actor_set_y_align (rect, CLUTTER_ACTOR_ALIGN_CENTER); } if (random_align) { clutter_actor_set_x_align (rect, g_random_int_range (0, 3)); clutter_actor_set_y_align (rect, g_random_int_range (0, 3)); } text = clutter_text_new_with_text ("Sans 8px", NULL); clutter_text_set_line_alignment (CLUTTER_TEXT (text), PANGO_ALIGN_CENTER); clutter_actor_add_child (rect, text); g_signal_connect (rect, "button-release-event", G_CALLBACK (button_release_cb), NULL); g_signal_connect (rect, "notify::x-expand", G_CALLBACK (changed_cb), text); g_signal_connect (rect, "notify::y-expand", G_CALLBACK (changed_cb), text); g_signal_connect (rect, "notify::x-align", G_CALLBACK (changed_cb), text); g_signal_connect (rect, "notify::y-align", G_CALLBACK (changed_cb), text); layout = clutter_actor_get_layout_manager (box); if (use_box) clutter_actor_add_child (box, rect); else clutter_grid_layout_attach (CLUTTER_GRID_LAYOUT (layout), rect, left, top, width, height); changed_cb (rect, NULL, text); }