int main (int argc, char *argv[]) { GtkWidget *window; GtkWidget *box; GtkWidget *footer; GtkWidget *button; GtkWidget *content; GtkCssProvider *provider; gtk_init (NULL, NULL); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_style_context_add_class (gtk_widget_get_style_context (window), "main"); provider = gtk_css_provider_new (); gtk_css_provider_load_from_data (provider, css, -1, NULL); gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (window), GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_USER); change_header (NULL, window); box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (window), box); footer = gtk_header_bar_new (); button = gtk_button_new_with_label ("Title"); g_signal_connect (button, "clicked", G_CALLBACK (change_title), footer); gtk_header_bar_pack_start (GTK_HEADER_BAR (footer), button); gtk_header_bar_set_custom_title (GTK_HEADER_BAR (footer), gtk_check_button_new_with_label ("Middle")); button = gtk_toggle_button_new_with_label ("Custom"); g_signal_connect (button, "clicked", G_CALLBACK (change_header), window); gtk_header_bar_pack_start (GTK_HEADER_BAR (footer), button); gtk_header_bar_set_custom_title (GTK_HEADER_BAR (footer), gtk_check_button_new_with_label ("Middle")); button = gtk_button_new_with_label ("Subtitle"); g_signal_connect (button, "clicked", G_CALLBACK (change_subtitle), NULL); gtk_header_bar_pack_end (GTK_HEADER_BAR (footer), button); button = gtk_button_new_with_label ("Fullscreen"); gtk_header_bar_pack_end (GTK_HEADER_BAR (footer), button); g_signal_connect (button, "clicked", G_CALLBACK (toggle_fullscreen), window); gtk_box_pack_end (GTK_BOX (box), footer, FALSE, FALSE, 0); content = gtk_image_new_from_icon_name ("start-here-symbolic", GTK_ICON_SIZE_DIALOG); gtk_image_set_pixel_size (GTK_IMAGE (content), 512); gtk_box_pack_start (GTK_BOX (box), content, FALSE, TRUE, 0); gtk_widget_show_all (window); gtk_main (); gtk_widget_destroy (window); return 0; }
static void gs_shell_set_header_end_widget (GsShell *shell, GtkWidget *widget) { GsShellPrivate *priv = gs_shell_get_instance_private (shell); GtkWidget *old_widget; GtkWidget *header; old_widget = priv->header_end_widget; header = GTK_WIDGET (gtk_builder_get_object (priv->builder, "header")); if (priv->header_end_widget == widget) return; if (widget != NULL) { g_object_ref (widget); gtk_header_bar_pack_end (GTK_HEADER_BAR (header), widget); } priv->header_end_widget = widget; if (old_widget != NULL) { gtk_container_remove (GTK_CONTAINER (header), old_widget); g_object_unref (old_widget); } }
static void setup_search (GtkAppChooserDialog *self) { gboolean use_header; g_object_get (self, "use-header-bar", &use_header, NULL); if (use_header) { GtkWidget *button; GtkWidget *image; GtkWidget *header; button = gtk_toggle_button_new (); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); image = gtk_image_new_from_icon_name ("edit-find-symbolic", GTK_ICON_SIZE_MENU); gtk_widget_show (image); gtk_container_add (GTK_CONTAINER (button), image); gtk_style_context_add_class (gtk_widget_get_style_context (button), "image-button"); gtk_style_context_remove_class (gtk_widget_get_style_context (button), "text-button"); gtk_widget_show (button); header = gtk_dialog_get_header_bar (GTK_DIALOG (self)); gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button); g_object_bind_property (button, "active", self->priv->search_bar, "search-mode-enabled", G_BINDING_BIDIRECTIONAL); g_object_bind_property (self->priv->search_entry, "sensitive", button, "sensitive", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); } }
static void garu_headerbar_init_playback_buttons (GaruHeaderbar *self) { GSettings *settings; GaruApplication *app; GtkWidget *box, *button, *image; app = GARU_APPLICATION (g_application_get_default ()); settings = garu_application_get_settings (app); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5); /* shuffle */ button = garu_utils_new_icon_button ("media-playlist-shuffle-symbolic", TRUE, FALSE); gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0); gtk_widget_show (button); /* repeat */ button = garu_utils_new_icon_button ("media-playlist-repeat-symbolic", TRUE, FALSE); gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0); gtk_widget_show (button); /* volume */ button = gtk_volume_button_new (); gtk_scale_button_set_value (GTK_SCALE_BUTTON (button), 1); g_settings_bind (settings, "volume", button, "value", G_SETTINGS_BIND_DEFAULT); gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0); gtk_widget_show (button); gtk_header_bar_pack_end (GTK_HEADER_BAR (self), box); gtk_widget_show (box); }
static void g_paste_ui_header_init (GPasteUiHeader *self) { GPasteUiHeaderPrivate *priv = g_paste_ui_header_get_instance_private (self); GtkHeaderBar *header_bar = GTK_HEADER_BAR (self); GtkWidget *settings = g_paste_ui_settings_new (); GtkWidget *search = g_paste_ui_search_new (); priv->settings = GTK_BUTTON (settings); priv->search = GTK_BUTTON (search); gtk_header_bar_set_title(header_bar, PACKAGE_STRING); gtk_header_bar_set_show_close_button (header_bar, TRUE); gtk_header_bar_pack_end (header_bar, settings); gtk_header_bar_pack_end (header_bar, search); }
/** * g_paste_ui_header_new: * @topwin: the main #GtkWindow * @client: a #GPasteClient instance * * Create a new instance of #GPasteUiHeader * * Returns: a newly allocated #GPasteUiHeader * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_header_new (GtkWindow *topwin, GPasteClient *client) { g_return_val_if_fail (GTK_IS_WINDOW (topwin), NULL); g_return_val_if_fail (G_PASTE_IS_CLIENT (client), NULL); GtkWidget *self = gtk_widget_new (G_PASTE_TYPE_UI_HEADER, NULL); GtkHeaderBar *bar = GTK_HEADER_BAR (self); gtk_header_bar_pack_start (bar, g_paste_ui_switch_new (topwin, client)); gtk_header_bar_pack_end (bar, g_paste_ui_about_new (gtk_window_get_application (topwin))); gtk_header_bar_pack_end (bar, g_paste_ui_empty_new (topwin, client)); return self; }
static void example_app_window_init (ExampleAppWindow *win) { gtk_widget_init_template (GTK_WIDGET (win)); ExampleAppWindowPrivate *priv = example_app_window_get_instance_private (win); gtk_header_bar_set_decoration_layout (GTK_HEADER_BAR (priv->header), ":"); priv->open_button = gtk_button_new_from_icon_name ("document-open-symbolic", GTK_ICON_SIZE_BUTTON); gtk_widget_set_valign (priv->open_button, GTK_ALIGN_CENTER); gtk_header_bar_pack_start (GTK_HEADER_BAR (priv->header), priv->open_button); gtk_widget_show (priv->open_button); g_signal_connect (priv->open_button, "clicked", (GCallback) on_open_clicked, win); priv->save_button = gtk_button_new_from_icon_name ("document-save-symbolic", GTK_ICON_SIZE_BUTTON); gtk_widget_set_valign (priv->save_button, GTK_ALIGN_CENTER); gtk_header_bar_pack_start (GTK_HEADER_BAR (priv->header), priv->save_button); gtk_widget_show (priv->save_button); g_signal_connect (priv->save_button, "clicked", (GCallback) on_save_clicked, win); priv->cancel_button = gtk_button_new_from_icon_name ("process-error-symbolic", GTK_ICON_SIZE_BUTTON); gtk_widget_set_valign (priv->cancel_button, GTK_ALIGN_CENTER); gtk_header_bar_pack_end (GTK_HEADER_BAR (priv->header), priv->cancel_button); gtk_widget_show (priv->cancel_button); g_signal_connect (priv->cancel_button, "clicked", (GCallback) on_cancel_clicked, win); priv->destroy_button = gtk_button_new_from_icon_name ("edit-delete-symbolic", GTK_ICON_SIZE_BUTTON); gtk_widget_set_valign (priv->destroy_button, GTK_ALIGN_CENTER); gtk_header_bar_pack_end (GTK_HEADER_BAR (priv->header), priv->destroy_button); gtk_widget_show (priv->destroy_button); g_signal_connect (priv->destroy_button, "clicked", (GCallback) on_destroy_clicked, win); }
static void setup_header_bar (GtkWidget *window, VteTerminal *vtterm, gboolean show_maximized_title) { /* * Using the default GtkHeaderBar title/subtitle widget makes the bar * too thick to look nice for a terminal, so set a custom widget. */ GtkWidget *hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5); const gchar *title = gtk_window_get_title (GTK_WINDOW (window)); GtkWidget *label = gtk_label_new (title ? title : "dwt"); g_object_bind_property (G_OBJECT (vtterm), "window-title", G_OBJECT (label), "label", G_BINDING_DEFAULT); GtkWidget *header = gtk_header_bar_new (); gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (header), TRUE); gtk_header_bar_set_has_subtitle (GTK_HEADER_BAR (header), FALSE); gtk_header_bar_set_custom_title (GTK_HEADER_BAR (header), label); GtkWidget *button = gtk_button_new_from_icon_name ("tab-new-symbolic", GTK_ICON_SIZE_BUTTON); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "app.new-terminal"); gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button); GtkWidget *revealer = gtk_revealer_new (); gtk_container_add (GTK_CONTAINER (revealer), gtk_image_new_from_icon_name ("software-update-urgent-symbolic", GTK_ICON_SIZE_BUTTON)); gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), 500); gtk_revealer_set_transition_type (GTK_REVEALER (revealer), GTK_REVEALER_TRANSITION_TYPE_CROSSFADE); gtk_header_bar_pack_end (GTK_HEADER_BAR (header), revealer); g_signal_connect (G_OBJECT (vtterm), "bell", G_CALLBACK (header_bar_term_beeped), revealer); g_object_bind_property (G_OBJECT (window), "urgency-hint", G_OBJECT (revealer), "reveal-child", G_BINDING_DEFAULT); gtk_window_set_titlebar (GTK_WINDOW (window), header); /* Hide the header bar when the window is maximized. */ if (!show_maximized_title) { g_object_bind_property (G_OBJECT (window), "is-maximized", G_OBJECT (header), "visible", G_BINDING_INVERT_BOOLEAN); } }
static void bjb_selection_toolbar_init (BjbSelectionToolbar *self) { BjbSelectionToolbarPrivate *priv; GtkWidget *widget; self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BJB_TYPE_SELECTION_TOOLBAR, BjbSelectionToolbarPrivate); priv = self->priv; widget = GTK_WIDGET (self); gtk_revealer_set_transition_type ( GTK_REVEALER (self), GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP); priv->bar = GTK_HEADER_BAR (gtk_header_bar_new ()); gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (priv->bar)); /* Trash notes */ priv->toolbar_trash = gtk_button_new_with_label (_("Delete")); gtk_header_bar_pack_start (priv->bar, priv->toolbar_trash); /* Notes color */ priv->toolbar_color = bjb_color_button_new (); gtk_widget_set_tooltip_text (GTK_WIDGET (priv->toolbar_color), _("Note color")); gtk_header_bar_pack_end (priv->bar, priv->toolbar_color); /* Notes tags */ priv->toolbar_tag = gtk_button_new_with_label (_("Add to Collection")); gtk_header_bar_pack_end (priv->bar, priv->toolbar_tag); gtk_widget_show_all (widget); bjb_selection_toolbar_fade_out (self); }
static void change_header (GtkButton *button, gpointer data) { GtkWidget *window = GTK_WIDGET (data); GtkWidget *label; GtkWidget *widget; GtkWidget *image; GtkWidget *box; if (button && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) { header = gtk_event_box_new (); gtk_style_context_add_class (gtk_widget_get_style_context (header), "titlebar"); gtk_style_context_add_class (gtk_widget_get_style_context (header), "header-bar"); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); g_object_set (box, "margin", 10, NULL); gtk_container_add (GTK_CONTAINER (header), box); label = gtk_label_new ("Label"); gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE); widget = gtk_level_bar_new (); gtk_level_bar_set_value (GTK_LEVEL_BAR (widget), 0.4); gtk_box_pack_start (GTK_BOX (box), widget, TRUE, TRUE); gtk_widget_show_all (header); } else { header = gtk_header_bar_new (); gtk_style_context_add_class (gtk_widget_get_style_context (header), "titlebar"); gtk_header_bar_set_title (GTK_HEADER_BAR (header), "Example header"); widget = gtk_button_new_with_label ("_Close"); gtk_button_set_use_underline (GTK_BUTTON (widget), TRUE); gtk_style_context_add_class (gtk_widget_get_style_context (widget), "suggested-action"); g_signal_connect (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL); gtk_header_bar_pack_end (GTK_HEADER_BAR (header), widget); widget= gtk_button_new (); image = gtk_image_new_from_icon_name ("bookmark-new-symbolic", GTK_ICON_SIZE_BUTTON); g_signal_connect (widget, "clicked", G_CALLBACK (on_bookmark_clicked), window); gtk_container_add (GTK_CONTAINER (widget), image); gtk_header_bar_pack_start (GTK_HEADER_BAR (header), widget); gtk_widget_show_all (header); } gtk_window_set_titlebar (GTK_WINDOW (window), header); }
static void ekiga_window_init_actions_toolbar (EkigaWindow *mw) { GtkWidget *image = NULL; GtkWidget *button = NULL; GtkWidget *switcher = NULL; g_return_if_fail (EKIGA_IS_WINDOW (mw)); mw->priv->actions_toolbar = gtk_header_bar_new (); gtk_window_set_titlebar (GTK_WINDOW (mw), mw->priv->actions_toolbar); /* Start packing buttons */ button = gtk_button_new (); image = gtk_image_new_from_icon_name ("call-start-symbolic", GTK_ICON_SIZE_MENU); gtk_button_set_image (GTK_BUTTON (button), image); gtk_widget_set_tooltip_text (GTK_WIDGET (button), _("Call the selected contact")); gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (button), "win.call"); gtk_header_bar_pack_start (GTK_HEADER_BAR (mw->priv->actions_toolbar), button); mw->priv->preview_button = gtk_toggle_button_new (); image = gtk_image_new_from_icon_name ("camera-web-symbolic", GTK_ICON_SIZE_MENU); gtk_button_set_image (GTK_BUTTON (mw->priv->preview_button), image); gtk_widget_set_tooltip_text (GTK_WIDGET (mw->priv->preview_button), _("Display images from your camera device")); gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (mw->priv->preview_button), "win.enable-preview"); gtk_header_bar_pack_start (GTK_HEADER_BAR (mw->priv->actions_toolbar), mw->priv->preview_button); switcher = gtk_stack_switcher_new (); gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (mw->priv->main_stack)); gtk_header_bar_set_custom_title (GTK_HEADER_BAR (mw->priv->actions_toolbar), switcher); gtk_widget_set_margin_end (GTK_WIDGET (switcher), 6); mw->priv->menu_button = gtk_menu_button_new (); g_object_set (G_OBJECT (mw->priv->menu_button), "use-popover", true, NULL); image = gtk_image_new_from_icon_name ("open-menu-symbolic", GTK_ICON_SIZE_MENU); gtk_button_set_image (GTK_BUTTON (mw->priv->menu_button), image); gtk_header_bar_pack_end (GTK_HEADER_BAR (mw->priv->actions_toolbar), mw->priv->menu_button); gtk_widget_show_all (mw->priv->actions_toolbar); gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (mw->priv->actions_toolbar), TRUE); }
GtkWidget * do_paint (GtkWidget *toplevel) { static GtkWidget *window = NULL; if (!window) { GtkWidget *draw_area, *headerbar, *colorbutton; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); draw_area = drawing_area_new (); gtk_container_add (GTK_CONTAINER (window), draw_area); headerbar = gtk_header_bar_new (); gtk_header_bar_set_title (GTK_HEADER_BAR (headerbar), "Paint"); gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (headerbar), TRUE); colorbutton = gtk_color_button_new (); g_signal_connect (colorbutton, "color-set", G_CALLBACK (color_button_color_set), draw_area); g_signal_connect (draw_area, "color-set", G_CALLBACK (drawing_area_color_set), colorbutton); gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (colorbutton), &(GdkRGBA) { 0, 0, 0, 1 }); gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), colorbutton); gtk_window_set_titlebar (GTK_WINDOW (window), headerbar); g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window); } if (!gtk_widget_get_visible (window)) gtk_widget_show (window); else gtk_widget_destroy (window); return window; }
GtkWidget * totem_interface_create_header_button (GtkWidget *header, GtkWidget *button, const char *icon_name, GtkPackType pack_type) { GtkWidget *image; GtkStyleContext *context; image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU); gtk_button_set_image (GTK_BUTTON (button), image); context = gtk_widget_get_style_context (button); gtk_style_context_add_class (context, "image-button"); g_object_set (G_OBJECT (button), "valign", GTK_ALIGN_CENTER, NULL); if (pack_type == GTK_PACK_END) gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button); else gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button); return button; }
static void GyahtzeeCreateMainWindow (GApplication *app, gpointer user_data) { GtkWidget *hbox, *vbox; GtkWidget *toolbar; GtkWidget *tmp; GtkWidget *dicebox; GtkWidget *undo_button; GtkWidget *menu_button; GtkWidget *icon; GtkBuilder *builder; GMenuModel *appmenu; int i, j; window = gtk_application_window_new (application); gtk_window_set_application (GTK_WINDOW (window), application); gtk_window_set_title (GTK_WINDOW (window), _(appName)); gtk_window_set_hide_titlebar_when_maximized (GTK_WINDOW (window), FALSE); gtk_window_set_icon_name (GTK_WINDOW (window), "org.gnome.Tali"); //games_conf_add_window (GTK_WINDOW (window), NULL); g_signal_connect (GTK_WIDGET (window), "key_press_event", G_CALLBACK (key_press), NULL); g_action_map_add_action_entries (G_ACTION_MAP (application), app_entries, G_N_ELEMENTS (app_entries), application); const gchar *vaccels_help[] = {"F1", NULL}; const gchar *vaccels_new[] = {"<Primary>n", NULL}; const gchar *vaccels_roll[] = {"<Primary>r", NULL}; const gchar *vaccels_undo[] = {"<Primary>z", NULL}; gtk_application_set_accels_for_action (application, "app.help", vaccels_help); gtk_application_set_accels_for_action (application, "app.new-game", vaccels_new); gtk_application_set_accels_for_action (application, "app.roll", vaccels_roll); gtk_application_set_accels_for_action (application, "app.undo", vaccels_undo); scores_action = g_action_map_lookup_action (G_ACTION_MAP (application), "scores"); undo_action = g_action_map_lookup_action (G_ACTION_MAP (application), "undo"); update_undo_sensitivity (); /*--- Headerbar ---*/ hbar = gtk_header_bar_new (); gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (hbar), TRUE); gtk_header_bar_set_title (GTK_HEADER_BAR (hbar), _(appName)); gtk_widget_show (hbar); gtk_window_set_titlebar (GTK_WINDOW (window), hbar); if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) undo_button = gtk_button_new_from_icon_name ("edit-undo-rtl-symbolic", GTK_ICON_SIZE_BUTTON); else undo_button = gtk_button_new_from_icon_name ("edit-undo-symbolic", GTK_ICON_SIZE_BUTTON); gtk_widget_set_valign (undo_button, GTK_ALIGN_CENTER); gtk_actionable_set_action_name (GTK_ACTIONABLE (undo_button), "app.undo"); gtk_widget_set_tooltip_text (undo_button, _("Undo your most recent move")); gtk_widget_show (undo_button); gtk_header_bar_pack_start (GTK_HEADER_BAR (hbar), undo_button); builder = gtk_builder_new_from_resource ("/org/gnome/Tali/ui/menus.ui"); appmenu = (GMenuModel *) gtk_builder_get_object (builder, "app-menu"); menu_button = gtk_menu_button_new(); icon = gtk_image_new_from_icon_name ("open-menu-symbolic", GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (menu_button), icon); gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (menu_button), appmenu); gtk_widget_show (menu_button); gtk_header_bar_pack_end (GTK_HEADER_BAR (hbar), menu_button); /*---- Content ----*/ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (window), vbox); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); /* Retreive dice pixmaps from memory or files */ LoadDicePixmaps (); /* Put all the dice in a vertical column */ dicebox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_pack_start (GTK_BOX (hbox), dicebox, FALSE, TRUE, 0); gtk_widget_show (dicebox); rollLabel = gtk_label_new (NULL); gtk_label_set_use_markup (GTK_LABEL (rollLabel), TRUE); gtk_widget_show (rollLabel); gtk_box_pack_start (GTK_BOX (dicebox), rollLabel, FALSE, TRUE, 5); mbutton = gtk_button_new_with_label (_("Roll!")); gtk_box_pack_end (GTK_BOX (dicebox), mbutton, FALSE, FALSE, 5); g_signal_connect (GTK_BUTTON (mbutton), "clicked", G_CALLBACK (roll_button_pressed_cb), NULL); gtk_widget_show (GTK_WIDGET (mbutton)); toolbar = gtk_toolbar_new (); gtk_orientable_set_orientation (GTK_ORIENTABLE (toolbar), GTK_ORIENTATION_VERTICAL); gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS); gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE); gtk_box_pack_end (GTK_BOX (dicebox), toolbar, TRUE, TRUE, 0); for (i = 0; i < NUMBER_OF_DICE; i++) { tmp = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); for (j = 0; j < NUMBER_OF_PIXMAPS; j++) { gtk_box_pack_start (GTK_BOX (tmp), dicePixmaps[i][j][GAME_YAHTZEE], FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (tmp), dicePixmaps[i][j][GAME_KISMET], FALSE, FALSE, 0); } diceBox[i] = gtk_toggle_tool_button_new (); gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (diceBox[i]), tmp); g_signal_connect (GTK_TOOL_BUTTON (diceBox[i]), "clicked", G_CALLBACK (modify_dice), &DiceValues[i]); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (diceBox[i]), -1); gtk_widget_show (GTK_WIDGET (diceBox[i])); gtk_widget_show (tmp); /*gtk_widget_show (dicePixmaps[i][0][game_type]);*/ } gtk_widget_show (toolbar); /* Scores displayed in score list */ ScoreList = create_score_list (); gtk_box_pack_end (GTK_BOX (hbox), ScoreList, TRUE, TRUE, 0); setup_score_list (ScoreList); gtk_widget_show (ScoreList); gtk_widget_show (hbox); gtk_widget_show (vbox); }
MidiogreApp *midiogre_app_init(void) { MidiogreApp *app; GtkWidget *header; GtkWidget *separator; GtkWidget *scrolled; GtkWidget *label,*frame; GtkWidget *button; GtkBox *box; gint i; GError *err; /* Allocate app */ app = calloc(1, sizeof(MidiogreApp)); /* Setup window */ app->window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); gtk_window_set_default_size(GTK_WINDOW(app->window), 600, 400); g_signal_connect(app->window, "destroy", G_CALLBACK(gtk_widget_destroyed), NULL); g_signal_connect(app->window, "key-release-event", G_CALLBACK(key_event), NULL); gtk_window_set_icon(app->window,gdk_pixbuf_new_from_resource("/org/prozum/midiogre/midiogre_logo.png",&err)); /* Setup header bar */ header = gtk_header_bar_new(); gtk_header_bar_set_title (GTK_HEADER_BAR(header), "Midiogre"); gtk_window_set_titlebar(app->window, header); /* Setup close button */ button = gtk_button_new(); gtk_container_add (GTK_CONTAINER(button), gtk_image_new_from_resource("/org/prozum/midiogre/icons/window-close-symbolic.symbolic.png")); gtk_header_bar_pack_end(GTK_HEADER_BAR(header), button); g_signal_connect_swapped(button, "clicked", G_CALLBACK(gtk_main_quit), app->window); /* Add seperator */ separator = gtk_separator_new(GTK_ORIENTATION_VERTICAL); gtk_header_bar_pack_end(GTK_HEADER_BAR(header), separator); /* Setup folder button */ button = gtk_button_new(); gtk_container_add (GTK_CONTAINER(button), gtk_image_new_from_resource("/org/prozum/midiogre/icons/document-open-symbolic.symbolic.png")); gtk_header_bar_pack_end(GTK_HEADER_BAR(header), button); g_signal_connect_swapped(button, "clicked", G_CALLBACK(folder_chooser), app->window); /* Global horizontal box */ app->win_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0)); gtk_container_add(GTK_CONTAINER(app->window), GTK_WIDGET(app->win_box)); /* Scroll container for sidepanel */ scrolled = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(app->win_box, scrolled, FALSE, FALSE, 0); /* Sidepanel box */ app->panel_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0)); gtk_container_add(GTK_CONTAINER (scrolled), GTK_WIDGET(app->panel_box)); gtk_container_set_border_width(GTK_CONTAINER(app->panel_box), 10); /* Frame with favorit info */ frame = gtk_frame_new("Favorite"); gtk_box_pack_start(app->panel_box, frame, FALSE, FALSE, 0); app->fav_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0)); gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(app->fav_box)); /* Current favorite */ app->fav_title_label = GTK_LABEL(gtk_label_new("")); gtk_label_set_max_width_chars(app->fav_title_label, 20); gtk_label_set_width_chars(app->fav_title_label, 20); gtk_box_pack_start(app->fav_box, GTK_WIDGET(app->fav_title_label), FALSE, FALSE, 0); app->fav_artist_label = GTK_LABEL(gtk_label_new("No favorite selected!")); gtk_label_set_max_width_chars(app->fav_artist_label, 20); gtk_label_set_width_chars(app->fav_artist_label, 20); gtk_box_pack_start(app->fav_box, GTK_WIDGET(app->fav_artist_label), FALSE, FALSE, 0); app->fav_album_label = GTK_LABEL(gtk_label_new("")); gtk_label_set_max_width_chars(app->fav_album_label, 20); gtk_label_set_width_chars(app->fav_album_label, 20); gtk_box_pack_start(app->fav_box, GTK_WIDGET(app->fav_album_label), FALSE, FALSE, 0); /* Frame with search criteria widgets */ frame = gtk_frame_new("Search"); gtk_box_pack_start(app->panel_box, frame, FALSE, FALSE, 0); app->search_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 10)); gtk_container_set_border_width(GTK_CONTAINER(app->search_box), 10); gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(app->search_box)); /* Title entry */ frame = gtk_frame_new("Title"); gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0); box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0)); gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(box)); gtk_container_set_border_width(GTK_CONTAINER(box), 10); app->title_entry = GTK_ENTRY(gtk_entry_new()); gtk_box_pack_start(box, GTK_WIDGET(app->title_entry), TRUE, FALSE, 0); /* Artist entry */ frame = gtk_frame_new("Artist"); gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(box), 10); box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0)); gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(box)); gtk_container_set_border_width(GTK_CONTAINER(box), 10); app->artist_entry = GTK_ENTRY(gtk_entry_new()); gtk_box_pack_start(box, GTK_WIDGET(app->artist_entry), TRUE, FALSE, 0); /* Album entry */ frame = gtk_frame_new("Album"); gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0); box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0)); gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(box)); gtk_container_set_border_width(GTK_CONTAINER(box), 10); app->album_entry = GTK_ENTRY(gtk_entry_new()); gtk_box_pack_start(box, GTK_WIDGET(app->album_entry), TRUE, FALSE, 0); /* Instrument class buttons */ frame = gtk_frame_new("Instrument Classes"); gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0); app->instr_grid = GTK_GRID(gtk_grid_new()); #if GTK_MINOR_VERSION >= 12 gtk_widget_set_margin_start(GTK_WIDGET(app->instr_grid), 10); gtk_widget_set_margin_end(GTK_WIDGET(app->instr_grid), 10); #else gtk_widget_set_margin_left(GTK_WIDGET(app->instr_grid), 10); gtk_widget_set_margin_right(GTK_WIDGET(app->instr_grid), 10); #endif gtk_widget_set_margin_bottom(GTK_WIDGET(app->instr_grid), 10); gtk_widget_set_margin_top(GTK_WIDGET(app->instr_grid), 10); gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(app->instr_grid)); for (i = 0; i < INSTR_CLASSES; i++) { label = gtk_label_new(instrument_classes[i]); gtk_widget_set_halign(GTK_WIDGET(label), GTK_ALIGN_START); gtk_grid_attach(app->instr_grid, label, 1, i + 1, 1, 1); app->instr_buttons[i] = GTK_CHECK_BUTTON(gtk_check_button_new()); gtk_widget_set_halign(GTK_WIDGET(app->instr_buttons[i]), GTK_ALIGN_END); gtk_grid_attach(app->instr_grid, GTK_WIDGET(app->instr_buttons[i]), 2, i + 1, 1, 1); } /* Result spinbutton */ frame = gtk_frame_new("Max result"); gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0); box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0)); gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(box)); gtk_container_set_border_width(GTK_CONTAINER(box), 10); app->result_spinbutton = GTK_SPIN_BUTTON(gtk_spin_button_new_with_range(1, 100, 1)); gtk_spin_button_set_value(app->result_spinbutton, 25); gtk_box_pack_start(box, GTK_WIDGET(app->result_spinbutton), TRUE, TRUE, 0); /* Search button */ app->search_button = GTK_BUTTON(gtk_button_new_with_label("Search")); gtk_box_pack_start(app->search_box, GTK_WIDGET(app->search_button), FALSE, FALSE, 0); g_signal_connect_swapped(app->search_button, "clicked", G_CALLBACK(search_event), app); /* Songboxes notebook (Tabsview) */ app->song_notebook = GTK_NOTEBOOK(gtk_notebook_new()); gtk_widget_set_hexpand(GTK_WIDGET(app->song_notebook), TRUE); gtk_box_pack_start(app->win_box, GTK_WIDGET(app->song_notebook), TRUE, TRUE, 0); /* Add song boxes */ app->songboxes[SONGBOX_ALPHA] = songbox_new(app->song_notebook, "Alphabetical"); app->songboxes[SONGBOX_FPRNT] = songbox_new(app->song_notebook, "Fingerprint"); app->songboxes[SONGBOX_BEST] = songbox_new(app->song_notebook, "Best Match"); app->songboxes[SONGBOX_POP] = songbox_new(app->song_notebook, "Popularity"); app->songboxes[SONGBOX_NEW] = songbox_new(app->song_notebook, "Newest"); /* Show all widgets */ gtk_widget_show_all(GTK_WIDGET(app->window)); /* Allocate song queue */ app->songs[SONGBOX_ALPHA] = g_queue_new(); app->songs[SONGBOX_FPRNT] = g_queue_new(); app->songs[SONGBOX_BEST] = g_queue_new(); app->songs[SONGBOX_POP] = g_queue_new(); app->songs[SONGBOX_NEW] = g_queue_new(); return app; }
int main (int argc, char *argv[]) { GtkWidget *window; GtkWidget *box; GtkWidget *header; GtkWidget *footer; GtkWidget *button; GtkWidget *image; GtkWidget *content; GtkCssProvider *provider; gtk_init (NULL, NULL); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); header = gtk_header_bar_new (); gtk_style_context_add_class (gtk_widget_get_style_context (header), "titlebar"); provider = gtk_css_provider_new (); gtk_css_provider_load_from_data (provider, css, -1, NULL); gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (window), GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_USER); gtk_header_bar_set_title (GTK_HEADER_BAR (header), "Example header"); button = gtk_button_new_from_stock (GTK_STOCK_CLOSE); gtk_style_context_add_class (gtk_widget_get_style_context (button), "suggested-action"); g_signal_connect (button, "clicked", G_CALLBACK (gtk_main_quit), NULL); gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button); button = gtk_button_new (); image = gtk_image_new_from_icon_name ("bookmark-new-symbolic", GTK_ICON_SIZE_BUTTON); gtk_container_add (GTK_CONTAINER (button), image); gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button); gtk_window_set_titlebar (GTK_WINDOW (window), header); box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (window), box); footer = gtk_header_bar_new (); button = gtk_button_new_with_label ("Start"); g_signal_connect (button, "clicked", G_CALLBACK (change_title), footer); gtk_header_bar_pack_start (GTK_HEADER_BAR (footer), button); gtk_header_bar_set_custom_title (GTK_HEADER_BAR (footer), gtk_check_button_new_with_label ("Middle")); button = gtk_button_new_with_label ("End 1"); g_signal_connect (button, "clicked", G_CALLBACK (change_subtitle), header); gtk_header_bar_pack_end (GTK_HEADER_BAR (footer), button); gtk_header_bar_pack_end (GTK_HEADER_BAR (footer), gtk_button_new_with_label ("End 2")); gtk_box_pack_end (GTK_BOX (box), footer, FALSE, FALSE, 0); content = gtk_image_new_from_icon_name ("start-here-symbolic", GTK_ICON_SIZE_DIALOG); gtk_image_set_pixel_size (GTK_IMAGE (content), 512); gtk_box_pack_start (GTK_BOX (box), content, FALSE, TRUE, 0); gtk_widget_show_all (window); gtk_main (); return 0; }
static void pragha_toolbar_init (PraghaToolbar *toolbar) { PraghaPreferences *preferences; GtkToolItem *prev_button, *play_button, *stop_button, *next_button; GtkToolItem *unfull_button, *shuffle_button, *repeat_button; GtkWidget *vol_button; const GBindingFlags binding_flags = G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL; preferences = pragha_preferences_get(); /* Setup Left control buttons */ prev_button = gtk_tool_button_new (NULL, NULL); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON(prev_button), "media-skip-backward"); gtk_widget_set_tooltip_text(GTK_WIDGET(prev_button), _("Previous Track")); toolbar->prev_button = prev_button; play_button = gtk_tool_button_new (NULL, NULL); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON(play_button), "media-playback-start"); gtk_widget_set_tooltip_text(GTK_WIDGET(play_button), _("Play / Pause Track")); toolbar->play_button = play_button; stop_button = gtk_tool_button_new (NULL, NULL); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON(stop_button), "media-playback-stop"); gtk_widget_set_tooltip_text(GTK_WIDGET(stop_button), _("Stop playback")); toolbar->stop_button = stop_button; next_button = gtk_tool_button_new (NULL, NULL); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON(next_button), "media-skip-forward"); gtk_widget_set_tooltip_text(GTK_WIDGET(next_button), _("Next Track")); toolbar->next_button = next_button; #if GTK_CHECK_VERSION (3, 12, 0) gtk_header_bar_pack_start(GTK_HEADER_BAR(toolbar), GTK_WIDGET(prev_button)); gtk_header_bar_pack_start(GTK_HEADER_BAR(toolbar), GTK_WIDGET(play_button)); gtk_header_bar_pack_start(GTK_HEADER_BAR(toolbar), GTK_WIDGET(stop_button)); gtk_header_bar_pack_start(GTK_HEADER_BAR(toolbar), GTK_WIDGET(next_button)); #else gtk_tool_insert_generic_item(GTK_TOOLBAR(toolbar), GTK_WIDGET(prev_button)); gtk_tool_insert_generic_item(GTK_TOOLBAR(toolbar), GTK_WIDGET(play_button)); gtk_tool_insert_generic_item(GTK_TOOLBAR(toolbar), GTK_WIDGET(stop_button)); gtk_tool_insert_generic_item(GTK_TOOLBAR(toolbar), GTK_WIDGET(next_button)); #endif /* Song info Box */ #if !GTK_CHECK_VERSION (3, 12, 0) GtkToolItem *boxitem = gtk_tool_item_new (); gtk_tool_item_set_expand (GTK_TOOL_ITEM(boxitem), TRUE); gtk_toolbar_insert (GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(boxitem), -1); GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_container_add (GTK_CONTAINER(boxitem), box); GtkWidget *playing = pragha_toolbar_get_song_box (toolbar); gtk_box_pack_start (GTK_BOX(box), playing, TRUE, TRUE, 5); #endif /* Setup Right control buttons */ unfull_button = gtk_tool_button_new (NULL, NULL); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON(unfull_button), "view-restore"); gtk_widget_set_tooltip_text(GTK_WIDGET(unfull_button), _("Leave Fullscreen")); toolbar->unfull_button = unfull_button; shuffle_button = gtk_toggle_tool_button_new(); gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(shuffle_button), "media-playlist-shuffle"); gtk_widget_set_tooltip_text(GTK_WIDGET(shuffle_button), _("Play songs in a random order")); repeat_button = gtk_toggle_tool_button_new (); gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(repeat_button), "media-playlist-repeat"); gtk_widget_set_tooltip_text(GTK_WIDGET(repeat_button), _("Repeat playback list at the end")); vol_button = gtk_volume_button_new(); g_object_set(vol_button, "use-symbolic", FALSE, NULL); gtk_button_set_relief(GTK_BUTTON(vol_button), GTK_RELIEF_NONE); g_object_set(G_OBJECT(vol_button), "size", GTK_ICON_SIZE_LARGE_TOOLBAR, NULL); toolbar->vol_button = vol_button; toolbar->extra_button_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); #if GTK_CHECK_VERSION (3, 12, 0) gtk_header_bar_pack_end(GTK_HEADER_BAR(toolbar), GTK_WIDGET(toolbar->extra_button_box)); gtk_header_bar_pack_end(GTK_HEADER_BAR(toolbar), GTK_WIDGET(vol_button)); gtk_header_bar_pack_end(GTK_HEADER_BAR(toolbar), GTK_WIDGET(repeat_button)); gtk_header_bar_pack_end(GTK_HEADER_BAR(toolbar), GTK_WIDGET(shuffle_button)); gtk_header_bar_pack_end(GTK_HEADER_BAR(toolbar), GTK_WIDGET(unfull_button)); #else gtk_tool_insert_generic_item(GTK_TOOLBAR(toolbar), GTK_WIDGET(unfull_button)); gtk_tool_insert_generic_item(GTK_TOOLBAR(toolbar), GTK_WIDGET(shuffle_button)); gtk_tool_insert_generic_item(GTK_TOOLBAR(toolbar), GTK_WIDGET(repeat_button)); gtk_tool_insert_generic_item(GTK_TOOLBAR(toolbar), GTK_WIDGET(vol_button)); gtk_tool_insert_generic_item(GTK_TOOLBAR(toolbar), GTK_WIDGET(toolbar->extra_button_box)); #endif /* Connect signals */ g_signal_connect(G_OBJECT(prev_button), "clicked", G_CALLBACK(prev_button_handler), toolbar); g_signal_connect(G_OBJECT(play_button), "clicked", G_CALLBACK(play_button_handler), toolbar); g_signal_connect(G_OBJECT(stop_button), "clicked", G_CALLBACK(stop_button_handler), toolbar); g_signal_connect(G_OBJECT(next_button), "clicked", G_CALLBACK(next_button_handler), toolbar); g_signal_connect(G_OBJECT(unfull_button), "clicked", G_CALLBACK(unfull_button_handler), toolbar); /*g_signal_connect(G_OBJECT (prev_button), "key-press-event", G_CALLBACK(panel_button_key_press), toolbar); g_signal_connect(G_OBJECT (play_button), "key-press-event", G_CALLBACK(panel_button_key_press), toolbar); g_signal_connect(G_OBJECT (stop_button), "key-press-event", G_CALLBACK(panel_button_key_press), toolbar); g_signal_connect(G_OBJECT (next_button), "key-press-event", G_CALLBACK(panel_button_key_press), toolbar); g_signal_connect(G_OBJECT (next_button), "key-press-event", G_CALLBACK(panel_button_key_press), toolbar); g_signal_connect(G_OBJECT (unfull_button), "key-press-event", G_CALLBACK(panel_button_key_press), toolbar); g_signal_connect(G_OBJECT (shuffle_button), "key-press-event", G_CALLBACK(panel_button_key_press), toolbar); g_signal_connect(G_OBJECT (repeat_button), "key-press-event", G_CALLBACK(panel_button_key_press), toolbar); g_signal_connect(G_OBJECT (vol_button), "key-press-event", G_CALLBACK(panel_button_key_press), toolbar);*/ g_signal_connect (G_OBJECT (vol_button), "value-changed", G_CALLBACK (vol_button_value_changed), toolbar); g_object_bind_property(preferences, "shuffle", shuffle_button, "active", binding_flags); g_object_bind_property(preferences, "repeat", repeat_button, "active", binding_flags); /* Fix styling */ #if GTK_CHECK_VERSION (3, 12, 0) pragha_toolbar_set_style(toolbar, pragha_preferences_get_gnome_style (preferences)); #endif gtk_widget_show(GTK_WIDGET(prev_button)); gtk_widget_show(GTK_WIDGET(play_button)); gtk_widget_show(GTK_WIDGET(stop_button)); gtk_widget_show(GTK_WIDGET(next_button)); gtk_widget_show(GTK_WIDGET(shuffle_button)); gtk_widget_show(GTK_WIDGET(repeat_button)); gtk_widget_show(GTK_WIDGET(vol_button)); gtk_widget_hide(GTK_WIDGET(toolbar->unfull_button)); gtk_widget_show(GTK_WIDGET(toolbar)); g_object_unref(preferences); }
static void ev_previewer_toolbar_constructed (GObject *object) { EvPreviewerToolbar *ev_previewer_toolbar = EV_PREVIEWER_TOOLBAR (object); EvPreviewerToolbarPrivate *priv; GtkWidget *hbox; GtkBuilder *builder; G_OBJECT_CLASS (ev_previewer_toolbar_parent_class)->constructed (object); priv = ev_previewer_toolbar_get_instance_private (ev_previewer_toolbar); builder = gtk_builder_new_from_resource ("/org/gnome/evince/previewer/ui/previewer.ui"); hbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); gtk_widget_set_halign (hbox, GTK_ALIGN_CENTER); gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_EXPAND); gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE); priv->previous_button = GTK_WIDGET (gtk_builder_get_object (builder, "go-previous-page")); gtk_box_pack_start (GTK_BOX (hbox), priv->previous_button, FALSE, FALSE, 0); gtk_widget_show (priv->previous_button); priv->next_button = GTK_WIDGET (gtk_builder_get_object (builder, "go-next-page")); gtk_box_pack_start (GTK_BOX (hbox), priv->next_button, FALSE, FALSE, 0); gtk_widget_show (priv->next_button); gtk_header_bar_pack_start (GTK_HEADER_BAR (ev_previewer_toolbar), hbox); gtk_widget_show (hbox); /* Page selector */ priv->page_selector = GTK_WIDGET (g_object_new (EV_TYPE_PAGE_ACTION_WIDGET, NULL)); gtk_widget_set_tooltip_text (priv->page_selector, _("Select page or search in the index")); atk_object_set_name (gtk_widget_get_accessible (priv->page_selector), _("Select page")); ev_page_action_widget_set_model (EV_PAGE_ACTION_WIDGET (priv->page_selector), ev_previewer_window_get_document_model (priv->window)); gtk_header_bar_pack_start (GTK_HEADER_BAR (ev_previewer_toolbar), priv->page_selector); gtk_widget_show (priv->page_selector); /* Print */ priv->print_button = GTK_WIDGET (gtk_builder_get_object (builder, "print")); gtk_header_bar_pack_end (GTK_HEADER_BAR (ev_previewer_toolbar), priv->print_button); gtk_widget_show (priv->print_button); /* Zoom */ hbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); gtk_widget_set_halign (hbox, GTK_ALIGN_CENTER); gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_EXPAND); gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE); priv->zoom_in_button = GTK_WIDGET (gtk_builder_get_object (builder, "zoom-in")); gtk_box_pack_start (GTK_BOX (hbox), priv->zoom_in_button, FALSE, FALSE, 0); gtk_widget_show (priv->zoom_in_button); priv->zoom_default_button = GTK_WIDGET (gtk_builder_get_object (builder, "zoom-default")); gtk_box_pack_start (GTK_BOX (hbox), priv->zoom_default_button, FALSE, FALSE, 0); gtk_widget_show (priv->zoom_default_button); priv->zoom_out_button = GTK_WIDGET (gtk_builder_get_object (builder, "zoom-out")); gtk_box_pack_start (GTK_BOX (hbox), priv->zoom_out_button, FALSE, FALSE, 0); gtk_widget_show (priv->zoom_out_button); gtk_header_bar_pack_end (GTK_HEADER_BAR (ev_previewer_toolbar), hbox); gtk_widget_show (hbox); g_object_unref (builder); }
static void on_activate (GApplication *app, gpointer data) { static GtkWidget *window = NULL; if (window == NULL) { GtkWidget *header, *sidebar_toggle, *animation_switch; GtkWidget *hbox, *revealer, *sidebar, *img; window = gtk_application_window_new (GTK_APPLICATION (app)); gtk_window_set_default_size (GTK_WINDOW (window), 400, 300); /* titlebar */ header = gtk_header_bar_new (); gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE); gtk_window_set_titlebar (GTK_WINDOW (window), header); sidebar_toggle = gtk_toggle_button_new_with_label ("Show Sidebar"); gtk_header_bar_pack_start (GTK_HEADER_BAR (header), sidebar_toggle); animation_switch = gtk_switch_new (); gtk_widget_set_valign (animation_switch, GTK_ALIGN_CENTER); gtk_header_bar_pack_end (GTK_HEADER_BAR (header), animation_switch); gtk_header_bar_pack_end (GTK_HEADER_BAR (header), gtk_label_new ("Animations")); /* content */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_container_add (GTK_CONTAINER (window), hbox); revealer = gtk_revealer_new (); gtk_revealer_set_transition_type (GTK_REVEALER (revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT); gtk_container_add (GTK_CONTAINER (hbox), revealer); sidebar = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_widget_set_size_request (sidebar, 150, -1); gtk_style_context_add_class (gtk_widget_get_style_context (sidebar), GTK_STYLE_CLASS_SIDEBAR); gtk_container_add (GTK_CONTAINER (revealer), sidebar); img = gtk_image_new (); g_object_set (img, "icon-name", "face-smile-symbolic", "pixel-size", 128, "hexpand", TRUE, "halign", GTK_ALIGN_CENTER, "valign", GTK_ALIGN_CENTER, NULL); gtk_container_add (GTK_CONTAINER (hbox), img); g_object_bind_property (sidebar_toggle, "active", revealer, "reveal-child", G_BINDING_SYNC_CREATE); g_object_bind_property (gtk_settings_get_default(), "gtk-enable-animations", animation_switch, "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); } gtk_window_present (GTK_WINDOW (window)); }
GtkWidget * reader_window_new(GtkApplication *application, CainteoirSettings *settings, CainteoirSpeechSynthesizers *synthesizers, const gchar *filename) { ReaderWindow *reader = READER_WINDOW(g_object_new(READER_TYPE_WINDOW, "application", application, nullptr)); ReaderWindowPrivate *priv = READER_WINDOW_PRIVATE(reader); priv->self = GTK_WIDGET(reader); priv->settings = CAINTEOIR_SETTINGS(g_object_ref(G_OBJECT(settings))); priv->tts = CAINTEOIR_SPEECH_SYNTHESIZERS(g_object_ref(G_OBJECT(synthesizers))); priv->application = READER_APPLICATION(application); gtk_window_set_default_size(GTK_WINDOW(reader), INDEX_PANE_WIDTH + DOCUMENT_PANE_WIDTH + 5, 300); gtk_window_set_title(GTK_WINDOW(reader), i18n("Cainteoir Text-to-Speech")); GtkWidget *layout = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_container_add(GTK_CONTAINER(reader), layout); priv->header = gtk_header_bar_new(); gtk_header_bar_set_title(GTK_HEADER_BAR(priv->header), i18n("Cainteoir Text-to-Speech")); if (cainteoir_settings_get_boolean(priv->settings, "window", "have-csd", TRUE)) { // Use client-side decorations (e.g. on Gnome Shell and Unity) ... gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(priv->header), TRUE); gtk_window_set_titlebar(GTK_WINDOW(reader), priv->header); } else { // Don't use client-side decorations (e.g. on KDE) ... gtk_box_pack_start(GTK_BOX(layout), priv->header, FALSE, FALSE, 0); } priv->actions = create_action_group(priv); gtk_widget_insert_action_group(GTK_WIDGET(reader), "cainteoir", G_ACTION_GROUP(priv->actions)); priv->view = reader_document_view_new(priv->settings); gtk_box_pack_start(GTK_BOX(layout), priv->view, TRUE, TRUE, 0); reader_document_view_set_index_pane_close_action_name(READER_DOCUMENT_VIEW(priv->view), "cainteoir.side-pane"); GtkWidget *bottombar = gtk_toolbar_new(); gtk_widget_set_size_request(bottombar, -1, 45); gtk_style_context_add_class(gtk_widget_get_style_context(bottombar), "bottombar"); gtk_box_pack_start(GTK_BOX(layout), bottombar, FALSE, FALSE, 0); GtkToolItem *record = gtk_tool_button_new(gtk_image_new_from_icon_name("media-record-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR), nullptr); gtk_toolbar_insert(GTK_TOOLBAR(bottombar), record, -1); gtk_actionable_set_action_name(GTK_ACTIONABLE(record), "cainteoir.record"); priv->play_stop = gtk_tool_button_new(nullptr, nullptr); gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(priv->play_stop), "media-playback-start-symbolic"); gtk_toolbar_insert(GTK_TOOLBAR(bottombar), priv->play_stop, -1); gtk_actionable_set_action_name(GTK_ACTIONABLE(priv->play_stop), "cainteoir.play-stop"); GtkToolItem *open = gtk_tool_button_new(gtk_image_new_from_icon_name("document-open-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR), nullptr); gtk_toolbar_insert(GTK_TOOLBAR(bottombar), open, -1); gtk_actionable_set_action_name(GTK_ACTIONABLE(open), "cainteoir.open"); GtkToolItem *timebar = gtk_tool_item_new(); gtk_tool_item_set_expand(GTK_TOOL_ITEM(timebar), TRUE); gtk_toolbar_insert(GTK_TOOLBAR(bottombar), timebar, -1); priv->timebar = cainteoir_timebar_new(); gtk_style_context_add_class(gtk_widget_get_style_context(priv->timebar), "timebar"); gtk_container_add(GTK_CONTAINER(timebar), priv->timebar); priv->previous = gtk_button_new(); gtk_button_set_image(GTK_BUTTON(priv->previous), gtk_image_new_from_icon_name("go-previous-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR)); gtk_header_bar_pack_start(GTK_HEADER_BAR(priv->header), priv->previous); gtk_actionable_set_action_name(GTK_ACTIONABLE(priv->previous), "cainteoir.view-previous"); GtkWidget *menu_button = gtk_menu_button_new(); gtk_button_set_image(GTK_BUTTON(menu_button), gtk_image_new_from_icon_name(HAMBURGER_MENU_ICON, GTK_ICON_SIZE_SMALL_TOOLBAR)); gtk_menu_button_set_menu_model(GTK_MENU_BUTTON(menu_button), create_main_menu()); gtk_header_bar_pack_end(GTK_HEADER_BAR(priv->header), menu_button); g_signal_connect(reader, "window-state-event", G_CALLBACK(on_window_state_changed), priv->settings); g_signal_connect(reader, "delete_event", G_CALLBACK(on_window_delete), priv); g_signal_connect(reader, "show", G_CALLBACK(on_window_show), priv); g_signal_connect(priv->tts, "speaking", G_CALLBACK(on_speaking), priv); g_signal_connect(priv->tts, "text-range-changed", G_CALLBACK(on_text_range_changed), priv); gtk_window_resize(GTK_WINDOW(reader), cainteoir_settings_get_integer(priv->settings, "window", "width", 700), cainteoir_settings_get_integer(priv->settings, "window", "height", 445)); gtk_window_move(GTK_WINDOW(reader), cainteoir_settings_get_integer(priv->settings, "window", "left", 0), cainteoir_settings_get_integer(priv->settings, "window", "top", 0)); if (cainteoir_settings_get_boolean(priv->settings, "window", "maximized", FALSE)) gtk_window_maximize(GTK_WINDOW(reader)); if (filename) reader_window_load_document(reader, filename); else { gchar *prev_filename = cainteoir_settings_get_string(priv->settings, "document", "filename", nullptr); if (prev_filename) { reader_window_load_document(reader, prev_filename); g_free(prev_filename); } } gchar *anchor = cainteoir_settings_get_string(priv->settings, "highlight", "anchor", "none"); if (anchor) { if (!strcmp(anchor, "top")) reader_window_set_highlight_anchor(reader, GTK_ALIGN_START); else if (!strcmp(anchor, "middle")) reader_window_set_highlight_anchor(reader, GTK_ALIGN_CENTER); else if (!strcmp(anchor, "bottom")) reader_window_set_highlight_anchor(reader, GTK_ALIGN_END); g_free(anchor); } return GTK_WIDGET(reader); }
/*********************************************************************** Menu */ void bmd_construct_menu (GtkApplication *app, gpointer data) { GtkWidget *headerbar; // the application menu displayed in the GNOME panel GMenu *appmenu; GMenu *editmenu; GtkWidget *openbutton; GtkWidget *savebutton; // the menu displayed as a popover below the gears button GMenu *gearmenu; GtkWidget *gearmenubutton; GtkWidget *gearicon; bmd_widgets *a = (bmd_widgets *) data; // define keyboard accelerators const gchar *open_accels[2] = { "<Ctrl>O", NULL }; const gchar *save_accels[2] = { "<Ctrl>S", NULL }; const gchar *quit_accels[2] = { "<Ctrl>Q", NULL }; const gchar *add_accels[2] = { "<Ctrl>A", NULL }; const gchar *del_accels[2] = { "<Ctrl>D", NULL }; const gchar *find_accels[2] = { "<Ctrl>F", NULL }; const gchar *help_accels[2] = { "F1", NULL }; // create and fill in the application menu in the GNOME panel appmenu = g_menu_new(); g_menu_append (appmenu, "About", "app.about"); g_menu_append (appmenu, "Help", "app.help"); g_menu_append (appmenu, "_Quit", "app.quit"); gtk_application_set_app_menu (GTK_APPLICATION (app), G_MENU_MODEL (appmenu)); g_object_unref (appmenu); // create a headerbar headerbar = gtk_header_bar_new (); gtk_widget_show (headerbar); gtk_header_bar_set_title (GTK_HEADER_BAR (headerbar), "Book Management"); gtk_header_bar_set_subtitle (GTK_HEADER_BAR (headerbar), "Simple Demo Application"); gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (headerbar), TRUE); gtk_window_set_titlebar (GTK_WINDOW (a->window), headerbar); // create an OPEN button, add it to the headerbar and connect the callbacks openbutton = gtk_button_new_with_label ("Open"); gtk_header_bar_pack_start (GTK_HEADER_BAR (headerbar), openbutton); gtk_actionable_set_action_name (GTK_ACTIONABLE (openbutton), "app.open"); // create the gear menu button gearmenubutton = gtk_menu_button_new(); gearicon = gtk_image_new_from_icon_name ("emblem-system-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_button_set_image (GTK_BUTTON (gearmenubutton), gearicon); gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), gearmenubutton); // create a menu for the gear button gearmenu = g_menu_new(); g_menu_append (gearmenu, "Save As ...", "app.saveAs"); editmenu = g_menu_new(); g_menu_append (editmenu, "_Find", "app.find"); g_menu_append (editmenu, "_Add", "app.add"); g_menu_append (editmenu, "_Delete", "app.delete"); g_menu_append_section (gearmenu, NULL, G_MENU_MODEL (editmenu)); gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (gearmenubutton), G_MENU_MODEL (gearmenu)); g_object_unref (editmenu); g_object_unref (gearmenu); // create an SAVE button, add it to the headerbar and connect the callbacks savebutton = gtk_button_new_with_label ("Save"); gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), savebutton); gtk_actionable_set_action_name (GTK_ACTIONABLE (savebutton), "app.save"); // connect keyboard accelerators gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.open", open_accels); gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.save", save_accels); gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.quit", quit_accels); gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.add", add_accels); gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.delete", del_accels); gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.find", find_accels); gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.help", help_accels); }
/** * Creates empty main application window */ GtkWidget *create_mainwindow (ezeedo_wrapper_structure *ezeedo) { // define widgets GtkWidget *window; GtkWidget *headerbar; GtkWidget *windowmenu_button; GtkWidget *stack; GtkWidget *stackswitcher; GtkWidget *todo_stack; GtkWidget *todo_paned; GtkWidget *todolist_scrollbox; GtkWidget *todolist_box; GtkWidget *categories_scrollbox; GtkWidget *categories_box; GtkWidget *task_entry; GtkWidget *done_stack; GtkWidget *donelist_scrollbox; GtkWidget *donelist_box; GtkWidget *archive_button; // define action GSimpleAction *about_action; // get window size and position from gsettings store GSettings *settings; gint width; gint height; gint x; gint y; gint sidebar_size; settings = g_settings_new ("org.y20k.ezeedo"); width = g_settings_get_int (settings, "main-window-width"); height = g_settings_get_int (settings, "main-window-height"); x = g_settings_get_int (settings, "main-window-position-y"); y = g_settings_get_int (settings, "main-window-position-y"); sidebar_size = g_settings_get_int (settings, "sidebar-size"); g_object_unref (settings); // create main window with title and default size window = gtk_application_window_new (ezeedo->application); gtk_window_set_title (GTK_WINDOW (window), "Ezeedo"); gtk_window_set_icon_name (GTK_WINDOW (window), EZEEDOICON); gtk_window_set_default_size (GTK_WINDOW (window), width, height); gtk_window_move (GTK_WINDOW (window), x, y); // create headerbar and stack switcher headerbar = gtk_header_bar_new (); gtk_header_bar_set_show_close_button (GTK_HEADER_BAR(headerbar), true); stackswitcher = gtk_stack_switcher_new (); // create stack for todo and done stack = gtk_stack_new (); // create stack for todolist todo_stack = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); // create paned container for left and right columns of todo tab todo_paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); gtk_paned_set_position (GTK_PANED(todo_paned), sidebar_size); // create categories scrollbox and box for left pane categories_scrollbox = gtk_scrolled_window_new (NULL, NULL); categories_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); // create todolist scrollbox and box for right pane todolist_scrollbox = gtk_scrolled_window_new (NULL, NULL); todolist_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); // create task entry task_entry = gtk_entry_new (); gtk_widget_set_margin_start (GTK_WIDGET(task_entry), 10); gtk_widget_set_margin_end (GTK_WIDGET(task_entry), 10); gtk_widget_set_margin_top (GTK_WIDGET(task_entry), 10); gtk_widget_set_margin_bottom (GTK_WIDGET(task_entry), 10); gtk_entry_set_placeholder_text (GTK_ENTRY(task_entry), "Enter new task"); gtk_entry_set_max_length (GTK_ENTRY(task_entry), TASKLENGTH); gtk_widget_grab_focus (task_entry); // create stack for donelist done_stack = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); // create donelist scrollbox and box donelist_scrollbox = gtk_scrolled_window_new (NULL, NULL); donelist_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); // create archive button archive_button = gtk_button_new_with_label ("Archive all done tasks"); gtk_widget_set_margin_start (GTK_WIDGET (archive_button), 10); gtk_widget_set_margin_end (GTK_WIDGET (archive_button), 10); gtk_widget_set_margin_top (GTK_WIDGET (archive_button), 10); gtk_widget_set_margin_bottom (GTK_WIDGET (archive_button), 10); // add some widgets to ezeedo wrapper structure ezeedo->window = window; ezeedo->todo_paned = todo_paned; ezeedo->categories_box = categories_box; ezeedo->todolist_box = todolist_box; ezeedo->donelist_box = donelist_box; // create window menu windowmenu_button = create_windowmenu (ezeedo); // create about action and connect about action signal about_action = g_simple_action_new ("about", NULL); g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (about_action)); g_signal_connect (about_action, "activate", G_CALLBACK (show_about_window), window); // detect entry signal g_signal_connect (task_entry, "activate", G_CALLBACK (add_task_entry), ezeedo); // detect archive button pressed g_signal_connect (archive_button, "clicked", G_CALLBACK (display_info_dialog), "Task archival is not supported yet."); // detect window close g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (close_window), ezeedo); // construct headerbar for main window gtk_window_set_titlebar (GTK_WINDOW(window), headerbar); gtk_header_bar_pack_start (GTK_HEADER_BAR(headerbar), stackswitcher); gtk_header_bar_pack_end (GTK_HEADER_BAR(headerbar), windowmenu_button); // add stack to main window gtk_container_add (GTK_CONTAINER(window), stack); // set stack switcher and populate stack with todolist and donelist gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER(stackswitcher), GTK_STACK(stack)); gtk_stack_add_titled (GTK_STACK(stack), todo_stack, "To do", "To do"); gtk_stack_add_titled (GTK_STACK(stack), done_stack, "Done", "Done"); // construct main todo stack gtk_container_add (GTK_CONTAINER(todo_stack), todo_paned); gtk_paned_add1 (GTK_PANED(todo_paned), categories_scrollbox); gtk_paned_add2 (GTK_PANED(todo_paned), todolist_scrollbox); // add box to scrollable box gtk_container_add (GTK_CONTAINER(todolist_scrollbox), todolist_box); // add task entry to todo stack gtk_container_add (GTK_CONTAINER(todo_stack), task_entry); // add box to scrollable box gtk_container_add (GTK_CONTAINER(categories_scrollbox), categories_box); // construct main donelist stack gtk_container_add (GTK_CONTAINER(done_stack), donelist_scrollbox); gtk_container_add (GTK_CONTAINER(donelist_scrollbox), donelist_box); return (window); }
void main_window_enable_csd(MainWindow *wnd) { GIcon *open_icon; GIcon *fullscreen_icon; GIcon *menu_icon; open_icon = g_themed_icon_new_with_default_fallbacks ("list-add-symbolic"); fullscreen_icon = g_themed_icon_new_with_default_fallbacks ("view-fullscreen-symbolic"); menu_icon = g_themed_icon_new_with_default_fallbacks ("view-list-symbolic"); wnd->playlist_width = PLAYLIST_DEFAULT_WIDTH+PLAYLIST_CSD_OFFSET; wnd->open_hdr_btn = gtk_menu_button_new(); wnd->fullscreen_hdr_btn = gtk_button_new(); wnd->menu_hdr_btn = gtk_menu_button_new(); gtk_widget_set_can_focus(wnd->open_hdr_btn, FALSE); gtk_widget_set_can_focus(wnd->fullscreen_hdr_btn, FALSE); gtk_widget_set_can_focus(wnd->menu_hdr_btn, FALSE); gtk_button_set_image ( GTK_BUTTON(wnd->fullscreen_hdr_btn), gtk_image_new_from_gicon (fullscreen_icon, GTK_ICON_SIZE_MENU )); gtk_button_set_image ( GTK_BUTTON(wnd->open_hdr_btn), gtk_image_new_from_gicon (open_icon, GTK_ICON_SIZE_MENU )); gtk_button_set_image ( GTK_BUTTON(wnd->menu_hdr_btn), gtk_image_new_from_gicon (menu_icon, GTK_ICON_SIZE_MENU )); gtk_menu_button_set_menu_model ( GTK_MENU_BUTTON(wnd->open_hdr_btn), G_MENU_MODEL(open_btn_build_menu()) ); gtk_menu_button_set_menu_model ( GTK_MENU_BUTTON(wnd->menu_hdr_btn), G_MENU_MODEL(menu_btn_build_menu()) ); gtk_header_bar_pack_start (GTK_HEADER_BAR(wnd->header_bar), wnd->open_hdr_btn); gtk_header_bar_pack_end (GTK_HEADER_BAR(wnd->header_bar), wnd->menu_hdr_btn); gtk_header_bar_pack_end (GTK_HEADER_BAR(wnd->header_bar), wnd->fullscreen_hdr_btn); gtk_actionable_set_action_name (GTK_ACTIONABLE(wnd->fullscreen_hdr_btn), "app.fullscreen"); gtk_paned_set_position( GTK_PANED(wnd->vid_area_paned), MAIN_WINDOW_DEFAULT_WIDTH -PLAYLIST_DEFAULT_WIDTH -PLAYLIST_CSD_OFFSET ); gtk_window_set_titlebar(GTK_WINDOW(wnd), wnd->header_bar); gtk_window_set_title(GTK_WINDOW(wnd), g_get_application_name()); }