static void page_removed_callback (GtkNotebook *notebook, GtkWidget *child, gint pgnum, gpointer data) { int np = gtk_notebook_get_n_pages(notebook); #if TDEBUG fprintf(stderr, "*** page_removed_callback: child=%p\n", (void *) child); #endif if (np < 5) { gtk_notebook_popup_disable(notebook); } if (np == 1) { /* only one tab left after removal: this page should not display its own closer button, nor should it be detachable */ GtkWidget *tab = gtk_notebook_get_nth_page(notebook, 0); gtk_notebook_set_tab_detachable(notebook, tab, FALSE); viewer_tab_show_closer(notebook, tab, FALSE); } }
static VALUE rg_set_tab_detachable(VALUE self, VALUE child, VALUE detachable) { gtk_notebook_set_tab_detachable(_SELF(self), GTK_WIDGET(RVAL2GOBJ(child)), RVAL2CBOOL(detachable)); return self; }
/** * 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)); } }
static void tabwin_unregister_dialog (GtkWidget *w, tabwin_t *tabwin) { if (tabwin != NULL && (tabwin == tabmod || tabwin == tabedit)) { /* @tabwin will be an invalid pointer if it got a delete-event before execution gets here */ GtkWidget *tab = tabwin->dlg_owner; #if TDEBUG fprintf(stderr, "*** unregister_dialog: owner = %p\n", (void *) tab); #endif if (tab != NULL) { GtkNotebook *notebook = GTK_NOTEBOOK(tabwin->tabs); windata_t *vwin = g_object_get_data(G_OBJECT(tab), "vwin"); gtk_widget_set_sensitive(GTK_WIDGET(vwin->mbar), TRUE); if (gtk_notebook_get_n_pages(notebook) > 1) { gtk_notebook_set_tab_detachable(notebook, tab, TRUE); } tabwin->dlg_owner = NULL; } tabwin->dialog = NULL; } }
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); }
/***************************************************************************** * create_param_notebook_page() * * Create a page of parameter input widgets. * Designed to be run out of a loop. *****************************************************************************/ void create_param_notebook_page(GtkWidget *main_window, GtkWidget *notebook, PARAM_PAGE *param_page, int page_num) { GtkWidget *label; GtkWidget *page; GtkWidget *event; GtkWidget *hbox; GtkWidget *vbox; int j = 0; int k = 0; int x = 0; int max_x = 0; /* Find number of columns for this notebook page */ for (j = 0; j < NUM_PARAM_GROUPS; j++) { if ((param_group[j].notebook_page == page_num) && (param_group[j].notebook_x > max_x)) { max_x = param_group[j].notebook_x; } } /* Start with an hbox, so param group columns can be attached, same as in one_page mode. */ event = gtk_event_box_new(); widget_set_backing_store(event); hbox = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(event), hbox); /* Run through all param groups, and add the ones for this page */ for (x = 0; x <= max_x; x++) { vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); for (j = 0; j < NUM_PARAM_GROUPS; j++) { k = notebook_order[j]; if ((param_group[k].notebook_page == page_num) && (param_group[k].notebook_x == x)) { create_param_group(main_window, vbox, & (param_group[k]), page_num); } } } gtk_container_add(GTK_CONTAINER(notebook), event); /* Set the label */ label = gtk_label_new(param_page->label); widget_set_custom_font(label, phasex_font_desc); widget_set_backing_store(label); page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), page_num); #if GTK_CHECK_VERSION(2, 10, 0) gtk_notebook_set_tab_detachable(GTK_NOTEBOOK(notebook), page, FALSE); #endif gtk_notebook_set_tab_label(GTK_NOTEBOOK(notebook), page, label); }
/** * 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 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); }
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); }
/** * 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); } }
/** * 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 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; }
static int nautilus_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 (nautilus_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); gtk_notebook_set_tab_detachable (gnotebook, tab_widget, TRUE); return position; }
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; }
static void page_added_callback (GtkNotebook *notebook, GtkWidget *child, gint pgnum, gpointer data) { int i, np = gtk_notebook_get_n_pages(notebook); GtkWidget *tab; if (np >= 5) { gtk_notebook_popup_enable(notebook); } if (np > 1) { for (i=0; i<np; i++) { tab = gtk_notebook_get_nth_page(notebook, i); gtk_notebook_set_tab_detachable(notebook, tab, TRUE); viewer_tab_show_closer(notebook, tab, TRUE); } } else { tab = gtk_notebook_get_nth_page(notebook, 0); viewer_tab_show_closer(notebook, tab, FALSE); } }
void tabwin_register_dialog (GtkWidget *w, gpointer p) { tabwin_t *tabwin = g_object_get_data(G_OBJECT(p), "tabwin"); GtkNotebook *notebook = GTK_NOTEBOOK(tabwin->tabs); gint pg = gtk_notebook_get_current_page(notebook); GtkWidget *tab = gtk_notebook_get_nth_page(notebook, pg); windata_t *vwin = g_object_get_data(G_OBJECT(tab), "vwin"); #if TDEBUG fprintf(stderr, "*** tabwin_register_dialog: w = %p, tab=%p\n", (void *) w, (void *) tab); #endif gtk_widget_set_sensitive(vwin->mbar, FALSE); gtk_notebook_set_tab_detachable(notebook, tab, FALSE); tabwin->dialog = w; tabwin->dlg_owner = tab; g_signal_connect(G_OBJECT(w), "destroy", G_CALLBACK(tabwin_unregister_dialog), tabwin); }
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; }