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); }
static ClutterActor* create_clutter_texture(EmpathyVideoWidget *object) { EmpathyVideoWidgetPriv *priv = GET_PRIV (object); ClutterActor *texture, *stage, *box; ClutterLayoutManager *layout; stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (object)); g_assert (stage != NULL); clutter_stage_set_color (CLUTTER_STAGE(stage), CLUTTER_COLOR_Black); layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); g_assert (layout != NULL); box = clutter_box_new (layout); g_assert (box != NULL); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); priv->notify_allocation_id = g_signal_connect (stage, "notify::allocation", G_CALLBACK(on_stage_allocation_changed), box); texture = clutter_texture_new (); g_assert (texture != NULL); clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (texture), TRUE); g_object_ref (G_OBJECT (texture)); clutter_box_pack (CLUTTER_BOX (box), texture, NULL, NULL); return texture; }
static void glide_window_insert_stage (GlideWindow *w) { ClutterColor cblack = {0x00, 0x00, 0x00, 0xff}; GtkWidget *fixed = GTK_WIDGET (gtk_builder_get_object (w->priv->builder, "embed-fixed")); GtkWidget *embed = glide_window_make_embed (); GdkColor black; gtk_fixed_set_has_window (GTK_FIXED (fixed), TRUE); // Nasty hack. g_signal_connect (fixed, "key-press-event", G_CALLBACK (glide_window_fixed_key_press_event), NULL); gdk_color_parse ("black", &black); gtk_widget_modify_bg (fixed, GTK_STATE_NORMAL, &black); w->priv->embed = embed; w->priv->stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (embed)); clutter_actor_set_size (w->priv->stage, DEFAULT_PRESENTATION_WIDTH, DEFAULT_PRESENTATION_HEIGHT); clutter_actor_show (w->priv->stage); clutter_stage_set_color (CLUTTER_STAGE (w->priv->stage), &cblack); gtk_fixed_put (GTK_FIXED (fixed), embed, 0, 0); gtk_widget_set_size_request (fixed, DEFAULT_PRESENTATION_WIDTH, DEFAULT_PRESENTATION_HEIGHT); gtk_widget_set_size_request (embed, DEFAULT_PRESENTATION_WIDTH, DEFAULT_PRESENTATION_HEIGHT); g_signal_connect_after (fixed, "size-allocate", G_CALLBACK (glide_window_fixed_embed_size_allocate), w); }
void AcceleratedCompositingContext::attachRootGraphicsLayer(GraphicsLayer* graphicsLayer) { if (!graphicsLayer) { gtk_container_remove(GTK_CONTAINER(m_webView), m_rootLayerEmbedder); m_rootLayerEmbedder = 0; m_rootGraphicsLayer = 0; return; } // Create an instance of GtkClutterEmbed to host actors as web layers. if (!m_rootLayerEmbedder) { m_rootLayerEmbedder = gtk_clutter_embed_new(); gtk_container_add(GTK_CONTAINER(m_webView), m_rootLayerEmbedder); gtk_widget_show(m_rootLayerEmbedder); } // Add a root layer to the stage. if (graphicsLayer) { m_rootGraphicsLayer = graphicsLayer; ClutterColor stageColor = { 0xFF, 0xFF, 0xFF, 0xFF }; ClutterActor* stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(m_rootLayerEmbedder)); clutter_stage_set_color(CLUTTER_STAGE(stage), &stageColor); clutter_container_add_actor(CLUTTER_CONTAINER(stage), m_rootGraphicsLayer->platformLayer()); clutter_actor_show_all(stage); } }
static void empathy_video_widget_dispose (GObject *object) { EmpathyVideoWidget *self = EMPATHY_VIDEO_WIDGET (object); EmpathyVideoWidgetPriv *priv = GET_PRIV (self); if (priv->dispose_has_run) return; priv->dispose_has_run = TRUE; if (priv->notify_allocation_id != 0) { ClutterActor *stage; stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (object)); g_signal_handler_disconnect (stage, priv->notify_allocation_id); priv->notify_allocation_id = 0; } if (priv->videosink != NULL) g_object_unref (priv->videosink); priv->videosink = NULL; if (priv->sink != NULL) g_object_unref (priv->sink); priv->sink = NULL; /* release any references held by the object here */ if (G_OBJECT_CLASS (empathy_video_widget_parent_class)->dispose) G_OBJECT_CLASS (empathy_video_widget_parent_class)->dispose (object); }
GtkWidget * gml_gtk_widget_new () { GtkWidget *obj; obj = g_object_new (GML_TYPE_GTK_WIDGET, NULL); GmlGtkWidget *gml = GML_GTK_WIDGET (obj); GtkGrid *grid = GTK_GRID (obj); gml->clutter_widget = gtk_clutter_embed_new (); gtk_widget_set_size_request (gml->clutter_widget, gml->width, gml->height); gml->stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (gml->clutter_widget)); clutter_stage_set_color (CLUTTER_STAGE (gml->stage), &(gml->stage_color)); clutter_actor_show (gml->stage); gtk_widget_set_vexpand (gml->clutter_widget, TRUE); gtk_widget_set_valign (gml->clutter_widget, GTK_ALIGN_FILL); gtk_widget_set_hexpand (gml->clutter_widget, TRUE); gtk_widget_set_halign (gml->clutter_widget, GTK_ALIGN_FILL); gtk_grid_attach (grid, gml->clutter_widget, 0, 0, 1, 1); return obj; }
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); }
static void cheese_widget_init (CheeseWidget *widget) { CheeseWidgetPrivate *priv = CHEESE_WIDGET_GET_PRIVATE (widget); GtkWidget *box; ClutterActor *stage, *frame; ClutterConstraint *constraint; ClutterColor black = { 0x00, 0x00, 0x00, 0xff }; priv->state = CHEESE_WIDGET_STATE_NONE; priv->error = NULL; /* XXX * remove this line if you want to debug */ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE); gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE); /* Spinner page */ priv->spinner = gtk_spinner_new (); box = gtk_event_box_new (); gtk_container_add (GTK_CONTAINER (box), priv->spinner); cheese_widget_spinner_invert (priv->spinner, box); gtk_widget_show_all (box); gtk_notebook_append_page (GTK_NOTEBOOK (widget), box, gtk_label_new ("spinner")); /* Webcam page */ priv->screen = gtk_clutter_embed_new (); stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->screen)); clutter_stage_set_color (CLUTTER_STAGE (stage), &black); frame = cheese_aspect_frame_new (); priv->texture = clutter_texture_new (); clutter_actor_set_size (priv->texture, 400, 300); mx_bin_set_child (MX_BIN (frame), priv->texture); clutter_container_add_actor (CLUTTER_CONTAINER (stage), frame); constraint = clutter_bind_constraint_new (stage, CLUTTER_BIND_SIZE, 0.0); clutter_actor_add_constraint_with_name (frame, "size", constraint); gtk_widget_show (priv->screen); clutter_actor_show (priv->texture); gtk_notebook_append_page (GTK_NOTEBOOK (widget), priv->screen, gtk_label_new ("webcam")); /* Problem page */ priv->problem = gtk_drawing_area_new (); gtk_widget_show (priv->problem); gtk_notebook_append_page (GTK_NOTEBOOK (widget), priv->problem, gtk_label_new ("got problems")); priv->settings = g_settings_new ("org.gnome.Cheese"); }
GtkWidget* ly_3shr_create () { GtkWidget *widget; ClutterActor *stage; widget=gtk_clutter_embed_new(); stage=gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(widget)); ClutterActor *list; list=mx_list_view_new(); }
void test_clutter(){ ClutterActor *stage; ClutterAction *action; stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(app.stage)); action = clutter_gesture_action_new(); clutter_actor_add_action(CLUTTER_ACTOR(stage), action); g_signal_connect(action, "gesture-begin", G_CALLBACK(on_gesture_begin), NULL); g_signal_connect(action, "gesture-progress", G_CALLBACK(on_gesture_progress), NULL); g_signal_connect(action, "gesture-end", G_CALLBACK(on_gesture_end), NULL); //~ g_signal_connect(stage, "button-press-event", G_CALLBACK(on_button_press), NULL); tool = TOOL_RECTANGLE; }
int main (int argc, char **argv) { GtkWidget *window; GtkWidget *screen; CheeseCamera *camera; ClutterActor *stage; ClutterActor *texture; bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return EXIT_FAILURE; if (!cheese_init (&argc, &argv)) return EXIT_FAILURE; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), 400, 300); g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (delete_callback), NULL); screen = gtk_clutter_embed_new (); stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (screen)); texture = clutter_texture_new (); clutter_actor_set_size (texture, 400, 300); clutter_actor_add_child (stage, texture); gtk_widget_show (screen); clutter_actor_show (texture); camera = cheese_camera_new (CLUTTER_TEXTURE (texture), NULL, 640, 480); cheese_camera_setup (camera, NULL, NULL); gtk_container_add (GTK_CONTAINER (window), screen); gtk_widget_show_all (window); cheese_camera_play (camera); g_timeout_add_seconds (5, (GSourceFunc) (time_cb), camera); gtk_main (); return EXIT_SUCCESS; }
static GtkWidget * create_embed (RBVisualizerPage *page) { ClutterActor *stage; GtkWidget *embed; embed = gtk_clutter_embed_new (); stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (embed)); g_signal_connect_object (stage, "allocation-changed", G_CALLBACK (resize_sink_texture), page->texture, 0); g_signal_connect_object (stage, "button-press-event", G_CALLBACK (stage_button_press_cb), page, 0); g_signal_connect_object (stage, "key-release-event", G_CALLBACK (stage_key_release_cb), page, 0); return embed; }
Preview::Preview(): width(0), height(0), blocknr(-1), color(-1), themeID(0), cell_size(20), cache(NULL), enabled(true) { blocks = new Block*[PREVIEW_WIDTH]; for (int i = 0; i < PREVIEW_WIDTH; i++) { blocks[i] = new Block [PREVIEW_HEIGHT]; } w = gtk_clutter_embed_new(); g_signal_connect (w, "size_allocate", G_CALLBACK (resize), this); /* FIXME: We should scale with the rest of the UI, but that requires * changes to the widget layout - i.e. wrap the preview in an * fixed-aspect box. */ gtk_widget_set_size_request (w, 120, 120); ClutterActor *stage; stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (w)); ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff }; clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); piece = clutter_group_new (); clutter_group_add (CLUTTER_GROUP (stage), piece); piece_timeline = clutter_timeline_new (180); alpha = clutter_alpha_new_full (piece_timeline, CLUTTER_EASE_IN_OUT_SINE); piece_behav = clutter_behaviour_scale_new (alpha, 0.6, 0.6, 1.0, 1.0); clutter_actor_set_anchor_point (piece, 60, 60); clutter_actor_set_position (CLUTTER_ACTOR(piece), 60, 60); clutter_behaviour_apply (piece_behav, piece); }
static void ekiga_extended_video_window_init_clutter (EkigaExtWindow *ew) { GtkWidget *clutter_widget = NULL; clutter_widget = gtk_clutter_embed_new (); gtk_widget_set_size_request (GTK_WIDGET (clutter_widget), STAGE_WIDTH, STAGE_HEIGHT); gtk_container_add (GTK_CONTAINER (ew), clutter_widget); ew->priv->stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter_widget)); clutter_actor_set_background_color (CLUTTER_ACTOR (ew->priv->stage), CLUTTER_COLOR_Black); clutter_stage_set_user_resizable (CLUTTER_STAGE (ew->priv->stage), TRUE); ew->priv->video_stream = CLUTTER_ACTOR (g_object_new (CLUTTER_TYPE_TEXTURE, "disable-slicing", TRUE, NULL)); clutter_actor_add_child (CLUTTER_ACTOR (ew->priv->stage), CLUTTER_ACTOR (ew->priv->video_stream)); clutter_actor_add_constraint (ew->priv->video_stream, clutter_align_constraint_new (ew->priv->stage, CLUTTER_ALIGN_BOTH, 0.5)); }
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); }
static void gt_player_backend_gstreamer_clutter_init(GtPlayerBackendGstreamerClutter* self) { GtPlayerBackendGstreamerClutterPrivate* priv = gt_player_backend_gstreamer_clutter_get_instance_private(self); static const ClutterColor bg_colour = {0x00, 0x00, 0x00, 0x00}; MESSAGE("Init"); priv->widget = gtk_clutter_embed_new(); priv->stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(priv->widget)); priv->player = clutter_gst_playback_new(); priv->video_actor = clutter_actor_new(); priv->content = clutter_gst_aspectratio_new(); g_object_ref(priv->widget); g_object_set(priv->content, "player", priv->player, NULL); g_object_set(priv->video_actor, "content", priv->content, NULL); clutter_actor_add_child(priv->stage, priv->video_actor); clutter_actor_set_background_color(priv->stage, &bg_colour); /* clutter_gst_playback_set_buffering_mode(priv->player, CLUTTER_GST_BUFFERING_MODE_STREAM); // In-memory buffering (let user choose?) */ clutter_gst_playback_set_buffering_mode(priv->player, CLUTTER_GST_BUFFERING_MODE_DOWNLOAD); // On-disk buffering g_object_bind_property(self, "volume", priv->player, "audio-volume", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); g_object_bind_property(self, "uri", priv->player, "uri", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); g_object_bind_property(priv->player, "buffer-fill", self, "buffer-fill", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); g_signal_connect(priv->widget, "size-allocate", G_CALLBACK(size_allocate_cb), self); //TODO: Change this into a configure signal }
void AcceleratedCompositingContext::setRootCompositingLayer(GraphicsLayer* graphicsLayer) { if (!graphicsLayer) { gtk_container_remove(GTK_CONTAINER(m_webView), m_rootLayerEmbedder); m_rootLayerEmbedder = 0; m_rootLayer = nullptr; m_nonCompositedContentLayer = nullptr; return; } // Create an instance of GtkClutterEmbed to embed actors as GraphicsLayers. if (!m_rootLayerEmbedder) { m_rootLayerEmbedder = gtk_clutter_embed_new(); gtk_container_add(GTK_CONTAINER(m_webView), m_rootLayerEmbedder); GtkAllocation allocation; gtk_widget_get_allocation(GTK_WIDGET(m_webView), &allocation); gtk_widget_size_allocate(GTK_WIDGET(m_rootLayerEmbedder), &allocation); gtk_widget_show(m_rootLayerEmbedder); } // Add the accelerated layer tree hierarchy. initialize(); m_nonCompositedContentLayer->removeAllChildren(); m_nonCompositedContentLayer->addChild(graphicsLayer); // Add a root GraphicsLayer to the stage. if (graphicsLayer) { ClutterColor stageColor = { 0xFF, 0xFF, 0xFF, 0xFF }; ClutterActor* stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(m_rootLayerEmbedder)); clutter_stage_set_color(CLUTTER_STAGE(stage), &stageColor); clutter_container_add_actor(CLUTTER_CONTAINER(stage), m_rootLayer->platformLayer()); clutter_actor_show_all(stage); } scheduleLayerFlush(); }
void Preview::previewBlock(gint bnr, gint bcol) { ClutterActor *stage; stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (w)); int x, y; blocknr = bnr; color = bcol; for (x = 0; x < PREVIEW_WIDTH; x++) { for (y = 0; y < PREVIEW_HEIGHT; y++) { if ((blocknr != -1) && blockTable[blocknr][0][x][y]) { blocks[x][y].emptyCell (); blocks[x][y].what = LAYING; blocks[x][y].createActor (piece, blocks_cache_get_block_texture_by_id (cache, color), cell_size, cell_size); clutter_actor_set_position (CLUTTER_ACTOR(blocks[x][y].actor), x*cell_size, y*cell_size); } else { blocks[x][y].what = EMPTY; if (blocks[x][y].actor) blocks[x][y].emptyCell (); } } } gint center_x, center_y; center_x = (sizeTable[blocknr][0][1] * cell_size / 2) + (offsetTable[blocknr][0][1] * cell_size); center_y = (sizeTable[blocknr][0][0] * cell_size / 2) + (offsetTable[blocknr][0][0] * cell_size); clutter_actor_set_anchor_point (piece, center_x, center_y); clutter_actor_set_position (CLUTTER_ACTOR(piece), width / 2, height / 2); clutter_timeline_start (piece_timeline); }
static GObject * gb_player_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties) { GObject * obj; GbPlayerClass * klass; GObjectClass * parent_class; GbPlayer * self; klass = GB_PLAYER_CLASS (g_type_class_peek (GB_TYPE_PLAYER)); parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass)); obj = parent_class->constructor (type, n_construct_properties, construct_properties); self = GB_PLAYER (obj); GbPlayerPrivate *p = GB_PLAYER_GET_PRIVATE(self); p->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); p->stage_widget = gtk_clutter_embed_new (); gtk_widget_set_size_request (p->stage_widget, 640, 480); g_signal_connect (p->window, "delete-event", G_CALLBACK(gtk_main_quit), NULL); p->filechooser = gtk_file_chooser_dialog_new ("Choose the media file", GTK_WINDOW(p->window), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); gtk_container_add (GTK_CONTAINER(p->window), p->stage_widget); p->stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED(p->stage_widget)); p->play = gdk_pixbuf_new_from_file(IMG_PATH "/start.svg", NULL); p->backward = gdk_pixbuf_new_from_file(IMG_PATH "/backward.svg", NULL); p->forward = gdk_pixbuf_new_from_file(IMG_PATH "/forward.svg", NULL); p->stop = gdk_pixbuf_new_from_file(IMG_PATH "/stop.svg", NULL); p->pause = gdk_pixbuf_new_from_file(IMG_PATH "/pause.svg", NULL); p->fullscreen = gdk_pixbuf_new_from_file(IMG_PATH "/fullscreen.svg", NULL); p->unfullscreen = gdk_pixbuf_new_from_file(IMG_PATH "/unfullscreen.svg", NULL); p->open_file = gdk_pixbuf_new_from_file(IMG_PATH "/openfile.svg", NULL); p->bgpixbuf = gdk_pixbuf_new_from_file(IMG_PATH "/background.svg", NULL); p->bglogo = gdk_pixbuf_new_from_file(IMG_PATH "/logo.svg", NULL); p->time = 0; p->controls_visible = TRUE; p->last_second = -1; p->filename = NULL; p->playing = FALSE; p->player = gst_element_factory_make ("playbin", "player"); p->show_hide_timeline = clutter_timeline_new_for_duration (1000); g_signal_connect(p->show_hide_timeline, "completed", G_CALLBACK(on_timeline_completed), (gpointer) self); /* p->playback_timeline = clutter_timeline_new_for_duration (1000); */ /* g_signal_connect(p->playback_timeline, "new-frame", */ /* G_CALLBACK(playback_cb), */ /* (gpointer) self); */ /* clutter_timeline_set_loop(p->playback_timeline, TRUE); */ /* clutter_timeline_start(p->playback_timeline); */ _gb_player_setup_widgets (self); _gb_player_connect_signals (self); // TODO: conectar o sinal de mouse move no stage nas areas dos controles pra poder mostrar ou esconder os controles }
static void setup_window (void) { GtkWidget *vbox; GtkWidget *packing; GtkWidget *menubar; GtkUIManager *ui_manager; GtkAccelGroup *accel_group; ClutterColor stage_color = {0x00,0x00,0x00,0xff}; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); clutter_widget = gtk_clutter_embed_new (); stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter_widget)); clutter_stage_set_color (CLUTTER_STAGE(stage), &stage_color); clutter_actor_set_size (CLUTTER_ACTOR (stage), properties->tilesize * BOARDWIDTH, properties->tilesize * BOARDHEIGHT); clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), FALSE); board = gnibbles_board_new (); gtk_window_set_title (GTK_WINDOW (window), _("Nibbles")); gtk_window_set_default_size (GTK_WINDOW (window), DEFAULT_WIDTH, DEFAULT_HEIGHT); games_conf_add_window (GTK_WINDOW (window), KEY_PREFERENCES_GROUP); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (delete_cb), NULL); g_signal_connect (G_OBJECT (window), "window_state_event", G_CALLBACK (window_state_cb), NULL); gtk_widget_realize (window); vbox = gtk_vbox_new (FALSE, 0); games_stock_init (); ui_manager = gtk_ui_manager_new (); create_menus (ui_manager); set_fullscreen_actions (FALSE); notebook = gtk_notebook_new (); gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE); accel_group = gtk_ui_manager_get_accel_group (ui_manager); gtk_window_add_accel_group (GTK_WINDOW (window), accel_group); menubar = gtk_ui_manager_get_widget (ui_manager, "/MainMenu"); gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0); packing = games_grid_frame_new (BOARDWIDTH, BOARDHEIGHT); gtk_widget_show (packing); gtk_container_add (GTK_CONTAINER (packing), clutter_widget); #ifdef GGZ_CLIENT chat = create_chat_widget (); gtk_box_pack_start (GTK_BOX (vbox), chat, FALSE, TRUE, 0); #endif g_signal_connect (G_OBJECT (clutter_widget), "configure_event", G_CALLBACK (configure_event_cb), NULL); g_signal_connect (G_OBJECT (window), "focus_out_event", G_CALLBACK (show_cursor_cb), NULL); gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), packing, NULL); gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), MAIN_PAGE); statusbar = gtk_statusbar_new (); gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (window), vbox); gtk_widget_show_all (window); #ifdef GGZ_CLIENT gtk_widget_hide (chat); #endif scoreboard = gnibbles_scoreboard_new (statusbar); }
int main(int argc, char *argv[]) { ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff }; /* Call gtk_clutter_init() to init both clutter and gtk+ */ if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) g_error ("Unable to initialize GtkClutter"); if (argc != 2) g_error ("Usage: example <image file>"); /* Create a toplevel window: */ GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), 640, 480); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); /* Create a table to hold the scrollbars and the ClutterEmbed widget: */ GtkWidget *table = gtk_table_new (2, 2, FALSE); gtk_container_add (GTK_CONTAINER (window), table); gtk_widget_show (table); /* Create ClutterEmbed widget for the stage: */ GtkWidget *embed = gtk_clutter_embed_new (); gtk_table_attach (GTK_TABLE (table), embed, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (embed); /* Init the stage: */ ClutterActor *stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (embed)); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_actor_set_size (stage, 640, 480); /* Create a viewport actor to be able to scroll actor. By passing NULL it * will create new GtkAdjustments. */ ClutterActor *viewport = gtk_clutter_viewport_new (NULL, NULL, NULL); clutter_container_add_actor (CLUTTER_CONTAINER (stage), viewport); /* Load image from first command line argument and add it to viewport: */ ClutterActor *texture = clutter_texture_new_from_file (argv[1], NULL); clutter_container_add_actor (CLUTTER_CONTAINER (viewport), texture); clutter_actor_set_position (texture, 0, 0); clutter_actor_set_position (texture, 0, 0); clutter_actor_set_position (viewport, 0, 0); clutter_actor_set_size (viewport, 640, 480); /* Create scrollbars and connect them to viewport: */ GtkAdjustment *h_adjustment = NULL; GtkAdjustment *v_adjustment = NULL; gtk_clutter_scrollable_get_adjustments (GTK_CLUTTER_SCROLLABLE (viewport), &h_adjustment, &v_adjustment); GtkWidget *scrollbar = gtk_vscrollbar_new (v_adjustment); gtk_table_attach (GTK_TABLE (table), scrollbar, 1, 2, 0, 1, 0, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (scrollbar); scrollbar = gtk_hscrollbar_new (h_adjustment); gtk_table_attach (GTK_TABLE (table), scrollbar, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_widget_show (scrollbar); gtk_widget_show (window); gtk_main(); return EXIT_SUCCESS; }
static gboolean on_status_view_button_release (ClutterActor *actor, ClutterButtonEvent *event, TweetWindow *window) { TweetWindowPrivate *priv = window->priv; #define JITTER 5 if (priv->in_press) { TwitterStatus *status; ClutterModelIter *iter; ClutterGeometry geometry = { 0, }; ClutterActor *stage, *info; priv->in_press = FALSE; if (abs (priv->press_y - event->y) > JITTER) return FALSE; iter = clutter_model_get_iter_at_row (CLUTTER_MODEL (priv->status_model), priv->press_row); if (!iter) return FALSE; status = tweet_status_model_get_status (priv->status_model, iter); if (!status) { g_object_unref (iter); return FALSE; } /* FIXME - abstract this call into a TweetStatusModel method */ tidy_list_view_get_cell_geometry (TIDY_LIST_VIEW (priv->status_view), priv->press_row, 0, TRUE, &geometry); stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->canvas)); info = tweet_status_info_new (status); g_signal_connect (info, "button-press-event", G_CALLBACK (on_info_button_press), window); g_signal_connect (info, "star-clicked", G_CALLBACK (on_star_clicked), window); g_signal_connect (info, "reply-clicked", G_CALLBACK (on_reply_clicked), window); clutter_container_add_actor (CLUTTER_CONTAINER (stage), info); clutter_actor_set_position (info, geometry.x + CANVAS_PADDING, geometry.y + CANVAS_PADDING); clutter_actor_set_size (info, geometry.width, 16); clutter_actor_set_opacity (info, 0); clutter_actor_set_reactive (info, TRUE); clutter_actor_show (info); tweet_actor_animate (info, TWEET_LINEAR, 250, "y", tweet_interval_new (G_TYPE_INT, geometry.y + CANVAS_PADDING, 100 + CANVAS_PADDING), "height", tweet_interval_new (G_TYPE_INT, 16, (CANVAS_HEIGHT - (100 * 2))), "opacity", tweet_interval_new (G_TYPE_UCHAR, 0, 196), NULL); clutter_actor_set_reactive (priv->status_view, FALSE); tweet_actor_animate (priv->status_view, TWEET_LINEAR, 250, "opacity", tweet_interval_new (G_TYPE_UCHAR, 255, 128), NULL); g_object_unref (status); g_object_unref (iter); } #undef JITTER return FALSE; }
static void tweet_window_constructed (GObject *gobject) { TweetWindow *window = TWEET_WINDOW (gobject); TweetWindowPrivate *priv = window->priv; ClutterActor *stage; ClutterActor *view; ClutterActor *img; ClutterColor stage_color = { 0, 0, 0, 255 }; stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->canvas)); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); view = tweet_status_view_new (priv->status_model); g_signal_connect (view, "button-press-event", G_CALLBACK (on_status_view_button_press), window); g_signal_connect (view, "button-release-event", G_CALLBACK (on_status_view_button_release), window); priv->scroll = tidy_finger_scroll_new (TIDY_FINGER_SCROLL_MODE_KINETIC); clutter_container_add_actor (CLUTTER_CONTAINER (priv->scroll), view); clutter_actor_show (view); clutter_actor_set_reactive (view, TRUE); priv->status_view = view; clutter_actor_set_size (priv->scroll, CANVAS_WIDTH, CANVAS_HEIGHT); clutter_actor_set_position (priv->scroll, CANVAS_PADDING, CANVAS_PADDING); clutter_container_add_actor (CLUTTER_CONTAINER (stage), priv->scroll); clutter_actor_set_reactive (priv->scroll, TRUE); clutter_actor_show (priv->scroll); img = tweet_texture_new_from_stock (GTK_WIDGET (window), GTK_STOCK_REFRESH, GTK_ICON_SIZE_DIALOG); if (!img) g_warning ("Unable to load the `%s' stock icon", GTK_STOCK_REFRESH); priv->spinner = tweet_spinner_new (); tweet_spinner_set_image (TWEET_SPINNER (priv->spinner), img); clutter_container_add_actor (CLUTTER_CONTAINER (stage), priv->spinner); clutter_actor_set_size (priv->spinner, 128, 128); clutter_actor_set_anchor_point (priv->spinner, 64, 64); clutter_actor_set_position (priv->spinner, WINDOW_WIDTH / 2, CANVAS_HEIGHT / 2); clutter_actor_show (priv->spinner); tweet_spinner_start (TWEET_SPINNER (priv->spinner)); tweet_actor_animate (priv->spinner, TWEET_LINEAR, 500, "opacity", tweet_interval_new (G_TYPE_UCHAR, 0, 127), NULL); clutter_actor_show (stage); gtk_widget_show (GTK_WIDGET (window)); twitter_client_get_user_timeline (priv->client, NULL, 0, NULL); priv->refresh_id = g_timeout_add_seconds (tweet_config_get_refresh_time (priv->config), refresh_timeout, window); }
/** * Creates the windows and other objects required to do calibration * under GTK. When the window is closed (timed out, calibration finished * or user cancellation), callback will be called, where you should call * calib_area_finish(). */ CalibArea * calib_area_new (GdkScreen *screen, int monitor, int device_id, FinishCallback callback, gpointer user_data, XYinfo *old_axis, int threshold_doubleclick, int threshold_misclick) { CalibArea *calib_area; GdkRectangle rect; GdkVisual *visual; #ifndef FAKE_AREA GdkWindow *window; GdkCursor *cursor; #endif /* FAKE_AREA */ GtkWidget *clutter_embed; ClutterActor *stage; g_return_val_if_fail (old_axis, NULL); g_return_val_if_fail (callback, NULL); g_debug ("Current calibration: %d, %d, %d, %d\n", old_axis->x_min, old_axis->y_min, old_axis->x_max, old_axis->y_max); calib_area = g_new0 (CalibArea, 1); calib_area->callback = callback; calib_area->user_data = user_data; calib_area->device_id = device_id; calib_area->calibrator.old_axis.x_min = old_axis->x_min; calib_area->calibrator.old_axis.x_max = old_axis->x_max; calib_area->calibrator.old_axis.y_min = old_axis->y_min; calib_area->calibrator.old_axis.y_max = old_axis->y_max; calib_area->calibrator.threshold_doubleclick = threshold_doubleclick; calib_area->calibrator.threshold_misclick = threshold_misclick; calib_area->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); #ifndef FAKE_AREA /* No cursor */ gtk_widget_realize (calib_area->window); window = gtk_widget_get_window (calib_area->window); cursor = gdk_cursor_new_for_display (gdk_display_get_default (), GDK_BLANK_CURSOR); gdk_window_set_cursor (window, cursor); g_object_unref (cursor); gtk_widget_set_can_focus (calib_area->window, TRUE); gtk_window_set_keep_above (GTK_WINDOW (calib_area->window), TRUE); #endif /* FAKE_AREA */ /* Set up the embedded stage */ clutter_embed = gtk_clutter_embed_new (); gtk_container_add (GTK_CONTAINER (calib_area->window), clutter_embed); stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter_embed)); /* Move to correct screen */ if (screen == NULL) screen = gdk_screen_get_default (); gdk_screen_get_monitor_geometry (screen, monitor, &rect); gtk_window_move (GTK_WINDOW (calib_area->window), rect.x, rect.y); gtk_window_set_default_size (GTK_WINDOW (calib_area->window), rect.width, rect.height); calib_area->calibrator.geometry = rect; set_up_stage (calib_area, stage); g_signal_connect (calib_area->window, "delete-event", G_CALLBACK (on_delete_event), calib_area); g_signal_connect (calib_area->window, "focus-out-event", G_CALLBACK(on_focus_out_event), calib_area); g_signal_connect (calib_area->window, "window-state-event", G_CALLBACK (on_fullscreen), calib_area); gtk_window_fullscreen (GTK_WINDOW (calib_area->window)); visual = gdk_screen_get_rgba_visual (screen); if (visual != NULL) gtk_widget_set_visual (GTK_WIDGET (calib_area->window), visual); gtk_widget_show_all (calib_area->window); clutter_actor_hide (calib_area->action_layer); return calib_area; }
RendererFuncs *renderer_clutter_new(PixbufRenderer *pr) { RendererClutter *rc = g_new0(RendererClutter, 1); rc->pr = pr; rc->f.area_changed = rc_area_changed; rc->f.update_pixbuf = rc_update_pixbuf; rc->f.free = rc_free; rc->f.update_zoom = rc_update_zoom; rc->f.invalidate_region = rc_invalidate_region; rc->f.scroll = rc_scroll; rc->f.update_viewport = rc_update_viewport; rc->f.overlay_add = rc_overlay_add; rc->f.overlay_set = rc_overlay_set; rc->f.overlay_get = rc_overlay_get; rc->f.stereo_set = rc_stereo_set; rc->stereo_mode = 0; rc->stereo_off_x = 0; rc->stereo_off_y = 0; rc->idle_update = 0; rc->pending_updates = NULL; rc->widget = gtk_bin_get_child(GTK_BIN(rc->pr)); if (rc->widget) { if (!GTK_CLUTTER_IS_EMBED(rc->widget)) { g_free(rc); DEBUG_3("pixbuf renderer has a child of other type than gtk_clutter_embed"); return NULL; } } else { rc->widget = gtk_clutter_embed_new(); gtk_container_add(GTK_CONTAINER(rc->pr), rc->widget); } gtk_event_box_set_above_child (GTK_EVENT_BOX(rc->pr), TRUE); rc->stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (rc->widget)); rc->group = clutter_group_new(); clutter_container_add_actor(CLUTTER_CONTAINER(rc->stage), rc->group); clutter_actor_set_clip_to_allocation(CLUTTER_ACTOR(rc->group), TRUE); rc->texture = clutter_texture_new (); clutter_container_add_actor(CLUTTER_CONTAINER(rc->group), rc->texture); renderer_clutter_init_checker_shader(rc); g_object_ref(G_OBJECT(rc->widget)); gtk_widget_show(rc->widget); return (RendererFuncs *) rc; }
int main (int argc, char *argv[]) { ClutterTimeline *timeline; ClutterActor *stage; GtkWidget *window, *stack, *clutter; GtkWidget *label, *button, *vbox; GdkPixbuf *pixbuf; SuperOH *oh; gint i; GError *error; error = NULL; if (gtk_clutter_init_with_args (&argc, &argv, NULL, NULL, NULL, &error) != CLUTTER_INIT_SUCCESS) { if (error) { g_critical ("Unable to initialize Clutter-GTK: %s", error->message); g_error_free (error); return EXIT_FAILURE; } else g_error ("Unable to initialize Clutter-GTK"); } /* calling gtk_clutter_init* multiple times should be safe */ g_assert (gtk_clutter_init (NULL, NULL) == CLUTTER_INIT_SUCCESS); pixbuf = gdk_pixbuf_new_from_file (EXAMPLES_DATADIR G_DIR_SEPARATOR_S "redhand.png", NULL); if (!pixbuf) g_error("pixbuf load failed"); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), WINWIDTH, WINHEIGHT); gtk_window_set_title (GTK_WINDOW (window), "Clutter Embedding"); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); vbox = gtk_grid_new (); gtk_orientable_set_orientation (GTK_ORIENTABLE (vbox), GTK_ORIENTATION_VERTICAL); gtk_widget_set_hexpand (vbox, TRUE); gtk_widget_set_vexpand (vbox, TRUE); gtk_container_add (GTK_CONTAINER (window), vbox); stack = gtk_stack_new (); gtk_container_add (GTK_CONTAINER (vbox), stack); label = gtk_label_new ("This is a label in a stack"); gtk_stack_add_named (GTK_STACK (stack), label, "label"); clutter = gtk_clutter_embed_new (); gtk_stack_add_named (GTK_STACK (stack), clutter, "clutter"); gtk_widget_realize (clutter); stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter)); clutter_actor_set_background_color (stage, CLUTTER_COLOR_LightSkyBlue); label = gtk_label_new ("This is a label"); gtk_container_add (GTK_CONTAINER (vbox), label); gtk_widget_set_hexpand (label, TRUE); button = gtk_button_new_with_label ("This is a button...clicky"); g_signal_connect (button, "clicked", G_CALLBACK (clickity), stack); gtk_container_add (GTK_CONTAINER (vbox), button); gtk_widget_set_hexpand (button, TRUE); button = gtk_button_new_with_mnemonic ("_Fullscreen"); g_signal_connect (button, "clicked", G_CALLBACK (on_fullscreen), window); gtk_container_add (GTK_CONTAINER (vbox), button); gtk_widget_set_hexpand (button, TRUE); button = gtk_button_new_with_mnemonic ("_Quit"); g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window); gtk_container_add (GTK_CONTAINER (vbox), button); gtk_widget_set_hexpand (button, TRUE); oh = g_new (SuperOH, 1); oh->stage = stage; oh->group = clutter_actor_new (); clutter_actor_set_pivot_point (oh->group, 0.5, 0.5); for (i = 0; i < NHANDS; i++) { gint x, y, w, h; /* Create a texture from pixbuf, then clone in to same resources */ if (i == 0) { oh->hand[i] = gtk_clutter_texture_new (); gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (oh->hand[i]), pixbuf, NULL); } else oh->hand[i] = clutter_clone_new (oh->hand[0]); /* Place around a circle */ w = clutter_actor_get_width (oh->hand[0]); h = clutter_actor_get_height (oh->hand[0]); x = WINWIDTH / 2 + RADIUS * cos (i * M_PI / (NHANDS / 2)) - w / 2; y = WINHEIGHT / 2 + RADIUS * sin (i * M_PI / (NHANDS / 2)) - h / 2; clutter_actor_set_position (oh->hand[i], x, y); clutter_actor_set_pivot_point (oh->hand[i], 0.5, 0.5); /* Add to our group group */ clutter_actor_add_child (oh->group, oh->hand[i]); } /* Add the group to the stage */ clutter_actor_add_child (stage, oh->group); clutter_actor_add_constraint (oh->group, clutter_align_constraint_new (oh->stage, CLUTTER_ALIGN_BOTH, 0.5)); g_signal_connect (stage, "button-press-event", G_CALLBACK (input_cb), oh); g_signal_connect (stage, "key-release-event", G_CALLBACK (input_cb), oh); gtk_widget_show_all (window); /* Create a timeline to manage animation */ timeline = clutter_timeline_new (6000); clutter_timeline_set_repeat_count (timeline, -1); /* fire a callback for frame change */ g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), oh); /* and start it */ clutter_timeline_start (timeline); gtk_main (); return 0; }
/* Gobj */ static void bjb_window_base_init (BjbWindowBase *self) { BjbWindowBasePriv *priv; const gchar *icons_path; gchar *full_path; GList *icons = NULL; GdkPixbuf *bjb ; GError *error = NULL ; GtkClutterEmbed *embed; self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self, BJB_TYPE_WINDOW_BASE, BjbWindowBasePriv); priv = self->priv; gtk_window_set_default_size (GTK_WINDOW (self), BJB_WIDTH, BJB_HEIGHT); gtk_window_set_position (GTK_WINDOW (self),GTK_WIN_POS_CENTER); gtk_window_set_title (GTK_WINDOW (self), BIJIBEN_MAIN_WIN_TITLE); /* Icon for window. TODO - Should be BjbApp */ icons_path = bijiben_get_bijiben_dir (); full_path = g_build_filename (icons_path, "icons", "hicolor", "48x48", "apps", "bijiben.png", NULL); bjb = gdk_pixbuf_new_from_file (full_path, &error); g_free (full_path); if ( error ) { g_message("%s", error->message); g_error_free(error); } icons = g_list_prepend(icons,bjb); gtk_window_set_default_icon_list(icons); g_list_foreach (icons, (GFunc) g_object_unref, NULL); g_list_free (icons); /* We probably want to offer a no entry window at first (startup) */ priv->entry = NULL ; priv->tags = get_all_tracker_tags(); priv->font = pango_font_description_from_string (BJB_DEFAULT_FONT); /* UI */ embed = GTK_CLUTTER_EMBED (gtk_clutter_embed_new()); gtk_clutter_embed_set_use_layout_size (embed, TRUE); gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (embed)); priv->stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (embed)); /* Signals */ g_signal_connect(GTK_WIDGET(self),"destroy", G_CALLBACK(bjb_window_base_destroy),self); }
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[]) { ClutterTimeline *timeline; ClutterActor *stage; ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff }; ClutterConstraint *constraint; GtkWidget *window, *clutter; GtkWidget *label, *button, *vbox; GdkPixbuf *pixbuf; SuperOH *oh; gint i; GError *error; error = NULL; gtk_clutter_init_with_args (&argc, &argv, NULL, NULL, NULL, &error); if (error) g_error ("Unable to initialize: %s", error->message); pixbuf = gdk_pixbuf_new_from_file ("redhand.png", NULL); if (!pixbuf) g_error("pixbuf load failed"); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); vbox = gtk_vbox_new (FALSE, 6); gtk_container_add (GTK_CONTAINER (window), vbox); clutter = gtk_clutter_embed_new (); gtk_widget_set_size_request (clutter, WINWIDTH, WINHEIGHT); gtk_container_add (GTK_CONTAINER (vbox), clutter); stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter)); label = gtk_label_new ("This is a label"); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); button = gtk_button_new_with_label ("This is a button...clicky"); g_signal_connect (button, "clicked", G_CALLBACK (clickity), NULL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); button = gtk_button_new_with_label ("Fullscreen"); gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_stock (GTK_STOCK_FULLSCREEN, GTK_ICON_SIZE_BUTTON)); g_signal_connect (button, "clicked", G_CALLBACK (on_fullscreen), window); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); button = gtk_button_new_from_stock (GTK_STOCK_QUIT); g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window); gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0); /* and its background color */ clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); oh = g_new (SuperOH, 1); oh->stage = stage; /* create a new group to hold multiple actors in a group */ oh->group = clutter_group_new (); for (i = 0; i < NHANDS; i++) { gint x, y, w, h; /* Create a texture from pixbuf, then clone in to same resources */ if (i == 0) { oh->hand[i] = gtk_clutter_texture_new (); gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (oh->hand[i]), pixbuf, NULL); } else oh->hand[i] = clutter_clone_new (oh->hand[0]); /* Place around a circle */ w = clutter_actor_get_width (oh->hand[0]); h = clutter_actor_get_height (oh->hand[0]); x = WINWIDTH/2 + RADIUS * cos (i * M_PI / (NHANDS/2)) - w/2; y = WINHEIGHT/2 + RADIUS * sin (i * M_PI / (NHANDS/2)) - h/2; clutter_actor_set_position (oh->hand[i], x, y); /* Add to our group group */ clutter_container_add_actor (CLUTTER_CONTAINER (oh->group), oh->hand[i]); } /* Add the group to the stage */ clutter_container_add_actor (CLUTTER_CONTAINER (stage), CLUTTER_ACTOR (oh->group)); constraint = clutter_align_constraint_new (oh->stage, CLUTTER_ALIGN_X_AXIS, 0.5); clutter_actor_add_constraint (oh->group, constraint); constraint = clutter_align_constraint_new (oh->stage, CLUTTER_ALIGN_Y_AXIS, 0.5); clutter_actor_add_constraint (oh->group, constraint); g_signal_connect (stage, "button-press-event", G_CALLBACK (input_cb), oh); g_signal_connect (stage, "key-release-event", G_CALLBACK (input_cb), oh); gtk_widget_show_all (window); /* Only show the actors after parent show otherwise it will just be * unrealized when the clutter foreign window is set. widget_show * will call show on the stage. */ clutter_actor_show_all (CLUTTER_ACTOR (oh->group)); /* Create a timeline to manage animation */ timeline = clutter_timeline_new (6000); g_object_set(timeline, "loop", TRUE, NULL); /* have it loop */ /* fire a callback for frame change */ g_signal_connect(timeline, "new-frame", G_CALLBACK (frame_cb), oh); /* and start it */ clutter_timeline_start (timeline); gtk_main(); return 0; }
GtkWidget *main_window(){ GtkWidget *vbox, *hpane, *vpane, *swin, *vbox2, *stage_width_entry, *stage_height_entry, *rectangle_button; WebKitWebView *web_view; ClutterActor *stage; ClutterColor stage_bg_color = { 128, 128, 128, 255 }, white = { 255, 255, 255, 255 } ; // Create widgets app.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); app.menubar = gtk_menu_bar_new(); app.toolbar = gtk_toolbar_new(); hpane = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL); vpane = gtk_paned_new(GTK_ORIENTATION_VERTICAL); app.statusbar = gtk_statusbar_new(); app.stage = gtk_clutter_embed_new(); app.notebook = gtk_notebook_new(); web_view= WEBKIT_WEB_VIEW(webkit_web_view_new()); swin = gtk_scrolled_window_new(NULL, NULL); vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); stage_width_entry = gtk_spin_button_new_with_range(0, 9999, 1); stage_height_entry = gtk_spin_button_new_with_range(0, 9999, 1); app.colorpicker = gtk_color_button_new(); app.fileselector = gtk_file_chooser_button_new("Background image", GTK_FILE_CHOOSER_ACTION_OPEN); app.background_repeat_select = gtk_combo_box_text_new(); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(app.background_repeat_select), "no-repeat"); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(app.background_repeat_select), "repeat-x"); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(app.background_repeat_select), "repeat-y"); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(app.background_repeat_select), "repeat-xy"); stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(app.stage)); rectangle_button = gtk_button_new_from_stock(GTK_STOCK_NEW); app.mainstage = clutter_rectangle_new_with_color(&white); // Pack widgets gtk_container_add(GTK_CONTAINER(app.window), vbox); gtk_box_pack_start(GTK_BOX(vbox), app.menubar, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), app.toolbar, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), app.notebook, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), app.statusbar, FALSE, FALSE, 0); gtk_notebook_append_page(GTK_NOTEBOOK(app.notebook), vpane, gtk_label_new("Animator")); gtk_notebook_append_page(GTK_NOTEBOOK(app.notebook), swin, gtk_label_new("Browser")); gtk_notebook_append_page(GTK_NOTEBOOK(app.notebook), gtk_label_new("tbc"), gtk_label_new("Source")); gtk_container_add(GTK_CONTAINER(swin), GTK_WIDGET(web_view)); gtk_paned_pack1(GTK_PANED(vpane), hpane, TRUE, TRUE); gtk_paned_pack2(GTK_PANED(vpane), gtk_label_new("Timeline"), FALSE, TRUE); gtk_paned_pack1(GTK_PANED(hpane), app.stage,TRUE, TRUE); gtk_paned_pack2(GTK_PANED(hpane), vbox2, FALSE, TRUE); gtk_box_pack_start(GTK_BOX(vbox2), stage_width_entry, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox2), stage_height_entry, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox2), app.colorpicker, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox2), app.fileselector, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox2), app.background_repeat_select, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox2), rectangle_button, FALSE, FALSE, 0); //Setup widgets gtk_paned_set_position(GTK_PANED(hpane), 600); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); webkit_web_view_load_uri(web_view, "http://www.webkitgtk.org/"); gtk_widget_set_size_request(app.stage, 800, 600); gtk_paned_set_position(GTK_PANED(hpane), 600); gtk_spin_button_set_value(GTK_SPIN_BUTTON(stage_width_entry), 300); gtk_spin_button_set_value(GTK_SPIN_BUTTON(stage_height_entry), 200); g_object_set_data(G_OBJECT(stage_width_entry), "type", "width"); g_object_set_data(G_OBJECT(stage_height_entry), "type", "height"); clutter_stage_set_user_resizable(CLUTTER_STAGE(stage), FALSE); gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(app.colorpicker), TRUE); gtk_combo_box_set_active(GTK_COMBO_BOX(app.background_repeat_select), 0); clutter_actor_set_background_color(stage, &stage_bg_color); clutter_actor_set_size(app.mainstage, 400, 300); clutter_actor_set_position(app.mainstage, 100, 100); clutter_actor_add_child(stage, app.mainstage); clutter_actor_show(app.mainstage); clutter_actor_show(stage); // Connect signals g_signal_connect(app.fileselector, "file-set", G_CALLBACK(on_file_set), NULL); g_signal_connect(app.window, "destroy", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(stage_width_entry, "value-changed", G_CALLBACK(on_stage_dim_changed), stage); g_signal_connect(stage_height_entry, "value-changed", G_CALLBACK(on_stage_dim_changed), stage); g_signal_connect(rectangle_button, "clicked", G_CALLBACK(on_new_button_clicked), NULL); return (app.window); }