Package ch.bailu.gtk.gtk
Class Notebook
- All Implemented Interfaces:
PointerInterface
`GtkNotebook` is a container whose children are pages switched
between using tabs.

There are many configuration options for `GtkNotebook`. Among
other things, you can choose on which edge the tabs appear
(see [method@Gtk.Notebook.set_tab_pos]), whether, if there are
too many tabs to fit the notebook should be made bigger or scrolling
arrows added (see [method@Gtk.Notebook.set_scrollable]), and whether
there will be a popup menu allowing the users to switch pages.
(see [method@Gtk.Notebook.popup_enable]).
# 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`:
```xml
<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 [method@Gtk.Notebook.set_show_border]).
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
`GtkNotebook` uses the following roles:
- %GTK_ACCESSIBLE_ROLE_GROUP for the notebook widget
- %GTK_ACCESSIBLE_ROLE_TAB_LIST for the list of tabs
- %GTK_ACCESSIBLE_ROLE_TAB role for each tab
- %GTK_ACCESSIBLE_ROLE_TAB_PANEL for each page
between using tabs.

There are many configuration options for `GtkNotebook`. Among
other things, you can choose on which edge the tabs appear
(see [method@Gtk.Notebook.set_tab_pos]), whether, if there are
too many tabs to fit the notebook should be made bigger or scrolling
arrows added (see [method@Gtk.Notebook.set_scrollable]), and whether
there will be a popup menu allowing the users to switch pages.
(see [method@Gtk.Notebook.popup_enable]).
# 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`:
```xml
<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 [method@Gtk.Notebook.set_show_border]).
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
`GtkNotebook` uses the following roles:
- %GTK_ACCESSIBLE_ROLE_GROUP for the notebook widget
- %GTK_ACCESSIBLE_ROLE_TAB_LIST for the list of tabs
- %GTK_ACCESSIBLE_ROLE_TAB role for each tab
- %GTK_ACCESSIBLE_ROLE_TAB_PANEL for each page
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfaceNested classes/interfaces inherited from class ch.bailu.gtk.gtk.Widget
Widget.OnDestroy, Widget.OnDestroyNotify, Widget.OnDirectionChanged, Widget.OnHide, Widget.OnKeynavFailed, Widget.OnMap, Widget.OnMnemonicActivate, Widget.OnMoveFocus, Widget.OnQueryTooltip, Widget.OnRealize, Widget.OnShow, Widget.OnStateFlagsChanged, Widget.OnTickCallback, Widget.OnUnmap, Widget.OnUnrealizeNested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class ch.bailu.gtk.gtk.Widget
SIGNAL_ON_DESTROY, SIGNAL_ON_DIRECTION_CHANGED, SIGNAL_ON_HIDE, SIGNAL_ON_KEYNAV_FAILED, SIGNAL_ON_MAP, SIGNAL_ON_MNEMONIC_ACTIVATE, SIGNAL_ON_MOVE_FOCUS, SIGNAL_ON_QUERY_TOOLTIP, SIGNAL_ON_REALIZE, SIGNAL_ON_SHOW, SIGNAL_ON_STATE_FLAGS_CHANGED, SIGNAL_ON_UNMAP, SIGNAL_ON_UNREALIZEFields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY -
Constructor Summary
ConstructorsConstructorDescriptionNotebook()Creates a new `GtkNotebook` widget with no pages.Notebook(PointerContainer pointer) -
Method Summary
Modifier and TypeMethodDescriptionintappendPage(Widget child, Widget tab_label) Appends a page to @notebook.intappendPageMenu(Widget child, Widget tab_label, Widget menu_label) Appends a page to @notebook, specifying the widget to use as the
label in the popup menu.Implements interfaceAccessible.Implements interfaceBuildable.Implements interfaceConstraintTarget.voidRemoves the child from the notebook.getActionWidget(int pack_type) Gets one of the action widgets.static ClassHandlerintReturns the page number of the current page.Gets the current group name for @notebook.static intgetMenuLabel(Widget child) Retrieves the menu label widget of the page containing @child.getMenuLabelText(Widget child) Retrieves the text of the menu label for the page containing
@child.intGets the number of pages in a notebook.getNthPage(int page_num) Returns the child widget contained in page number @page_num.Returns the `GtkNotebookPage` for @child.getPages()Returns a `GListModel` that contains the pages of the notebook.static longstatic TypeSystem.TypeSizebooleanReturns whether the tab label area has arrows for scrolling.booleanReturns whether a bevel will be drawn around the notebook pages.booleanReturns whether the tabs of the notebook are shown.booleangetTabDetachable(Widget child) Returns whether the tab contents can be detached from @notebook.getTabLabel(Widget child) Returns the tab label widget for the page @child.getTabLabelText(Widget child) Retrieves the text of the tab label for the page containing
@child.intGets the edge at which the tabs are drawn.booleangetTabReorderable(Widget child) Gets whether the tab can be reordered via drag and drop or not.static longstatic TypeSystem.TypeSizeintinsertPage(Widget child, Widget tab_label, int position) Insert a page into @notebook at the given position.intinsertPageMenu(Widget child, Widget tab_label, Widget menu_label, int position) Insert a page into @notebook at the given position, specifying
the widget to use as the label in the popup menu.voidnextPage()Switches to the next page.Connect to signal "change-current-page".Connect to signal "create-window".onFocusTab(Notebook.OnFocusTab signal) Connect to signal "focus-tab".Connect to signal "move-focus-out".onPageAdded(Notebook.OnPageAdded signal) Connect to signal "page-added".onPageRemoved(Notebook.OnPageRemoved signal) Connect to signal "page-removed".Connect to signal "page-reordered".onReorderTab(Notebook.OnReorderTab signal) Connect to signal "reorder-tab".onSelectPage(Notebook.OnSelectPage signal) Connect to signal "select-page".onSwitchPage(Notebook.OnSwitchPage signal) Connect to signal "switch-page".intFinds the index of the page which contains the given child
widget.voidDisables the popup menu.voidEnables the popup menu.intprependPage(Widget child, Widget tab_label) Prepends a page to @notebook.intprependPageMenu(Widget child, Widget tab_label, Widget menu_label) Prepends a page to @notebook, specifying the widget to use as the
label in the popup menu.voidprevPage()Switches to the previous page.voidremovePage(int page_num) Removes a page from the notebook given its index
in the notebook.voidreorderChild(Widget child, int position) Reorders the page containing @child, so that it appears in position
@position.voidsetActionWidget(Widget widget, int pack_type) Sets @widget as one of the action widgets.voidsetCurrentPage(int page_num) Switches to the page number @page_num.voidsetGroupName(Str group_name) Sets a group name for @notebook.voidsetGroupName(String group_name) Sets a group name for @notebook.voidsetMenuLabel(Widget child, Widget menu_label) Changes the menu label for the page containing @child.voidsetMenuLabelText(Widget child, Str menu_text) Creates a new label and sets it as the menu label of @child.voidsetMenuLabelText(Widget child, String menu_text) Creates a new label and sets it as the menu label of @child.voidsetScrollable(boolean scrollable) Sets whether the tab label area will have arrows for
scrolling if there are too many tabs to fit in the area.voidsetShowBorder(boolean show_border) Sets whether a bevel will be drawn around the notebook pages.voidsetShowTabs(boolean show_tabs) Sets whether to show the tabs for the notebook or not.voidsetTabDetachable(Widget child, boolean detachable) Sets whether the tab can be detached from @notebook to another
notebook or widget.voidsetTabLabel(Widget child, Widget tab_label) Changes the tab label for @child.voidsetTabLabelText(Widget child, Str tab_text) Creates a new label and sets it as the tab label for the page
containing @child.voidsetTabLabelText(Widget child, String tab_text) Creates a new label and sets it as the tab label for the page
containing @child.voidsetTabPos(int pos) Sets the edge at which the tabs are drawn.voidsetTabReorderable(Widget child, boolean reorderable) Sets whether the notebook tab can be reordered
via drag and drop or not.Methods inherited from class ch.bailu.gtk.gtk.Widget
actionSetEnabled, actionSetEnabled, activate, activateAction, activateAction, activateActionVariant, activateActionVariant, activateDefault, addController, addCssClass, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getCanFocus, getCanTarget, getChildVisible, getClipboard, getCssClasses, getCssName, getCursor, getDefaultDirection, getDirection, getDisplay, getFirstChild, getFocusable, getFocusChild, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeCssClass, removeMnemonicLabel, removeTickCallback, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipMarkup, setTooltipText, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, snapshotChild, triggerTooltipQuery, unmap, unparent, unrealize, unsetStateFlagsMethods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnrefMethods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacksMethods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNullMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
SIGNAL_ON_CHANGE_CURRENT_PAGE
- See Also:
-
SIGNAL_ON_CREATE_WINDOW
- See Also:
-
SIGNAL_ON_FOCUS_TAB
- See Also:
-
SIGNAL_ON_MOVE_FOCUS_OUT
- See Also:
-
SIGNAL_ON_PAGE_ADDED
- See Also:
-
SIGNAL_ON_PAGE_REMOVED
- See Also:
-
SIGNAL_ON_PAGE_REORDERED
- See Also:
-
SIGNAL_ON_REORDER_TAB
- See Also:
-
SIGNAL_ON_SELECT_PAGE
- See Also:
-
SIGNAL_ON_SWITCH_PAGE
- See Also:
-
-
Constructor Details
-
Notebook
-
Notebook
public Notebook()Creates a new `GtkNotebook` widget with no pages.
-
-
Method Details
-
getClassHandler
-
appendPage
Appends a page to @notebook.- Parameters:
child- the `GtkWidget` to use as the contents of the pagetab_label- the `GtkWidget` to be used as the label for the page, or %NULL to use the default label, “page N”- Returns:
- the index (starting from 0) of the appended page in the notebook, or -1 if function fails
-
appendPageMenu
public int appendPageMenu(@Nonnull Widget child, @Nullable Widget tab_label, @Nullable Widget menu_label) Appends a page to @notebook, specifying the widget to use as the
label in the popup menu.- Parameters:
child- the `GtkWidget` to use as the contents of the pagetab_label- the `GtkWidget` to be used as the label for the page, or %NULL to use the default label, “page N”menu_label- the widget to use as a label for the page-switch menu, if that is enabled. If %NULL, and @tab_label is a `GtkLabel` or %NULL, then the menu label will be a newly created label with the same text as @tab_label; if @tab_label is not a `GtkLabel`, @menu_label must be specified if the page-switch menu is to be used.- Returns:
- the index (starting from 0) of the appended page in the notebook, or -1 if function fails
-
detachTab
Removes the child from the notebook.
This function is very similar to [method@Gtk.Notebook.remove_page],
but additionally informs the notebook that the removal
is happening as part of a tab DND operation, which should
not be cancelled.- Parameters:
child- a child
-
getActionWidget
Gets one of the action widgets.
See [method@Gtk.Notebook.set_action_widget].- Parameters:
pack_type- pack type of the action widget to receive- Returns:
- The action widget with the given @pack_type or %NULL when this action widget has not been set
-
getCurrentPage
public 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.
-
getGroupName
Gets the current group name for @notebook.- Returns:
- the group name, or %NULL if none is set
-
getMenuLabel
Retrieves the menu label widget of the page containing @child.- Parameters:
child- a widget contained in a page of @notebook- Returns:
- the menu label, or %NULL if the notebook page does not have a menu label other than the default (the tab label).
-
getMenuLabelText
Retrieves the text of the menu label for the page containing
@child.- Parameters:
child- the child widget of a page of the notebook.- Returns:
- the text of the tab label, or %NULL if the widget does not have a menu label other than the default menu label, or the menu label widget is not a `GtkLabel`. The string is owned by the widget and must not be freed.
-
getNPages
public int getNPages()Gets the number of pages in a notebook.- Returns:
- the number of pages in the notebook
-
getNthPage
Returns the child widget contained in page number @page_num.- Parameters:
page_num- the index of a page in the notebook, or -1 to get the last page- Returns:
- the child widget, or %NULL if @page_num is out of bounds
-
getPage
Returns the `GtkNotebookPage` for @child.- Parameters:
child- a child of @notebook- Returns:
- the `GtkNotebookPage` for @child
-
getPages
Returns a `GListModel` that contains the pages of the notebook.
This can be used to keep an up-to-date view. The model also
implements [iface@Gtk.SelectionModel] and can be used to track
and modify the visible page.- Returns:
- a `GListModel` for the notebook's children
-
getScrollable
public boolean getScrollable()Returns whether the tab label area has arrows for scrolling.- Returns:
- %TRUE if arrows for scrolling are present
-
getShowBorder
public boolean getShowBorder()Returns whether a bevel will be drawn around the notebook pages.- Returns:
- %TRUE if the bevel is drawn
-
getShowTabs
public boolean getShowTabs()Returns whether the tabs of the notebook are shown.- Returns:
- %TRUE if the tabs are shown
-
getTabDetachable
Returns whether the tab contents can be detached from @notebook.- Parameters:
child- a child `GtkWidget`- Returns:
- %TRUE if the tab is detachable.
-
getTabLabel
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.- Parameters:
child- the page- Returns:
- the tab label
-
getTabLabelText
Retrieves the text of the tab label for the page containing
@child.- Parameters:
child- a widget contained in a page of @notebook- Returns:
- the text of the tab label, or %NULL if the tab label idget is not a `GtkLabel`. The string is owned by the widget and must not be freed.
-
getTabPos
public int getTabPos()Gets the edge at which the tabs are drawn.- Returns:
- the edge at which the tabs are drawn
-
getTabReorderable
Gets whether the tab can be reordered via drag and drop or not.- Parameters:
child- a child `GtkWidget`- Returns:
- %TRUE if the tab is reorderable.
-
insertPage
Insert a page into @notebook at the given position.- Parameters:
child- the `GtkWidget` to use as the contents of the pagetab_label- the `GtkWidget` to be used as the label for the page, or %NULL to use the default label, “page N”position- the index (starting at 0) at which to insert the page, or -1 to append the page after all other pages- Returns:
- the index (starting from 0) of the inserted page in the notebook, or -1 if function fails
-
insertPageMenu
public int insertPageMenu(@Nonnull Widget child, @Nullable Widget tab_label, @Nullable Widget menu_label, int position) Insert a page into @notebook at the given position, specifying
the widget to use as the label in the popup menu.- Parameters:
child- the `GtkWidget` to use as the contents of the pagetab_label- the `GtkWidget` to be used as the label for the page, or %NULL to use the default label, “page N”menu_label- the widget to use as a label for the page-switch menu, if that is enabled. If %NULL, and @tab_label is a `GtkLabel` or %NULL, then the menu label will be a newly created label with the same text as @tab_label; if @tab_label is not a `GtkLabel`, @menu_label must be specified if the page-switch menu is to be used.position- the index (starting at 0) at which to insert the page, or -1 to append the page after all other pages.- Returns:
- the index (starting from 0) of the inserted page in the notebook
-
nextPage
public void nextPage()Switches to the next page.
Nothing happens if the current page is the last page. -
pageNum
Finds the index of the page which contains the given child
widget.- Parameters:
child- a `GtkWidget`- Returns:
- the index of the page containing @child, or -1 if @child is not in the notebook
-
popupDisable
public void popupDisable()Disables the popup menu. -
popupEnable
public 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. -
prependPage
Prepends a page to @notebook.- Parameters:
child- the `GtkWidget` to use as the contents of the pagetab_label- the `GtkWidget` to be used as the label for the page, or %NULL to use the default label, “page N”- Returns:
- the index (starting from 0) of the prepended page in the notebook, or -1 if function fails
-
prependPageMenu
public int prependPageMenu(@Nonnull Widget child, @Nullable Widget tab_label, @Nullable Widget menu_label) Prepends a page to @notebook, specifying the widget to use as the
label in the popup menu.- Parameters:
child- the `GtkWidget` to use as the contents of the pagetab_label- the `GtkWidget` to be used as the label for the page, or %NULL to use the default label, “page N”menu_label- the widget to use as a label for the page-switch menu, if that is enabled. If %NULL, and @tab_label is a `GtkLabel` or %NULL, then the menu label will be a newly created label with the same text as @tab_label; if @tab_label is not a `GtkLabel`, @menu_label must be specified if the page-switch menu is to be used.- Returns:
- the index (starting from 0) of the prepended page in the notebook, or -1 if function fails
-
prevPage
public void prevPage()Switches to the previous page.
Nothing happens if the current page is the first page. -
removePage
public void removePage(int page_num) Removes a page from the notebook given its index
in the notebook.- Parameters:
page_num- the index of a notebook page, starting from 0. If -1, the last page will be removed.
-
reorderChild
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 of the list.- Parameters:
child- the child to moveposition- the new position, or -1 to move to the end
-
setActionWidget
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 side.- Parameters:
widget- a `GtkWidget`pack_type- pack type of the action widget
-
setCurrentPage
public void setCurrentPage(int page_num) Switches to the page number @page_num.
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.- Parameters:
page_num- index of the page to switch to, starting from 0. If negative, the last page will be used. If greater than the number of pages in the notebook, nothing will be done.
-
setGroupName
Sets a group name for @notebook.
Notebooks with the same name will be able to exchange tabs
via drag and drop. A notebook with a %NULL group name will
not be able to exchange tabs with any other notebook.- Parameters:
group_name- the name of the notebook group, or %NULL to unset it
-
setGroupName
Sets a group name for @notebook.
Notebooks with the same name will be able to exchange tabs
via drag and drop. A notebook with a %NULL group name will
not be able to exchange tabs with any other notebook.- Parameters:
group_name- the name of the notebook group, or %NULL to unset it
-
setMenuLabel
Changes the menu label for the page containing @child.- Parameters:
child- the child widgetmenu_label- the menu label, or %NULL for default
-
setMenuLabelText
Creates a new label and sets it as the menu label of @child.- Parameters:
child- the child widgetmenu_text- the label text
-
setMenuLabelText
Creates a new label and sets it as the menu label of @child.- Parameters:
child- the child widgetmenu_text- the label text
-
setScrollable
public void setScrollable(boolean scrollable) Sets whether the tab label area will have arrows for
scrolling if there are too many tabs to fit in the area.- Parameters:
scrollable- %TRUE if scroll arrows should be added
-
setShowBorder
public void setShowBorder(boolean 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.- Parameters:
show_border- %TRUE if a bevel should be drawn around the notebook
-
setShowTabs
public void setShowTabs(boolean show_tabs) Sets whether to show the tabs for the notebook or not.- Parameters:
show_tabs- %TRUE if the tabs should be shown
-
setTabDetachable
Sets whether the tab can be detached from @notebook to another
notebook or widget.
Note that two notebooks must share a common group identificator
(see [method@Gtk.Notebook.set_group_name]) to allow automatic tabs
interchange between them.
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.
Note that you should use [method@Gtk.Notebook.detach_tab] instead
of [method@Gtk.Notebook.remove_page] if you want to remove the tab
from the source notebook as part of accepting a drop. Otherwise,
the source notebook will think that the dragged tab was removed
from underneath the ongoing drag operation, and will initiate a
drag cancel animation.
```c
static void
on_drag_data_received (GtkWidget *widget,
GdkDrop *drop,
GtkSelectionData *data,
guint time,
gpointer user_data)
{
GtkDrag *drag;
GtkWidget *notebook;
GtkWidget **child;
drag = gtk_drop_get_drag (drop);
notebook = g_object_get_data (drag, "gtk-notebook-drag-origin");
child = (void*) gtk_selection_data_get_data (data);
// process_widget (*child);
gtk_notebook_detach_tab (GTK_NOTEBOOK (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.- Parameters:
child- a child `GtkWidget`detachable- whether the tab is detachable or not
-
setTabLabel
Changes the tab label for @child.
If %NULL is specified for @tab_label, then the page will
have the label “page N”.- Parameters:
child- the pagetab_label- the tab label widget to use, or %NULL for default tab label
-
setTabLabelText
Creates a new label and sets it as the tab label for the page
containing @child.- Parameters:
child- the pagetab_text- the label text
-
setTabLabelText
Creates a new label and sets it as the tab label for the page
containing @child.- Parameters:
child- the pagetab_text- the label text
-
setTabPos
public void setTabPos(int pos) Sets the edge at which the tabs are drawn.- Parameters:
pos- the edge to draw the tabs at
-
setTabReorderable
Sets whether the notebook tab can be reordered
via drag and drop or not.- Parameters:
child- a child `GtkWidget`reorderable- whether the tab is reorderable or not
-
onChangeCurrentPage
Connect to signal "change-current-page".
SeeNotebook.OnChangeCurrentPage.onChangeCurrentPage(int)for signal description.
FieldSIGNAL_ON_CHANGE_CURRENT_PAGEcontains original signal name and can be used as resource reference.- Parameters:
signal- callback function (lambda).- Returns:
SignalHandler. Can be used to disconnect signal and to release callback function.
-
onCreateWindow
Connect to signal "create-window".
SeeNotebook.OnCreateWindow.onCreateWindow(ch.bailu.gtk.gtk.Widget)for signal description.
FieldSIGNAL_ON_CREATE_WINDOWcontains original signal name and can be used as resource reference.- Parameters:
signal- callback function (lambda).- Returns:
SignalHandler. Can be used to disconnect signal and to release callback function.
-
onFocusTab
Connect to signal "focus-tab".
SeeNotebook.OnFocusTab.onFocusTab(int)for signal description.
FieldSIGNAL_ON_FOCUS_TABcontains original signal name and can be used as resource reference.- Parameters:
signal- callback function (lambda).- Returns:
SignalHandler. Can be used to disconnect signal and to release callback function.
-
onMoveFocusOut
Connect to signal "move-focus-out".
SeeNotebook.OnMoveFocusOut.onMoveFocusOut(int)for signal description.
FieldSIGNAL_ON_MOVE_FOCUS_OUTcontains original signal name and can be used as resource reference.- Parameters:
signal- callback function (lambda).- Returns:
SignalHandler. Can be used to disconnect signal and to release callback function.
-
onPageAdded
Connect to signal "page-added".
SeeNotebook.OnPageAdded.onPageAdded(ch.bailu.gtk.gtk.Widget, int)for signal description.
FieldSIGNAL_ON_PAGE_ADDEDcontains original signal name and can be used as resource reference.- Parameters:
signal- callback function (lambda).- Returns:
SignalHandler. Can be used to disconnect signal and to release callback function.
-
onPageRemoved
Connect to signal "page-removed".
SeeNotebook.OnPageRemoved.onPageRemoved(ch.bailu.gtk.gtk.Widget, int)for signal description.
FieldSIGNAL_ON_PAGE_REMOVEDcontains original signal name and can be used as resource reference.- Parameters:
signal- callback function (lambda).- Returns:
SignalHandler. Can be used to disconnect signal and to release callback function.
-
onPageReordered
Connect to signal "page-reordered".
SeeNotebook.OnPageReordered.onPageReordered(ch.bailu.gtk.gtk.Widget, int)for signal description.
FieldSIGNAL_ON_PAGE_REORDEREDcontains original signal name and can be used as resource reference.- Parameters:
signal- callback function (lambda).- Returns:
SignalHandler. Can be used to disconnect signal and to release callback function.
-
onReorderTab
Connect to signal "reorder-tab".
SeeNotebook.OnReorderTab.onReorderTab(int, boolean)for signal description.
FieldSIGNAL_ON_REORDER_TABcontains original signal name and can be used as resource reference.- Parameters:
signal- callback function (lambda).- Returns:
SignalHandler. Can be used to disconnect signal and to release callback function.
-
onSelectPage
Connect to signal "select-page".
SeeNotebook.OnSelectPage.onSelectPage(boolean)for signal description.
FieldSIGNAL_ON_SELECT_PAGEcontains original signal name and can be used as resource reference.- Parameters:
signal- callback function (lambda).- Returns:
SignalHandler. Can be used to disconnect signal and to release callback function.
-
onSwitchPage
Connect to signal "switch-page".
SeeNotebook.OnSwitchPage.onSwitchPage(ch.bailu.gtk.gtk.Widget, int)for signal description.
FieldSIGNAL_ON_SWITCH_PAGEcontains original signal name and can be used as resource reference.- Parameters:
signal- callback function (lambda).- Returns:
SignalHandler. Can be used to disconnect signal and to release callback function.
-
asAccessible
Implements interfaceAccessible. Call this to get access to interface functions.- Overrides:
asAccessiblein classWidget- Returns:
Accessible
-
asBuildable
Implements interfaceBuildable. Call this to get access to interface functions.- Overrides:
asBuildablein classWidget- Returns:
Buildable
-
asConstraintTarget
Implements interfaceConstraintTarget. Call this to get access to interface functions.- Overrides:
asConstraintTargetin classWidget- Returns:
ConstraintTarget
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-