/* test custom positioning */ static GtkWidget * test_relative (void) { GtkWidget *win; GtkWidget *grid; GtkWidget *overlay; GtkWidget *text; GtkWidget *child; GdkRGBA color; win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (win), "Custom positioning"); overlay = gtk_overlay_new (); gdk_rgba_parse (&color, "yellow"); G_GNUC_BEGIN_IGNORE_DEPRECATIONS gtk_widget_override_background_color (overlay, 0, &color); G_GNUC_END_IGNORE_DEPRECATIONS gtk_container_add (GTK_CONTAINER (win), overlay); grid = gtk_grid_new (); gtk_container_add (GTK_CONTAINER (overlay), grid); gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Above"), 1, 0, 1, 1); gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Below"), 1, 2, 1, 1); gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Left"), 0, 1, 1, 1); gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Right"), 2, 1, 1, 1); text = gtk_text_view_new (); gtk_widget_set_size_request (text, 200, 200); g_object_set (text, "margin", 5, NULL); gtk_widget_set_hexpand (text, TRUE); gtk_widget_set_vexpand (text, TRUE); gtk_grid_attach (GTK_GRID (grid), text, 1, 1, 1, 1); g_signal_connect (overlay, "get-child-position", G_CALLBACK (get_child_position), text); child = gtk_label_new ("Top left overlay"); gtk_widget_set_halign (child, GTK_ALIGN_START); gtk_widget_set_valign (child, GTK_ALIGN_START); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child); g_object_set (child, "margin", 1, NULL); child = gtk_label_new ("Bottom right overlay"); gtk_widget_set_halign (child, GTK_ALIGN_END); gtk_widget_set_valign (child, GTK_ALIGN_END); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child); g_object_set (child, "margin", 1, NULL); return win; }
/* test that margins and non-zero allocation x/y * of the main widget are handled correctly */ static GtkWidget * test_nonzerox (void) { GtkWidget *win; GtkWidget *grid; GtkWidget *overlay; GtkWidget *text; GtkWidget *child; GdkRGBA color; win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (win), "Non-zero X"); grid = gtk_grid_new (); g_object_set (grid, "margin", 5, NULL); gtk_container_add (GTK_CONTAINER (win), grid); gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Above"), 1, 0, 1, 1); gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Below"), 1, 2, 1, 1); gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Left"), 0, 1, 1, 1); gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Right"), 2, 1, 1, 1); overlay = gtk_overlay_new (); gdk_rgba_parse (&color, "red"); G_GNUC_BEGIN_IGNORE_DEPRECATIONS gtk_widget_override_background_color (overlay, 0, &color); G_GNUC_END_IGNORE_DEPRECATIONS gtk_grid_attach (GTK_GRID (grid), overlay, 1, 1, 1, 1); text = gtk_text_view_new (); gtk_widget_set_size_request (text, 200, 200); gtk_widget_set_hexpand (text, TRUE); gtk_widget_set_vexpand (text, TRUE); gtk_container_add (GTK_CONTAINER (overlay), text); child = gtk_label_new ("I'm the overlay"); gtk_widget_set_halign (child, GTK_ALIGN_START); gtk_widget_set_valign (child, GTK_ALIGN_START); g_object_set (child, "margin", 3, NULL); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child); child = gtk_label_new ("No, I'm the overlay"); gtk_widget_set_halign (child, GTK_ALIGN_END); gtk_widget_set_valign (child, GTK_ALIGN_END); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child); g_object_set (child, "margin", 3, NULL); return win; }
/* test GTK_ALIGN_FILL handling */ static GtkWidget * test_fullwidth (void) { GtkWidget *win; GtkWidget *overlay; GtkWidget *text; GtkWidget *child; win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (win), "Full-width"); overlay = gtk_overlay_new (); gtk_container_add (GTK_CONTAINER (win), overlay); text = gtk_text_view_new (); gtk_widget_set_size_request (text, 200, 200); gtk_widget_set_hexpand (text, TRUE); gtk_widget_set_vexpand (text, TRUE); gtk_container_add (GTK_CONTAINER (overlay), text); child = gtk_label_new ("Fullwidth top overlay"); gtk_widget_set_halign (child, GTK_ALIGN_FILL); gtk_widget_set_valign (child, GTK_ALIGN_START); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child); g_object_set (child, "margin", 4, NULL); return win; }
static void gtk_color_editor_init (GtkColorEditor *editor) { GdkRGBA transparent = { 0, 0, 0, 0 }; editor->priv = G_TYPE_INSTANCE_GET_PRIVATE (editor, GTK_TYPE_COLOR_EDITOR, GtkColorEditorPrivate); editor->priv->use_alpha = TRUE; g_type_ensure (GTK_TYPE_COLOR_SCALE); g_type_ensure (GTK_TYPE_COLOR_PLANE); g_type_ensure (GTK_TYPE_COLOR_SWATCH); gtk_widget_init_template (GTK_WIDGET (editor)); /* Some post processing is needed in code to set this up */ gtk_widget_set_events (editor->priv->swatch, gtk_widget_get_events (editor->priv->swatch) & ~(GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK)); if (gtk_widget_get_direction (editor->priv->h_slider) == GTK_TEXT_DIR_RTL) gtk_style_context_add_class (gtk_widget_get_style_context (editor->priv->h_slider), GTK_STYLE_CLASS_SCALE_HAS_MARKS_ABOVE); else gtk_style_context_add_class (gtk_widget_get_style_context (editor->priv->h_slider), GTK_STYLE_CLASS_SCALE_HAS_MARKS_BELOW); gtk_widget_override_background_color (editor->priv->overlay, 0, &transparent); /* Create the scaled popup adjustments manually here because connecting user data is not * supported by template GtkBuilder xml (it would be possible to set this up in the xml * but require 4 separate callbacks and would be rather ugly). */ gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (editor->priv->h_entry), scaled_adjustment (editor->priv->h_adj, 100)); gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (editor->priv->s_entry), scaled_adjustment (editor->priv->s_adj, 100)); gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (editor->priv->v_entry), scaled_adjustment (editor->priv->v_adj, 100)); gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (editor->priv->a_entry), scaled_adjustment (editor->priv->a_adj, 100)); /* This can be setup in the .ui file, but requires work in Glade otherwise it cannot be edited there */ gtk_overlay_add_overlay (GTK_OVERLAY (editor->priv->overlay), editor->priv->sv_popup); gtk_overlay_add_overlay (GTK_OVERLAY (editor->priv->overlay), editor->priv->h_popup); gtk_overlay_add_overlay (GTK_OVERLAY (editor->priv->overlay), editor->priv->a_popup); }
static void photos_tool_filter_button_init (PhotosToolFilterButton *self) { self->overlay = gtk_overlay_new (); self->selected_image = gtk_image_new_from_icon_name ("object-select-symbolic", GTK_ICON_SIZE_INVALID); gtk_widget_set_halign (self->selected_image, GTK_ALIGN_CENTER); gtk_widget_set_valign (self->selected_image, GTK_ALIGN_CENTER); gtk_widget_set_no_show_all (self->selected_image, TRUE); gtk_image_set_pixel_size (GTK_IMAGE (self->selected_image), 48); gtk_overlay_add_overlay (GTK_OVERLAY (self->overlay), self->selected_image); }
int main (int argc, char *argv[]) { GtkWidget *window, *vbox, *label; GtkWidget *combo, *scale, *overlay, *da; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), 400, 300); 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); combo = gtk_combo_box_text_new (); scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 360, 1); label = gtk_label_new ("This label may be ellipsized\nto make it fit."); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "NONE"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "START"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "MIDDLE"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "END"); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0); gtk_widget_set_halign (label, GTK_ALIGN_CENTER); gtk_widget_set_valign (label, GTK_ALIGN_CENTER); da = gtk_drawing_area_new (); gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), overlay_draw, label, NULL); overlay = gtk_overlay_new (); gtk_container_add (GTK_CONTAINER (overlay), da); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), label); gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, TRUE); gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, TRUE); gtk_box_pack_start (GTK_BOX (vbox), overlay, TRUE, TRUE); g_object_set_data (G_OBJECT (label), "combo", combo); g_signal_connect (combo, "changed", G_CALLBACK (combo_changed_cb), label); g_signal_connect (scale, "value-changed", G_CALLBACK (scale_changed_cb), label); gtk_widget_show_all (window); gtk_main (); return 0; }
static GtkWidget * test_chase (void) { GtkWidget *win; GtkWidget *overlay; GtkWidget *sw; GtkWidget *text; GtkWidget *child; GtkTextBuffer *buffer; gchar *contents; gsize len; win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (win), "Chase"); overlay = gtk_overlay_new (); gtk_widget_set_events (overlay, GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK); gtk_container_add (GTK_CONTAINER (win), overlay); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (sw), 200); gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), 200); gtk_container_add (GTK_CONTAINER (overlay), sw); text = gtk_text_view_new (); buffer = gtk_text_buffer_new (NULL); if (!g_file_get_contents ("testoverlay.c", &contents, &len, NULL)) { contents = g_strdup ("Text should go here..."); len = strlen (contents); } gtk_text_buffer_set_text (buffer, contents, len); g_free (contents); gtk_text_view_set_buffer (GTK_TEXT_VIEW (text), buffer); gtk_widget_set_hexpand (text, TRUE); gtk_widget_set_vexpand (text, TRUE); gtk_container_add (GTK_CONTAINER (sw), text); child = gtk_label_new ("Try to enter"); gtk_widget_set_halign (child, GTK_ALIGN_START); gtk_widget_set_valign (child, GTK_ALIGN_END); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child); g_object_set (child, "margin", 4, NULL); g_signal_connect (overlay, "enter-notify-event", G_CALLBACK (on_enter), child); return win; }
static GtkWidget * test_stacking (void) { GtkWidget *win; GtkWidget *overlay; GtkWidget *main_child; GtkWidget *label; GtkWidget *child; GtkWidget *grid; GtkWidget *check1; GtkWidget *check2; GdkRGBA color; win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (win), "Stacking"); grid = gtk_grid_new (); overlay = gtk_overlay_new (); main_child = gtk_event_box_new (); gdk_rgba_parse (&color, "green"); G_GNUC_BEGIN_IGNORE_DEPRECATIONS gtk_widget_override_background_color (main_child, 0, &color); G_GNUC_END_IGNORE_DEPRECATIONS gtk_widget_set_hexpand (main_child, TRUE); gtk_widget_set_vexpand (main_child, TRUE); label = gtk_label_new ("Main child"); child = gtk_label_new ("Overlay"); gtk_widget_set_halign (child, GTK_ALIGN_END); gtk_widget_set_valign (child, GTK_ALIGN_END); check1 = gtk_check_button_new_with_label ("Show main"); g_object_bind_property (main_child, "visible", check1, "active", G_BINDING_BIDIRECTIONAL); check2 = gtk_check_button_new_with_label ("Show overlay"); g_object_bind_property (child, "visible", check2, "active", G_BINDING_BIDIRECTIONAL); gtk_container_add (GTK_CONTAINER (main_child), label); gtk_container_add (GTK_CONTAINER (overlay), main_child); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child); gtk_grid_attach (GTK_GRID (grid), overlay, 1, 0, 1, 3); gtk_container_add (GTK_CONTAINER (win), grid); gtk_grid_attach (GTK_GRID (grid), check1, 0, 0, 1, 1); gtk_grid_attach (GTK_GRID (grid), check2, 0, 1, 1, 1); child = gtk_label_new (""); gtk_widget_set_vexpand (child, TRUE); gtk_grid_attach (GTK_GRID (grid), child, 0, 2, 1, 1); return win; }
/* test that scrolling works as expected */ static GtkWidget * test_scrolling (void) { GtkWidget *win; GtkWidget *overlay; GtkWidget *sw; GtkWidget *text; GtkWidget *child; GtkTextBuffer *buffer; gchar *contents; gsize len; win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (win), "Scrolling"); overlay = gtk_overlay_new (); gtk_container_add (GTK_CONTAINER (win), overlay); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (sw), 200); gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), 200); gtk_container_add (GTK_CONTAINER (overlay), sw); text = gtk_text_view_new (); buffer = gtk_text_buffer_new (NULL); if (!g_file_get_contents ("testoverlay.c", &contents, &len, NULL)) { contents = g_strdup ("Text should go here..."); len = strlen (contents); } gtk_text_buffer_set_text (buffer, contents, len); g_free (contents); gtk_text_view_set_buffer (GTK_TEXT_VIEW (text), buffer); gtk_widget_set_hexpand (text, TRUE); gtk_widget_set_vexpand (text, TRUE); gtk_container_add (GTK_CONTAINER (sw), text); child = gtk_label_new ("This should be visible"); gtk_widget_set_halign (child, GTK_ALIGN_CENTER); gtk_widget_set_valign (child, GTK_ALIGN_END); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child); g_object_set (child, "margin", 4, NULL); return win; }
void glade_gtk_overlay_add_child (GladeWidgetAdaptor *adaptor, GObject *object, GObject *child) { gchar *special_type = g_object_get_data (child, "special-child-type"); GtkWidget *bin_child; if ((special_type && !strcmp (special_type, "overlay")) || ((bin_child = gtk_bin_get_child (GTK_BIN (object))) && !GLADE_IS_PLACEHOLDER (bin_child))) { g_object_set_data (child, "special-child-type", "overlay"); gtk_overlay_add_overlay (GTK_OVERLAY (object), GTK_WIDGET (child)); } else /* Chain Up */ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->add (adaptor, object, child); }
static gboolean activate_link (GtkLabel *label, const gchar *uri, GisPrivacyPage *page) { GtkWidget *dialog; GtkWidget *overlay; GtkWidget *view; GtkWidget *progress_bar; dialog = gtk_dialog_new_with_buttons (_("Privacy Policy"), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (page))), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR, NULL); overlay = gtk_overlay_new (); gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), overlay); progress_bar = gtk_progress_bar_new (); gtk_style_context_add_class (gtk_widget_get_style_context (progress_bar), GTK_STYLE_CLASS_OSD); gtk_widget_set_halign (progress_bar, GTK_ALIGN_FILL); gtk_widget_set_valign (progress_bar, GTK_ALIGN_START); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), progress_bar); view = webkit_web_view_new (); gtk_widget_set_size_request (view, 600, 500); gtk_widget_set_hexpand (view, TRUE); gtk_widget_set_vexpand (view, TRUE); g_signal_connect (view, "notify::estimated-load-progress", G_CALLBACK (notify_progress_cb), progress_bar); gtk_container_add (GTK_CONTAINER (overlay), view); gtk_widget_show_all (overlay); gtk_window_present (GTK_WINDOW (dialog)); webkit_web_view_load_uri (WEBKIT_WEB_VIEW (view), uri); return TRUE; }
static void nautilus_window_slot_constructed (GObject *object) { NautilusWindowSlot *slot = NAUTILUS_WINDOW_SLOT (object); GtkWidget *extras_vbox; G_OBJECT_CLASS (nautilus_window_slot_parent_class)->constructed (object); gtk_orientable_set_orientation (GTK_ORIENTABLE (slot), GTK_ORIENTATION_VERTICAL); gtk_widget_show (GTK_WIDGET (slot)); extras_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); slot->extra_location_widgets = extras_vbox; gtk_box_pack_start (GTK_BOX (slot), extras_vbox, FALSE, FALSE, 0); gtk_widget_show (extras_vbox); slot->query_editor = NAUTILUS_QUERY_EDITOR (nautilus_query_editor_new ()); nautilus_window_slot_add_extra_location_widget (slot, GTK_WIDGET (slot->query_editor)); g_object_add_weak_pointer (G_OBJECT (slot->query_editor), (gpointer *) &slot->query_editor); slot->view_overlay = gtk_overlay_new (); gtk_widget_add_events (slot->view_overlay, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); gtk_box_pack_start (GTK_BOX (slot), slot->view_overlay, TRUE, TRUE, 0); gtk_widget_show (slot->view_overlay); slot->floating_bar = nautilus_floating_bar_new (NULL, NULL, FALSE); gtk_widget_set_halign (slot->floating_bar, GTK_ALIGN_END); gtk_widget_set_valign (slot->floating_bar, GTK_ALIGN_END); gtk_overlay_add_overlay (GTK_OVERLAY (slot->view_overlay), slot->floating_bar); g_signal_connect (slot->floating_bar, "action", G_CALLBACK (floating_bar_action_cb), slot); slot->title = g_strdup (_("Loading...")); }
static void nemo_window_slot_init (NemoWindowSlot *slot) { GtkWidget *extras_vbox; gtk_orientable_set_orientation (GTK_ORIENTABLE (slot), GTK_ORIENTATION_VERTICAL); gtk_widget_show (GTK_WIDGET (slot)); extras_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); slot->extra_location_widgets = extras_vbox; gtk_box_pack_start (GTK_BOX (slot), extras_vbox, FALSE, FALSE, 0); gtk_widget_show (extras_vbox); slot->query_editor = NEMO_QUERY_EDITOR (nemo_query_editor_new ()); slot->query_editor_revealer = gtk_revealer_new (); gtk_container_add (GTK_CONTAINER (slot->query_editor_revealer), GTK_WIDGET (slot->query_editor)); gtk_widget_show_all (slot->query_editor_revealer); nemo_window_slot_add_extra_location_widget (slot, slot->query_editor_revealer); slot->view_overlay = gtk_overlay_new (); gtk_widget_add_events (slot->view_overlay, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); gtk_box_pack_start (GTK_BOX (slot), slot->view_overlay, TRUE, TRUE, 0); gtk_widget_show (slot->view_overlay); slot->floating_bar = nemo_floating_bar_new ("", FALSE); gtk_widget_set_halign (slot->floating_bar, GTK_ALIGN_END); gtk_widget_set_valign (slot->floating_bar, GTK_ALIGN_END); gtk_overlay_add_overlay (GTK_OVERLAY (slot->view_overlay), slot->floating_bar); g_signal_connect (slot->floating_bar, "action", G_CALLBACK (floating_bar_action_cb), slot); slot->title = g_strdup (_("Loading...")); }
static GtkWidget * create_popup (GtkColorEditor *editor, GtkWidget *attach, GtkWidget *contents) { GtkWidget *popup; g_object_set (contents, "margin", 12, NULL); popup = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_style_context_add_class (gtk_widget_get_style_context (popup), GTK_STYLE_CLASS_TOOLTIP); gtk_container_add (GTK_CONTAINER (popup), contents); gtk_widget_show_all (contents); gtk_widget_set_no_show_all (popup, TRUE); g_signal_connect (popup, "draw", G_CALLBACK (popup_draw), editor); gtk_overlay_add_overlay (GTK_OVERLAY (editor->priv->overlay), popup); g_signal_connect (attach, "popup-menu", G_CALLBACK (popup_edit), editor); return popup; }
static void fsearch_application_window_init (FsearchApplicationWindow *self) { g_assert (FSEARCH_WINDOW_IS_WINDOW (self)); gtk_widget_init_template (GTK_WIDGET (self)); GtkCssProvider *provider = gtk_css_provider_new (); gtk_css_provider_load_from_resource (provider, "/org/fsearch/fsearch/shared.css"); gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); g_object_unref (provider); create_view_and_model (self); //self->selection_popover = create_popover (self->selection_toggle_button); //g_signal_connect (self->selection_popover, // "closed", // G_CALLBACK (set_toggle_button), // (gpointer)self->selection_toggle_button); self->database_popover = create_popover (self->database_toggle_button); fill_database_popover (self->database_popover); g_signal_connect (self->database_popover, "closed", G_CALLBACK (set_toggle_button), (gpointer)self->database_toggle_button); FsearchApplication *app = FSEARCH_APPLICATION_DEFAULT; g_signal_connect (app, "database-update", G_CALLBACK (update_database_cb), self); g_signal_connect (app, "database-updated", G_CALLBACK (updated_database_cb), self); g_signal_connect (gtk_icon_theme_get_default (), "changed", G_CALLBACK (icon_theme_changed_cb), self); GtkBuilder *builder = gtk_builder_new_from_resource ("/org/fsearch/fsearch/overlay.ui"); // Overlay when no search results are found self->no_search_results_overlay = GTK_WIDGET (gtk_builder_get_object (builder, "no_search_results")); gtk_overlay_add_overlay (GTK_OVERLAY (self->search_overlay), self->no_search_results_overlay); // Overlay when database is empty self->empty_database_overlay = GTK_WIDGET (gtk_builder_get_object (builder, "empty_database")); gtk_overlay_add_overlay (GTK_OVERLAY (self->search_overlay), self->empty_database_overlay); // Overlay when search query is empty self->empty_search_query_overlay = GTK_WIDGET (gtk_builder_get_object (builder, "empty_search_query")); gtk_overlay_add_overlay (GTK_OVERLAY (self->search_overlay), self->empty_search_query_overlay); // Overlay when database is updating self->database_updating_overlay = GTK_WIDGET (gtk_builder_get_object (builder, "database_updating")); gtk_overlay_add_overlay (GTK_OVERLAY (self->search_overlay), self->database_updating_overlay); self->database_updating_label = GTK_WIDGET (gtk_builder_get_object (builder, "database_updating_label")); g_object_unref (builder); }
int main (int argc, char *argv[]) { //const std::string creatureDB[]={"pidgeot","gardevoir"}; - For creature catalog~~ //std::cout<<creatureDB[0]; /* Initialize GTK+ */ g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, (GLogFunc) gtk_false, NULL); gtk_init (&argc, &argv); g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, g_log_default_handler, NULL); /* Main window configuration */ win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_resizable (GTK_WINDOW (win), false); gtk_widget_set_size_request(win,windowWidth,windowHeight); gtk_container_set_border_width (GTK_CONTAINER (win), 0); gtk_window_set_title (GTK_WINDOW (win), "Pokemon"); gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_CENTER); gtk_widget_realize (win); g_signal_connect (win, "destroy", gtk_main_quit, NULL); gtk_window_set_icon_from_file(GTK_WINDOW(win),"images/winIcon.png",NULL); //gtk_window_set_decorated (GTK_WINDOW(win),FALSE); //Óáèðàåò ñòàíäàðòíîå îôîðìëåíèå îêíà windows /* Initializing objects */ zeBigContainer = gtk_box_new (GTK_ORIENTATION_VERTICAL,0); zeBigContainerOverlay = gtk_overlay_new(); topPart = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0); topPartCenter = gtk_alignment_new (0.5,0.5,1,1); topPartLeft = gtk_box_new (GTK_ORIENTATION_VERTICAL,0); topPartCenter = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0); topPartRight = gtk_box_new (GTK_ORIENTATION_VERTICAL,0); bottomPart = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0); buttons = gtk_grid_new (); dialogScrollFrame = gtk_scrolled_window_new(NULL,NULL); dialogText = gtk_text_view_new (); dialogBuffer = gtk_text_buffer_new (NULL); button1 = gtk_button_new (); button2 = gtk_button_new (); button3 = gtk_button_new (); button4 = gtk_button_new_with_label ("Restart"); button5 = gtk_button_new_with_label ("Back to choosing screen"); topMidPart = gtk_image_new_from_file ("images/topPic.jpg"); IMGBackground = gtk_image_new_from_file ("images/pokeBackground.jpg"); leftImage = gtk_image_new_from_file ("images/filler.PNG"); rightImage = gtk_image_new_from_file ("images/filler.PNG"); leftBar = gtk_progress_bar_new (); rightBar = gtk_progress_bar_new (); /* Setting dialogText */ gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(dialogText), GTK_TEXT_WINDOW_LEFT, 5); gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(dialogText), GTK_TEXT_WINDOW_BOTTOM, 20); gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(dialogText), GTK_TEXT_WINDOW_TOP, 5); gtk_text_view_set_editable(GTK_TEXT_VIEW(dialogText), FALSE); gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(dialogText), FALSE); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(dialogText),GTK_WRAP_WORD); /* Setting progress bars */ gtk_progress_bar_set_inverted(GTK_PROGRESS_BAR(rightBar),TRUE); gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(leftBar),TRUE); gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(rightBar),TRUE); /* Various initializations */ gtk_box_set_homogeneous((GtkBox*)topPartCenter,TRUE); gtk_box_set_homogeneous((GtkBox*)topPart,TRUE); gtk_box_set_homogeneous((GtkBox*)bottomPart,TRUE); gtk_box_set_homogeneous((GtkBox*)zeBigContainer,TRUE); gtk_grid_set_row_homogeneous((GtkGrid*)buttons,TRUE); gtk_grid_set_column_homogeneous((GtkGrid*)buttons,TRUE); gtk_grid_set_row_spacing((GtkGrid*)buttons,12); gtk_grid_set_column_spacing((GtkGrid*)buttons,12); g_object_set (buttons,"margin",12,NULL); g_object_set (topPart,"margin",12,NULL); gtk_container_set_border_width(GTK_CONTAINER(dialogScrollFrame),5); //gtk_box_set_child_packing((GtkBox*)zeBigContainer,bottomPart,gTRUE,gTRUE,100,GTK_PACK_START); gtk_text_view_set_buffer (GTK_TEXT_VIEW(dialogText), dialogBuffer); gtk_text_buffer_set_text(dialogBuffer, "", -1); //gtk_text_buffer_get_iter_at_offset (dialogBuffer, &lastCharIter, -1); gtk_text_buffer_get_end_iter(dialogBuffer, &endIter); fontDesc = pango_font_description_from_string("Consolas"); gtk_widget_override_font(dialogText,fontDesc); endMark = gtk_text_mark_new ("endMark",FALSE); endMark = gtk_text_buffer_get_mark(dialogBuffer,"insert"); gtk_button_set_always_show_image(GTK_BUTTON(button1),TRUE); gtk_button_set_always_show_image(GTK_BUTTON(button2),TRUE); gtk_button_set_always_show_image(GTK_BUTTON(button3),TRUE); /* Building objects */ gtk_container_add (GTK_CONTAINER(win),zeBigContainerOverlay); gtk_overlay_add_overlay(GTK_OVERLAY(zeBigContainerOverlay),zeBigContainer); gtk_container_add (GTK_CONTAINER(zeBigContainerOverlay),IMGBackground); gtk_container_add (GTK_CONTAINER(zeBigContainer),topPart); gtk_container_add (GTK_CONTAINER(zeBigContainer),bottomPart); gtk_container_add (GTK_CONTAINER(topPart),topPartLeft); // Â topPartLeft âñòàâëÿòü ëåâûé áàð gtk_container_add (GTK_CONTAINER(topPartLeft),leftBar); gtk_container_add (GTK_CONTAINER(topPartLeft),leftImage); gtk_container_add (GTK_CONTAINER(topPart),topPartCenter); gtk_container_add (GTK_CONTAINER(topPart),topPartRight); // â topPartRight - ïðàâûé... gtk_container_add (GTK_CONTAINER(topPartRight),rightBar); gtk_container_add (GTK_CONTAINER(topPartRight),rightImage); gtk_container_add (GTK_CONTAINER(topPartCenter),topMidPart); gtk_container_add (GTK_CONTAINER(bottomPart),dialogScrollFrame); gtk_container_add (GTK_CONTAINER(dialogScrollFrame),dialogText); gtk_container_add (GTK_CONTAINER(bottomPart),buttons); gtk_grid_attach (GTK_GRID(buttons),button1, 1,1,1,1); gtk_grid_attach (GTK_GRID(buttons),button2, 1,2,1,1); gtk_grid_attach (GTK_GRID(buttons),button3, 1,3,1,1); gtk_grid_attach (GTK_GRID(buttons),button4, 1,4,1,1); gtk_grid_attach (GTK_GRID(buttons),button5, 1,5,1,1); /* Signal connects and some shiatd */ g_signal_connect(G_OBJECT(button1), "clicked", Cast1, NULL); g_signal_connect(G_OBJECT(button2), "clicked", Cast2, NULL); g_signal_connect(G_OBJECT(button3), "clicked", Cast3, NULL); g_signal_connect(G_OBJECT(button4), "clicked", combatStart, NULL); g_signal_connect(G_OBJECT(button5), "clicked", backToChoosingScreen,NULL); /* Creature chooser window configuration */ // TO BE CONTINUED.......................................................................... /* Window creation/configuration (win2) */ win2win = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_resizable (GTK_WINDOW (win2win), false); gtk_widget_set_size_request(win2win,windowWidth,windowHeight); gtk_window_set_title (GTK_WINDOW (win2win), "Pokemon creature chooser"); gtk_window_set_position (GTK_WINDOW (win2win), GTK_WIN_POS_CENTER); gtk_widget_realize (win2win); g_signal_connect (win2win, "destroy", gtk_main_quit, NULL); gtk_window_set_icon_from_file(GTK_WINDOW(win2win),"images/winIcon.png",NULL); /* Initializing objects (win2) */ win2topLabel = gtk_image_new_from_file("images/logo.png"); //win2topLabel = gtk_label_new(""); //gtk_label_set_markup(GTK_LABEL(win2topLabel),"<small>Small</small><big>Bold</big>"); win2BigContainer = gtk_grid_new(); win2BigContainerOverlay = gtk_overlay_new (); win2TopPart = gtk_grid_new (); win2MiddlePart = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0); win2BottomPart = gtk_grid_new(); win2BackgroundIMG = gtk_image_new_from_file ("images/pokeBackground.jpg"); win2button1 = gtk_button_new_with_label(">>Switch Screens<<"); win2button2 = gtk_button_new_with_label("Exit"); win2buttonReset = gtk_button_new_with_label("Reset"); win2creatureIcon1 = gtk_button_new(); win2creatureIcon2 = gtk_button_new(); win2creatureIcon3 = gtk_button_new(); win2creatureIcon4 = gtk_button_new(); win2creatureIcon5 = gtk_button_new(); win2creatureIcon1IMG = gtk_image_new_from_file("images/ImagePidgeotSmall.png"); win2creatureIcon2IMG = gtk_image_new_from_file("images/ImageGardevoirSmall.png"); win2creatureIcon3IMG = gtk_image_new_from_file("images/ImageArcanineSmall.png"); win2creatureIcon4IMG = gtk_image_new_from_file("images/ImagePikachuSmall.png"); win2creatureIcon5IMG = gtk_image_new_from_file("images/ImageFishSmall.png"); win2ImageVersus = gtk_image_new_from_file ("images/versus.png"); win2MiddleFirst = gtk_image_new_from_file ("images/facelessVoid.png"); win2MiddleSecond = gtk_image_new_from_file ("images/facelessVoid.png"); /* Various initializations (win2) */ gtk_grid_set_row_homogeneous((GtkGrid*)win2BigContainer,TRUE); gtk_grid_set_column_homogeneous((GtkGrid*)win2BigContainer,TRUE); gtk_grid_set_row_spacing((GtkGrid*)win2BigContainer,12); gtk_grid_set_column_spacing((GtkGrid*)win2BigContainer,12); //g_object_set (win2BigContainer,"margin",12,NULL); gtk_grid_set_row_homogeneous((GtkGrid*)win2BottomPart,TRUE); gtk_grid_set_column_homogeneous((GtkGrid*)win2BottomPart,TRUE); gtk_grid_set_row_spacing((GtkGrid*)win2BottomPart,12); gtk_grid_set_column_spacing((GtkGrid*)win2BottomPart,12); g_object_set (win2BottomPart,"margin",12,NULL); gtk_grid_set_row_homogeneous((GtkGrid*)win2TopPart,TRUE); gtk_grid_set_column_homogeneous((GtkGrid*)win2TopPart,TRUE); gtk_grid_set_row_spacing((GtkGrid*)win2TopPart,12); gtk_grid_set_column_spacing((GtkGrid*)win2TopPart,12); g_object_set (win2TopPart,"margin",12,NULL); gtk_box_set_homogeneous(GTK_BOX(win2MiddlePart),TRUE); gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon1),TRUE); gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon2),TRUE); gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon3),TRUE); gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon4),TRUE); gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon5),TRUE); gtk_button_set_image(GTK_BUTTON(win2creatureIcon1),win2creatureIcon1IMG); gtk_button_set_image(GTK_BUTTON(win2creatureIcon2),win2creatureIcon2IMG); gtk_button_set_image(GTK_BUTTON(win2creatureIcon3),win2creatureIcon3IMG); gtk_button_set_image(GTK_BUTTON(win2creatureIcon4),win2creatureIcon4IMG); gtk_button_set_image(GTK_BUTTON(win2creatureIcon5),win2creatureIcon5IMG); /* Building objects (win2) */ gtk_container_add (GTK_CONTAINER(win2win),win2BigContainerOverlay); gtk_overlay_add_overlay(GTK_OVERLAY(win2BigContainerOverlay),win2BigContainer); gtk_container_add (GTK_CONTAINER(win2BigContainerOverlay),win2BackgroundIMG); gtk_grid_attach(GTK_GRID(win2BigContainer),win2topLabel,1,1,1,2);//1 gtk_grid_attach(GTK_GRID(win2BigContainer),win2TopPart,1,2,1,3);//3 gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon1,1,1,1,1); gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon2,2,1,1,1); gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon3,3,1,1,1); gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon4,4,1,1,1); gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon5,5,1,1,1); gtk_grid_attach(GTK_GRID(win2BigContainer),win2MiddlePart,1,5,1,3);//3 gtk_grid_attach(GTK_GRID(win2BigContainer),win2BottomPart,1,8,1,3);//3 gtk_container_add (GTK_CONTAINER(win2MiddlePart),win2MiddleFirst); gtk_container_add (GTK_CONTAINER(win2MiddlePart),win2ImageVersus); gtk_container_add (GTK_CONTAINER(win2MiddlePart),win2MiddleSecond); gtk_grid_attach (GTK_GRID(win2BottomPart),win2button1, 1,1,3,1); gtk_grid_attach (GTK_GRID(win2BottomPart),win2buttonReset,4,1,1,1); gtk_grid_attach (GTK_GRID(win2BottomPart),win2button2, 5,1,1,1); /* Signal connects (win2) */ g_signal_connect (G_OBJECT(win2button1),"clicked",win2StartGame,NULL); g_signal_connect (G_OBJECT(win2button2),"clicked",gtk_main_quit,NULL); g_signal_connect (G_OBJECT(win2creatureIcon1),"clicked",win2pidgeotSelect,NULL); g_signal_connect (G_OBJECT(win2creatureIcon2),"clicked",win2gardevoirSelect,NULL); g_signal_connect (G_OBJECT(win2creatureIcon3),"clicked",win2arcanineSelect,NULL); g_signal_connect (G_OBJECT(win2creatureIcon4),"clicked",win2pikachuSelect,NULL); g_signal_connect (G_OBJECT(win2creatureIcon5),"clicked",win2mightyfishSelect,NULL); g_signal_connect (G_OBJECT(win2buttonReset),"clicked",win2CharReset,NULL); /* Other stuff */ srand(time(NULL)); write ("___________________________________________________\n"); /* Enter the main loop */ gtk_widget_show_all (win2win); gtk_main (); return 0; };
GtkWidget * do_css_multiplebgs (GtkWidget *do_widget) { if (!window) { GtkWidget *paned, *container, *child; GtkStyleProvider *provider; GtkTextBuffer *text; GBytes *bytes; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget)); gtk_window_set_default_size (GTK_WINDOW (window), 400, 300); g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window); container = gtk_overlay_new (); gtk_widget_add_events (container, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK); gtk_container_add (GTK_CONTAINER (window), container); child = gtk_drawing_area_new (); gtk_widget_set_name (child, "canvas"); g_signal_connect (child, "draw", G_CALLBACK (drawing_area_draw), NULL); gtk_container_add (GTK_CONTAINER (container), child); child = gtk_button_new (); gtk_widget_add_events (child, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK); gtk_overlay_add_overlay (GTK_OVERLAY (container), child); gtk_widget_set_name (child, "bricks-button"); gtk_widget_set_halign (child, GTK_ALIGN_CENTER); gtk_widget_set_valign (child, GTK_ALIGN_CENTER); gtk_widget_set_size_request (child, 200, 80); paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL); gtk_overlay_add_overlay (GTK_OVERLAY (container), paned); /* Need a filler so we get a handle */ child = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (paned), child); text = gtk_text_buffer_new (NULL); gtk_text_buffer_create_tag (text, "warning", "underline", PANGO_UNDERLINE_SINGLE, NULL); gtk_text_buffer_create_tag (text, "error", "underline", PANGO_UNDERLINE_ERROR, NULL); provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ()); container = gtk_scrolled_window_new (NULL, NULL); gtk_container_add (GTK_CONTAINER (paned), container); child = gtk_text_view_new_with_buffer (text); gtk_container_add (GTK_CONTAINER (container), child); g_signal_connect (text, "changed", G_CALLBACK (css_text_changed), provider); bytes = g_resources_lookup_data ("/css_multiplebgs/gtk.css", 0, NULL); gtk_text_buffer_set_text (text, g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes)); g_signal_connect (provider, "parsing-error", G_CALLBACK (show_parsing_error), gtk_text_view_get_buffer (GTK_TEXT_VIEW (child))); apply_css (window, provider); } if (!gtk_widget_get_visible (window)) gtk_widget_show_all (window); else { gtk_widget_destroy (window); window = NULL; } return window; }
int main(int argc, char *argv[]) { signal_user_data_t *ud; GError *error = NULL; GOptionContext *context; hb_global_init(); #ifdef ENABLE_NLS bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); #endif context = g_option_context_new(_("- Transcode media formats")); g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE); g_option_context_add_group(context, gtk_get_option_group(TRUE)); #if defined(_ENABLE_GST) g_option_context_add_group(context, gst_init_get_option_group()); #endif g_option_context_parse(context, &argc, &argv, &error); if (error != NULL) { g_warning("%s: %s", G_STRFUNC, error->message); g_clear_error(&error); } g_option_context_free(context); #if defined(_WIN32) if (win32_console) { // Enable console logging if(AttachConsole(ATTACH_PARENT_PROCESS) || AllocConsole()){ close(STDOUT_FILENO); freopen("CONOUT$", "w", stdout); close(STDERR_FILENO); freopen("CONOUT$", "w", stderr); } } else { // Non-console windows apps do not have a stderr->_file // assigned properly stderr->_file = STDERR_FILENO; stdout->_file = STDOUT_FILENO; } #endif if (argc > 1 && dvd_device == NULL && argv[1][0] != '-') { dvd_device = argv[1]; } gtk_init(&argc, &argv); GtkCssProvider *css = gtk_css_provider_new(); error = NULL; gtk_css_provider_load_from_data(css, MyCSS, -1, &error); if (error == NULL) { GdkScreen *ss = gdk_screen_get_default(); gtk_style_context_add_provider_for_screen(ss, GTK_STYLE_PROVIDER(css), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } else { g_warning("%s: %s", G_STRFUNC, error->message); g_clear_error(&error); } #if !defined(_WIN32) notify_init("HandBrake"); #endif ghb_resource_init(); ghb_load_icons(); #if !defined(_WIN32) dbus_g_thread_init(); #endif ghb_udev_init(); ghb_write_pid_file(); ud = g_malloc0(sizeof(signal_user_data_t)); ud->debug = ghb_debug; g_log_set_handler(NULL, G_LOG_LEVEL_DEBUG, debug_log_handler, ud); g_log_set_handler("Gtk", G_LOG_LEVEL_WARNING, warn_log_handler, ud); //g_log_set_handler("Gtk", G_LOG_LEVEL_CRITICAL, warn_log_handler, ud); ud->globals = ghb_dict_new(); ud->prefs = ghb_dict_new(); ud->settings_array = ghb_array_new(); ud->settings = ghb_dict_new(); ghb_array_append(ud->settings_array, ud->settings); ud->builder = create_builder_or_die(BUILDER_NAME); // Enable events that alert us to media change events watch_volumes(ud); //GtkWidget *widget = GHB_WIDGET(ud->builder, "PictureDetelecineCustom"); //gtk_entry_set_inner_border(widget, 2); // Since GtkBuilder no longer assigns object ids to widget names // Assign a few that are necessary for style overrides to work GtkWidget *widget; #if defined(_NO_UPDATE_CHECK) widget = GHB_WIDGET(ud->builder, "check_updates_box"); gtk_widget_hide(widget); #endif // Must set the names of the widgets that I want to modify // style for. gtk_widget_set_name(GHB_WIDGET(ud->builder, "preview_hud"), "preview_hud"); gtk_widget_set_name(GHB_WIDGET(ud->builder, "preview_frame"), "preview_frame"); gtk_widget_set_name(GHB_WIDGET(ud->builder, "live_preview_play"), "live_preview_play"); gtk_widget_set_name(GHB_WIDGET(ud->builder, "live_preview_progress"), "live_preview_progress"); gtk_widget_set_name(GHB_WIDGET(ud->builder, "live_encode_progress"), "live_encode_progress"); gtk_widget_set_name(GHB_WIDGET(ud->builder, "live_duration"), "live_duration"); gtk_widget_set_name(GHB_WIDGET(ud->builder, "preview_show_crop"), "preview_show_crop"); gtk_widget_set_name(GHB_WIDGET(ud->builder, "preview_fullscreen"), "preview_fullscreen"); widget = GHB_WIDGET(ud->builder, "preview_hud"); gtk_widget_set_name(widget, "preview_hud"); widget = GHB_WIDGET(ud->builder, "preview_window"); gtk_widget_set_name(widget, "preview_window"); // Set up the "hud" control overlay for the preview window GtkWidget *preview_box, *draw, *hud, *blender; preview_box = GHB_WIDGET(ud->builder, "preview_window_box"); draw = GHB_WIDGET(ud->builder, "preview_image"); hud = GHB_WIDGET(ud->builder, "preview_hud"); #if 0 // GTK_CHECK_VERSION(3, 0, 0) // This uses the new GtkOverlay widget. // // Unfortunately, GtkOverlay is broken in a couple of ways. // // First, it doesn't respect gtk_widget_shape_combine_region() // on it's child overlays. It appears to just ignore the clip // mask of the child. // // Second, it doesn't respect window opacity. // // So for now, I'll just continue using my home-grown overlay // widget (GhbCompositor). blender = gtk_overlay_new(); gtk_container_add(GTK_CONTAINER(preview_box), blender); gtk_container_add(GTK_CONTAINER(blender), draw); gtk_widget_set_valign (hud, GTK_ALIGN_END); gtk_widget_set_halign (hud, GTK_ALIGN_CENTER); gtk_overlay_add_overlay(GTK_OVERLAY(blender), hud); g_signal_connect(G_OBJECT(blender), "get-child-position", G_CALLBACK(position_overlay_cb), ud); gtk_widget_show(blender); #else // Set up compositing for hud blender = ghb_compositor_new(); gtk_container_add(GTK_CONTAINER(preview_box), blender); ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), draw, 1, 1); ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), hud, 2, .85); gtk_widget_show(blender); #endif // Redirect stderr to the activity window ghb_preview_init(ud); IoRedirect(ud); ghb_log( "%s - %s - %s", HB_PROJECT_TITLE, HB_PROJECT_BUILD_TITLE, HB_PROJECT_URL_WEBSITE ); ghb_init_dep_map(); // Need to connect x264_options textview buffer to the changed signal // since it can't be done automatically GtkTextView *textview; GtkTextBuffer *buffer; textview = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "x264Option")); buffer = gtk_text_view_get_buffer(textview); g_signal_connect(buffer, "changed", (GCallback)x264_entry_changed_cb, ud); textview = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "VideoOptionExtra")); buffer = gtk_text_view_get_buffer(textview); g_signal_connect(buffer, "changed", (GCallback)video_option_changed_cb, ud); textview = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "MetaLongDescription")); buffer = gtk_text_view_get_buffer(textview); g_signal_connect(buffer, "changed", (GCallback)plot_changed_cb, ud); ghb_combo_init(ud); g_debug("ud %p\n", ud); g_debug("ud->builder %p\n", ud->builder); bind_audio_tree_model(ud); bind_subtitle_tree_model(ud); bind_presets_tree_model(ud); bind_queue_tree_model(ud); bind_chapter_tree_model(ud); // Connect up the signals to their callbacks // I wrote my own connector so that I could pass user data // to the callbacks. Builder's standard autoconnect doesn't all this. gtk_builder_connect_signals_full(ud->builder, MyConnect, ud); ghb_init_audio_defaults_ui(ud); ghb_init_subtitle_defaults_ui(ud); // Parsing x264 options "" initializes x264 widgets to proper defaults ghb_x264_init(ud); // Load prefs before presets. Some preset defaults may depend // on preference settings. // First load default values ghb_settings_init(ud->prefs, "Preferences"); ghb_settings_init(ud->globals, "Globals"); ghb_settings_init(ud->settings, "Initialization"); ghb_settings_init(ud->settings, "OneTimeInitialization"); // Load user preferences file ghb_prefs_load(ud); // Store user preferences into ud->prefs ghb_prefs_to_settings(ud->prefs); int logLevel = ghb_dict_get_int(ud->prefs, "LoggingLevel"); ghb_backend_init(logLevel); // Load the presets files ghb_presets_load(ud); // Note that ghb_preset_to_settings(ud->settings) is called when // the default preset is selected. ghb_settings_to_ui(ud, ud->globals); ghb_settings_to_ui(ud, ud->prefs); // Note that ghb_settings_to_ui(ud->settings) happens when initial // empty title is initialized. if (ghb_dict_get_bool(ud->prefs, "hbfd")) { ghb_hbfd(ud, TRUE); } const gchar *source = ghb_dict_get_string(ud->prefs, "default_source"); ghb_dvd_set_current(source, ud); // Populate the presets tree view ghb_presets_list_init(ud, NULL); // Get the first preset name if (arg_preset != NULL) { ghb_select_preset(ud->builder, arg_preset); } else { ghb_select_default_preset(ud->builder); } // Grey out widgets that are dependent on a disabled feature ghb_check_all_depencencies(ud); if (dvd_device != NULL) { // Source overridden from command line option ghb_dict_set_string(ud->globals, "scan_source", dvd_device); g_idle_add((GSourceFunc)ghb_idle_scan, ud); } else { GhbValue *gval = ghb_dict_get_value(ud->prefs, "default_source"); ghb_dict_set(ud->globals, "scan_source", ghb_value_dup(gval)); } // Reload and check status of the last saved queue g_idle_add((GSourceFunc)ghb_reload_queue, ud); // Start timer for monitoring libhb status, 500ms g_timeout_add(200, ghb_timer_cb, (gpointer)ud); // Add dvd devices to File menu ghb_volname_cache_init(); GHB_THREAD_NEW("Cache Volume Names", (GThreadFunc)ghb_cache_volnames, ud); GtkWidget *ghb_window = GHB_WIDGET(ud->builder, "hb_window"); gint window_width, window_height; GdkGeometry geo = { -1, -1, 1920, 768, -1, -1, 10, 10, 0, 0, GDK_GRAVITY_NORTH_WEST }; GdkWindowHints geo_mask; geo_mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_BASE_SIZE; gtk_window_set_geometry_hints(GTK_WINDOW(ghb_window), ghb_window, &geo, geo_mask); window_width = ghb_dict_get_int(ud->prefs, "window_width"); window_height = ghb_dict_get_int(ud->prefs, "window_height"); /* * Filter objects in GtkBuilder xml * Unfortunately, GtkFilter is poorly supported by GtkBuilder, * so a lot of the setup must happen in code. SourceFilterAll SourceFilterVideo SourceFilterTS SourceFilterMPG SourceFilterEVO SourceFilterVOB SourceFilterMKV SourceFilterMP4 SourceFilterAVI SourceFilterMOV SourceFilterOGG SourceFilterFLV SourceFilterWMV */ // Add filters to source chooser GtkFileFilter *filter; GtkFileChooser *chooser; chooser = GTK_FILE_CHOOSER(GHB_WIDGET(ud->builder, "source_dialog")); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAll")); gtk_file_filter_set_name(filter, _("All")); gtk_file_filter_add_pattern(filter, "*"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterVideo")); gtk_file_filter_set_name(filter, _("Video")); gtk_file_filter_add_mime_type(filter, "video/*"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterTS")); gtk_file_filter_set_name(filter, "TS"); gtk_file_filter_add_pattern(filter, "*.ts"); gtk_file_filter_add_pattern(filter, "*.TS"); gtk_file_filter_add_pattern(filter, "*.m2ts"); gtk_file_filter_add_pattern(filter, "*.M2TS"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMPG")); gtk_file_filter_set_name(filter, "MPG"); gtk_file_filter_add_pattern(filter, "*.mpg"); gtk_file_filter_add_pattern(filter, "*.MPG"); gtk_file_filter_add_pattern(filter, "*.mepg"); gtk_file_filter_add_pattern(filter, "*.MEPG"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterEVO")); gtk_file_filter_set_name(filter, "EVO"); gtk_file_filter_add_pattern(filter, "*.evo"); gtk_file_filter_add_pattern(filter, "*.EVO"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterVOB")); gtk_file_filter_set_name(filter, "VOB"); gtk_file_filter_add_pattern(filter, "*.vob"); gtk_file_filter_add_pattern(filter, "*.VOB"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMKV")); gtk_file_filter_set_name(filter, "MKV"); gtk_file_filter_add_pattern(filter, "*.mkv"); gtk_file_filter_add_pattern(filter, "*.MKV"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMP4")); gtk_file_filter_set_name(filter, "MP4"); gtk_file_filter_add_pattern(filter, "*.mp4"); gtk_file_filter_add_pattern(filter, "*.MP4"); gtk_file_filter_add_pattern(filter, "*.m4v"); gtk_file_filter_add_pattern(filter, "*.M4V"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMOV")); gtk_file_filter_set_name(filter, "MOV"); gtk_file_filter_add_pattern(filter, "*.mov"); gtk_file_filter_add_pattern(filter, "*.MOV"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAVI")); gtk_file_filter_set_name(filter, "AVI"); gtk_file_filter_add_pattern(filter, "*.avi"); gtk_file_filter_add_pattern(filter, "*.AVI"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterOGG")); gtk_file_filter_set_name(filter, "OGG"); gtk_file_filter_add_pattern(filter, "*.ogg"); gtk_file_filter_add_pattern(filter, "*.OGG"); gtk_file_filter_add_pattern(filter, "*.ogv"); gtk_file_filter_add_pattern(filter, "*.OGV"); gtk_file_filter_add_pattern(filter, "*.ogm"); gtk_file_filter_add_pattern(filter, "*.OGM"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterFLV")); gtk_file_filter_set_name(filter, "FLV"); gtk_file_filter_add_pattern(filter, "*.flv"); gtk_file_filter_add_pattern(filter, "*.FLV"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterWMV")); gtk_file_filter_set_name(filter, "WMV"); gtk_file_filter_add_pattern(filter, "*.wmv"); gtk_file_filter_add_pattern(filter, "*.WMV"); gtk_file_chooser_add_filter(chooser, filter); // Gtk has a really stupid bug. If the file chooser is showing // hidden files AND there is no filter set, it will not select // the filename when gtk_file_chooser_set_filename is called. // So add a completely unnessary filter to prevent this behavior. filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAll")); gtk_file_chooser_set_filter(chooser, filter); PangoFontDescription *font_desc; font_desc = pango_font_description_from_string("monospace 10"); textview = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "activity_view")); gtk_widget_override_font(GTK_WIDGET(textview), font_desc); pango_font_description_free(font_desc); // Grrrr! Gtk developers !!!hard coded!!! the width of the // radio buttons in GtkStackSwitcher to 100!!! // // Thankfully, GtkStackSwitcher is a regular container object // and we can access the buttons to change their width. GList *stack_switcher_children, *link; GtkContainer * stack_switcher = GTK_CONTAINER( GHB_WIDGET(ud->builder, "SettingsStackSwitcher")); link = stack_switcher_children = gtk_container_get_children(stack_switcher); while (link != NULL) { GtkWidget *widget = link->data; gtk_widget_set_size_request(widget, -1, -1); gtk_widget_set_hexpand(widget, TRUE); gtk_widget_set_halign(widget, GTK_ALIGN_FILL); link = link->next; } g_list_free(stack_switcher_children); gtk_window_resize(GTK_WINDOW(ghb_window), window_width, window_height); gtk_widget_show(ghb_window); // Everything should be go-to-go. Lets rock! gtk_main(); ghb_backend_close(); ghb_value_free(&ud->queue); ghb_value_free(&ud->settings_array); ghb_value_free(&ud->prefs); ghb_value_free(&ud->globals); ghb_value_free(&ud->x264_priv); g_io_channel_unref(ud->activity_log); ghb_settings_close(); ghb_resource_free(); #if !defined(_WIN32) notify_uninit(); #endif g_object_unref(ud->builder); g_free(ud->current_dvd_device); g_free(ud); return 0; }
static void gb_editor_tab_init (GbEditorTab *tab) { GtkSourceCompletion *completion; GbEditorTabPrivate *priv; priv = tab->priv = gb_editor_tab_get_instance_private(tab); priv->is_empty = TRUE; priv->document = gb_editor_document_new(); priv->first_change_handler = g_signal_connect_object (priv->document, "changed", G_CALLBACK (gb_editor_tab_handle_first_change), tab, G_CONNECT_SWAPPED); priv->search_settings = gtk_source_search_settings_new (); priv->search = gtk_source_search_context_new (GTK_SOURCE_BUFFER (priv->document), priv->search_settings); g_signal_connect_object (priv->document, "notify::file", G_CALLBACK (gb_editor_tab_update_title), tab, (G_CONNECT_AFTER | G_CONNECT_SWAPPED)); priv->vbox = g_object_new (GTK_TYPE_BOX, "orientation", GTK_ORIENTATION_VERTICAL, "visible", TRUE, NULL); gtk_container_add (GTK_CONTAINER (tab), priv->vbox); priv->search_bar = g_object_new (GTK_TYPE_SEARCH_BAR, "search-mode-enabled", FALSE, "show-close-button", FALSE, "visible", TRUE, NULL); gtk_container_add (GTK_CONTAINER (priv->vbox), priv->search_bar); priv->search_entry = g_object_new (GTK_TYPE_SEARCH_ENTRY, "visible", TRUE, "width-chars", 32, NULL); g_object_bind_property (priv->search_entry, "text", priv->search_settings, "search-text", G_BINDING_SYNC_CREATE); g_signal_connect_object (priv->search_entry, "changed", G_CALLBACK (gb_editor_tab_search_entry_changed), tab, (G_CONNECT_AFTER | G_CONNECT_SWAPPED)); gtk_container_add (GTK_CONTAINER (priv->search_bar), priv->search_entry); priv->overlay = g_object_new(GTK_TYPE_OVERLAY, "vexpand", TRUE, "visible", TRUE, NULL); gtk_container_add(GTK_CONTAINER(priv->vbox), priv->overlay); priv->scroller = g_object_new(GTK_TYPE_SCROLLED_WINDOW, "visible", TRUE, NULL); gtk_container_add(GTK_CONTAINER(priv->overlay), priv->scroller); priv->text_view = g_object_new(GB_TYPE_SOURCE_VIEW, "buffer", priv->document, "visible", TRUE, NULL); gtk_container_add(GTK_CONTAINER(priv->scroller), priv->text_view); completion = gtk_source_view_get_completion (GTK_SOURCE_VIEW (priv->text_view)); g_object_set (completion, "show-headers", FALSE, "select-on-show", TRUE, NULL); priv->snippets_provider = g_object_new (GB_TYPE_SOURCE_SNIPPET_COMPLETION_PROVIDER, "source-view", priv->text_view, NULL); gtk_source_completion_add_provider (completion, priv->snippets_provider, NULL); priv->search_overlay = g_object_new (GB_TYPE_SOURCE_OVERLAY, "hexpand", TRUE, "search-context", priv->search, "source-view", priv->text_view, "vexpand", TRUE, "visible", FALSE, NULL); gtk_overlay_add_overlay(GTK_OVERLAY(priv->overlay), priv->search_overlay); priv->progress_bar = g_object_new (GTK_TYPE_PROGRESS_BAR, "halign", GTK_ALIGN_FILL, "valign", GTK_ALIGN_START, NULL); gtk_style_context_add_class (gtk_widget_get_style_context (priv->progress_bar), GTK_STYLE_CLASS_OSD); gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay), priv->progress_bar); priv->floating_bar = g_object_new(NAUTILUS_TYPE_FLOATING_BAR, "halign", GTK_ALIGN_END, "valign", GTK_ALIGN_END, "visible", TRUE, NULL); gtk_overlay_add_overlay(GTK_OVERLAY(priv->overlay), priv->floating_bar); g_signal_connect_object (priv->text_view, "toggle-overwrite", G_CALLBACK (gb_editor_tab_update_location), tab, (G_CONNECT_AFTER | G_CONNECT_SWAPPED)); g_signal_connect_object (priv->document, "notify::language", G_CALLBACK (gb_editor_tab_apply_settings), tab, (G_CONNECT_AFTER | G_CONNECT_SWAPPED)); g_signal_connect_object (priv->document, "delete-range", G_CALLBACK (gb_editor_tab_update_location), tab, (G_CONNECT_AFTER | G_CONNECT_SWAPPED)); g_signal_connect_object (priv->document, "insert-text", G_CALLBACK (gb_editor_tab_update_location), tab, (G_CONNECT_AFTER | G_CONNECT_SWAPPED)); g_signal_connect_object (priv->document, "mark-set", G_CALLBACK (gb_editor_tab_update_location), tab, (G_CONNECT_AFTER | G_CONNECT_SWAPPED)); g_signal_connect_object (priv->text_view, "grab-focus", G_CALLBACK (gb_editor_tab_emit_focused), tab, (G_CONNECT_AFTER | G_CONNECT_SWAPPED)); priv->shared_settings = g_settings_new ("org.gnome.builder.preferences.editor"); g_settings_bind (priv->shared_settings, "font", tab, "font", G_SETTINGS_BIND_GET); g_settings_bind (priv->shared_settings, "style-scheme", tab, "style-scheme-name", G_SETTINGS_BIND_GET); gb_editor_tab_update_location (tab); gb_editor_tab_apply_settings (tab); }
static void ide_debugger_editor_addin_add_ui (IdeDebuggerEditorAddin *self) { GtkWidget *scroll_box; GtkWidget *box; GtkWidget *hpaned; GtkWidget *utilities; GtkWidget *overlay; g_assert (IDE_IS_DEBUGGER_EDITOR_ADDIN (self)); g_assert (IDE_IS_EDITOR_SURFACE (self->editor)); #define OBSERVE_DESTROY(ptr) \ g_signal_connect ((ptr), "destroy", G_CALLBACK (gtk_widget_destroyed), &(ptr)) overlay = ide_editor_surface_get_overlay (self->editor); self->controls = g_object_new (IDE_TYPE_DEBUGGER_CONTROLS, "transition-duration", 500, "transition-type", GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP, "reveal-child", FALSE, "visible", TRUE, "halign", GTK_ALIGN_CENTER, "valign", GTK_ALIGN_END, NULL); OBSERVE_DESTROY (self->controls); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), GTK_WIDGET (self->controls)); self->panel = g_object_new (DZL_TYPE_DOCK_WIDGET, "title", _("Debugger"), "icon-name", "builder-debugger-symbolic", "visible", FALSE, NULL); OBSERVE_DESTROY (self->panel); box = g_object_new (GTK_TYPE_NOTEBOOK, "visible", TRUE, NULL); gtk_container_add (GTK_CONTAINER (self->panel), box); hpaned = g_object_new (DZL_TYPE_MULTI_PANED, "orientation", GTK_ORIENTATION_HORIZONTAL, "visible", TRUE, NULL); gtk_container_add_with_properties (GTK_CONTAINER (box), GTK_WIDGET (hpaned), "tab-label", _("Threads"), NULL); self->threads_view = g_object_new (IDE_TYPE_DEBUGGER_THREADS_VIEW, "hexpand", TRUE, "visible", TRUE, NULL); OBSERVE_DESTROY (self->threads_view); g_signal_connect_swapped (self->threads_view, "frame-activated", G_CALLBACK (on_frame_activated), self); gtk_container_add (GTK_CONTAINER (hpaned), GTK_WIDGET (self->threads_view)); self->locals_view = g_object_new (IDE_TYPE_DEBUGGER_LOCALS_VIEW, "width-request", 250, "visible", TRUE, NULL); OBSERVE_DESTROY (self->locals_view); gtk_container_add (GTK_CONTAINER (hpaned), GTK_WIDGET (self->locals_view)); self->breakpoints_view = g_object_new (IDE_TYPE_DEBUGGER_BREAKPOINTS_VIEW, "visible", TRUE, NULL); OBSERVE_DESTROY (self->breakpoints_view); gtk_container_add_with_properties (GTK_CONTAINER (box), GTK_WIDGET (self->breakpoints_view), "tab-label", _("Breakpoints"), NULL); self->libraries_view = g_object_new (IDE_TYPE_DEBUGGER_LIBRARIES_VIEW, "visible", TRUE, NULL); OBSERVE_DESTROY (self->libraries_view); gtk_container_add_with_properties (GTK_CONTAINER (box), GTK_WIDGET (self->libraries_view), "tab-label", _("Libraries"), NULL); self->registers_view = g_object_new (IDE_TYPE_DEBUGGER_REGISTERS_VIEW, "visible", TRUE, NULL); OBSERVE_DESTROY (self->registers_view); gtk_container_add_with_properties (GTK_CONTAINER (box), GTK_WIDGET (self->registers_view), "tab-label", _("Registers"), NULL); scroll_box = g_object_new (GTK_TYPE_BOX, "orientation", GTK_ORIENTATION_HORIZONTAL, "visible", TRUE, NULL); gtk_container_add_with_properties (GTK_CONTAINER (box), GTK_WIDGET (scroll_box), "tab-label", _("Log"), NULL); self->log_view = g_object_new (IDE_TYPE_TERMINAL, "hexpand", TRUE, "visible", TRUE, NULL); OBSERVE_DESTROY (self->log_view); gtk_container_add (GTK_CONTAINER (scroll_box), GTK_WIDGET (self->log_view)); self->log_view_scroller = g_object_new (GTK_TYPE_SCROLLBAR, "adjustment", gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (self->log_view)), "orientation", GTK_ORIENTATION_VERTICAL, "visible", TRUE, NULL); gtk_container_add (GTK_CONTAINER (scroll_box), GTK_WIDGET (self->log_view_scroller)); utilities = ide_editor_surface_get_utilities (self->editor); gtk_container_add (GTK_CONTAINER (utilities), GTK_WIDGET (self->panel)); #undef OBSERVE_DESTROY }
void gth_window_add_overlay (GthWindow *window, GtkWidget *widget) { gtk_overlay_add_overlay (GTK_OVERLAY (window->priv->overlay), widget); }
int main (int argc, char *argv[]) { GtkWidget *window, *box, *hbox, *button, *spinner, *check, *fps_label, *gears, *extra_hbox, *bbox, *overlay, *revealer, *frame, *label, *scrolled; int i; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "GdkGears"); gtk_window_set_default_size (GTK_WINDOW (window), 640, 640); gtk_container_set_border_width (GTK_CONTAINER (window), 12); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); overlay = gtk_overlay_new (); gtk_container_add (GTK_CONTAINER (window), overlay); gtk_widget_show (overlay); revealer = gtk_revealer_new (); gtk_widget_set_halign (revealer, GTK_ALIGN_END); gtk_widget_set_valign (revealer, GTK_ALIGN_START); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), revealer); gtk_widget_show (revealer); frame = gtk_frame_new (NULL); gtk_style_context_add_class (gtk_widget_get_style_context (frame), "app-notification"); gtk_container_add (GTK_CONTAINER (revealer), frame); gtk_widget_show (frame); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE); gtk_box_set_spacing (GTK_BOX (hbox), 6); gtk_container_add (GTK_CONTAINER (frame), hbox); gtk_widget_show (hbox); label = gtk_label_new ("This is a transparent overlay widget!!!!\nAmazing, eh?"); gtk_container_add (GTK_CONTAINER (hbox), label); gtk_widget_show (label); box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE); gtk_box_set_spacing (GTK_BOX (box), 6); gtk_container_add (GTK_CONTAINER (overlay), box); gtk_widget_show (box); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE); gtk_box_set_spacing (GTK_BOX (box), 6); gtk_container_add (GTK_CONTAINER (box), hbox); gtk_widget_show (hbox); gears = gtk_gears_new (); gtk_widget_set_hexpand (gears, TRUE); gtk_widget_set_vexpand (gears, TRUE); gtk_container_add (GTK_CONTAINER (hbox), gears); gtk_widget_show (gears); for (i = 0; i < GTK_GEARS_N_AXIS; i++) gtk_container_add (GTK_CONTAINER (hbox), create_axis_slider (GTK_GEARS (gears), i)); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE); gtk_box_set_spacing (GTK_BOX (hbox), 6); gtk_container_add (GTK_CONTAINER (box), hbox); gtk_widget_show (hbox); fps_label = gtk_label_new (""); gtk_container_add (GTK_CONTAINER (hbox), fps_label); gtk_widget_show (fps_label); gtk_gears_set_fps_label (GTK_GEARS (gears), GTK_LABEL (fps_label)); spinner = gtk_spinner_new (); gtk_box_pack_end (GTK_BOX (hbox), spinner, FALSE, FALSE, 0); gtk_widget_show (spinner); gtk_spinner_start (GTK_SPINNER (spinner)); check = gtk_check_button_new_with_label ("Animate spinner"); gtk_box_pack_end (GTK_BOX (hbox), check, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE); gtk_widget_show (check); g_signal_connect (check, "toggled", G_CALLBACK (toggle_spin), spinner); check = gtk_check_button_new_with_label ("Alpha"); gtk_box_pack_end (GTK_BOX (hbox), check, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), FALSE); gtk_widget_show (check); g_signal_connect (check, "toggled", G_CALLBACK (toggle_alpha), gears); check = gtk_check_button_new_with_label ("Overlay"); gtk_box_pack_end (GTK_BOX (hbox), check, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), FALSE); gtk_widget_show (check); g_signal_connect (check, "toggled", G_CALLBACK (toggle_overlay), revealer); scrolled = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); gtk_container_add (GTK_CONTAINER (box), scrolled); gtk_widget_show (scrolled); extra_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE); gtk_box_set_spacing (GTK_BOX (extra_hbox), 6); gtk_container_add (GTK_CONTAINER (scrolled), extra_hbox); gtk_widget_show (extra_hbox); bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); gtk_box_set_spacing (GTK_BOX (bbox), 6); gtk_container_add (GTK_CONTAINER (box), bbox); gtk_widget_show (bbox); button = gtk_button_new_with_label ("Moar gears!"); gtk_widget_set_hexpand (button, TRUE); gtk_container_add (GTK_CONTAINER (bbox), button); g_signal_connect (button, "clicked", G_CALLBACK (moar_gears), extra_hbox); gtk_widget_show (button); button = gtk_button_new_with_label ("Quit"); gtk_widget_set_hexpand (button, TRUE); gtk_container_add (GTK_CONTAINER (bbox), button); g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window); gtk_widget_show (button); gtk_widget_show (window); gtk_main (); return EXIT_SUCCESS; }
GtkWidget * create_videobox(entry * argEntry) { GtkWidget * top; GtkWidget * box; GtkWidget * title; GtkWidget * author; GtkWidget * duration; GtkWidget * thumboverlay; /*GTKoverlay to overlay author and duration over the image thumb.*/ GtkWidget * thumb; GdkRGBA * bgcolor = NULL; uint8_t colorret =0; if(argEntry == (entry *) NULL) return (GtkWidget *) NULL; //construction top = gtk_event_box_new(); box = gtk_box_new(GTK_ORIENTATION_VERTICAL,0); get_thumb_filename(argEntry); thumb = gtk_image_new_from_file(argEntry->fields[THUMBLOC]); title = gtk_label_new(argEntry->fields[TITLE]); author = gtk_label_new(argEntry->fields[AUTHOR]); duration = gtk_label_new(argEntry->fields[DURATION]); thumboverlay = gtk_overlay_new(); gtk_label_set_ellipsize(GTK_LABEL(title),PANGO_ELLIPSIZE_END); gtk_label_set_ellipsize(GTK_LABEL(author),PANGO_ELLIPSIZE_END); gtk_label_set_line_wrap(GTK_LABEL(title),gtk_true()); gtk_widget_set_tooltip_text(title,argEntry->fields[TITLE]); gtk_widget_set_size_request(thumboverlay,120,20); gtk_widget_set_size_request(top,ENTRYWIDTH,ENTRYHEIGHT); gtk_widget_set_valign(author,GTK_ALIGN_START); gtk_widget_set_halign(author,GTK_ALIGN_START); gtk_widget_set_valign(duration,GTK_ALIGN_END); gtk_widget_set_halign(duration,GTK_ALIGN_END); //Adding widgets gtk_container_add(GTK_CONTAINER(thumboverlay), thumb); gtk_container_add(GTK_CONTAINER(top), box); gtk_overlay_add_overlay(GTK_OVERLAY(thumboverlay),author); gtk_overlay_add_overlay(GTK_OVERLAY(thumboverlay),duration); gtk_box_set_homogeneous(GTK_BOX(box),FALSE); gtk_box_pack_start(GTK_BOX(box),title,FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(box),thumboverlay,FALSE,FALSE,0); //Color bgcolor = get_bgcolor(argEntry->fields[AUTHOR]); colorret = adjust_titlecolor(bgcolor); gtk_widget_override_color(title,GTK_STATE_FLAG_NORMAL,RGBARRAY[colorret]); gtk_widget_override_background_color(top,GTK_STATE_FLAG_NORMAL,bgcolor); free(bgcolor); // gtk_widget_add_events(thumb, GDK_BUTTON_MOTION_MASK); g_signal_connect(top,"button-press-event",G_CALLBACK(get_ytstream),argEntry->fields[ID]); gtk_widget_override_background_color(thumboverlay,GTK_STATE_FLAG_NORMAL,&BLACK); gtk_widget_override_color(author,GTK_STATE_FLAG_NORMAL,&WHITE); gtk_widget_override_color(duration,GTK_STATE_FLAG_NORMAL,&WHITE); gtk_widget_show_all(top); return top; }
/** * gb_view_source_init: * @: (in): A #GbViewSource. * * Initializes the newly created #GbViewSource instance. */ static void gb_view_source_init (GbViewSource *source) { GbViewSourcePrivate *priv; GtkWidget *overlay; ENTRY; source->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE(source, GB_TYPE_VIEW_SOURCE, GbViewSourcePrivate); g_object_set(source, "icon-name", GTK_STOCK_FILE, "name", _("Unsaved Document"), NULL); priv->buffer = gtk_source_buffer_new(NULL); g_signal_connect_swapped(priv->buffer, "notify::cursor-position", G_CALLBACK(gb_view_source_notify_cursor), source); g_signal_connect_swapped(priv->buffer, "modified-changed", G_CALLBACK(gb_view_source_buffer_modified_changed), source); overlay = g_object_new(GTK_TYPE_OVERLAY, "visible", TRUE, NULL); g_signal_connect(overlay, "get-child-position", G_CALLBACK(gb_view_source_position_progress), NULL); gtk_container_add_with_properties(GTK_CONTAINER(source), overlay, "left-attach", 0, "width", 1, "top-attach", 0, "height", 1, NULL); priv->vpaned = g_object_new(GTK_TYPE_VPANED, "visible", TRUE, NULL); gtk_container_add(GTK_CONTAINER(overlay), priv->vpaned); priv->progress = g_object_new(GB_TYPE_PROGRESS_BAR, "visible", FALSE, NULL); gtk_overlay_add_overlay(GTK_OVERLAY(overlay), priv->progress); priv->scroller1 = g_object_new(gb_get_scrolled_window_gtype(), "expand", TRUE, "visible", TRUE, NULL); gtk_container_add_with_properties(GTK_CONTAINER(priv->vpaned), priv->scroller1, "shrink", FALSE, "resize", TRUE, NULL); priv->source1 = gb_view_source_create_source_view(source); gtk_container_add(GTK_CONTAINER(priv->scroller1), priv->source1); { GtkSourceLanguageManager *langs = gtk_source_language_manager_get_default(); const gchar * const * ids = gtk_source_language_manager_get_language_ids(langs); GtkSourceLanguage *lang; const gchar *section; GHashTable *section_menu; GPtrArray *sorted; GtkWidget *controls = gb_view_get_controls(GB_VIEW(source)); GtkWidget *menu; GtkWidget *mitem; GtkWidget *submenu; guint i; section_menu = g_hash_table_new(g_str_hash, g_str_equal); menu = gtk_menu_new(); sorted = g_ptr_array_new(); for (i = 0; ids[i]; i++) { lang = gtk_source_language_manager_get_language(langs, ids[i]); g_ptr_array_add(sorted, lang); } g_ptr_array_sort(sorted, lang_sort_func); for (i = 0; i < sorted->len; i++) { lang = g_ptr_array_index(sorted, i); section = gtk_source_language_get_section(lang); if (!(submenu = g_hash_table_lookup(section_menu, section))) { submenu = gtk_menu_new(); mitem = g_object_new(GTK_TYPE_MENU_ITEM, "label", section, "submenu", submenu, "visible", TRUE, NULL); gtk_container_add(GTK_CONTAINER(menu), mitem); g_hash_table_insert(section_menu, (gchar*)section, submenu); } mitem = g_object_new(GTK_TYPE_MENU_ITEM, "label", gtk_source_language_get_name(lang), "visible", TRUE, NULL); g_signal_connect_swapped(mitem, "activate", G_CALLBACK(gb_view_source_lang_activate), source); g_object_set_data(G_OBJECT(mitem), "language-id", (gchar *)gtk_source_language_get_id(lang)); gtk_container_add(GTK_CONTAINER(submenu), mitem); } g_ptr_array_free(sorted, TRUE); priv->lang_combo = g_object_new(GB_TYPE_MENU_BUTTON, "hexpand", FALSE, "label", "", "menu", menu, "tooltip-text", _("Set source language."), "visible", TRUE, NULL); gb_widget_shrink_font( gb_menu_button_get_label_widget( GB_MENU_BUTTON(priv->lang_combo))); gtk_style_context_add_class(gtk_widget_get_style_context(priv->lang_combo), GB_STYLE_CLASS_TOP_BAR); gtk_container_add_with_properties(GTK_CONTAINER(controls), priv->lang_combo, "expand", FALSE, NULL); g_hash_table_unref(section_menu); } { GtkWidget *controls = gb_view_get_controls(GB_VIEW(source)); GtkWidget *b; GtkWidget *item; GtkWidget *menu; GtkWidget *group = NULL; gboolean active; gchar *str; int tabs[] = { 2, 3, 4, 5, 8, 0 }; int i; b = g_object_new(GB_TYPE_MENU_BUTTON, "hexpand", FALSE, "label", "4", "tooltip-text", _("Set tab-character width."), "visible", TRUE, "width-request", 45, NULL); menu = gtk_menu_new(); for (i = 0; tabs[i]; i++) { str = g_strdup_printf("%d", tabs[i]); item = g_object_new(GTK_TYPE_RADIO_MENU_ITEM, "group", group, "label", str, "visible", TRUE, NULL); if (!group) { group = item; } active = (tabs[i] == gtk_source_view_get_tab_width( GTK_SOURCE_VIEW(priv->source1))); g_object_set(item, "active", active, NULL); if (active) { g_object_set(b, "label", str, NULL); } g_signal_connect(item, "activate", G_CALLBACK(gb_view_source_tab_size_activate), source); gtk_container_add(GTK_CONTAINER(menu), item); g_free(str); } g_object_set(b, "menu", menu, NULL); item = g_object_new(GTK_TYPE_SEPARATOR_MENU_ITEM, "visible", TRUE, NULL); gtk_container_add(GTK_CONTAINER(menu), item); item = g_object_new(GTK_TYPE_CHECK_MENU_ITEM, "active", TRUE, "label", _("Use Spaces"), "visible", TRUE, NULL); g_signal_connect(item, "toggled", G_CALLBACK(gb_view_source_spaces_toggled), source); gtk_container_add(GTK_CONTAINER(menu), item); gb_widget_shrink_font(gb_menu_button_get_label_widget(GB_MENU_BUTTON(b))); gtk_style_context_add_class(gtk_widget_get_style_context(b), GB_STYLE_CLASS_TOP_BAR); gtk_container_add_with_properties(GTK_CONTAINER(controls), b, "expand", FALSE, NULL); priv->size_combo = b; } { GtkWidget *controls = gb_view_get_controls(GB_VIEW(source)); GtkWidget *img; GtkWidget *b; img = g_object_new(GTK_TYPE_IMAGE, "icon-name", "gb-split", "icon-size", GTK_ICON_SIZE_MENU, "visible", TRUE, NULL); b = g_object_new(GTK_TYPE_TOGGLE_BUTTON, "child", img, "tooltip-text", _("Split the editor into two views."), "visible", TRUE, NULL); gtk_style_context_add_class(gtk_widget_get_style_context(b), GB_STYLE_CLASS_TOP_BAR); gtk_container_add_with_properties(GTK_CONTAINER(controls), b, "expand", FALSE, NULL); g_signal_connect(b, "toggled", G_CALLBACK(split_toggled), source); } { GtkWidget *hbox; GtkWidget *vp; GtkWidget *c; hbox = g_object_new(GTK_TYPE_HBOX, "height-request", 30, "visible", TRUE, NULL); gtk_container_add_with_properties(GTK_CONTAINER(source), hbox, "height", 1, "left-attach", 0, "top-attach", 1, "width", 1, NULL); gtk_container_add(GTK_CONTAINER(hbox), (c = g_object_new(GTK_TYPE_COMBO_BOX, "visible", TRUE, NULL))); gtk_style_context_add_class(gtk_widget_get_style_context(c), GB_STYLE_CLASS_BOTTOM_BAR); vp = g_object_new(GTK_TYPE_VIEWPORT, "visible", TRUE, NULL); gtk_style_context_add_class(gtk_widget_get_style_context(vp), GB_STYLE_CLASS_BOTTOM_BAR); gtk_container_add_with_properties(GTK_CONTAINER(hbox), vp, "expand", FALSE, "fill", TRUE, NULL); priv->pos_label = g_object_new(GTK_TYPE_LABEL, "label", _("Line 1, Column 1"), "visible", TRUE, "xalign", 1.0f, "xpad", 6, NULL); gb_widget_shrink_font(priv->pos_label); gtk_container_add(GTK_CONTAINER(vp), priv->pos_label); } priv->theme_handler = g_signal_connect_swapped(gtk_settings_get_default(), "notify::gtk-application-prefer-dark-theme", G_CALLBACK(gb_view_source_update_style), source); EXIT; }
static void gth_media_viewer_page_real_activate (GthViewerPage *base, GthBrowser *browser) { GthMediaViewerPage *self; gboolean rtl; if (! gstreamer_init ()) return; self = (GthMediaViewerPage*) base; self->priv->browser = browser; g_action_map_add_action_entries (G_ACTION_MAP (browser), actions, G_N_ELEMENTS (actions), browser); self->priv->screenshot_button = gth_browser_add_header_bar_button (browser, GTH_BROWSER_HEADER_SECTION_VIEWER_VIEW, "camera-photo-symbolic", _("Take a screenshot"), "win.video-screenshot", NULL); rtl = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL; /* video area */ self->priv->area = gtk_drawing_area_new (); /* do not use the rgba visual on the drawing area */ { GdkVisual *visual; visual = gdk_screen_get_system_visual (gtk_widget_get_screen (GTK_WIDGET (self->priv->area))); if (visual != NULL) gtk_widget_set_visual (GTK_WIDGET (self->priv->area), visual); } gtk_widget_set_double_buffered (self->priv->area, FALSE); gtk_widget_add_events (self->priv->area, (gtk_widget_get_events (self->priv->area) | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_SCROLL_MASK)); gtk_widget_set_can_focus (self->priv->area, TRUE); gtk_widget_show (self->priv->area); g_signal_connect (G_OBJECT (self->priv->area), "realize", G_CALLBACK (video_area_realize_cb), self); g_signal_connect (G_OBJECT (self->priv->area), "unrealize", G_CALLBACK (video_area_unrealize_cb), self); g_signal_connect (G_OBJECT (self->priv->area), "draw", G_CALLBACK (video_area_draw_cb), self); g_signal_connect (G_OBJECT (self->priv->area), "button_press_event", G_CALLBACK (video_area_button_press_cb), self); g_signal_connect (G_OBJECT (self->priv->area), "popup-menu", G_CALLBACK (video_area_popup_menu_cb), self); g_signal_connect (G_OBJECT (self->priv->area), "scroll_event", G_CALLBACK (video_area_scroll_event_cb), self); g_signal_connect (G_OBJECT (self->priv->area), "key_press_event", G_CALLBACK (video_area_key_press_cb), self); /* mediabar */ self->priv->builder = _gtk_builder_new_from_file ("mediabar.ui", "gstreamer_tools"); self->priv->mediabar = GET_WIDGET ("mediabar"); gtk_widget_set_halign (self->priv->mediabar, GTK_ALIGN_FILL); gtk_widget_set_valign (self->priv->mediabar, GTK_ALIGN_END); gtk_image_set_from_icon_name (GTK_IMAGE (GET_WIDGET ("play_slower_image")), rtl ? "media-seek-backward-rtl-symbolic" : "media-seek-backward-symbolic", GTK_ICON_SIZE_MENU); gtk_image_set_from_icon_name (GTK_IMAGE (GET_WIDGET ("play_faster_image")), rtl ? "media-seek-forward-rtl-symbolic" : "media-seek-forward-symbolic", GTK_ICON_SIZE_MENU); g_signal_connect (GET_WIDGET ("volume_adjustment"), "value-changed", G_CALLBACK (volume_value_changed_cb), self); g_signal_connect (GET_WIDGET ("position_adjustment"), "value-changed", G_CALLBACK (position_value_changed_cb), self); g_signal_connect (GET_WIDGET ("play_button"), "clicked", G_CALLBACK (play_button_clicked_cb), self); g_signal_connect (GET_WIDGET ("play_slower_button"), "clicked", G_CALLBACK (play_slower_button_clicked_cb), self); g_signal_connect (GET_WIDGET ("play_faster_button"), "clicked", G_CALLBACK (play_faster_button_clicked_cb), self); self->priv->mediabar_revealer = gtk_revealer_new (); gtk_revealer_set_transition_type (GTK_REVEALER (self->priv->mediabar_revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP); gtk_widget_set_halign (self->priv->mediabar_revealer, GTK_ALIGN_FILL); gtk_widget_set_valign (self->priv->mediabar_revealer, GTK_ALIGN_END); gtk_widget_show (self->priv->mediabar_revealer); gtk_container_add (GTK_CONTAINER (self->priv->mediabar_revealer), self->priv->mediabar); self->priv->area_box = gtk_overlay_new (); gtk_container_add (GTK_CONTAINER (self->priv->area_box), self->priv->area); gtk_overlay_add_overlay (GTK_OVERLAY (self->priv->area_box), self->priv->mediabar_revealer); gtk_widget_show (self->priv->area_box); gth_browser_set_viewer_widget (browser, self->priv->area_box); gtk_widget_realize (self->priv->area); gth_browser_register_viewer_control (self->priv->browser, self->priv->mediabar); gth_viewer_page_focus (GTH_VIEWER_PAGE (self)); }
int main (int argc, char *argv[]) { GtkWidget *win, *overlay, *grid, *main_child, *child, *label, *sw; GdkRGBA color; gchar *str; gtk_init (&argc, &argv); win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (win), 600, 600); grid = gtk_grid_new (); child = gtk_event_box_new (); gdk_rgba_parse (&color, "red"); gtk_widget_override_background_color (child, 0, &color); gtk_widget_set_hexpand (child, TRUE); gtk_widget_set_vexpand (child, TRUE); gtk_container_add (GTK_CONTAINER (grid), child); label = gtk_label_new ("Out of overlay"); gtk_container_add (GTK_CONTAINER (child), label); overlay = gtk_overlay_new (); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS); gtk_container_add (GTK_CONTAINER (overlay), sw); main_child = gtk_event_box_new (); gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), main_child); gdk_rgba_parse (&color, "green"); gtk_widget_override_background_color (main_child, 0, &color); gtk_widget_set_hexpand (main_child, TRUE); gtk_widget_set_vexpand (main_child, TRUE); label = gtk_label_new ("Main child"); gtk_container_add (GTK_CONTAINER (main_child), label); child = gtk_label_new (NULL); str = g_strdup_printf ("%p", child); gtk_label_set_text (GTK_LABEL (child), str); g_free (str); g_print ("Bottom/Right child: %p\n", child); gtk_widget_set_halign (child, GTK_ALIGN_END); gtk_widget_set_valign (child, GTK_ALIGN_END); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child); g_signal_connect (child, "size-allocate", G_CALLBACK (child_size_allocate), overlay); child = gtk_label_new (NULL); str = g_strdup_printf ("%p", child); gtk_label_set_text (GTK_LABEL (child), str); g_free (str); g_print ("Left/Top child: %p\n", child); gtk_widget_set_halign (child, GTK_ALIGN_START); gtk_widget_set_valign (child, GTK_ALIGN_START); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child); g_signal_connect (child, "size-allocate", G_CALLBACK (child_size_allocate), overlay); child = gtk_label_new (NULL); str = g_strdup_printf ("%p", child); gtk_label_set_text (GTK_LABEL (child), str); g_free (str); g_print ("Right/Center child: %p\n", child); gtk_widget_set_halign (child, GTK_ALIGN_END); gtk_widget_set_valign (child, GTK_ALIGN_CENTER); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child); g_signal_connect (child, "size-allocate", G_CALLBACK (child_size_allocate), overlay); child = gtk_label_new (NULL); str = g_strdup_printf ("%p", child); gtk_label_set_text (GTK_LABEL (child), str); g_free (str); gtk_widget_set_margin_left (child, 55); gtk_widget_set_margin_top (child, 4); g_print ("Left/Top margined child: %p\n", child); gtk_widget_set_halign (child, GTK_ALIGN_START); gtk_widget_set_valign (child, GTK_ALIGN_START); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child); g_signal_connect (child, "size-allocate", G_CALLBACK (child_size_allocate), overlay); child = gtk_label_new (NULL); str = g_strdup_printf ("%p", child); gtk_label_set_text (GTK_LABEL (child), str); g_free (str); g_print ("Custom get-child-position child: %p\n", child); gtk_widget_set_halign (child, GTK_ALIGN_START); gtk_widget_set_valign (child, GTK_ALIGN_START); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child); g_signal_connect (child, "size-allocate", G_CALLBACK (child_size_allocate), overlay); g_signal_connect (overlay, "get-child-position", G_CALLBACK (overlay_get_child_position), child); gtk_grid_attach (GTK_GRID (grid), overlay, 1, 0, 1, 3); gtk_container_add (GTK_CONTAINER (win), grid); g_print ("\n"); gtk_widget_show_all (win); gtk_main (); return 0; }
int main (int argc, char *argv[]) { GtkWidget *win; GtkWidget *box; GtkWidget *button; GtkWidget *button2; GtkBuilder *builder; GMenuModel *model; GSimpleActionGroup *actions; GtkWidget *overlay; GtkWidget *grid; GtkWidget *popover; GtkWidget *popover2; GtkWidget *label; GtkWidget *check; GtkWidget *combo; gtk_init (&argc, &argv); win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (win), 400, 600); actions = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (actions), entries, G_N_ELEMENTS (entries), NULL); gtk_widget_insert_action_group (win, "top", G_ACTION_GROUP (actions)); overlay = gtk_overlay_new (); gtk_container_add (GTK_CONTAINER (win), overlay); grid = gtk_grid_new (); gtk_widget_set_halign (grid, GTK_ALIGN_FILL); gtk_widget_set_valign (grid, GTK_ALIGN_FILL); gtk_grid_set_row_spacing (GTK_GRID (grid), 10); gtk_grid_set_column_spacing (GTK_GRID (grid), 10); gtk_container_add (GTK_CONTAINER (overlay), grid); label = gtk_label_new (""); gtk_widget_set_hexpand (label, TRUE); gtk_widget_set_vexpand (label, TRUE); gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); label = gtk_label_new (""); gtk_widget_set_hexpand (label, TRUE); gtk_widget_set_vexpand (label, TRUE); gtk_grid_attach (GTK_GRID (grid), label, 3, 6, 1, 1); builder = gtk_builder_new_from_file ("popover.ui"); model = (GMenuModel *)gtk_builder_get_object (builder, "menu"); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); button = gtk_menu_button_new (); gtk_container_add (GTK_CONTAINER (box), button); button2 = gtk_menu_button_new (); gtk_container_add (GTK_CONTAINER (box), button2); gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), model); gtk_menu_button_set_use_popover (GTK_MENU_BUTTON (button), TRUE); popover = GTK_WIDGET (gtk_menu_button_get_popover (GTK_MENU_BUTTON (button))); builder = gtk_builder_new_from_file ("popover2.ui"); popover2 = (GtkWidget *)gtk_builder_get_object (builder, "popover"); gtk_menu_button_set_popover (GTK_MENU_BUTTON (button2), popover2); g_object_set (box, "margin", 10, NULL); gtk_widget_set_halign (box, GTK_ALIGN_END); gtk_widget_set_valign (box, GTK_ALIGN_START); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), box); label = gtk_label_new ("Popover hexpand"); check = gtk_check_button_new (); g_object_bind_property (check, "active", popover, "hexpand", G_BINDING_DEFAULT); g_object_bind_property (check, "active", popover2, "hexpand", G_BINDING_DEFAULT); gtk_grid_attach (GTK_GRID (grid), label , 1, 1, 1, 1); gtk_grid_attach (GTK_GRID (grid), check, 2, 1, 1, 1); label = gtk_label_new ("Popover vexpand"); check = gtk_check_button_new (); g_object_bind_property (check, "active", popover, "vexpand", G_BINDING_DEFAULT); g_object_bind_property (check, "active", popover2, "vexpand", G_BINDING_DEFAULT); gtk_grid_attach (GTK_GRID (grid), label , 1, 2, 1, 1); gtk_grid_attach (GTK_GRID (grid), check, 2, 2, 1, 1); label = gtk_label_new ("Button direction"); combo = gtk_combo_box_text_new (); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "up", "Up"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "down", "Down"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "left", "Left"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "right", "Right"); g_object_bind_property (combo, "active", button, "direction", G_BINDING_DEFAULT); g_object_bind_property (combo, "active", button2, "direction", G_BINDING_DEFAULT); gtk_grid_attach (GTK_GRID (grid), label , 1, 3, 1, 1); gtk_grid_attach (GTK_GRID (grid), combo, 2, 3, 1, 1); label = gtk_label_new ("Button halign"); combo = gtk_combo_box_text_new (); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "fill", "Fill"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "start", "Start"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "end", "End"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center", "Center"); g_object_bind_property (combo, "active", box, "halign", G_BINDING_DEFAULT); gtk_grid_attach (GTK_GRID (grid), label , 1, 4, 1, 1); gtk_grid_attach (GTK_GRID (grid), combo, 2, 4, 1, 1); label = gtk_label_new ("Button valign"); combo = gtk_combo_box_text_new (); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "fill", "Fill"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "start", "Start"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "end", "End"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center", "Center"); g_object_bind_property (combo, "active", box, "valign", G_BINDING_DEFAULT); gtk_grid_attach (GTK_GRID (grid), label , 1, 5, 1, 1); gtk_grid_attach (GTK_GRID (grid), combo, 2, 5, 1, 1); gtk_widget_show_all (win); gtk_main (); return 0; }
static void photos_preview_nav_buttons_constructed (GObject *object) { PhotosPreviewNavButtons *self = PHOTOS_PREVIEW_NAV_BUTTONS (object); PhotosPreviewNavButtonsPrivate *priv = self->priv; GtkStyleContext *context; GtkWidget *button; GtkWidget *image; GtkWidget *toolbar; gboolean is_rtl; const gchar *next_icon_name; const gchar *prev_icon_name; G_OBJECT_CLASS (photos_preview_nav_buttons_parent_class)->constructed (object); is_rtl = (gtk_widget_get_direction (priv->preview_view) == GTK_TEXT_DIR_RTL); prev_icon_name = is_rtl ? PHOTOS_ICON_GO_NEXT_SYMBOLIC : PHOTOS_ICON_GO_PREVIOUS_SYMBOLIC; next_icon_name = is_rtl ? PHOTOS_ICON_GO_PREVIOUS_SYMBOLIC : PHOTOS_ICON_GO_NEXT_SYMBOLIC; priv->prev_widget = gtk_revealer_new (); gtk_widget_set_halign (priv->prev_widget, GTK_ALIGN_START); gtk_widget_set_margin_start (priv->prev_widget, 30); gtk_widget_set_margin_end (priv->prev_widget, 30); gtk_widget_set_valign (priv->prev_widget, GTK_ALIGN_CENTER); gtk_revealer_set_transition_type (GTK_REVEALER (priv->prev_widget), GTK_REVEALER_TRANSITION_TYPE_CROSSFADE); gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay), priv->prev_widget); image = gtk_image_new_from_icon_name (prev_icon_name, GTK_ICON_SIZE_INVALID); gtk_image_set_pixel_size (GTK_IMAGE (image), 16); button = gtk_button_new (); gtk_container_add (GTK_CONTAINER (button), image); context = gtk_widget_get_style_context (button); gtk_style_context_add_class (context, "osd"); gtk_container_add (GTK_CONTAINER (priv->prev_widget), button); g_signal_connect_swapped (button, "clicked", G_CALLBACK (photos_preview_nav_buttons_prev_clicked), self); g_signal_connect_swapped (button, "enter-notify-event", G_CALLBACK (photos_preview_nav_buttons_enter_notify), self); g_signal_connect_swapped (button, "leave-notify-event", G_CALLBACK (photos_preview_nav_buttons_leave_notify), self); priv->next_widget = gtk_revealer_new (); gtk_widget_set_halign (priv->next_widget, GTK_ALIGN_END); gtk_widget_set_margin_start (priv->next_widget, 30); gtk_widget_set_margin_end (priv->next_widget, 30); gtk_widget_set_valign (priv->next_widget, GTK_ALIGN_CENTER); gtk_revealer_set_transition_type (GTK_REVEALER (priv->next_widget), GTK_REVEALER_TRANSITION_TYPE_CROSSFADE); gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay), priv->next_widget); image = gtk_image_new_from_icon_name (next_icon_name, GTK_ICON_SIZE_INVALID); gtk_image_set_pixel_size (GTK_IMAGE (image), 16); button = gtk_button_new (); gtk_container_add (GTK_CONTAINER (button), image); context = gtk_widget_get_style_context (button); gtk_style_context_add_class (context, "osd"); gtk_container_add (GTK_CONTAINER (priv->next_widget), button); g_signal_connect_swapped (button, "clicked", G_CALLBACK (photos_preview_nav_buttons_next_clicked), self); g_signal_connect_swapped (button, "enter-notify-event", G_CALLBACK (photos_preview_nav_buttons_enter_notify), self); g_signal_connect_swapped (button, "leave-notify-event", G_CALLBACK (photos_preview_nav_buttons_leave_notify), self); priv->toolbar_widget = gtk_revealer_new (); gtk_widget_set_halign (priv->toolbar_widget, GTK_ALIGN_FILL); gtk_widget_set_valign (priv->toolbar_widget, GTK_ALIGN_END); gtk_revealer_set_transition_type (GTK_REVEALER (priv->toolbar_widget), GTK_REVEALER_TRANSITION_TYPE_CROSSFADE); gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay), priv->toolbar_widget); toolbar = gtk_action_bar_new (); context = gtk_widget_get_style_context (toolbar); gtk_style_context_add_class (context, "osd"); gtk_container_add (GTK_CONTAINER (priv->toolbar_widget), toolbar); g_signal_connect_swapped (toolbar, "enter-notify-event", G_CALLBACK (photos_preview_nav_buttons_enter_notify), self); g_signal_connect_swapped (toolbar, "leave-notify-event", G_CALLBACK (photos_preview_nav_buttons_leave_notify), self); priv->favorite_button = gd_header_toggle_button_new (); gd_header_button_set_symbolic_icon_name (GD_HEADER_BUTTON (priv->favorite_button), PHOTOS_ICON_FAVORITE_SYMBOLIC); gtk_action_bar_pack_end (GTK_ACTION_BAR (toolbar), priv->favorite_button); g_signal_connect_swapped (priv->favorite_button, "clicked", G_CALLBACK (photos_preview_nav_buttons_favorite_clicked), self); g_signal_connect_swapped (priv->overlay, "motion-notify-event", G_CALLBACK (photos_preview_nav_buttons_motion_notify), self); }
/** * @brief * @param ui The GstSwitchUI instance. * @memberof GstSwitchUI */ static void gst_switch_ui_init (GstSwitchUI * ui) { GtkWidget *main_box, *right_box; GtkWidget *scrollwin; GtkWidget *overlay; GtkStyleContext *style; GdkDisplay *display; GdkScreen *screen; GError *error = NULL; g_mutex_init (&ui->audio_lock); g_mutex_init (&ui->compose_lock); g_mutex_init (&ui->select_lock); g_mutex_init (&ui->faces_lock); g_mutex_init (&ui->tracking_lock); display = gdk_display_get_default (); screen = gdk_display_get_default_screen (display); ui->css = gtk_css_provider_new (); gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (ui->css), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); ui->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (ui->window), 640, 480); gtk_window_set_title (GTK_WINDOW (ui->window), "GstSwitch"); g_signal_connect (G_OBJECT (ui->window), "key-press-event", G_CALLBACK (gst_switch_ui_key_event), ui); main_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5); right_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); //gtk_widget_set_hexpand (right_box, TRUE); //gtk_widget_set_vexpand (right_box, TRUE); ui->preview_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); gtk_widget_set_name (ui->preview_box, "previews"); gtk_widget_set_size_request (ui->preview_box, 120, -1); gtk_widget_set_vexpand (ui->preview_box, TRUE); overlay = gtk_overlay_new (); gtk_widget_set_hexpand (overlay, TRUE); gtk_widget_set_vexpand (overlay, TRUE); ui->compose_view = gtk_drawing_area_new (); gtk_widget_set_name (ui->compose_view, "compose"); gtk_widget_set_double_buffered (ui->compose_view, FALSE); gtk_widget_set_hexpand (ui->compose_view, TRUE); gtk_widget_set_vexpand (ui->compose_view, TRUE); gtk_widget_set_events (ui->compose_view, GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); /* g_signal_connect (ui->compose_view, "draw", G_CALLBACK (gst_switch_ui_compose_draw), ui); */ g_signal_connect (ui->compose_view, "key-press-event", G_CALLBACK (gst_switch_ui_compose_key_event), ui); g_signal_connect (ui->compose_view, "motion-notify-event", G_CALLBACK (gst_switch_ui_compose_view_motion), ui); g_signal_connect (ui->compose_view, "button-press-event", G_CALLBACK (gst_switch_ui_compose_view_press), ui); ui->compose_overlay = gtk_fixed_new (); style = gtk_widget_get_style_context (ui->compose_overlay); gtk_style_context_add_class (style, "compose"); gtk_widget_set_halign (ui->compose_overlay, GTK_ALIGN_START); gtk_widget_set_valign (ui->compose_overlay, GTK_ALIGN_START); //gtk_fixed_put (GTK_FIXED (ui->compose_overlay), w, 5, 5); ui->status = gtk_label_new (NULL); gtk_widget_set_hexpand (ui->status, TRUE); gtk_misc_set_alignment (GTK_MISC (ui->status), 1.0, 0); scrollwin = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_widget_set_size_request (scrollwin, 130, -1); gtk_widget_set_vexpand (scrollwin, TRUE); gtk_container_add (GTK_CONTAINER (scrollwin), ui->preview_box); gtk_container_add (GTK_CONTAINER (overlay), ui->compose_view); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), ui->compose_overlay); gtk_box_pack_start (GTK_BOX (right_box), overlay, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (right_box), ui->status, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (main_box), scrollwin, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (main_box), right_box, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (ui->window), main_box); gtk_container_set_border_width (GTK_CONTAINER (ui->window), 5); g_signal_connect (G_OBJECT (ui->window), "delete-event", G_CALLBACK (gst_switch_ui_window_closed), ui); gtk_css_provider_load_from_data (ui->css, gst_switch_ui_css, -1, &error); g_assert_no_error (error); /* gtk_widget_show_all (ui->window); gtk_widget_realize (ui->window); */ }
static void photos_preview_nav_buttons_constructed (GObject *object) { PhotosPreviewNavButtons *self = PHOTOS_PREVIEW_NAV_BUTTONS (object); GtkStyleContext *context; GtkWidget *button; GtkWidget *image; G_OBJECT_CLASS (photos_preview_nav_buttons_parent_class)->constructed (object); self->prev_widget = g_object_ref_sink (gtk_revealer_new ()); gtk_widget_set_halign (self->prev_widget, GTK_ALIGN_START); gtk_widget_set_margin_start (self->prev_widget, 30); gtk_widget_set_margin_end (self->prev_widget, 30); gtk_widget_set_valign (self->prev_widget, GTK_ALIGN_CENTER); gtk_revealer_set_transition_type (GTK_REVEALER (self->prev_widget), GTK_REVEALER_TRANSITION_TYPE_CROSSFADE); gtk_overlay_add_overlay (GTK_OVERLAY (self->overlay), self->prev_widget); image = gtk_image_new_from_icon_name (PHOTOS_ICON_GO_PREVIOUS_SYMBOLIC, GTK_ICON_SIZE_INVALID); gtk_image_set_pixel_size (GTK_IMAGE (image), 16); button = gtk_button_new (); gtk_button_set_image (GTK_BUTTON (button), image); gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "app.load-previous"); context = gtk_widget_get_style_context (button); gtk_style_context_add_class (context, "osd"); gtk_container_add (GTK_CONTAINER (self->prev_widget), button); g_signal_connect_swapped (button, "enter-notify-event", G_CALLBACK (photos_preview_nav_buttons_enter_notify), self); g_signal_connect_swapped (button, "leave-notify-event", G_CALLBACK (photos_preview_nav_buttons_leave_notify), self); self->next_widget = g_object_ref_sink (gtk_revealer_new ()); gtk_widget_set_halign (self->next_widget, GTK_ALIGN_END); gtk_widget_set_margin_start (self->next_widget, 30); gtk_widget_set_margin_end (self->next_widget, 30); gtk_widget_set_valign (self->next_widget, GTK_ALIGN_CENTER); gtk_revealer_set_transition_type (GTK_REVEALER (self->next_widget), GTK_REVEALER_TRANSITION_TYPE_CROSSFADE); gtk_overlay_add_overlay (GTK_OVERLAY (self->overlay), self->next_widget); image = gtk_image_new_from_icon_name (PHOTOS_ICON_GO_NEXT_SYMBOLIC, GTK_ICON_SIZE_INVALID); gtk_image_set_pixel_size (GTK_IMAGE (image), 16); button = gtk_button_new (); gtk_button_set_image (GTK_BUTTON (button), image); gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "app.load-next"); context = gtk_widget_get_style_context (button); gtk_style_context_add_class (context, "osd"); gtk_container_add (GTK_CONTAINER (self->next_widget), button); g_signal_connect_swapped (button, "enter-notify-event", G_CALLBACK (photos_preview_nav_buttons_enter_notify), self); g_signal_connect_swapped (button, "leave-notify-event", G_CALLBACK (photos_preview_nav_buttons_leave_notify), self); g_signal_connect_swapped (self->overlay, "motion-notify-event", G_CALLBACK (photos_preview_nav_buttons_motion_notify), self); self->tap_gesture = gtk_gesture_multi_press_new (self->preview_view); gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (self->tap_gesture), TRUE); g_signal_connect_swapped (self->tap_gesture, "released", G_CALLBACK (photos_preview_nav_buttons_multi_press_released), self); g_signal_connect_swapped (self->tap_gesture, "stopped", G_CALLBACK (photos_preview_nav_buttons_multi_press_stopped), self); /* We will not need them any more */ self->overlay = NULL; self->preview_view = NULL; }