gtk.notebook
Module for [Notebook] class
Types 3
The #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 [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], [gtk.notebook.Notebook.popupDisable])
GtkNotebook as GtkBuildable
The GtkNotebook 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.
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 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>CSS nodes
notebook
├── header.top
│ ├── [<action widget>]
│ ├── tabs
│ │ ├── [arrow]
│ │ ├── tab
│ │ │ ╰── <tab label>
┊ ┊ ┊
│ │ ├── tab[.reorderable-page]
│ │ │ ╰── <tab label>
│ │ ╰── [arrow]
│ ╰── [<action widget>]
│
╰── stack
├── <child>
┊
╰── <child>GtkNotebook 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, regarldess of text direction.
NotebookGidBuilder builder()Get builder for [gtk.notebook.Notebook] Returns: New builder objectbool enablePopup() @propertyvoid enablePopup(bool propval) @propertyvoid groupName(string propval) @propertySet `groupName` property. Params: propval = Group name for tab drag and drop.int page() @propertyvoid page(int propval) @propertybool scrollable() @propertyvoid scrollable(bool propval) @propertybool showBorder() @propertyvoid showBorder(bool propval) @propertybool showTabs() @propertyvoid showTabs(bool propval) @propertygtk.types.PositionType tabPos() @propertyvoid tabPos(gtk.types.PositionType propval) @propertyint 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. See [gtk.notebook.Notebook.setActionWidget].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 setgtk.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 notebookgtk.widget.Widget getNthPage(int pageNum)Returns the child widget contained in page number page_num.bool getScrollable()Returns whether the tab label area has arrows for scrolling. See [gtk.notebook.Notebook.setScrollable]. Returns: true if arrows for scrolling are presentbool getShowBorder()Returns whether a bevel will be drawn around the notebook pages. See [gtk.notebook.Notebook.setShowBorder]. Returns: true if the bevel is drawnbool getShowTabs()Returns whether the tabs of the notebook are shown. See [gtk.notebook.Notebook.setShowTabs]. Returns: true if the tabs are shownbool getTabDetachable(gtk.widget.Widget child)Returns whether the tab contents can be detached from notebook.ushort getTabHborder()Returns the horizontal width of a tab border. Returns: horizontal width of a tab bordergtk.widget.Widget getTabLabel(gtk.widget.Widget child)Returns the tab label widget for the page child. null is returned if child is not in notebook or if no tab label has specifically been set for 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 for switching pages in the notebook are drawn. Returns: the edge at which the tabs are drawnbool getTabReorderable(gtk.widget.Widget child)Gets whether the tab can be reordered via drag and drop or not.ushort getTabVborder()Returns the vertical width of a tab border. Returns: vertical width of a tab borderint 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. Nothing happens if the current page is the last 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: if the user clicks with the right mouse button on the tab labels, a menu with all the pages will be popped up.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. Nothing happens if the current page is the first 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. If position is greater than or equal to the number of children in the list or negative, child will be moved to the end o...void setActionWidget(gtk.widget.Widget widget, gtk.types.PackType packType)Sets widget as one of the action widgets. Depending on the pack type the widget will be placed before or after the tabs. You can use a #GtkBox if you need to pack more than one widget on the same s...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. This only has a visual effect when the tabs are not shown. See [gtk.notebook.Notebook.setShowTabs].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. If null is specified for tab_label, then the page will have the label “page N”.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 for switching pages in the notebook 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] == int)))
&& (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] == int)))
&& (Parameters!T.length < 4 || (ParameterStorageClassTuple!T[3] == ParameterStorageClass.none && is(Parameters!T[3] : gtk.notebook.Notebook)))
&& Parameters!T.length < 5)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.T enablePopup(bool propval)T groupName(string propval)Set `groupName` property. Params: propval = Group name for tab drag and drop. Returns: Builder instance for fluent chainingT page(int propval)T scrollable(bool propval)T showBorder(bool propval)T showTabs(bool propval)T tabPos(gtk.types.PositionType propval)