gtk.notebook

Module for [Notebook] class

Types 3

[gtk.notebook.Notebook] is a container whose children are pages switched between using tabs.

!An example GtkNotebook

There are many configuration options for [gtk.notebook.Notebook]. Among other things, you can choose on which edge the tabs appear (see [gtk.notebook.Notebook.setTabPos]), whether, if there are too many tabs to fit the notebook should be made bigger or scrolling arrows added (see [gtk.notebook.Notebook.setScrollable]), and whether there will be a popup menu allowing the users to switch pages. (see [gtk.notebook.Notebook.popupEnable]).

GtkNotebook as GtkBuildable

The [gtk.notebook.Notebook] implementation of the [gtk.buildable.Buildable] 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.

To add a child widget in the notebooks action area, specify "action-start" or “action-end” as the “type” attribute of the <child> element.

An example of a UI definition fragment with [gtk.notebook.Notebook]:

<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>

CSS nodes

notebook
├── header.top
│   ├── [<action widget>]
│   ├── tabs
│   │   ├── [arrow]
│   │   ├── tab
│   │   │   ╰── <tab label>
┊   ┊   ┊
│   │   ├── tab[.reorderable-page]
│   │   │   ╰── <tab label>
│   │   ╰── [arrow]
│   ╰── [<action widget>]
│
╰── stack
   ├── <child>
   ┊
   ╰── <child>

[gtk.notebook.Notebook] has a main CSS node with name notebook, a subnode with name header and below that a subnode with name tabs which contains one subnode per tab with name tab.

If action widgets are present, their CSS nodes are placed next to the tabs node. If the notebook is scrollable, CSS nodes with name arrow are placed as first and last child of the tabs node.

The main node gets the .frame style class when the notebook has a border (see [gtk.notebook.Notebook.setShowBorder]).

The header node gets one of the style class .top, .bottom, .left or .right, depending on where the tabs are placed. For reorderable pages, the tab node gets the .reorderable-page class.

A tab node gets the .dnd style class while it is moved with drag-and-drop.

The nodes are always arranged from left-to-right, regardless of text direction.

Accessibility

[gtk.notebook.Notebook] uses the following roles:

  • [gtk.types.AccessibleRole.Group] for the notebook widget
  • [gtk.types.AccessibleRole.TabList] for the list of tabs
  • [gtk.types.AccessibleRole.Tab] role for each tab
  • [gtk.types.AccessibleRole.TabPanel] for each page
