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); } }
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 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(); }
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 * glide_window_make_embed () { GtkWidget *embed = gtk_clutter_embed_new (); // TODO: Leaks signal. g_signal_connect (embed, "enter-notify-event", G_CALLBACK (glide_window_stage_enter_notify), NULL); gtk_widget_set_can_focus (embed, TRUE); return embed; }
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 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(); }
static void tweet_window_init (TweetWindow *window) { TweetWindowPrivate *priv; GtkWidget *hbox, *button; GTK_WINDOW (window)->type = GTK_WINDOW_TOPLEVEL; gtk_window_set_resizable (GTK_WINDOW (window), FALSE); gtk_window_set_title (GTK_WINDOW (window), "Tweet"); gtk_widget_set_size_request (GTK_WIDGET (window), WINDOW_WIDTH, -1); window->priv = priv = TWEET_WINDOW_GET_PRIVATE (window); priv->vbox = gtk_vbox_new (FALSE, 6); gtk_container_add (GTK_CONTAINER (window), priv->vbox); gtk_widget_show (priv->vbox); priv->canvas = gtk_clutter_embed_new (); gtk_widget_set_size_request (priv->canvas, CANVAS_WIDTH, CANVAS_HEIGHT); gtk_container_add (GTK_CONTAINER (priv->vbox), priv->canvas); gtk_widget_show (priv->canvas); hbox = gtk_hbox_new (FALSE, 12); gtk_box_pack_end (GTK_BOX (priv->vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); priv->entry = gtk_entry_new (); gtk_box_pack_start (GTK_BOX (hbox), priv->entry, TRUE, TRUE, 0); gtk_widget_set_tooltip_text (priv->entry, "Update your status"); gtk_widget_show (priv->entry); g_signal_connect (priv->entry, "activate", G_CALLBACK (on_entry_activate), window); g_signal_connect (priv->entry, "changed", G_CALLBACK (on_entry_changed), window); priv->counter = gtk_label_new ("<span color='green'>0</span>"); gtk_label_set_use_markup (GTK_LABEL (priv->counter), TRUE); gtk_box_pack_start (GTK_BOX (hbox), priv->counter, FALSE, FALSE, 0); gtk_widget_show (priv->counter); button = gtk_button_new (); gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_stock (GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_BUTTON)); gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_set_sensitive (button, FALSE); gtk_widget_show (button); g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_activate), priv->entry); priv->send_button = button; priv->status_model = TWEET_STATUS_MODEL (tweet_status_model_new ()); priv->config = tweet_config_get_default (); priv->client = twitter_client_new_for_user (tweet_config_get_username (priv->config), tweet_config_get_password (priv->config)); g_signal_connect (priv->client, "status-received", G_CALLBACK (on_status_received), window); g_signal_connect (priv->client, "timeline-complete", G_CALLBACK (on_timeline_complete), window); }
int main (int argc, char **argv) { GtkWidget *window, *embed, *vbox, *menubar, *vpaned, *textpanel; ClutterActor *stage, *grid_view; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); g_thread_init (NULL); profile_timer = g_timer_new (); clutter_init (&argc, &argv); gtk_init(&argc, &argv); g_set_application_name("GNOME Social Zone"); mx_style_load_from_file (mx_style_get_default (), THEMEDIR "/panel.css", NULL); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), _("GNOME Social Zone")); gtk_window_set_icon_name (GTK_WINDOW (window), "gnome-social-zone"); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), vbox); menubar = get_menubar_menu (GTK_WIDGET(window)); vpaned = gtk_vpaned_new (); gtk_box_pack_start(GTK_BOX (vbox), menubar, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX (vbox), vpaned, TRUE, TRUE, 0); embed = gtk_clutter_embed_new (); gtk_paned_pack1 (GTK_PANED (vpaned), GTK_WIDGET(embed), FALSE, FALSE); textpanel = get_text_panel(); gtk_paned_pack2 (GTK_PANED (vpaned), textpanel, TRUE, TRUE); stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (embed)); clutter_actor_realize (stage); grid_view = g_object_new (PENGE_TYPE_GRID_VIEW, NULL); clutter_container_add_actor (CLUTTER_CONTAINER (stage), (ClutterActor *)grid_view); clutter_actor_set_size ((ClutterActor *)grid_view, 1016, 536); gtk_widget_set_size_request (embed, 1016, 536); clutter_actor_show_all (stage); gtk_widget_show_all (GTK_WIDGET(window)); g_signal_connect_after (stage, "paint", (GCallback)_stage_paint_cb, NULL); g_message (G_STRLOC ": PROFILE: Main loop started: %f", g_timer_elapsed (profile_timer, NULL)); gtk_main(); return 0; }
GnibblesBoard * gnibbles_board_new (gint t_w, gint t_h) { ClutterColor stage_color = {0x00,0x00,0x00,0xff}; GnibblesBoard *board = g_new (GnibblesBoard, 1); board->width = t_w; board->height = t_h; board->level = NULL; board->surface =NULL; board->clutter_widget = gtk_clutter_embed_new (); ClutterActor *stage; load_pixmap (); stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (board->clutter_widget)); clutter_stage_set_color (CLUTTER_STAGE(stage), &stage_color); clutter_stage_set_user_resizable (CLUTTER_STAGE(stage), FALSE); clutter_actor_set_size (CLUTTER_ACTOR (stage), properties->tilesize * BOARDWIDTH, properties->tilesize * BOARDHEIGHT); clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), FALSE); clutter_actor_show (stage); gchar *filename; const char *dirname; dirname = games_runtime_get_directory (GAMES_RUNTIME_GAME_PIXMAP_DIRECTORY); filename = g_build_filename (dirname, "wall-small-empty.svg", NULL); /* Using ClutterScript to set special texture property such as "repeat-x", * "repeat-y" and "keep-aspect-ratio" */ gchar texture_script[200]; g_sprintf (texture_script, "[" " {" " \"id\" : \"surface\"," " \"type\" : \"ClutterTexture\"," " \"filename\" : \"%s\"," " \"x\" : 0," " \"y\" : 0," " \"width\" : %d," " \"height\" : %d," " \"keep-aspect-ratio\" : true" " \"visible\" : true," " \"repeat-x\" : true," " \"repeat-y\" : true" " }" "]", filename, properties->tilesize, properties->tilesize); ClutterScript *script = clutter_script_new (); clutter_script_load_from_data (script, texture_script, -1, NULL); clutter_script_get_objects (script, "surface", &(board->surface), NULL); clutter_actor_set_size (CLUTTER_ACTOR (board->surface), properties->tilesize * BOARDWIDTH, properties->tilesize * BOARDHEIGHT); clutter_container_add_actor (CLUTTER_CONTAINER (stage), board->surface); clutter_actor_show (board->surface); g_object_unref (script); return board; }
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 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 }
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); }
int main (int argc, char *argv[]) { ClutterActor *stage0, *stage1, *stage2, *tex1, *tex2; GtkWidget *window, *clutter0, *clutter1, *clutter2; GtkWidget *notebook, *vbox; ClutterColor col0 = { 0xdd, 0xff, 0xdd, 0xff }; ClutterColor col1 = { 0xff, 0xff, 0xff, 0xff }; ClutterColor col2 = { 0, 0, 0, 0xff }; if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) g_error ("Unable to initialize GtkClutter"); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); notebook = gtk_notebook_new (); gtk_container_add (GTK_CONTAINER (window), notebook); clutter0 = gtk_clutter_embed_new (); gtk_widget_set_size_request (clutter0, 320, 320); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), clutter0, gtk_label_new ("One stage")); stage0 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter0)); clutter_stage_set_color (CLUTTER_STAGE (stage0), &col0); vbox = gtk_vbox_new (FALSE, 6); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, gtk_label_new ("Two stages")); clutter1 = gtk_clutter_embed_new (); gtk_widget_set_size_request (clutter1, 320, 240); stage1 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter1)); clutter_stage_set_color (CLUTTER_STAGE(stage1), &col1); tex1 = gtk_clutter_texture_new (); gtk_clutter_texture_set_from_stock (GTK_CLUTTER_TEXTURE (tex1), clutter1, GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG, NULL); clutter_actor_set_anchor_point (tex1, clutter_actor_get_width (tex1) / 2, clutter_actor_get_height (tex1) / 2); clutter_actor_set_position (tex1, 160, 120); clutter_stage_add (stage1, tex1); clutter_actor_show (tex1); gtk_container_add (GTK_CONTAINER (vbox), clutter1); clutter2 = gtk_clutter_embed_new (); gtk_widget_set_size_request (clutter2, 320, 120); stage2 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter2)); clutter_stage_set_color (CLUTTER_STAGE(stage2), &col2); tex2 = gtk_clutter_texture_new (); gtk_clutter_texture_set_from_icon_name (GTK_CLUTTER_TEXTURE (tex2), clutter1, "user-info", GTK_ICON_SIZE_BUTTON, NULL); clutter_actor_set_anchor_point (tex2, clutter_actor_get_width (tex2) / 2, clutter_actor_get_height (tex2) / 2); clutter_actor_set_position (tex2, 160, 60); clutter_stage_add (stage2, tex2); gtk_container_add (GTK_CONTAINER (vbox), clutter2); g_signal_connect (stage2, "allocation-changed", G_CALLBACK (on_stage2_allocation_changed), tex2); gtk_widget_show_all (window); gtk_main(); return 0; }
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[]) { 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; }
int main (int argc, char *argv[]) { ClutterTimeline *timeline; ClutterActor *stage; ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff }; GtkWidget *window, *clutter; GtkWidget *button, *vbox; gint i; if (gtk_clutter_init_with_args (&argc, &argv, NULL, NULL, NULL, NULL) != CLUTTER_INIT_SUCCESS) g_error ("Unable to initialize GtkClutter"); if (argc != 1) do_rotate = FALSE; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_container_add (GTK_CONTAINER (window), vbox); clutter = gtk_clutter_embed_new (); gtk_widget_set_size_request (clutter, WINWIDTH, WINHEIGHT); gtk_box_pack_start (GTK_BOX (vbox), clutter, TRUE, TRUE, 0); stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter)); button = gtk_button_new_with_mnemonic ("_Quit"); g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window); gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0); clutter_actor_set_background_color (stage, &stage_color); nwidgets = 0; /* create a new group to hold multiple actors in a group */ group = clutter_actor_new (); clutter_actor_set_pivot_point (group, 0.5, 0.5); for (i = 0; i < MAX_NWIDGETS; i++) { widgets[i] = create_gtk_actor (i); nwidgets++; add_clutter_actor (widgets[i], group, i); } /* Add the group to the stage and center it*/ clutter_actor_add_child (stage, group); clutter_actor_add_constraint (group, clutter_align_constraint_new (stage, CLUTTER_ALIGN_BOTH, 0.5)); 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), stage); /* and start it */ clutter_timeline_start (timeline); g_timeout_add_seconds (3, add_or_remove_timeout, NULL); gtk_main(); return 0; }
/** * 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; }
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[]) { ClutterActor *stage0, *stage1, *stage2, *tex1, *tex2; GtkWidget *window, *clutter0, *clutter1, *clutter2; GtkWidget *notebook, *vbox; ClutterColor col0 = { 0xdd, 0xff, 0xdd, 0xff }; ClutterColor col1 = { 0xff, 0xff, 0xff, 0xff }; ClutterColor col2 = { 0, 0, 0, 0xff }; if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) g_error ("Unable to initialize GtkClutter"); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), 600, 400); gtk_window_set_title (GTK_WINDOW (window), "Multiple GtkClutterEmbed"); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); notebook = gtk_notebook_new (); gtk_container_add (GTK_CONTAINER (window), notebook); clutter0 = gtk_clutter_embed_new (); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), clutter0, gtk_label_new ("One stage")); stage0 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter0)); clutter_actor_set_background_color (stage0, &col0); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, gtk_label_new ("Two stages")); clutter1 = gtk_clutter_embed_new (); gtk_widget_set_size_request (clutter1, 320, 240); stage1 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter1)); clutter_actor_set_background_color (stage1, &col1); tex1 = gtk_clutter_texture_new (); gtk_clutter_texture_set_from_icon_name (GTK_CLUTTER_TEXTURE (tex1), clutter1, "dialog-information", GTK_ICON_SIZE_DIALOG, NULL); clutter_actor_set_position (tex1, 160 - clutter_actor_get_width (tex1) / 2.0, 120 - clutter_actor_get_height (tex1) / 2.0); clutter_actor_add_child (stage1, tex1); clutter_actor_show (tex1); gtk_container_add (GTK_CONTAINER (vbox), clutter1); clutter2 = gtk_clutter_embed_new (); gtk_widget_set_size_request (clutter2, 320, 120); stage2 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter2)); clutter_actor_set_background_color (stage2, &col2); tex2 = gtk_clutter_texture_new (); gtk_clutter_texture_set_from_icon_name (GTK_CLUTTER_TEXTURE (tex2), clutter1, "user-info", GTK_ICON_SIZE_BUTTON, NULL); clutter_actor_add_constraint (tex2, clutter_align_constraint_new (stage2, CLUTTER_ALIGN_BOTH, .5)); clutter_actor_add_child (stage2, tex2); gtk_container_add (GTK_CONTAINER (vbox), clutter2); gtk_widget_show_all (window); gtk_main(); return 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; }
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; }