/** * Gets called when the Application is started, creates the main window. */ void activate(GtkApplication *app, gpointer user_data) { GtkWidget *window; window = gtk_application_window_new(app); gtk_window_set_title(GTK_WINDOW(window), "PSV Kanu EFB"); gtk_window_set_default_size(GTK_WINDOW(window), 600, 300); g_signal_connect(G_OBJECT(window), "key-press-event", G_CALLBACK(on_key_pressed), NULL); GtkWidget *box_main; box_main = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_container_add(GTK_CONTAINER(window), box_main); GtkWidget *notebook_main; notebook_main = gtk_notebook_new(); gtk_box_pack_start(GTK_BOX(box_main), notebook_main, TRUE, TRUE, 0); gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook_main), TRUE); gtk_notebook_popup_enable(GTK_NOTEBOOK(notebook_main)); //KALENDER gtk_notebook_append_page(GTK_NOTEBOOK(notebook_main), calendar_get_instance(), gtk_label_new("Kalender")); gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(notebook_main), calendar_get_instance(), TRUE); //FAHRTENBUCH gtk_notebook_append_page(GTK_NOTEBOOK(notebook_main), efb_get_instance(), gtk_label_new("Fahrtenbuch")); gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(notebook_main), efb_get_instance(), TRUE); gtk_widget_show_all(window); }
static VALUE rg_set_tab_reorderable(VALUE self, VALUE child, VALUE reorderable) { gtk_notebook_set_tab_reorderable(_SELF(self), GTK_WIDGET(RVAL2GOBJ(child)), RVAL2CBOOL(reorderable)); return self; }
void anjuta_docman_add_document (AnjutaDocman *docman, IAnjutaDocument *doc, GFile* file) { AnjutaDocmanPage *page; page = anjuta_docman_page_new (); anjuta_docman_page_init (docman, doc, file, page); /* list order matches pages in book, initially at least */ docman->priv->pages = g_list_prepend (docman->priv->pages, (gpointer)page); gtk_notebook_prepend_page_menu (GTK_NOTEBOOK (docman), page->widget, page->box, page->menu_box); gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (docman), page->widget, TRUE); g_signal_connect (G_OBJECT (doc), "update-save-ui", G_CALLBACK (on_document_update_save_ui), docman); g_signal_connect (G_OBJECT (doc), "destroy", G_CALLBACK (on_document_destroy), docman); g_object_ref (doc); anjuta_docman_set_current_document (docman, doc); anjuta_shell_present_widget (docman->shell, GTK_WIDGET (docman->priv->plugin->vbox), NULL); anjuta_docman_update_documents_menu (docman); g_signal_emit_by_name (docman, "document-added", doc); }
void Notebook::GTKAddCloseButtonAndReorderable(int idx) { MyNotebookPage *pg = (MyNotebookPage*) wxNotebook::GetNotebookPage(idx); wxWindow* page = GetPage((size_t)idx); // Place a close button if(HasCloseButton()) { GtkWidget *image; MyGtkPageInfo *pgInfo = new MyGtkPageInfo; pgInfo->m_button = gtk_button_new(); pgInfo->m_box = pg->m_box; pgInfo->m_book = this; image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); gtk_widget_set_size_request(image, 12, 12); gtk_button_set_image (GTK_BUTTON(pgInfo->m_button), image); gtk_widget_set_name (pgInfo->m_button, "tab-close-button"); gtk_button_set_relief(GTK_BUTTON(pgInfo->m_button), GTK_RELIEF_NONE); gtk_box_pack_end (GTK_BOX(pg->m_box), pgInfo->m_button, FALSE, FALSE, 0); // wxGTK has already used gtk_box_pack_end for the tab's label, so atm the close button will be on the left // so re-order it to position 0, which in a GTK_PACK_END box means the far right gtk_box_reorder_child(GTK_BOX(pg->m_box), pgInfo->m_button, 0); gtk_box_set_spacing (GTK_BOX(pg->m_box), 5); #ifdef __WXGTK3__ g_signal_connect (pgInfo->m_button, "clicked", G_CALLBACK (OnNotebookButtonClicked), pgInfo); #else gtk_signal_connect (GTK_OBJECT (pgInfo->m_button), "clicked", GTK_SIGNAL_FUNC (OnNotebookButtonClicked), pgInfo); #endif m_gtk_page_info[page] = pgInfo; GTKShowCloseButton(idx); } // Make this tab re-orderable gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(this->m_widget), page->m_widget, true); g_signal_connect(GTK_NOTEBOOK(this->m_widget), "page-reordered", G_CALLBACK(OnPageReordered), this); }
static void populate_notebook (gpointer data, gpointer user_data) { gchar *header_name; GtkWidget *header = NULL; GtkWidget *h_data; GtkWidget *scrolled_window; GtkWidget *notebook; notebook = (GtkWidget *) user_data; header_name = (gchar *) data; if (strcmp (header_name, "comment")) { header = gtk_label_new (header_name); gtk_label_set_text (GTK_LABEL (header), header_name); h_data = create_tree_view (); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); gtk_container_add (GTK_CONTAINER (scrolled_window), h_data); gtk_notebook_append_page_menu (GTK_NOTEBOOK (notebook), scrolled_window, header, NULL); gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (notebook), scrolled_window, TRUE); g_hash_table_insert (ui->notebook_hash, header_name, scrolled_window); } }
/** * gedit_notebook_add_tab: * @nb: a #GeditNotebook * @tab: a #GeditTab * @position: the position where the @tab should be added * @jump_to: %TRUE to set the @tab as active * * Adds the specified @tab to the @nb. */ void gedit_notebook_add_tab (GeditNotebook *nb, GeditTab *tab, gint position, gboolean jump_to) { GtkWidget *tab_label; g_return_if_fail (GEDIT_IS_NOTEBOOK (nb)); g_return_if_fail (GEDIT_IS_TAB (tab)); tab_label = create_tab_label (nb, tab); gtk_notebook_insert_page (GTK_NOTEBOOK (nb), GTK_WIDGET (tab), tab_label, position); gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (nb), GTK_WIDGET (tab), TRUE); gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (nb), GTK_WIDGET (tab), TRUE); /* The signal handler may have reordered the tabs */ position = gtk_notebook_page_num (GTK_NOTEBOOK (nb), GTK_WIDGET (tab)); if (jump_to) { gtk_notebook_set_current_page (GTK_NOTEBOOK (nb), position); gtk_widget_grab_focus (GTK_WIDGET (tab)); } }
gu_tab_t * gu_tab_create(gu_window_t *gw, int select, prop_t *nav) { gu_tab_t *gt = calloc(1, sizeof(gu_tab_t)); prop_sub_t *s; int idx; gt->gt_gw = gw; LIST_INSERT_HEAD(&gw->gw_tabs, gt, gt_link); gw->gw_current_tab = gt; gw->gw_ntabs++; gt->gt_nav = nav ?: nav_spawn(); if(prop_set_parent(gt->gt_nav, prop_get_global())) abort(); gt->gt_vbox = gtk_vbox_new(FALSE, 1); gtk_widget_show(gt->gt_vbox); gt->gt_notebook = gtk_notebook_new(); gtk_widget_show(gt->gt_notebook); gtk_notebook_set_show_border(GTK_NOTEBOOK(gt->gt_notebook), 0); gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gt->gt_notebook), 0); gu_toolbar_add(gt, gt->gt_vbox); gtk_container_add(GTK_CONTAINER(gt->gt_vbox), gt->gt_notebook); build_tab_header(gt); s = prop_subscribe(0, PROP_TAG_NAME("nav", "pages"), PROP_TAG_CALLBACK, gu_nav_pages, gt, PROP_TAG_COURIER, glibcourier, PROP_TAG_NAMED_ROOT, gt->gt_nav, "nav", NULL); gu_unsubscribe_on_destroy(GTK_OBJECT(gt->gt_notebook), s); // Add to tab's notebook idx = gtk_notebook_append_page(GTK_NOTEBOOK(gw->gw_notebook), gt->gt_vbox, gt->gt_label); gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(gw->gw_notebook), gt->gt_vbox, 1); if(select) gtk_notebook_set_current_page(GTK_NOTEBOOK(gw->gw_notebook), idx); if(gw->gw_ntabs > 1) gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gw->gw_notebook), 1); return gt; }
void empathy_chat_window_add_chat (EmpathyChatWindow *window, EmpathyChat *chat) { EmpathyChatWindowPriv *priv; GtkWidget *label; GtkWidget *child; gint x, y, w, h; g_return_if_fail (window != NULL); g_return_if_fail (EMPATHY_IS_CHAT (chat)); priv = GET_PRIV (window); /* Reference the chat object */ g_object_ref (chat); /* If this window has just been created, position it */ if (priv->chats == NULL) { empathy_geometry_load (chat_get_window_id_for_geometry (chat), &x, &y, &w, &h); if (x >= 0 && y >= 0) { /* Let the window manager position it if we don't have * good x, y coordinates. */ gtk_window_move (GTK_WINDOW (priv->dialog), x, y); } if (w > 0 && h > 0) { /* Use the defaults from the glade file if we don't have * good w, h geometry. */ gtk_window_resize (GTK_WINDOW (priv->dialog), w, h); } } child = GTK_WIDGET (chat); label = chat_window_create_label (window, chat); gtk_widget_show (child); g_signal_connect (chat, "notify::name", G_CALLBACK (chat_window_chat_notify_cb), NULL); g_signal_connect (chat, "notify::subject", G_CALLBACK (chat_window_chat_notify_cb), NULL); g_signal_connect (chat, "notify::remote-contact", G_CALLBACK (chat_window_chat_notify_cb), NULL); chat_window_chat_notify_cb (chat); gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), child, label); gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (priv->notebook), child, TRUE); gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (priv->notebook), child, TRUE); gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK (priv->notebook), child, TRUE, TRUE, GTK_PACK_START); DEBUG ("Chat added (%d references)", G_OBJECT (chat)->ref_count); }
void ui_playlist_notebook_create_tab(gint playlist) { GtkWidget *scrollwin, *treeview; GtkWidget *label, *entry, *ebox, *hbox; GtkAdjustment *vscroll; gint position = aud_playlist_get_position (playlist); scrollwin = gtk_scrolled_window_new(NULL, NULL); vscroll = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scrollwin)); treeview = ui_playlist_widget_new(playlist); g_object_set_data(G_OBJECT(scrollwin), "treeview", treeview); gtk_container_add(GTK_CONTAINER(scrollwin), treeview); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_widget_show_all(scrollwin); ebox = gtk_event_box_new(); gtk_event_box_set_visible_window ((GtkEventBox *) ebox, FALSE); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); label = gtk_label_new (""); set_tab_label (playlist, (GtkLabel *) label); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); entry = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(ebox), hbox); gtk_widget_show_all(ebox); gtk_widget_hide(entry); gtk_box_pack_end ((GtkBox *) hbox, make_close_button (playlist), FALSE, FALSE, 0); g_object_set_data(G_OBJECT(ebox), "label", label); g_object_set_data(G_OBJECT(ebox), "entry", entry); g_object_set_data(G_OBJECT(ebox), "page", scrollwin); gtk_notebook_insert_page (UI_PLAYLIST_NOTEBOOK, scrollwin, ebox, playlist); gtk_notebook_set_tab_reorderable(UI_PLAYLIST_NOTEBOOK, scrollwin, TRUE); g_object_set_data ((GObject *) treeview, "playlist-id", GINT_TO_POINTER (aud_playlist_get_unique_id (playlist))); if (position >= 0) { aud_playlist_select_all (playlist, FALSE); aud_playlist_entry_set_selected (playlist, position, TRUE); audgui_list_set_highlight (treeview, position); audgui_list_set_focus (treeview, position); } g_signal_connect(ebox, "button-press-event", G_CALLBACK(tab_button_press_cb), NULL); g_signal_connect(ebox, "key-press-event", G_CALLBACK(tab_key_press_cb), NULL); g_signal_connect(entry, "activate", G_CALLBACK(tab_title_save), ebox); g_signal_connect_swapped (vscroll, "value-changed", G_CALLBACK(ui_playlist_widget_scroll), treeview); }
/** \brief Add a new module to mod-mgr. * \param module The GtkSatModule widget to add * \param dock Flag indicating whether module should be docked or not. * * This function registers a new module in the mod-mgr. If the dock flag is true * the module is added to the mod-mgr notebook, otherwise it will be up to the * caller to create a proper container. * */ gint mod_mgr_add_module (GtkWidget *module, gboolean dock) { gint retcode = 0; gint page; if (module) { /* add module to internal list */ modules = g_slist_append (modules, module); if (dock) { /* add module to notebook if state = DOCKED */ page = gtk_notebook_append_page (GTK_NOTEBOOK (nbook), module, gtk_label_new (GTK_SAT_MODULE (module)->name)); /* allow nmodule to be dragged to different position */ gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK(nbook), module, TRUE); gtk_notebook_set_current_page (GTK_NOTEBOOK (nbook), page); /* send message to logger */ sat_log_log (SAT_LOG_LEVEL_MSG, _("%s: Added %s to module manger (page %d)."), __FUNCTION__, GTK_SAT_MODULE (module)->name, page); } else { /* send message to logger */ sat_log_log (SAT_LOG_LEVEL_MSG, _("%s: Added %s to module manger (NOT DOCKED)."), __FUNCTION__, GTK_SAT_MODULE (module)->name); } retcode = 0; } else { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Module %s seems to be NULL"), __FUNCTION__, GTK_SAT_MODULE (module)->name); retcode = 1; } /* disable tabs if only one page in notebook */ if ((gtk_notebook_get_n_pages (GTK_NOTEBOOK(nbook))) == 1) { gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nbook), FALSE); } else { gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nbook), TRUE); } update_window_title (); return retcode; }
/** * schema_browser_perspective_display_diagram * */ void schema_browser_perspective_display_diagram (SchemaBrowserPerspective *bpers, gint fav_id) { GtkWidget *diagram = NULL; if (fav_id >= 0) { gint ntabs, i; ntabs = gtk_notebook_get_n_pages (GTK_NOTEBOOK (bpers->priv->notebook)); for (i = 0; i < ntabs; i++) { GtkWidget *child; child = gtk_notebook_get_nth_page (GTK_NOTEBOOK (bpers->priv->notebook), i); if (IS_RELATIONS_DIAGRAM (child)) { if (relations_diagram_get_fav_id (RELATIONS_DIAGRAM (child)) == fav_id) { gtk_notebook_set_current_page (GTK_NOTEBOOK (bpers->priv->notebook), i); return; } } } GError *error = NULL; diagram = relations_diagram_new_with_fav_id (browser_window_get_connection (bpers->priv->bwin), fav_id, &error); if (! diagram) { ui_show_error ((GtkWindow*) gtk_widget_get_toplevel ((GtkWidget*) bpers), error && error->message ? error->message : _("Could not load diagram")); g_clear_error (&error); } } else diagram = relations_diagram_new (browser_window_get_connection (bpers->priv->bwin)); if (diagram) { GtkWidget *close_btn; GtkWidget *tab_label; gint i; tab_label = browser_page_get_tab_label (BROWSER_PAGE (diagram), &close_btn); i = gtk_notebook_append_page (GTK_NOTEBOOK (bpers->priv->notebook), diagram, tab_label); g_signal_connect (close_btn, "clicked", G_CALLBACK (close_button_clicked_cb), diagram); gtk_widget_show (diagram); tab_label = browser_page_get_tab_label (BROWSER_PAGE (diagram), NULL); gtk_notebook_set_menu_label (GTK_NOTEBOOK (bpers->priv->notebook), diagram, tab_label); gtk_notebook_set_current_page (GTK_NOTEBOOK (bpers->priv->notebook), i); gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (bpers->priv->notebook), diagram, TRUE); gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (bpers->priv->notebook), diagram, TRUE); } }
void cgraphics_workspace_window_widget_create( widget_t *widget ) { widget_t *parent = WIDGET(OBJECT(widget)->parent); widget->native = gtk_layout_new( NULL, NULL ); cgraphics_widget_create( widget ); gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(parent->native), GTK_WIDGET(widget->native), TRUE); gtk_notebook_set_tab_detachable(GTK_NOTEBOOK(parent->native), GTK_WIDGET(widget->native), TRUE); }
void new_tab_page(struct Gtkabber *gtkabber, GtkWidget *socket) { gtk_widget_show( socket ); gtk_notebook_append_page( GTK_NOTEBOOK(gtkabber->toplevel.notebook), socket, NULL ); gtk_notebook_set_current_page( GTK_NOTEBOOK(gtkabber->toplevel.notebook), -1 ); gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK( gtkabber->toplevel.notebook), socket, TRUE); printf("%d\n", gtk_socket_get_id( GTK_SOCKET( socket ) ) ); fflush(stdout); }
void notebook_new_tab(GtkWidget *notebook) { Notebook *nb = (Notebook *)notebook; GtkWidget *tabview = tabview_new(); gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(notebook), tabview, TRUE); gtk_notebook_set_tab_detachable(GTK_NOTEBOOK(notebook), tabview, TRUE); gtk_widget_set_can_focus(tabview, FALSE); GtkWidget *label = gtk_label_new("Test tab"); gtk_widget_set_can_focus(label, FALSE); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tabview, label); }
static void action_clicked_cb (GtkWidget *button, GtkWidget *notebook) { GtkWidget *page, *title; page = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (page), "Addition"); title = gtk_label_new ("Addition"); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, title); gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (notebook), page, TRUE); gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (notebook), page, TRUE); }
/** * schema_browser_perspective_new * * Creates new #BrowserPerspective widget which */ BrowserPerspective * schema_browser_perspective_new (BrowserWindow *bwin) { TConnection *tcnc; BrowserPerspective *bpers; SchemaBrowserPerspective *perspective; gboolean fav_supported; bpers = (BrowserPerspective*) g_object_new (TYPE_SCHEMA_BROWSER_PERSPECTIVE, NULL); perspective = (SchemaBrowserPerspective*) bpers; tcnc = browser_window_get_connection (bwin); fav_supported = t_connection_get_favorites (tcnc) ? TRUE : FALSE; perspective->priv->bwin = bwin; /* contents */ GtkWidget *paned, *wid, *nb; paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); if (fav_supported) { wid = favorite_selector_new (tcnc); g_signal_connect (wid, "selection-changed", G_CALLBACK (fav_selection_changed_cb), bpers); gtk_paned_add1 (GTK_PANED (paned), wid); gtk_paned_set_position (GTK_PANED (paned), DEFAULT_FAVORITES_SIZE); perspective->priv->favorites = wid; } nb = browser_perspective_create_notebook (bpers); perspective->priv->notebook = nb; gtk_paned_add2 (GTK_PANED (paned), nb); wid = objects_index_new (tcnc); g_signal_connect (wid, "selection-changed", G_CALLBACK (objects_index_selection_changed_cb), bpers); gtk_notebook_append_page (GTK_NOTEBOOK (nb), wid, ui_make_tab_label_with_icon (_("Index"), "help-about", FALSE, NULL)); gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (nb), wid, TRUE); gtk_notebook_set_group_name (GTK_NOTEBOOK (nb), "schema-browser"); gtk_notebook_set_menu_label (GTK_NOTEBOOK (nb), wid, ui_make_tab_label_with_icon (_("Index"), "help-about", FALSE, NULL)); gtk_box_pack_start (GTK_BOX (bpers), paned, TRUE, TRUE, 0); gtk_widget_show_all (paned); if (perspective->priv->favorites && !perspective->priv->favorites_shown) gtk_widget_hide (perspective->priv->favorites); return bpers; }
static GtkWidget* create_notebook_non_dragable_content (gchar **labels, const gchar *group, GtkPositionType pos) { GtkWidget *notebook, *title, *page, *action_widget; notebook = gtk_notebook_new (); gtk_widget_set_vexpand (notebook, TRUE); gtk_widget_set_hexpand (notebook, TRUE); action_widget = gtk_button_new_from_icon_name ("list-add-symbolic", GTK_ICON_SIZE_BUTTON); g_signal_connect (action_widget, "clicked", G_CALLBACK (action_clicked_cb), notebook); gtk_widget_show (action_widget); gtk_notebook_set_action_widget (GTK_NOTEBOOK (notebook), action_widget, GTK_PACK_END); g_signal_connect (notebook, "create-window", G_CALLBACK (window_creation_function), NULL); gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), pos); gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE); gtk_container_set_border_width (GTK_CONTAINER (notebook), 6); gtk_notebook_set_group_name (GTK_NOTEBOOK (notebook), group); while (*labels) { GtkWidget *button; button = gtk_button_new_with_label (*labels); /* Use GtkListBox since it bubbles up motion notify event, which can * experience more issues than GtkBox. */ page = gtk_list_box_new (); gtk_container_add (GTK_CONTAINER (page), button); title = gtk_label_new (*labels); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, title); gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (notebook), page, TRUE); gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (notebook), page, TRUE); labels++; } g_signal_connect (GTK_NOTEBOOK (notebook), "page-reordered", G_CALLBACK (on_page_reordered), NULL); g_signal_connect_after (G_OBJECT (notebook), "drag-begin", G_CALLBACK (on_notebook_drag_begin), NULL); return notebook; }
static void menu_popup_current_page_cb(GtkWidget *widget, HybridChatWindow *chat) { HybridChatWindow *newchat; GtkWidget *vbox; gint page_index; HybridConversation *newconv; HybridConversation *parent; HybridBuddy *buddy; vbox = chat->vbox; /* * First we increase the reference value of vbox, * prevent it from being destroyed by gtk_notebook_remove_page(). */ g_object_ref(vbox); /* * When closing the chat panel, the chat object will be destroyed, * so we must store the buddy first before closing the tab. */ buddy = chat->data; close_tab(chat); parent = chat->parent; newconv = hybrid_conv_create(); conv_list = g_slist_append(conv_list, newconv); gtk_notebook_set_show_tabs(GTK_NOTEBOOK(newconv->notebook), FALSE); newchat = g_new0(HybridChatWindow, 1); newchat->parent = newconv; newchat->data = buddy; newchat->vbox = vbox; newconv->chat_buddies = g_slist_append(newconv->chat_buddies, newchat); newchat->pagelabel = create_note_label(newchat); page_index = gtk_notebook_append_page(GTK_NOTEBOOK(newconv->notebook), vbox, newchat->pagelabel); gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(newconv->notebook), vbox, TRUE); gtk_notebook_set_tab_detachable(GTK_NOTEBOOK(newconv->notebook), vbox, TRUE); gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(newconv->notebook), vbox, TRUE, TRUE, GTK_PACK_START); }
LifereaHtmlView * browser_tabs_add_new (const gchar *url, const gchar *title, gboolean activate) { GtkWidget *close_button, *labelBox; tabInfo *tab; int i; tab = g_new0 (tabInfo, 1); tab->htmlview = liferea_htmlview_new (TRUE /* internal browsing */); tab->widget = liferea_htmlview_get_widget (tab->htmlview); tabs->priv->list = g_slist_append (tabs->priv->list, tab); g_object_set_data (G_OBJECT (tab->widget), "tabInfo", tab); g_signal_connect (tab->htmlview, "title-changed", G_CALLBACK (on_htmlview_title_changed), tab); g_signal_connect (tab->htmlview, "statusbar-changed", G_CALLBACK (on_htmlview_status_message), NULL); /* create tab widgets */ tab->label = gtk_label_new (create_label_text (title)); gtk_label_set_ellipsize (GTK_LABEL (tab->label), PANGO_ELLIPSIZE_END); gtk_label_set_width_chars (GTK_LABEL (tab->label), 17); labelBox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); gtk_box_pack_start (GTK_BOX (labelBox), tab->label, FALSE, FALSE, 0); close_button = gedit_close_button_new (); gtk_box_pack_end (GTK_BOX (labelBox), close_button, FALSE, FALSE, 0); g_signal_connect ((gpointer)close_button, "clicked", G_CALLBACK (on_htmlview_close_tab), (gpointer)tab); gtk_widget_show_all (labelBox); i = gtk_notebook_append_page (tabs->priv->notebook, tab->widget, labelBox); g_signal_connect (gtk_notebook_get_nth_page (tabs->priv->notebook, i), "key-press-event", G_CALLBACK (on_tab_key_press), (gpointer)tab); gtk_notebook_set_show_tabs (tabs->priv->notebook, TRUE); gtk_notebook_set_tab_reorderable (tabs->priv->notebook, tab->widget, TRUE); if (activate && (i != -1)) gtk_notebook_set_current_page (tabs->priv->notebook, i); if (url) liferea_htmlview_launch_URL_internal (tab->htmlview, (gchar *)url); return tab->htmlview; }
/** * schema_browser_perspective_display_table_info * * Display (and create if necessary) a new page for the table's properties */ void schema_browser_perspective_display_table_info (SchemaBrowserPerspective *bpers, const gchar *table_schema, const gchar *table_name, G_GNUC_UNUSED const gchar *table_short_name) { g_return_if_fail (IS_SCHEMA_BROWSER_PERSPECTIVE (bpers)); gint ntabs, i; ntabs = gtk_notebook_get_n_pages (GTK_NOTEBOOK (bpers->priv->notebook)); for (i = 0; i < ntabs; i++) { GtkWidget *child; child = gtk_notebook_get_nth_page (GTK_NOTEBOOK (bpers->priv->notebook), i); if (IS_TABLE_INFO (child)) { if (!strcmp (table_schema, table_info_get_table_schema (TABLE_INFO (child))) && !strcmp (table_name, table_info_get_table_name (TABLE_INFO (child)))) { gtk_notebook_set_current_page (GTK_NOTEBOOK (bpers->priv->notebook), i); return; } } } GtkWidget *ti; ti = table_info_new (browser_window_get_connection (bpers->priv->bwin), table_schema, table_name); if (ti) { GtkWidget *close_btn; GtkWidget *tab_label; gint i; tab_label = browser_page_get_tab_label (BROWSER_PAGE (ti), &close_btn); i = gtk_notebook_append_page (GTK_NOTEBOOK (bpers->priv->notebook), ti, tab_label); g_signal_connect (close_btn, "clicked", G_CALLBACK (close_button_clicked_cb), ti); gtk_widget_show (ti); tab_label = browser_page_get_tab_label (BROWSER_PAGE (ti), NULL); gtk_notebook_set_menu_label (GTK_NOTEBOOK (bpers->priv->notebook), ti, tab_label); gtk_notebook_set_current_page (GTK_NOTEBOOK (bpers->priv->notebook), i); gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (bpers->priv->notebook), ti, TRUE); gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (bpers->priv->notebook), ti, TRUE); } }
static GtkWidget* create_notebook (gchar **labels, const gchar *group, GtkPositionType pos) { GtkWidget *notebook, *title, *page, *action_widget; notebook = gtk_notebook_new (); gtk_widget_set_vexpand (notebook, TRUE); gtk_widget_set_hexpand (notebook, TRUE); action_widget = gtk_button_new_from_icon_name ("list-add-symbolic", GTK_ICON_SIZE_BUTTON); g_signal_connect (action_widget, "clicked", G_CALLBACK (action_clicked_cb), notebook); gtk_widget_show (action_widget); gtk_notebook_set_action_widget (GTK_NOTEBOOK (notebook), action_widget, GTK_PACK_END); g_signal_connect (notebook, "create-window", G_CALLBACK (window_creation_function), NULL); gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), pos); gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE); gtk_container_set_border_width (GTK_CONTAINER (notebook), 6); gtk_notebook_set_group_name (GTK_NOTEBOOK (notebook), group); while (*labels) { page = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (page), *labels); title = gtk_label_new (*labels); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, title); gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (notebook), page, TRUE); gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (notebook), page, TRUE); labels++; } g_signal_connect (GTK_NOTEBOOK (notebook), "page-reordered", G_CALLBACK (on_page_reordered), NULL); g_signal_connect_after (G_OBJECT (notebook), "drag-begin", G_CALLBACK (on_notebook_drag_begin), NULL); return notebook; }
/** * Initialize the chat panel. */ static void init_chat_window(HybridChatWindow *chat) { GtkWidget *vbox; HybridConversation *conv; gint page_index; g_return_if_fail(chat != NULL); conv = chat->parent; if (g_slist_length(conv->chat_buddies) == 1) { gtk_notebook_set_show_tabs(GTK_NOTEBOOK(conv->notebook), FALSE); } else { gtk_notebook_set_show_tabs(GTK_NOTEBOOK(conv->notebook), TRUE); } vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); chat->vbox = vbox; chat->pagelabel = create_note_label(chat); page_index = gtk_notebook_append_page(GTK_NOTEBOOK(conv->notebook), vbox, chat->pagelabel); gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(conv->notebook), vbox, TRUE); gtk_notebook_set_tab_detachable(GTK_NOTEBOOK(conv->notebook), vbox, TRUE); gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(conv->notebook), vbox, TRUE, TRUE, GTK_PACK_START); init_chat_window_body(vbox, chat); /* * The function should stay here. Because of the following reason: * * Note that due to historical reasons, GtkNotebook refuses to * switch to a page unless the child widget is visible. * ---- GtkNotebook */ gtk_notebook_set_current_page(GTK_NOTEBOOK(conv->notebook), page_index); /* focus the send textview */ gtk_widget_grab_focus(chat->sendtext); }
static int nemo_notebook_insert_page (GtkNotebook *gnotebook, GtkWidget *tab_widget, GtkWidget *tab_label, GtkWidget *menu_label, int position) { g_assert (GTK_IS_WIDGET (tab_widget)); position = GTK_NOTEBOOK_CLASS (nemo_notebook_parent_class)->insert_page (gnotebook, tab_widget, tab_label, menu_label, position); gtk_notebook_set_show_tabs (gnotebook, gtk_notebook_get_n_pages (gnotebook) > 1); gtk_notebook_set_tab_reorderable (gnotebook, tab_widget, TRUE); return position; }
void gnm_notebook_insert_tab (GnmNotebook *nb, GtkWidget *label, int pos) { GtkWidget *dummy_page = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_widget_set_size_request (dummy_page, 1, 1); g_object_set_data (G_OBJECT (label), DUMMY_KEY, dummy_page); g_signal_connect_object (G_OBJECT (label), "destroy", G_CALLBACK (cb_label_destroyed), dummy_page, 0); cb_label_visibility (label, NULL, dummy_page); g_signal_connect_object (G_OBJECT (label), "notify::visible", G_CALLBACK (cb_label_visibility), dummy_page, 0); gtk_notebook_insert_page (GTK_NOTEBOOK (nb), dummy_page, label, pos); gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (nb), dummy_page, TRUE); }
void ephy_notebook_tab_set_pinned (EphyNotebook *notebook, GtkWidget *embed, gboolean is_pinned) { GtkWidget *tab_label; gboolean expanded; if (is_pinned) { gtk_notebook_reorder_child (GTK_NOTEBOOK (notebook), embed, 0); expanded = FALSE; } else { expanded = g_settings_get_boolean (EPHY_SETTINGS_UI, EPHY_PREFS_UI_EXPAND_TABS_BAR); } gtk_container_child_set (GTK_CONTAINER (notebook), embed, "tab-expand", expanded, NULL); gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (notebook), embed, !is_pinned); tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook), embed); ephy_tab_label_set_pinned (tab_label, is_pinned); }
static GtkWidget* create_notebook_with_notebooks (gchar **labels, const gchar *group, GtkPositionType pos) { GtkWidget *notebook, *title, *page; gint count = 0; notebook = gtk_notebook_new (); g_signal_connect (notebook, "create-window", G_CALLBACK (window_creation_function), NULL); gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), pos); gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE); gtk_container_set_border_width (GTK_CONTAINER (notebook), 6); gtk_notebook_set_group_name (GTK_NOTEBOOK (notebook), group); while (*labels) { page = create_notebook (labels, group, pos); gtk_notebook_popup_enable (GTK_NOTEBOOK (page)); title = gtk_label_new (*labels); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, title); gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (notebook), page, TRUE); gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (notebook), page, TRUE); count++; labels++; } g_signal_connect (GTK_NOTEBOOK (notebook), "page-reordered", G_CALLBACK (on_page_reordered), NULL); g_signal_connect_after (G_OBJECT (notebook), "drag-begin", G_CALLBACK (on_notebook_drag_begin), NULL); return notebook; }
void append_new_tab(Document *doc) { GtkWidget *scroll, *label; label = gtk_label_new(doc->basename); scroll = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll), GTK_SHADOW_NONE); gtk_widget_set_vexpand(scroll, TRUE); gtk_container_add(GTK_CONTAINER(scroll), doc->view); /* Store the structure inside the GtkScrolledWindow. * This way, we can use GtkNotebook to supply the * correct Document struct instead of keeping an * additional list ourselves. */ g_object_set_data_full(G_OBJECT(scroll), "doc", doc, (GDestroyNotify)free_document); gtk_widget_show_all(scroll); gtk_notebook_append_page(GTK_NOTEBOOK(lightpad->tabs), scroll, label); gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(lightpad->tabs), scroll, TRUE); }
static int ephy_notebook_insert_page (GtkNotebook *gnotebook, GtkWidget *tab_widget, GtkWidget *tab_label, GtkWidget *menu_label, int position) { EphyNotebook *notebook = EPHY_NOTEBOOK (gnotebook); /* Destroy passed-in tab label */ if (tab_label != NULL) { g_object_ref_sink (tab_label); g_object_unref (tab_label); } g_assert (EPHY_IS_EMBED (tab_widget)); tab_label = build_tab_label (notebook, EPHY_EMBED (tab_widget)); update_tabs_visibility (notebook, TRUE); position = GTK_NOTEBOOK_CLASS (ephy_notebook_parent_class)->insert_page (gnotebook, tab_widget, tab_label, menu_label, position); gtk_notebook_set_tab_reorderable (gnotebook, tab_widget, TRUE); gtk_notebook_set_tab_detachable (gnotebook, tab_widget, TRUE); gtk_container_child_set (GTK_CONTAINER (gnotebook), GTK_WIDGET (tab_widget), "tab-expand", g_settings_get_boolean (EPHY_SETTINGS_UI, EPHY_PREFS_UI_EXPAND_TABS_BAR), NULL); return position; }
LifereaHtmlView * browser_tabs_add_new (const gchar *url, const gchar *title, gboolean activate) { GtkWidget *widget, *label, *toolbar, *htmlframe, *image; tabInfo *tab; int i; tab = g_new0 (tabInfo, 1); tab->widget = gtk_vbox_new (FALSE, 0); tab->htmlview = liferea_htmlview_new (TRUE); tab->history = browser_tab_history_new (); tabs->priv->list = g_slist_append (tabs->priv->list, tab); g_object_set_data (G_OBJECT (tab->widget), "tabInfo", tab); g_signal_connect (tab->htmlview, "title-changed", G_CALLBACK (on_htmlview_title_changed), tab); g_signal_connect (tab->htmlview, "location-changed", G_CALLBACK (on_htmlview_location_changed), tab); g_signal_connect (tab->htmlview, "statusbar-changed", G_CALLBACK (on_htmlview_status_message), NULL); /* create tab widgets */ label = gtk_label_new (create_label_text (title)); gtk_label_set_ellipsize (GTK_LABEL(label), PANGO_ELLIPSIZE_END); gtk_label_set_max_width_chars (GTK_LABEL(label), 17); gtk_widget_show (label); toolbar = gtk_hbox_new (FALSE, 6); widget = gtk_button_new (); gtk_button_set_relief (GTK_BUTTON (widget), GTK_RELIEF_NONE); image = gtk_image_new_from_stock ("gtk-go-back", GTK_ICON_SIZE_BUTTON); gtk_widget_show (image); gtk_container_add (GTK_CONTAINER (widget), image); gtk_box_pack_start (GTK_BOX (toolbar), widget, FALSE, FALSE, 0); g_signal_connect ((gpointer)widget, "clicked", G_CALLBACK (on_tab_history_back), (gpointer)tab); gtk_widget_set_sensitive(widget, FALSE); tab->back = widget; widget = gtk_button_new (); gtk_button_set_relief (GTK_BUTTON(widget), GTK_RELIEF_NONE); image = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_BUTTON); gtk_widget_show (image); gtk_container_add (GTK_CONTAINER (widget), image); gtk_box_pack_start (GTK_BOX (toolbar), widget, FALSE, FALSE, 0); g_signal_connect ((gpointer)widget, "clicked", G_CALLBACK (on_tab_history_forward), (gpointer)tab); gtk_widget_set_sensitive (widget, FALSE); tab->forward = widget; widget = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (widget), url?url:""); g_object_set_data (G_OBJECT (tab->widget), "url_entry", widget); gtk_box_pack_start (GTK_BOX (toolbar), widget, TRUE, TRUE, 0); g_signal_connect ((gpointer)widget, "activate", G_CALLBACK (on_tab_url_entry_activate), (gpointer)tab); tab->urlentry = widget; widget = gtk_button_new (); gtk_button_set_relief (GTK_BUTTON(widget), GTK_RELIEF_NONE); image = gtk_image_new_from_stock ("gtk-close", GTK_ICON_SIZE_BUTTON); gtk_widget_show (image); gtk_container_add (GTK_CONTAINER (widget), image); gtk_box_pack_end (GTK_BOX (toolbar), widget, FALSE, FALSE, 0); g_signal_connect ((gpointer)widget, "clicked", G_CALLBACK (on_htmlview_close_tab), (gpointer)tab); htmlframe = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (htmlframe), GTK_SHADOW_IN); gtk_container_add (GTK_CONTAINER (htmlframe), liferea_htmlview_get_widget (tab->htmlview)); gtk_box_pack_start (GTK_BOX (tab->widget), toolbar, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (tab->widget), htmlframe, TRUE, TRUE, 0); gtk_widget_show_all (tab->widget); i = gtk_notebook_append_page (tabs->priv->notebook, tab->widget, label); g_signal_connect (gtk_notebook_get_nth_page (tabs->priv->notebook, i), "key-press-event", G_CALLBACK (on_tab_key_press), (gpointer)tab); gtk_notebook_set_show_tabs (tabs->priv->notebook, TRUE); gtk_notebook_set_tab_reorderable (tabs->priv->notebook, tab->widget, TRUE); if (activate && (i != -1)) gtk_notebook_set_current_page (tabs->priv->notebook, i); if (url) { browser_tab_history_add_location (tab, (gchar *)url); liferea_htmlview_launch_URL_internal (tab->htmlview, (gchar *)url); } return tab->htmlview; }
static void on_session_duplicate (GSQLSession *session, gpointer user_data) { GSQL_TRACE_FUNC; GSQLSession *new_session; GSQLEOracleSession *new_spec, *spec; gchar *username, *database, *password; GSQLWorkspace *new_workspace, *workspace; GSQLNavigation *navigation; gchar buffer[256], info[32]; GSQLCursor *cursor; GSQLVariable *variable; GSQLCursorState c_state; GtkWidget *sessions; gchar *session_name; GList *lst; GtkWidget *header; gint ret; gchar *sql = "select version from product_component_version " "where instr(lower(product),'oracle') >0 " "and rownum <2 "; GSQL_FIXME; /* Do rework this function, not yet, later. It seems like a hack :) */ spec = session->spec; new_spec = g_malloc0 (sizeof (GSQLEOracleSession)); new_spec->mode = spec->mode; username = (gchar *) gsql_session_get_username (session); password = (gchar *) gsql_session_get_password (session); database = (gchar *) gsql_session_get_database_name (session); workspace = gsql_session_get_workspace (session); if (!oracle_session_open (new_spec, username, password, database, buffer)) { g_free (spec); gsql_message_add (workspace, GSQL_MESSAGE_ERROR, buffer); return; } new_session = gsql_session_new_with_attrs ("session-username", username, "session-password", password, "session-database", database, NULL); new_session->spec = new_spec; new_session->engine = session->engine; cursor = gsql_cursor_new (session, sql); c_state = gsql_cursor_open (cursor, FALSE); memset ((void *) info, 0, 32); if ((c_state == GSQL_CURSOR_STATE_OPEN) && (gsql_cursor_fetch (cursor, 1))) { lst = g_list_first (cursor->var_list); variable = GSQL_VARIABLE (lst->data); g_snprintf (info, 32, "%s", (gchar *) variable->value); } else { g_snprintf (info, 32, "%s", "0.0.0.0"); } gsql_cursor_close (cursor); gsql_session_set_attrs (new_session, "session-info", info, NULL); new_workspace = gsql_workspace_new (new_session); navigation = gsql_workspace_get_navigation (new_workspace); nav_tree_set_root (navigation, (gchar *) username); g_signal_connect (G_OBJECT (new_session), "close", G_CALLBACK (on_session_close), new_session); g_signal_connect (G_OBJECT (new_session), "reopen", G_CALLBACK (on_session_reopen), new_session); g_signal_connect (G_OBJECT (new_session), "duplicate", G_CALLBACK (on_session_duplicate), new_session); g_signal_connect (G_OBJECT (new_session), "commit", G_CALLBACK (on_session_commit), new_session); g_signal_connect (G_OBJECT (new_session), "rollback", G_CALLBACK (on_session_rollback), new_session); g_signal_connect (G_OBJECT (new_session), "switch", G_CALLBACK (on_session_switch), new_session); g_snprintf(buffer, 256, _("Connect to the Oracle database \"<b>%s</b>\" succesfully\n" "<small>(%s)</small>"), g_utf8_strup (database, g_utf8_strlen (database, 128)), new_spec->server_version); gsql_message_add (new_workspace, GSQL_MESSAGE_NORMAL, buffer); GSQL_DEBUG ("New session created with name [%s]", gsql_session_get_name (new_session)); sessions = g_object_get_data(G_OBJECT(gsql_window), "sessions"); session_name = gsql_session_get_name (new_session); header = gsql_utils_header_new (create_pixmap(new_session->engine->file_logo), session_name, NULL, FALSE, (gint) 1); gtk_widget_show (GTK_WIDGET (new_session)); ret = gtk_notebook_append_page (GTK_NOTEBOOK(sessions), GTK_WIDGET (new_session), header); gtk_notebook_set_current_page (GTK_NOTEBOOK(sessions), ret); gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK(sessions), GTK_WIDGET (new_session), TRUE); }