static GtkWidget * normal_contents (void) { GtkWidget *table; GtkWidget *toolbar; GtkWidget *handlebox; GtkWidget *statusbar; GtkWidget *contents; GtkWidget *sw; GtkItemFactory *item_factory; table = gtk_table_new (1, 4, FALSE); /* Create the menubar */ item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", NULL); gtk_item_factory_set_translate_func(item_factory, (GtkTranslateFunc)gettext, NULL, NULL); /* Set up item factory to go away */ g_object_ref (item_factory); g_object_ref_sink (item_factory); g_object_unref (item_factory); g_object_set_data_full (G_OBJECT (table), "<main>", item_factory, (GDestroyNotify) g_object_unref); /* create menu items */ gtk_item_factory_create_items (item_factory, G_N_ELEMENTS (menu_items), menu_items, NULL); gtk_table_attach (GTK_TABLE (table), gtk_item_factory_get_widget (item_factory, "<main>"), /* X direction */ /* Y direction */ 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0); /* Create the toolbar */ toolbar = gtk_toolbar_new (); GtkToolItem *newButton = gtk_tool_button_new_from_stock(GTK_STOCK_NEW); gtk_tool_item_set_tooltip_text(newButton, "Open another one of these windows"); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), newButton, -1); /*-1 means append to end of toolbar*/ GtkToolItem *openButton = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN); gtk_tool_item_set_tooltip_text(openButton, "This is a demo button with an \'open\' icon"); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), openButton, -1); /*-1 means append to end of toolbar*/ GtkToolItem *quitButton = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT); gtk_tool_item_set_tooltip_text(quitButton, "This is a demo button with a \'quit\' icon"); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), quitButton, -1); /*-1 means append to end of toolbar*/ handlebox = gtk_handle_box_new (); gtk_container_add (GTK_CONTAINER (handlebox), toolbar); gtk_table_attach (GTK_TABLE (table), handlebox, /* X direction */ /* Y direction */ 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); /* Create document */ sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN); gtk_table_attach (GTK_TABLE (table), sw, /* X direction */ /* Y direction */ 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); contents = gtk_text_view_new (); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (contents), PANGO_WRAP_WORD); gtk_container_add (GTK_CONTAINER (sw), contents); /* Create statusbar */ statusbar = gtk_statusbar_new (); gtk_table_attach (GTK_TABLE (table), statusbar, /* X direction */ /* Y direction */ 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_widget_show_all (table); return table; }
static void ephy_find_toolbar_init (EphyFindToolbar *toolbar) { EphyFindToolbarPrivate *priv; GtkToolbar *gtoolbar; GtkToolItem *item; GtkWidget *alignment, *arrow, *box; GtkWidget *checkbox; priv = toolbar->priv = EPHY_FIND_TOOLBAR_GET_PRIVATE (toolbar); gtoolbar = GTK_TOOLBAR (toolbar); gtk_toolbar_set_style (gtoolbar, GTK_TOOLBAR_BOTH_HORIZ); /* Find: |_____| */ alignment = gtk_alignment_new (0.0, 0.5, 1.0, 0.0); gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 2, 2); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_container_add (GTK_CONTAINER (alignment), box); priv->label = gtk_label_new (NULL); gtk_box_pack_start (GTK_BOX (box), priv->label, FALSE, FALSE, 0); priv->entry = gtk_entry_new (); gtk_entry_set_width_chars (GTK_ENTRY (priv->entry), 32); gtk_entry_set_max_length (GTK_ENTRY (priv->entry), 512); gtk_box_pack_start (GTK_BOX (box), priv->entry, TRUE, TRUE, 0); item = gtk_tool_item_new (); gtk_container_add (GTK_CONTAINER (item), alignment); /* gtk_tool_item_set_expand (item, TRUE); */ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); gtk_widget_show_all (GTK_WIDGET (item)); /* Prev */ arrow = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_NONE); priv->prev = gtk_tool_button_new (arrow, _("Find Previous")); gtk_tool_item_set_is_important (priv->prev, TRUE); gtk_tool_item_set_tooltip_text (priv->prev, _("Find previous occurrence of the search string")); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->prev, -1); gtk_widget_show_all (GTK_WIDGET (priv->prev)); /* Next */ arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE); priv->next = gtk_tool_button_new (arrow, _("Find Next")); gtk_tool_item_set_is_important (priv->next, TRUE); gtk_tool_item_set_tooltip_text (priv->next, _("Find next occurrence of the search string")); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->next, -1); gtk_widget_show_all (GTK_WIDGET (priv->next)); /* Case sensitivity */ checkbox = gtk_check_button_new_with_mnemonic (_("_Case sensitive")); priv->case_sensitive = checkbox; item = gtk_tool_item_new (); gtk_container_add (GTK_CONTAINER (item), checkbox); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); gtk_widget_show_all (GTK_WIDGET (item)); /* Populate the overflow menu */ g_signal_connect (item, "create-menu-proxy", G_CALLBACK (toolitem_create_menu_proxy_cb), toolbar); priv->sep = gtk_separator_tool_item_new (); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->sep, -1); priv->status_item = gtk_tool_item_new (); gtk_tool_item_set_expand (priv->status_item, TRUE); priv->status_label = gtk_label_new (""); gtk_misc_set_alignment (GTK_MISC (priv->status_label), 0.0, 0.5); gtk_label_set_ellipsize (GTK_LABEL (priv->status_label), PANGO_ELLIPSIZE_END); gtk_container_add (GTK_CONTAINER (priv->status_item), priv->status_label); gtk_widget_show (priv->status_label); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), priv->status_item, -1); /* connect signals */ g_signal_connect (priv->entry, "key-press-event", G_CALLBACK (entry_key_press_event_cb), toolbar); g_signal_connect_after (priv->entry, "changed", G_CALLBACK (entry_changed_cb), toolbar); g_signal_connect (priv->entry, "activate", G_CALLBACK (entry_activate_cb), toolbar); g_signal_connect_swapped (priv->next, "clicked", G_CALLBACK (find_next_cb), toolbar); g_signal_connect_swapped (priv->prev, "clicked", G_CALLBACK (find_prev_cb), toolbar); g_signal_connect (priv->case_sensitive, "toggled", G_CALLBACK (case_sensitive_toggled_cb), toolbar); }
static void activate (GtkApplication *app, gpointer user_data) { GtkWidget *grid; GtkWidget *window; GtkWidget *toolbar; GtkToolItem *new_button; GtkToolItem *open_button; GtkToolItem *undo_button; GtkStyleContext *style_context; GSimpleAction *undo_action; window = gtk_application_window_new (app); gtk_window_set_title (GTK_WINDOW (window), "Toolbar with Tooltips Example"); gtk_window_set_default_size (GTK_WINDOW (window), 400, 200); /* Here we begin to create the toolbar */ toolbar = gtk_toolbar_new (); /* Set the toolbar to be the primary toolbar of the application */ style_context = gtk_widget_get_style_context (toolbar); gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_PRIMARY_TOOLBAR); /* Create a button for the "new" action, with a stock image */ new_button = gtk_tool_button_new_from_stock (GTK_STOCK_NEW); gtk_tool_item_set_is_important (new_button, TRUE); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), new_button, 0); gtk_widget_show (GTK_WIDGET (new_button)); /* Set the action name for the "new" action. We use "app.new" to * indicate that the action controls the application. */ gtk_actionable_set_action_name (GTK_ACTIONABLE (new_button), "app.new"); /******************************* * Tooltip for the New ToolItem: * a tooltip with text *******************************/ gtk_tool_item_set_tooltip_text (new_button, "Create a new file"); /* "Open" */ open_button = gtk_tool_button_new_from_stock (GTK_STOCK_OPEN); gtk_tool_item_set_is_important (open_button, TRUE); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), open_button, 1); gtk_widget_show (GTK_WIDGET (open_button)); gtk_actionable_set_action_name (GTK_ACTIONABLE (open_button), "app.open"); /******************************* * Tooltip for the Open ToolItem: * a tooltip using Pango markup * language *******************************/ gtk_tool_item_set_tooltip_text (open_button, "Open an <i>existing</i> file"); /* "Undo" */ undo_button = gtk_tool_button_new_from_stock (GTK_STOCK_UNDO); gtk_tool_item_set_is_important (undo_button, TRUE); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), undo_button, 2); gtk_widget_show (GTK_WIDGET (undo_button)); /* In this case, we use "win.undo" to indicate that * the action controls only the window */ gtk_actionable_set_action_name (GTK_ACTIONABLE (undo_button), "win.undo"); /******************************* * Tooltip for the Undo ToolItem: * a tooltip with an image *******************************/ gtk_widget_set_has_tooltip (GTK_WIDGET (undo_button), TRUE); // Next, we connect the query_tooltip signal g_signal_connect (undo_button, "query-tooltip", G_CALLBACK (undo_tooltip_callback), NULL); gtk_widget_set_hexpand (toolbar, TRUE); gtk_widget_show (toolbar); grid = gtk_grid_new (); gtk_grid_attach (GTK_GRID (grid), toolbar, 0, 0, 1, 1); gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (grid)); gtk_widget_show (GTK_WIDGET (grid)); /* Use the action names to create the actions that control the window, and * connect them to the appropriate callbackfunctions. */ undo_action = g_simple_action_new ("undo", NULL); g_signal_connect (undo_action, "activate", G_CALLBACK (undo_callback), GTK_WINDOW (window)); g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (undo_action)); gtk_widget_show (window); }
static void main_window_create_toolbars(void) { //updated toolbar code with the new gtk+ functions // Create the Main Toolbar main_window.toolbar_main = gtk_toolbar_new (); gtk_widget_show (main_window.toolbar_main); gnome_app_add_toolbar (GNOME_APP (main_window.window), GTK_TOOLBAR (main_window.toolbar_main), "toolbar1", BONOBO_DOCK_ITEM_BEH_NORMAL, BONOBO_DOCK_TOP, 1, 0, 0); gtk_container_set_border_width (GTK_CONTAINER (main_window.toolbar_main), 1); gtk_toolbar_set_style (GTK_TOOLBAR (main_window.toolbar_main), GTK_TOOLBAR_ICONS); gtk_toolbar_set_show_arrow (GTK_TOOLBAR (main_window.toolbar_main), FALSE); // Add the File operations to the Main Toolbar //main_window.toolbar_main_button_new = gtk_toolbar_insert_stock (GTK_TOOLBAR (main_window.toolbar_main),GTK_STOCK_NEW, _("New File"), NULL, NULL, NULL, -1); main_window.toolbar_main_button_new = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_NEW)); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM (main_window.toolbar_main_button_new), _("New File")); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_main_button_new), -1); gtk_widget_show (main_window.toolbar_main_button_new); //main_window.toolbar_main_button_open = gtk_toolbar_insert_stock (GTK_TOOLBAR (main_window.toolbar_main),GTK_STOCK_OPEN, _("Open File"), NULL, NULL, NULL, -1); //gtk_widget_show (main_window.toolbar_main_button_open); main_window.toolbar_main_button_open = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_OPEN)); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM (main_window.toolbar_main_button_open), _("Open File")); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_main_button_open), -1); gtk_widget_show (main_window.toolbar_main_button_open); // main_window.toolbar_main_button_save = gtk_toolbar_insert_stock (GTK_TOOLBAR (main_window.toolbar_main),GTK_STOCK_SAVE, _("Save File"), NULL, NULL, NULL, -1); main_window.toolbar_main_button_save = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_SAVE)); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM (main_window.toolbar_main_button_save), _("Save File")); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_main_button_save), -1); gtk_widget_show (main_window.toolbar_main_button_save); // main_window.toolbar_main_button_save_as = gtk_toolbar_insert_stock (GTK_TOOLBAR (main_window.toolbar_main),GTK_STOCK_SAVE_AS, _("Save File As..."), NULL, NULL, NULL, -1); main_window.toolbar_main_button_save_as = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_SAVE_AS)); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM (main_window.toolbar_main_button_save_as), _("Save File As...")); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_main_button_save_as), -1); gtk_widget_show (main_window.toolbar_main_button_save_as); // main_window.toolbar_main_button_close = gtk_toolbar_insert_stock (GTK_TOOLBAR (main_window.toolbar_main),GTK_STOCK_CLOSE, _("Close File"), NULL, NULL, NULL, -1); main_window.toolbar_main_button_close = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_CLOSE)); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM (main_window.toolbar_main_button_close), _("Close File")); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_main_button_close), -1); gtk_widget_show (main_window.toolbar_main_button_close); gtk_signal_connect (GTK_OBJECT (main_window.toolbar_main_button_open), "clicked", GTK_SIGNAL_FUNC (on_open1_activate), NULL); gtk_signal_connect (GTK_OBJECT (main_window.toolbar_main_button_new), "clicked", GTK_SIGNAL_FUNC (on_new1_activate), NULL); gtk_signal_connect (GTK_OBJECT (main_window.toolbar_main_button_save), "clicked", GTK_SIGNAL_FUNC (on_save1_activate), NULL); gtk_signal_connect (GTK_OBJECT (main_window.toolbar_main_button_save_as), "clicked", GTK_SIGNAL_FUNC (on_save_as1_activate), NULL); gtk_signal_connect (GTK_OBJECT (main_window.toolbar_main_button_close), "clicked", GTK_SIGNAL_FUNC (on_close1_activate), NULL); // gtk_toolbar_append_space(GTK_TOOLBAR(main_window.toolbar_main)); main_window.toolbar_separator=gtk_separator_tool_item_new(); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_separator), -1); gtk_widget_show (GTK_WIDGET(main_window.toolbar_separator)); // Add the Undo operations to the Main Toolbar // main_window.toolbar_main_button_undo = gtk_toolbar_insert_stock (GTK_TOOLBAR (main_window.toolbar_main),GTK_STOCK_UNDO, _("Undo last change"), NULL, NULL, NULL, -1); main_window.toolbar_main_button_undo = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_UNDO)); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM (main_window.toolbar_main_button_undo), _("Undo last change")); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_main_button_undo), -1); gtk_widget_show (main_window.toolbar_main_button_undo); // main_window.toolbar_main_button_redo = gtk_toolbar_insert_stock (GTK_TOOLBAR (main_window.toolbar_main),GTK_STOCK_REDO, _("Redo last change"), NULL, NULL, NULL, -1); main_window.toolbar_main_button_redo = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_REDO)); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM (main_window.toolbar_main_button_redo), _("Redo last change")); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_main_button_redo), -1); gtk_widget_show (main_window.toolbar_main_button_redo); gtk_signal_connect (GTK_OBJECT (main_window.toolbar_main_button_undo), "clicked", GTK_SIGNAL_FUNC (on_undo1_activate), NULL); gtk_signal_connect (GTK_OBJECT (main_window.toolbar_main_button_redo), "clicked", GTK_SIGNAL_FUNC (on_redo1_activate), NULL); //gtk_toolbar_append_space(GTK_TOOLBAR(main_window.toolbar_main)); main_window.toolbar_separator=gtk_separator_tool_item_new(); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_separator), -1); gtk_widget_show (GTK_WIDGET(main_window.toolbar_separator)); // Add the Clipboard operations to the Main Toolbar //main_window.toolbar_main_button_cut = gtk_toolbar_insert_stock (GTK_TOOLBAR (main_window.toolbar_main),GTK_STOCK_CUT, _("Cut current selection"), NULL, NULL, NULL, -1); main_window.toolbar_main_button_cut = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_CUT)); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM (main_window.toolbar_main_button_cut), _("Cut current selection")); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_main_button_cut), -1); gtk_signal_connect (GTK_OBJECT (main_window.toolbar_main_button_cut), "clicked", GTK_SIGNAL_FUNC (on_cut1_activate), NULL); gtk_widget_show (main_window.toolbar_main_button_cut); // main_window.toolbar_main_button_copy = gtk_toolbar_insert_stock (GTK_TOOLBAR (main_window.toolbar_main),GTK_STOCK_COPY, _("Copy current selection"), NULL, NULL, NULL, -1); main_window.toolbar_main_button_copy = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_COPY)); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM (main_window.toolbar_main_button_copy), _("Copy current selection")); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_main_button_copy), -1); gtk_signal_connect (GTK_OBJECT (main_window.toolbar_main_button_copy), "clicked", GTK_SIGNAL_FUNC (on_copy1_activate), NULL); gtk_widget_show (main_window.toolbar_main_button_copy); //main_window.toolbar_main_button_paste = gtk_toolbar_insert_stock (GTK_TOOLBAR (main_window.toolbar_main),GTK_STOCK_PASTE, _("Paste current selection"), NULL, NULL, NULL, -1); main_window.toolbar_main_button_paste = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_PASTE)); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM (main_window.toolbar_main_button_paste), _("Paste current selection")); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_main_button_paste), -1); gtk_signal_connect (GTK_OBJECT (main_window.toolbar_main_button_paste), "clicked", GTK_SIGNAL_FUNC (on_paste1_activate), NULL); gtk_widget_show (main_window.toolbar_main_button_paste); //gtk_toolbar_append_space(GTK_TOOLBAR(main_window.toolbar_main)); main_window.toolbar_separator=gtk_separator_tool_item_new(); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_separator), -1); gtk_widget_show (GTK_WIDGET(main_window.toolbar_separator)); // Add the Search operations to the Main Toolbar // main_window.toolbar_main_button_find = gtk_toolbar_insert_stock (GTK_TOOLBAR (main_window.toolbar_main),GTK_STOCK_FIND, _("Find text"), NULL, NULL, NULL, -1); main_window.toolbar_main_button_find = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_FIND)); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM (main_window.toolbar_main_button_find), _("Find Text")); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_main_button_find), -1); gtk_widget_show (main_window.toolbar_main_button_find); gtk_signal_connect (GTK_OBJECT (main_window.toolbar_main_button_find), "clicked", GTK_SIGNAL_FUNC (on_find1_activate), NULL); //main_window.toolbar_main_button_replace = gtk_toolbar_insert_stock (GTK_TOOLBAR (main_window.toolbar_main),GTK_STOCK_FIND_AND_REPLACE, _("Find/Replace text"), NULL, NULL, NULL, -1); main_window.toolbar_main_button_replace = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_FIND_AND_REPLACE)); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM (main_window.toolbar_main_button_replace), _("Find/Replace text")); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_main_button_replace), -1); gtk_signal_connect (GTK_OBJECT (main_window.toolbar_main_button_replace), "clicked", GTK_SIGNAL_FUNC (on_replace1_activate), NULL); gtk_widget_show (main_window.toolbar_main_button_replace); main_window.toolbar_separator=gtk_separator_tool_item_new(); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_separator), -1); gtk_widget_show (GTK_WIDGET(main_window.toolbar_separator)); // Add the indent/unindent operations to the Main Toolbar /*indent block*/ main_window.toolbar_main_button_indent = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_INDENT)); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM (main_window.toolbar_main_button_indent), _("Indent block")); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_main_button_indent), -1); gtk_signal_connect (GTK_OBJECT (main_window.toolbar_main_button_indent), "clicked", GTK_SIGNAL_FUNC (block_indent), NULL); gtk_widget_show (main_window.toolbar_main_button_indent); /*unindent block*/ main_window.toolbar_main_button_unindent = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_UNINDENT)); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM (main_window.toolbar_main_button_unindent), _("Unindent block")); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_main_button_unindent), -1); gtk_signal_connect (GTK_OBJECT (main_window.toolbar_main_button_unindent), "clicked", GTK_SIGNAL_FUNC (block_unindent), NULL); gtk_widget_show (main_window.toolbar_main_button_unindent); main_window.toolbar_separator=gtk_separator_tool_item_new(); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_separator), -1); gtk_widget_show (GTK_WIDGET(main_window.toolbar_separator)); //zoom in main_window.toolbar_main_button_zoom_in = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_ZOOM_IN)); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM (main_window.toolbar_main_button_zoom_in), _("Zoom in")); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_main_button_zoom_in), -1); gtk_signal_connect (GTK_OBJECT (main_window.toolbar_main_button_zoom_in), "clicked", GTK_SIGNAL_FUNC (zoom_in), NULL); gtk_widget_show (main_window.toolbar_main_button_zoom_in); //zoom out main_window.toolbar_main_button_zoom_out = GTK_WIDGET(gtk_tool_button_new_from_stock(GTK_STOCK_ZOOM_OUT)); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM (main_window.toolbar_main_button_zoom_out), _("Zoom out")); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_main), GTK_TOOL_ITEM (main_window.toolbar_main_button_zoom_out), -1); gtk_signal_connect (GTK_OBJECT (main_window.toolbar_main_button_zoom_out), "clicked", GTK_SIGNAL_FUNC (zoom_out), NULL); gtk_widget_show (main_window.toolbar_main_button_zoom_out); // Create the Search Toolbar GtkToolItem *item; main_window.toolbar_find = gtk_toolbar_new (); gtk_widget_show (main_window.toolbar_find); gtk_toolbar_set_show_arrow (GTK_TOOLBAR (main_window.toolbar_find), FALSE); gtk_container_set_border_width (GTK_CONTAINER (main_window.toolbar_find), 1); gnome_app_add_toolbar (GNOME_APP (main_window.window), GTK_TOOLBAR (main_window.toolbar_find), "toolbar_search", BONOBO_DOCK_ITEM_BEH_NORMAL, BONOBO_DOCK_TOP, 2, 0, 0); main_window.toolbar_find_search_label = gtk_label_new(_("Search for: ")); gtk_widget_show(main_window.toolbar_find_search_label); item=gtk_tool_item_new(); gtk_tool_item_set_expand (item, TRUE); gtk_container_add (GTK_CONTAINER (item), main_window.toolbar_find_search_label); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_find), GTK_TOOL_ITEM (item), -1); gtk_widget_show(GTK_WIDGET(item)); item=gtk_tool_item_new(); gtk_tool_item_set_expand (item, TRUE); main_window.toolbar_find_search_entry = gtk_entry_new(); gtk_widget_show(main_window.toolbar_find_search_entry); gtk_container_add (GTK_CONTAINER (item), main_window.toolbar_find_search_entry); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM (item), _("Incremental search")); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_find), GTK_TOOL_ITEM (item), -1); gtk_widget_show(GTK_WIDGET(item)); //gtk_toolbar_append_widget(GTK_TOOLBAR (main_window.toolbar_find), main_window.toolbar_find_search_entry, _("Incremental search"),NULL); gtk_signal_connect_after(GTK_OBJECT(main_window.toolbar_find_search_entry), "insert_text", GTK_SIGNAL_FUNC(inc_search_typed), NULL); gtk_signal_connect_after(GTK_OBJECT(main_window.toolbar_find_search_entry), "key_release_event", GTK_SIGNAL_FUNC(inc_search_key_release_event), NULL); gtk_signal_connect_after(GTK_OBJECT(main_window.toolbar_find_search_entry), "activate", GTK_SIGNAL_FUNC(inc_search_activate), NULL); main_window.toolbar_separator=gtk_separator_tool_item_new(); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_find), GTK_TOOL_ITEM (main_window.toolbar_separator), -1); gtk_widget_show (GTK_WIDGET(main_window.toolbar_separator)); //gtk_toolbar_append_space(GTK_TOOLBAR(main_window.toolbar_find)); main_window.toolbar_find_goto_label = gtk_label_new(_("Go to line: ")); gtk_widget_show(main_window.toolbar_find_goto_label); item=gtk_tool_item_new(); gtk_tool_item_set_expand (item, TRUE); gtk_container_add (GTK_CONTAINER (item), main_window.toolbar_find_goto_label); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_find), GTK_TOOL_ITEM (item), -1); gtk_widget_show(GTK_WIDGET(item)); // gtk_toolbar_append_widget(GTK_TOOLBAR (main_window.toolbar_find), main_window.toolbar_find_goto_label,NULL,NULL); main_window.toolbar_find_goto_entry = gtk_entry_new_with_max_length(6); gtk_entry_set_width_chars(GTK_ENTRY(main_window.toolbar_find_goto_entry),7); gtk_widget_show(main_window.toolbar_find_goto_entry); item=gtk_tool_item_new(); gtk_tool_item_set_expand (item, TRUE); gtk_container_add (GTK_CONTAINER (item), main_window.toolbar_find_goto_entry); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM (item), _("Go to line")); gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_find), GTK_TOOL_ITEM (item), -1); gtk_widget_show(GTK_WIDGET(item)); // gtk_toolbar_append_widget(GTK_TOOLBAR (main_window.toolbar_find), main_window.toolbar_find_goto_entry, _("Go to line"),NULL); gtk_signal_connect_after(GTK_OBJECT(main_window.toolbar_find_goto_entry), "activate", GTK_SIGNAL_FUNC(goto_line_activate), NULL); /* GtkToolItem * search_toolbar_separator; search_toolbar_separator = gtk_separator_tool_item_new(); gtk_separator_tool_item_set_draw(search_toolbar_separator, FALSE); gtk_tool_item_set_expand(search_toolbar_separator, TRUE); //gtk_toolbar_insert(GTK_TOOLBAR(main_window.toolbar_find), search_toolbar_separator, 0); gtk_toolbar_append_widget(GTK_TOOLBAR (main_window.toolbar_find), search_toolbar_separator,NULL,NULL); gtk_widget_show(search_toolbar_separator); */ }
bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) { wxToolBarTool* tool = static_cast<wxToolBarTool*>(toolBase); GSList* radioGroup; GtkWidget* bin_child; switch ( tool->GetStyle() ) { case wxTOOL_STYLE_BUTTON: switch (tool->GetKind()) { case wxITEM_CHECK: tool->m_item = gtk_toggle_tool_button_new(); g_signal_connect(tool->m_item, "toggled", G_CALLBACK(item_toggled), tool); break; case wxITEM_RADIO: radioGroup = GetRadioGroup(pos); if (!radioGroup) { // this is the first button in the radio button group, // it will be toggled automatically by GTK so bring the // internal flag in sync tool->Toggle(true); } tool->m_item = gtk_radio_tool_button_new(radioGroup); g_signal_connect(tool->m_item, "toggled", G_CALLBACK(item_toggled), tool); break; default: wxFAIL_MSG("unknown toolbar child type"); // fall through case wxITEM_DROPDOWN: case wxITEM_NORMAL: tool->m_item = gtk_tool_button_new(NULL, ""); g_signal_connect(tool->m_item, "clicked", G_CALLBACK(item_clicked), tool); break; } if (!HasFlag(wxTB_NOICONS)) { GtkWidget* image = gtk_image_new(); gtk_tool_button_set_icon_widget( GTK_TOOL_BUTTON(tool->m_item), image); tool->SetImage(); gtk_widget_show(image); #ifdef __WXGTK3__ g_signal_connect(image, "draw", G_CALLBACK(image_draw), tool); #else g_signal_connect(image, "expose_event", G_CALLBACK(image_expose_event), tool); #endif } if (!tool->GetLabel().empty()) { gtk_tool_button_set_label( GTK_TOOL_BUTTON(tool->m_item), wxGTK_CONV(tool->GetLabel())); // needed for labels in horizontal toolbar with wxTB_HORZ_LAYOUT gtk_tool_item_set_is_important(tool->m_item, true); } if (!HasFlag(wxTB_NO_TOOLTIPS) && !tool->GetShortHelp().empty()) { #if GTK_CHECK_VERSION(2, 12, 0) if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,12,0) == NULL) { gtk_tool_item_set_tooltip_text(tool->m_item, wxGTK_CONV(tool->GetShortHelp())); } else #endif { #ifndef __WXGTK3__ gtk_tool_item_set_tooltip(tool->m_item, m_tooltips, wxGTK_CONV(tool->GetShortHelp()), ""); #endif } } bin_child = gtk_bin_get_child(GTK_BIN(tool->m_item)); g_signal_connect(bin_child, "button_press_event", G_CALLBACK(button_press_event), tool); g_signal_connect(bin_child, "enter_notify_event", G_CALLBACK(enter_notify_event), tool); g_signal_connect(bin_child, "leave_notify_event", G_CALLBACK(enter_notify_event), tool); if (tool->GetKind() == wxITEM_DROPDOWN) tool->CreateDropDown(); gtk_toolbar_insert(m_toolbar, tool->m_item, int(pos)); break; case wxTOOL_STYLE_SEPARATOR: tool->m_item = gtk_separator_tool_item_new(); if ( tool->IsStretchable() ) { gtk_separator_tool_item_set_draw ( GTK_SEPARATOR_TOOL_ITEM(tool->m_item), FALSE ); gtk_tool_item_set_expand(tool->m_item, TRUE); } gtk_toolbar_insert(m_toolbar, tool->m_item, int(pos)); break; case wxTOOL_STYLE_CONTROL: wxWindow* control = tool->GetControl(); if (gtk_widget_get_parent(control->m_widget) == NULL) AddChildGTK(control); tool->m_item = GTK_TOOL_ITEM(gtk_widget_get_parent(gtk_widget_get_parent(control->m_widget))); if (gtk_toolbar_get_item_index(m_toolbar, tool->m_item) != int(pos)) { g_object_ref(tool->m_item); gtk_container_remove( GTK_CONTAINER(m_toolbar), GTK_WIDGET(tool->m_item)); gtk_toolbar_insert(m_toolbar, tool->m_item, int(pos)); g_object_unref(tool->m_item); } break; } gtk_widget_show(GTK_WIDGET(tool->m_item)); InvalidateBestSize(); return true; }