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:

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 nothrowGet `enablePopup` property. Returns: If true, pressing the right mouse button on the notebook shows a page switching menu.
void enablePopup(bool propval) @property nothrowSet `enablePopup` property. Params: propval = If true, pressing the right mouse button on the notebook shows a page switching menu.
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 nothrowGet `page` property. Returns: The index of the current page.
void page(int propval) @property nothrowSet `page` property. Params: propval = The index of the current page.
gio.list_model.ListModel pages() @property nothrowGet `pages` property. Returns: A selection model with the pages.
bool scrollable() @property nothrowGet `scrollable` property. Returns: If true, scroll arrows are added if there are too many pages to fit.
void scrollable(bool propval) @property nothrowSet `scrollable` property. Params: propval = If true, scroll arrows are added if there are too many pages to fit.
bool showBorder() @property nothrowGet `showBorder` property. Returns: Whether the border should be shown.
void showBorder(bool propval) @property nothrowSet `showBorder` property. Params: propval = Whether the border should be shown.
bool showTabs() @property nothrowGet `showTabs` property. Returns: Whether tabs should be shown.
void showTabs(bool propval) @property nothrowSet `showTabs` property. Params: propval = Whether tabs should be shown.
gtk.types.PositionType tabPos() @property nothrowGet `tabPos` property. Returns: Which side of the notebook holds the tabs.
void tabPos(gtk.types.PositionType propval) @property nothrowSet `tabPos` property. Params: propval = Which side of the notebook holds the tabs.
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.
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.
gtk.notebook_page.NotebookPage getPage(gtk.widget.Widget child) nothrowReturns the [gtk.notebook_page.NotebookPage] for child.
gio.list_model.ListModel getPages() nothrowReturns a [gio.list_model.ListModel] that contains the pages of the notebook.
bool getScrollable() nothrowReturns whether the tab label area has arrows for scrolling. Returns: true if arrows for scrolling are present
bool getShowBorder() nothrowReturns whether a bevel will be drawn around the notebook pages. Returns: true if the bevel is drawn
bool getShowTabs() nothrowReturns whether the tabs of the notebook are shown. Returns: true if the tabs are shown
bool getTabDetachable(gtk.widget.Widget child) nothrowReturns whether the tab contents can be detached from notebook.
gtk.widget.Widget getTabLabel(gtk.widget.Widget child) nothrowReturns the tab label widget for the page 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 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.
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.
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.
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.
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.
void setActionWidget(gtk.widget.Widget widget, gtk.types.PackType packType) nothrowSets widget as one of the action widgets.
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.
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.
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 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] : gtk.notebook.Notebook))) && Parameters!T.length < 3) 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 [gtk.notebook.Notebook] widget with no pages. Returns: the newly created [gtk.notebook.Notebook]

Fluent builder implementation template for gtk.notebook.Notebook

Methods
T enablePopup(bool propval) nothrowSet `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) nothrowSet `groupName` property. Params: propval = Group name for tab drag and drop. Returns: Builder instance for fluent chaining
T page(int propval) nothrowSet `page` property. Params: propval = The index of the current page. Returns: Builder instance for fluent chaining
T scrollable(bool propval) nothrowSet `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) nothrowSet `showBorder` property. Params: propval = Whether the border should be shown. Returns: Builder instance for fluent chaining
T showTabs(bool propval) nothrowSet `showTabs` property. Params: propval = Whether tabs should be shown. Returns: Builder instance for fluent chaining
T tabPos(gtk.types.PositionType propval) nothrowSet `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
Notebook build() nothrowCreate object from builder. Returns: New object