Synopsis#include <gtk/gtk.h> GtkNotebook; GtkNotebookPage; GtkWidget* gtk_notebook_new (void); gint gtk_notebook_append_page (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label); gint gtk_notebook_append_page_menu (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label, GtkWidget *menu_label); gint gtk_notebook_prepend_page (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label); gint gtk_notebook_prepend_page_menu (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label, GtkWidget *menu_label); gint gtk_notebook_insert_page (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label, gint position); gint gtk_notebook_insert_page_menu (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label, GtkWidget *menu_label, gint position); void gtk_notebook_remove_page (GtkNotebook *notebook, gint page_num); #define gtk_notebook_current_page gint gtk_notebook_page_num (GtkNotebook *notebook, GtkWidget *child); #define gtk_notebook_set_page void gtk_notebook_next_page (GtkNotebook *notebook); void gtk_notebook_prev_page (GtkNotebook *notebook); void gtk_notebook_reorder_child (GtkNotebook *notebook, GtkWidget *child, gint position); void gtk_notebook_set_tab_pos (GtkNotebook *notebook, GtkPositionType pos); void gtk_notebook_set_show_tabs (GtkNotebook *notebook, gboolean show_tabs); void gtk_notebook_set_show_border (GtkNotebook *notebook, gboolean show_border); void gtk_notebook_set_scrollable (GtkNotebook *notebook, gboolean scrollable); void gtk_notebook_set_tab_border (GtkNotebook *notebook, guint border_width); void gtk_notebook_popup_enable (GtkNotebook *notebook); void gtk_notebook_popup_disable (GtkNotebook *notebook); gint gtk_notebook_get_current_page (GtkNotebook *notebook); GtkWidget* gtk_notebook_get_menu_label (GtkNotebook *notebook, GtkWidget *child); GtkWidget* gtk_notebook_get_nth_page (GtkNotebook *notebook, gint page_num); gint gtk_notebook_get_n_pages (GtkNotebook *notebook); GtkWidget* gtk_notebook_get_tab_label (GtkNotebook *notebook, GtkWidget *child); void gtk_notebook_query_tab_label_packing (GtkNotebook *notebook, GtkWidget *child, gboolean *expand, gboolean *fill, GtkPackType *pack_type); void gtk_notebook_set_homogeneous_tabs (GtkNotebook *notebook, gboolean homogeneous); void gtk_notebook_set_menu_label (GtkNotebook *notebook, GtkWidget *child, GtkWidget *menu_label); void gtk_notebook_set_menu_label_text (GtkNotebook *notebook, GtkWidget *child, const gchar *menu_text); void gtk_notebook_set_tab_hborder (GtkNotebook *notebook, guint tab_hborder); void gtk_notebook_set_tab_label (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label); void gtk_notebook_set_tab_label_packing (GtkNotebook *notebook, GtkWidget *child, gboolean expand, gboolean fill, GtkPackType pack_type); void gtk_notebook_set_tab_label_text (GtkNotebook *notebook, GtkWidget *child, const gchar *tab_text); void gtk_notebook_set_tab_vborder (GtkNotebook *notebook, guint tab_vborder); void gtk_notebook_set_tab_reorderable (GtkNotebook *notebook, GtkWidget *child, gboolean reorderable); void gtk_notebook_set_tab_detachable (GtkNotebook *notebook, GtkWidget *child, gboolean detachable); const gchar* gtk_notebook_get_menu_label_text (GtkNotebook *notebook, GtkWidget *child); gboolean gtk_notebook_get_scrollable (GtkNotebook *notebook); gboolean gtk_notebook_get_show_border (GtkNotebook *notebook); gboolean gtk_notebook_get_show_tabs (GtkNotebook *notebook); const gchar* gtk_notebook_get_tab_label_text (GtkNotebook *notebook, GtkWidget *child); GtkPositionType gtk_notebook_get_tab_pos (GtkNotebook *notebook); gboolean gtk_notebook_get_tab_reorderable (GtkNotebook *notebook, GtkWidget *child); gboolean gtk_notebook_get_tab_detachable (GtkNotebook *notebook, GtkWidget *child); void gtk_notebook_set_current_page (GtkNotebook *notebook, gint page_num); void gtk_notebook_set_group_id (GtkNotebook *notebook, gint group_id); gint gtk_notebook_get_group_id (GtkNotebook *notebook); void gtk_notebook_set_group (GtkNotebook *notebook, gpointer group); gpointer gtk_notebook_get_group (GtkNotebook *notebook); GtkNotebook* (*GtkNotebookWindowCreationFunc) (GtkNotebook *source, GtkWidget *page, gint x, gint y, gpointer data); void gtk_notebook_set_window_creation_hook (GtkNotebookWindowCreationFunc func, gpointer data, GDestroyNotify destroy); Object HierarchyGObject +----GInitiallyUnowned +----GtkObject +----GtkWidget +----GtkContainer +----GtkNotebook Properties"enable-popup" gboolean : Read / Write "group" gpointer : Read / Write "group-id" gint : Read / Write "homogeneous" gboolean : Read / Write "page" gint : Read / Write "scrollable" gboolean : Read / Write "show-border" gboolean : Read / Write "show-tabs" gboolean : Read / Write "tab-border" guint : Write "tab-hborder" guint : Read / Write "tab-pos" GtkPositionType : Read / Write "tab-vborder" guint : Read / Write Child Properties"detachable" gboolean : Read / Write "menu-label" gchar* : Read / Write "position" gint : Read / Write "reorderable" gboolean : Read / Write "tab-expand" gboolean : Read / Write "tab-fill" gboolean : Read / Write "tab-label" gchar* : Read / Write "tab-pack" GtkPackType : Read / Write Style Properties"arrow-spacing" gint : Read "has-backward-stepper" gboolean : Read "has-forward-stepper" gboolean : Read "has-secondary-backward-stepper" gboolean : Read "has-secondary-forward-stepper" gboolean : Read "tab-curvature" gint : Read "tab-overlap" gint : Read Signals"change-current-page" : Run Last / Action "create-window" : Run Last "focus-tab" : Run Last / Action "move-focus-out" : Run Last / Action "page-added" : Run Last "page-removed" : Run Last "page-reordered" : Run Last "reorder-tab" : Run Last / Action "select-page" : Run Last / Action "switch-page" : Run Last DescriptionThe GtkNotebook widget is a GtkContainer whose children are pages that can be switched between using tab labels along one edge.
There are many configuration options for GtkNotebook. Among other
things, you can choose on which edge the tabs appear
(see GtkNotebook as GtkBuildableThe GtkNoteboopk implementation of the GtkBuildable interface supports placing children into tabs by specifying "tab" as the "type" attribute of a <child> element. Note that the content of the tab must be created before the tab can be filled. A tab child can be specified without specifying a <child> type attribute. Example 38. A UI definition fragment with GtkNotebook <object class="GtkNotebook"> <child> <object class="GtkLabel" id="notebook-content"> <property name="label">Content</property> </object> </child> <child type="tab"> <object class="GtkLabel" id="notebook-tab"> <property name="label">Tab</property> </object> </child> </object> DetailsGtkNotebookPagetypedef struct _GtkNotebookPage GtkNotebookPage; The GtkNotebookPage is an opaque implementation detail of GtkNotebook. gtk_notebook_new ()GtkWidget* gtk_notebook_new (void); Creates a new GtkNotebook widget with no pages.
gtk_notebook_append_page ()gint gtk_notebook_append_page (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label);
Appends a page to
gtk_notebook_append_page_menu ()gint gtk_notebook_append_page_menu (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label, GtkWidget *menu_label);
Appends a page to
gtk_notebook_prepend_page ()gint gtk_notebook_prepend_page (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label);
Prepends a page to
gtk_notebook_prepend_page_menu ()gint gtk_notebook_prepend_page_menu (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label, GtkWidget *menu_label);
Prepends a page to
gtk_notebook_insert_page ()gint gtk_notebook_insert_page (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label, gint position);
Insert a page into
gtk_notebook_insert_page_menu ()gint gtk_notebook_insert_page_menu (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label, GtkWidget *menu_label, gint position);
Insert a page into
gtk_notebook_remove_page ()void gtk_notebook_remove_page (GtkNotebook *notebook, gint page_num); Removes a page from the notebook given its index in the notebook.
gtk_notebook_current_page#define gtk_notebook_current_page gtk_notebook_get_current_page Warning
Deprecated compatibility macro. Use
gtk_notebook_page_num ()gint gtk_notebook_page_num (GtkNotebook *notebook, GtkWidget *child); Finds the index of the page which contains the given child widget.
gtk_notebook_set_page#define gtk_notebook_set_page gtk_notebook_set_current_page Warning
Deprecated compatibility macro. Use
gtk_notebook_next_page ()void gtk_notebook_next_page (GtkNotebook *notebook); Switches to the next page. Nothing happens if the current page is the last page.
gtk_notebook_prev_page ()void gtk_notebook_prev_page (GtkNotebook *notebook); Switches to the previous page. Nothing happens if the current page is the first page.
gtk_notebook_reorder_child ()void gtk_notebook_reorder_child (GtkNotebook *notebook, GtkWidget *child, gint position);
Reorders the page containing
gtk_notebook_set_tab_pos ()void gtk_notebook_set_tab_pos (GtkNotebook *notebook, GtkPositionType pos); Sets the edge at which the tabs for switching pages in the notebook are drawn.
gtk_notebook_set_show_tabs ()void gtk_notebook_set_show_tabs (GtkNotebook *notebook, gboolean show_tabs); Sets whether to show the tabs for the notebook or not.
gtk_notebook_set_show_border ()void gtk_notebook_set_show_border (GtkNotebook *notebook, gboolean show_border);
Sets whether a bevel will be drawn around the notebook pages.
This only has a visual effect when the tabs are not shown.
See
gtk_notebook_set_scrollable ()void gtk_notebook_set_scrollable (GtkNotebook *notebook, gboolean scrollable); Sets whether the tab label area will have arrows for scrolling if there are too many tabs to fit in the area.
gtk_notebook_set_tab_border ()void gtk_notebook_set_tab_border (GtkNotebook *notebook, guint border_width); Warning
Sets the width the border around the tab labels
in a notebook. This is equivalent to calling
gtk_notebook_set_tab_hborder (
gtk_notebook_popup_enable ()void gtk_notebook_popup_enable (GtkNotebook *notebook); Enables the popup menu: if the user clicks with the right mouse button on the bookmarks, a menu with all the pages will be popped up.
gtk_notebook_popup_disable ()void gtk_notebook_popup_disable (GtkNotebook *notebook); Disables the popup menu.
gtk_notebook_get_current_page ()gint gtk_notebook_get_current_page (GtkNotebook *notebook); Returns the page number of the current page.
gtk_notebook_get_menu_label ()GtkWidget* gtk_notebook_get_menu_label (GtkNotebook *notebook, GtkWidget *child);
Retrieves the menu label widget of the page containing
gtk_notebook_get_nth_page ()GtkWidget* gtk_notebook_get_nth_page (GtkNotebook *notebook, gint page_num);
Returns the child widget contained in page number
gtk_notebook_get_n_pages ()gint gtk_notebook_get_n_pages (GtkNotebook *notebook); Gets the number of pages in a notebook.
Since 2.2 gtk_notebook_get_tab_label ()GtkWidget* gtk_notebook_get_tab_label (GtkNotebook *notebook, GtkWidget *child);
Returns the tab label widget for the page
gtk_notebook_query_tab_label_packing ()void gtk_notebook_query_tab_label_packing (GtkNotebook *notebook, GtkWidget *child, gboolean *expand, gboolean *fill, GtkPackType *pack_type);
Query the packing attributes for the tab label of the page
containing
gtk_notebook_set_homogeneous_tabs ()void gtk_notebook_set_homogeneous_tabs (GtkNotebook *notebook, gboolean homogeneous); Warning
Sets whether the tabs must have all the same size or not.
gtk_notebook_set_menu_label ()void gtk_notebook_set_menu_label (GtkNotebook *notebook, GtkWidget *child, GtkWidget *menu_label);
Changes the menu label for the page containing
gtk_notebook_set_menu_label_text ()void gtk_notebook_set_menu_label_text (GtkNotebook *notebook, GtkWidget *child, const gchar *menu_text);
Creates a new label and sets it as the menu label of
gtk_notebook_set_tab_hborder ()void gtk_notebook_set_tab_hborder (GtkNotebook *notebook, guint tab_hborder); Warning
Sets the width of the horizontal border of tab labels.
gtk_notebook_set_tab_label ()void gtk_notebook_set_tab_label (GtkNotebook *notebook, GtkWidget *child, GtkWidget *tab_label);
Changes the tab label for
gtk_notebook_set_tab_label_packing ()void gtk_notebook_set_tab_label_packing (GtkNotebook *notebook, GtkWidget *child, gboolean expand, gboolean fill, GtkPackType pack_type);
Sets the packing parameters for the tab label of the page
containing
gtk_notebook_set_tab_label_text ()void gtk_notebook_set_tab_label_text (GtkNotebook *notebook, GtkWidget *child, const gchar *tab_text);
Creates a new label and sets it as the tab label for the page
containing
gtk_notebook_set_tab_vborder ()void gtk_notebook_set_tab_vborder (GtkNotebook *notebook, guint tab_vborder); Warning
Sets the width of the vertical border of tab labels.
gtk_notebook_set_tab_reorderable ()void gtk_notebook_set_tab_reorderable (GtkNotebook *notebook, GtkWidget *child, gboolean reorderable); Sets whether the notebook tab can be reordered via drag and drop or not.
Since 2.10 gtk_notebook_set_tab_detachable ()void gtk_notebook_set_tab_detachable (GtkNotebook *notebook, GtkWidget *child, gboolean detachable);
Sets whether the tab can be detached from
Note that 2 notebooks must share a common group identificator
(see If you want a widget to interact with a notebook through DnD (i.e.: accept dragged tabs from it) it must be set as a drop destination and accept the target "GTK_NOTEBOOK_TAB". The notebook will fill the selection with a GtkWidget** pointing to the child widget that corresponds to the dropped tab. static void on_drop_zone_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection_data, guint info, guint time, gpointer user_data) { GtkWidget *notebook; GtkWidget **child; notebook = gtk_drag_get_source_widget (context); child = (void*) selection_data->data; process_widget (*child); gtk_container_remove (GTK_CONTAINER (notebook), *child); }
If you want a notebook to accept drags from other widgets, you will have to set your own DnD code to do it.
Since 2.10 gtk_notebook_get_menu_label_text ()const gchar* gtk_notebook_get_menu_label_text (GtkNotebook *notebook, GtkWidget *child);
Retrieves the text of the menu label for the page containing
gtk_notebook_get_scrollable ()gboolean gtk_notebook_get_scrollable (GtkNotebook *notebook);
Returns whether the tab label area has arrows for scrolling. See
gtk_notebook_get_show_border ()gboolean gtk_notebook_get_show_border (GtkNotebook *notebook);
Returns whether a bevel will be drawn around the notebook pages. See
gtk_notebook_get_show_tabs ()gboolean gtk_notebook_get_show_tabs (GtkNotebook *notebook);
Returns whether the tabs of the notebook are shown. See
gtk_notebook_get_tab_label_text ()const gchar* gtk_notebook_get_tab_label_text (GtkNotebook *notebook, GtkWidget *child);
Retrieves the text of the tab label for the page containing
gtk_notebook_get_tab_pos ()GtkPositionType gtk_notebook_get_tab_pos (GtkNotebook *notebook); Gets the edge at which the tabs for switching pages in the notebook are drawn.
gtk_notebook_get_tab_reorderable ()gboolean gtk_notebook_get_tab_reorderable (GtkNotebook *notebook, GtkWidget *child); Gets whether the tab can be reordered via drag and drop or not.
Since 2.10 gtk_notebook_get_tab_detachable ()gboolean gtk_notebook_get_tab_detachable (GtkNotebook *notebook, GtkWidget *child);
Returns whether the tab contents can be detached from
Since 2.10 gtk_notebook_set_current_page ()void gtk_notebook_set_current_page (GtkNotebook *notebook, gint page_num);
Switches to the page number Note that due to historical reasons, GtkNotebook refuses to switch to a page unless the child widget is visible. Therefore, it is recommended to show child widgets before adding them to a notebook.
gtk_notebook_set_group_id ()void gtk_notebook_set_group_id (GtkNotebook *notebook, gint group_id); Warning
Sets an group identificator for
Since 2.10 gtk_notebook_get_group_id ()gint gtk_notebook_get_group_id (GtkNotebook *notebook); Warning
Gets the current group identificator for
Since 2.10 gtk_notebook_set_group ()void gtk_notebook_set_group (GtkNotebook *notebook, gpointer group);
Sets a group identificator pointer for
Since 2.12 gtk_notebook_get_group ()gpointer gtk_notebook_get_group (GtkNotebook *notebook);
Gets the current group identificator pointer for
Since 2.12 GtkNotebookWindowCreationFunc ()GtkNotebook* (*GtkNotebookWindowCreationFunc) (GtkNotebook *source, GtkWidget *page, gint x, gint y, gpointer data);
A function used by GtkNotebook when a detachable tab is dropped
in the root window, it's used to create a window containing a notebook
where the tab will be attached. This function will also be responsible
of moving/resizing the window and adding the necessary properties to
the notebook (i.e.: group-id).
If the function returns
gtk_notebook_set_window_creation_hook ()void gtk_notebook_set_window_creation_hook (GtkNotebookWindowCreationFunc func, gpointer data, GDestroyNotify destroy); Installs a global function used to create a window when a detached tab is dropped in an empty area.
Since 2.10 Property DetailsThe
|
|
the object which received the signal. |
|
|
|
user data set when the signal handler was connected. |
Returns : |
"create-window"
signalGtkNotebook* user_function (GtkNotebook *notebook, GtkWidget *page, gint x, gint y, gpointer user_data) : Run Last
The ::create-window signal is emitted when a detachable tab is dropped on the root window.
A handler for this signal can create a window containing a notebook where the tab will be attached. It is also responsible for moving/resizing the window and adding the necessary properties to the notebook (e.g. the "group-id" ).
The default handler uses the global window creation hook,
if one has been set with gtk_notebook_set_window_creation_hook()
.
|
the GtkNotebook emitting the signal |
|
the tab of notebook that is being detached
|
|
the X coordinate where the drop happens |
|
the Y coordinate where the drop happens |
|
user data set when the signal handler was connected. |
Returns : |
a GtkNotebook that page should be added to, or NULL .
|
Since 2.12
"focus-tab"
signalgboolean user_function (GtkNotebook *notebook, GtkNotebookTab arg1, gpointer user_data) : Run Last / Action
|
the object which received the signal. |
|
|
|
user data set when the signal handler was connected. |
Returns : |
"move-focus-out"
signalvoid user_function (GtkNotebook *notebook, GtkDirectionType arg1, gpointer user_data) : Run Last / Action
|
the object which received the signal. |
|
|
|
user data set when the signal handler was connected. |
"page-added"
signalvoid user_function (GtkNotebook *notebook, GtkWidget *child, guint page_num, gpointer user_data) : Run Last
the ::page-added signal is emitted in the notebook right after a page is added to the notebook.
|
the GtkNotebook |
|
the child GtkWidget affected |
|
the new page number for child
|
|
user data set when the signal handler was connected. |
Since 2.10
"page-removed"
signalvoid user_function (GtkNotebook *notebook, GtkWidget *child, guint page_num, gpointer user_data) : Run Last
the ::page-removed signal is emitted in the notebook right after a page is removed from the notebook.
|
the GtkNotebook |
|
the child GtkWidget affected |
|
the child page number
|
|
user data set when the signal handler was connected. |
Since 2.10
"page-reordered"
signalvoid user_function (GtkNotebook *notebook, GtkWidget *child, guint page_num, gpointer user_data) : Run Last
the ::page-reordered signal is emitted in the notebook right after a page has been reordered.
|
the GtkNotebook |
|
the child GtkWidget affected |
|
the new page number for child
|
|
user data set when the signal handler was connected. |
Since 2.10
"reorder-tab"
signalgboolean user_function (GtkNotebook *notebook, GtkDirectionType arg1, gboolean arg2, gpointer user_data) : Run Last / Action
|
the object which received the signal. |
|
|
|
|
|
user data set when the signal handler was connected. |
Returns : |
"select-page"
signalgboolean user_function (GtkNotebook *notebook, gboolean arg1, gpointer user_data) : Run Last / Action
|
the object which received the signal. |
|
|
|
user data set when the signal handler was connected. |
Returns : |
"switch-page"
signalvoid user_function (GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer user_data) : Run Last
Emitted when the user or a function changes the current page.
|
the object which received the signal. |
|
the new current page |
|
the index of the page |
|
user data set when the signal handler was connected. |