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.

Methods
GType _getGType() static nothrow
GType _gType() @property nothrow
Notebook self() nothrowReturns `this`, for use in `with` statements.
NotebookGidBuilder builder() static nothrowGet builder for [gtk.notebook.Notebook] Returns: New builder object
bool enablePopup() @property nothrow
void enablePopup(bool propval) @property nothrow
string groupName() @property nothrowGet `groupName` property. Returns: Group name for tab drag and drop.
void groupName(string propval) @property nothrowSet `groupName` property. Params: propval = Group name for tab drag and drop.
int page() @property nothrow
void page(int propval) @property nothrow
bool scrollable() @property nothrow
void scrollable(bool propval) @property nothrow
bool showBorder() @property nothrow
void showBorder(bool propval) @property nothrow
bool showTabs() @property nothrow
void showTabs(bool propval) @property nothrow
gtk.types.PositionType tabPos() @property nothrow
void tabPos(gtk.types.PositionType propval) @property nothrow
int appendPage(gtk.widget.Widget child, gtk.widget.Widget tabLabel = null) nothrowAppends a page to notebook.
int appendPageMenu(gtk.widget.Widget child, gtk.widget.Widget tabLabel = null, gtk.widget.Widget menuLabel = null) nothrowAppends a page to notebook, specifying the widget to use as the label in the popup menu.
void detachTab(gtk.widget.Widget child) nothrowRemoves the child from the notebook.
gtk.widget.Widget getActionWidget(gtk.types.PackType packType) nothrowGets one of the action widgets. See [gtk.notebook.Notebook.setActionWidget].
int getCurrentPage() nothrowReturns 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() nothrowGets the current group name for notebook. Returns: the group name, or null if none is set
gtk.widget.Widget getMenuLabel(gtk.widget.Widget child) nothrowRetrieves the menu label widget of the page containing child.
string getMenuLabelText(gtk.widget.Widget child) nothrowRetrieves the text of the menu label for the page containing child.
int getNPages() nothrowGets the number of pages in a notebook. Returns: the number of pages in the notebook
gtk.widget.Widget getNthPage(int pageNum) nothrowReturns the child widget contained in page number page_num.
bool getScrollable() nothrowReturns whether the tab label area has arrows for scrolling. See [gtk.notebook.Notebook.setScrollable]. Returns: true if arrows for scrolling are present
bool getShowBorder() nothrowReturns whether a bevel will be drawn around the notebook pages. See [gtk.notebook.Notebook.setShowBorder]. Returns: true if the bevel is drawn
bool getShowTabs() nothrowReturns whether the tabs of the notebook are shown. See [gtk.notebook.Notebook.setShowTabs]. Returns: true if the tabs are shown
bool getTabDetachable(gtk.widget.Widget child) nothrowReturns whether the tab contents can be detached from notebook.
ushort getTabHborder() nothrowReturns the horizontal width of a tab border. Returns: horizontal width of a tab border
gtk.widget.Widget getTabLabel(gtk.widget.Widget child) nothrowReturns 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) nothrowRetrieves the text of the tab label for the page containing child.
gtk.types.PositionType getTabPos() nothrowGets the edge at which the tabs for switching pages in the notebook are drawn. Returns: the edge at which the tabs are drawn
bool getTabReorderable(gtk.widget.Widget child) nothrowGets whether the tab can be reordered via drag and drop or not.
ushort getTabVborder() nothrowReturns the vertical width of a tab border. Returns: vertical width of a tab border
int insertPage(gtk.widget.Widget child, gtk.widget.Widget tabLabel, int position) nothrowInsert a page into notebook at the given position.
int insertPageMenu(gtk.widget.Widget child, gtk.widget.Widget tabLabel, gtk.widget.Widget menuLabel, int position) nothrowInsert a page into notebook at the given position, specifying the widget to use as the label in the popup menu.
void nextPage() nothrowSwitches to the next page. Nothing happens if the current page is the last page.
int pageNum(gtk.widget.Widget child) nothrowFinds the index of the page which contains the given child widget.
void popupDisable() nothrowDisables the popup menu.
void popupEnable() nothrowEnables 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) nothrowPrepends a page to notebook.
int prependPageMenu(gtk.widget.Widget child, gtk.widget.Widget tabLabel = null, gtk.widget.Widget menuLabel = null) nothrowPrepends a page to notebook, specifying the widget to use as the label in the popup menu.
void prevPage() nothrowSwitches to the previous page. Nothing happens if the current page is the first page.
void removePage(int pageNum) nothrowRemoves a page from the notebook given its index in the notebook.
void reorderChild(gtk.widget.Widget child, int position) nothrowReorders 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) nothrowSets 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) nothrowSwitches to the page number page_num.
void setGroupName(string groupName = null) nothrowSets a group name for notebook.
void setMenuLabel(gtk.widget.Widget child, gtk.widget.Widget menuLabel = null) nothrowChanges the menu label for the page containing child.
void setMenuLabelText(gtk.widget.Widget child, string menuText) nothrowCreates a new label and sets it as the menu label of child.
void setScrollable(bool scrollable) nothrowSets 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) nothrowSets 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) nothrowSets whether to show the tabs for the notebook or not.
void setTabDetachable(gtk.widget.Widget child, bool detachable) nothrowSets whether the tab can be detached from notebook to another notebook or widget.
void setTabLabel(gtk.widget.Widget child, gtk.widget.Widget tabLabel = null) nothrowChanges 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) nothrowCreates a new label and sets it as the tab label for the page containing child.
void setTabPos(gtk.types.PositionType pos) nothrowSets the edge at which the tabs for switching pages in the notebook are drawn.
void setTabReorderable(gtk.widget.Widget child, bool reorderable) nothrowSets 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect to `SwitchPage` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new #GtkNotebook widget with no pages. Returns: the newly created #GtkNotebook

Fluent builder implementation template for gtk.notebook.Notebook

Methods
T enablePopup(bool propval) nothrow
T groupName(string propval) nothrowSet `groupName` property. Params: propval = Group name for tab drag and drop. Returns: Builder instance for fluent chaining
T page(int propval) nothrow
T scrollable(bool propval) nothrow
T showBorder(bool propval) nothrow
T showTabs(bool propval) nothrow
T tabPos(gtk.types.PositionType propval) nothrow

Fluent builder for gtk.notebook.Notebook

Methods
Notebook build() nothrowCreate object from builder. Returns: New object