Methods
GType _gType() @property
Notebook self()Returns `this`, for use in `with` statements.
NotebookGidBuilder builder()Get builder for [gtk.notebook.Notebook] Returns: New builder object
bool enablePopup() @propertyGet `enablePopup` property. Returns: If true, pressing the right mouse button on the notebook shows a page switching menu.
void enablePopup(bool propval) @propertySet `enablePopup` property. Params: propval = If true, pressing the right mouse button on the notebook shows a page switching menu.
string groupName() @propertyGet `groupName` property. Returns: Group name for tab drag and drop.
void groupName(string propval) @propertySet `groupName` property. Params: propval = Group name for tab drag and drop.
int page() @propertyGet `page` property. Returns: The index of the current page.
void page(int propval) @propertySet `page` property. Params: propval = The index of the current page.
gio.list_model.ListModel pages() @propertyGet `pages` property. Returns: A selection model with the pages.
bool scrollable() @propertyGet `scrollable` property. Returns: If true, scroll arrows are added if there are too many pages to fit.
void scrollable(bool propval) @propertySet `scrollable` property. Params: propval = If true, scroll arrows are added if there are too many pages to fit.
bool showBorder() @propertyGet `showBorder` property. Returns: Whether the border should be shown.
void showBorder(bool propval) @propertySet `showBorder` property. Params: propval = Whether the border should be shown.
bool showTabs() @propertyGet `showTabs` property. Returns: Whether tabs should be shown.
void showTabs(bool propval) @propertySet `showTabs` property. Params: propval = Whether tabs should be shown.
gtk.types.PositionType tabPos() @propertyGet `tabPos` property. Returns: Which side of the notebook holds the tabs.
void tabPos(gtk.types.PositionType propval) @propertySet `tabPos` property. Params: propval = Which side of the notebook holds the tabs.
int appendPage(gtk.widget.Widget child, gtk.widget.Widget tabLabel = null)Appends a page to notebook.
int appendPageMenu(gtk.widget.Widget child, gtk.widget.Widget tabLabel = null, gtk.widget.Widget menuLabel = null)Appends a page to notebook, specifying the widget to use as the label in the popup menu.
void detachTab(gtk.widget.Widget child)Removes the child from the notebook.
gtk.widget.Widget getActionWidget(gtk.types.PackType packType)Gets one of the action widgets.
int getCurrentPage()Returns the page number of the current page. Returns: the index (starting from 0) of the current page in the notebook. If the notebook has no pages, then -1 will be returned.
string getGroupName()Gets the current group name for notebook. Returns: the group name, or null if none is set
gtk.widget.Widget getMenuLabel(gtk.widget.Widget child)Retrieves the menu label widget of the page containing child.
string getMenuLabelText(gtk.widget.Widget child)Retrieves the text of the menu label for the page containing child.
int getNPages()Gets the number of pages in a notebook. Returns: the number of pages in the notebook
gtk.widget.Widget getNthPage(int pageNum)Returns the child widget contained in page number page_num.
gtk.notebook_page.NotebookPage getPage(gtk.widget.Widget child)Returns the [gtk.notebook_page.NotebookPage] for child.
gio.list_model.ListModel getPages()Returns a [gio.list_model.ListModel] that contains the pages of the notebook.
bool getScrollable()Returns whether the tab label area has arrows for scrolling. Returns: true if arrows for scrolling are present
bool getShowBorder()Returns whether a bevel will be drawn around the notebook pages. Returns: true if the bevel is drawn
bool getShowTabs()Returns whether the tabs of the notebook are shown. Returns: true if the tabs are shown
bool getTabDetachable(gtk.widget.Widget child)Returns whether the tab contents can be detached from notebook.
gtk.widget.Widget getTabLabel(gtk.widget.Widget child)Returns the tab label widget for the page child.
string getTabLabelText(gtk.widget.Widget child)Retrieves the text of the tab label for the page containing child.
gtk.types.PositionType getTabPos()Gets the edge at which the tabs are drawn. Returns: the edge at which the tabs are drawn
bool getTabReorderable(gtk.widget.Widget child)Gets whether the tab can be reordered via drag and drop or not.
int insertPage(gtk.widget.Widget child, gtk.widget.Widget tabLabel, int position)Insert a page into notebook at the given position.
int insertPageMenu(gtk.widget.Widget child, gtk.widget.Widget tabLabel, gtk.widget.Widget menuLabel, int position)Insert a page into notebook at the given position, specifying the widget to use as the label in the popup menu.
void nextPage()Switches to the next page.
int pageNum(gtk.widget.Widget child)Finds the index of the page which contains the given child widget.
void popupDisable()Disables the popup menu.
void popupEnable()Enables the popup menu.
int prependPage(gtk.widget.Widget child, gtk.widget.Widget tabLabel = null)Prepends a page to notebook.
int prependPageMenu(gtk.widget.Widget child, gtk.widget.Widget tabLabel = null, gtk.widget.Widget menuLabel = null)Prepends a page to notebook, specifying the widget to use as the label in the popup menu.
void prevPage()Switches to the previous page.
void removePage(int pageNum)Removes a page from the notebook given its index in the notebook.
void reorderChild(gtk.widget.Widget child, int position)Reorders the page containing child, so that it appears in position position.
void setActionWidget(gtk.widget.Widget widget, gtk.types.PackType packType)Sets widget as one of the action widgets.
void setCurrentPage(int pageNum)Switches to the page number page_num.
void setGroupName(string groupName = null)Sets a group name for notebook.
void setMenuLabel(gtk.widget.Widget child, gtk.widget.Widget menuLabel = null)Changes the menu label for the page containing child.
void setMenuLabelText(gtk.widget.Widget child, string menuText)Creates a new label and sets it as the menu label of child.
void setScrollable(bool scrollable)Sets whether the tab label area will have arrows for scrolling if there are too many tabs to fit in the area.
void setShowBorder(bool showBorder)Sets whether a bevel will be drawn around the notebook pages.
void setShowTabs(bool showTabs)Sets whether to show the tabs for the notebook or not.
void setTabDetachable(gtk.widget.Widget child, bool detachable)Sets whether the tab can be detached from notebook to another notebook or widget.
void setTabLabel(gtk.widget.Widget child, gtk.widget.Widget tabLabel = null)Changes the tab label for child.
void setTabLabelText(gtk.widget.Widget child, string tabText)Creates a new label and sets it as the tab label for the page containing child.
void setTabPos(gtk.types.PositionType pos)Sets the edge at which the tabs are drawn.
void setTabReorderable(gtk.widget.Widget child, bool reorderable)Sets whether the notebook tab can be reordered via drag and drop or not.
gulong connectChangeCurrentPage(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == bool) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == int))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.notebook.Notebook))) && Parameters!T.length < 3)Connect to `ChangeCurrentPage` signal.
gulong connectCreateWindow(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T : gtk.notebook.Notebook) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.widget.Widget))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.notebook.Notebook))) && Parameters!T.length < 3)Connect to `CreateWindow` signal.
gulong connectFocusTab(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == bool) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.types.NotebookTab))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.notebook.Notebook))) && Parameters!T.length < 3)Connect to `FocusTab` signal.
gulong connectMoveFocusOut(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.types.DirectionType))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.notebook.Notebook))) && Parameters!T.length < 3)Connect to `MoveFocusOut` signal.
gulong connectPageAdded(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.widget.Widget))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == uint))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.notebook.Notebook))) && Parameters!T.length < 4)Connect to `PageAdded` signal.
gulong connectPageRemoved(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.widget.Widget))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == uint))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.notebook.Notebook))) && Parameters!T.length < 4)Connect to `PageRemoved` signal.
gulong connectPageReordered(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.widget.Widget))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == uint))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.notebook.Notebook))) && Parameters!T.length < 4)Connect to `PageReordered` signal.
gulong connectReorderTab(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == bool) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.types.DirectionType))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == bool))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.notebook.Notebook))) && Parameters!T.length < 4)Connect to `ReorderTab` signal.
gulong connectSelectPage(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == bool) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == bool))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.notebook.Notebook))) && Parameters!T.length < 3)Connect to `SelectPage` signal.
gulong connectSwitchPage(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.widget.Widget))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == uint))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.notebook.Notebook))) && Parameters!T.length < 4)Connect to `SwitchPage` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new [gtk.notebook.Notebook] widget with no pages. Returns: the newly created [gtk.notebook.Notebook]
Methods
T enablePopup(bool propval)Set `enablePopup` property. Params: propval = If true, pressing the right mouse button on the notebook shows a page switching menu. Returns: Builder instance for fluent chaining
T groupName(string propval)Set `groupName` property. Params: propval = Group name for tab drag and drop. Returns: Builder instance for fluent chaining
T page(int propval)Set `page` property. Params: propval = The index of the current page. Returns: Builder instance for fluent chaining
T scrollable(bool propval)Set `scrollable` property. Params: propval = If true, scroll arrows are added if there are too many pages to fit. Returns: Builder instance for fluent chaining
T showBorder(bool propval)Set `showBorder` property. Params: propval = Whether the border should be shown. Returns: Builder instance for fluent chaining
T showTabs(bool propval)Set `showTabs` property. Params: propval = Whether tabs should be shown. Returns: Builder instance for fluent chaining
T tabPos(gtk.types.PositionType propval)Set `tabPos` property. Params: propval = Which side of the notebook holds the tabs. Returns: Builder instance for fluent chaining

Fluent builder for [gtk.notebook.Notebook]

Methods