Class Notebook
- All Implemented Interfaces:
Proxy
,Accessible
,Buildable
,ConstraintTarget
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 setTabPos(org.gnome.gtk.PositionType)
), whether, if there are
too many tabs to fit the notebook should be made bigger or scrolling
arrows added (see setScrollable(boolean)
), and whether
there will be a popup menu allowing the users to switch pages.
(see popupEnable()
).
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>
Shortcuts and Gestures
GtkNotebook
supports the following keyboard shortcuts:
Shift
+F10
orMenu
opens the context menu.Home
moves the focus to the first tab.End
moves the focus to the last tab.
Additionally, the following signals have default keybindings:
Gtk.Notebook::change-current-page
Gtk.Notebook::focus-tab
Gtk.Notebook::move-focus-out
Gtk.Notebook::reorder-tab
Gtk.Notebook::select-page
Tabs support drag-and-drop between notebooks sharing the same group-name
,
or to new windows by handling the ::create-window
signal.
Actions
GtkNotebook
defines a set of built-in actions:
menu.popup
opens the tabs context menu.
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 setShowBorder(boolean)
).
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:
AccessibleRole.GROUP
for the notebook widgetAccessibleRole.TAB_LIST
for the list of tabsAccessibleRole.TAB
role for each tabAccessibleRole.TAB_PANEL
for each page
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Notebook.Builder<B extends Notebook.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theChangeCurrentPageCallback
callback.static interface
Functional interface declaration of theCreateWindowCallback
callback.static interface
Functional interface declaration of theFocusTabCallback
callback.static interface
Functional interface declaration of theMoveFocusOutCallback
callback.static interface
Functional interface declaration of thePageAddedCallback
callback.static interface
Functional interface declaration of thePageRemovedCallback
callback.static interface
Functional interface declaration of thePageReorderedCallback
callback.static interface
Functional interface declaration of theReorderTabCallback
callback.static interface
Functional interface declaration of theSelectPageCallback
callback.static interface
Functional interface declaration of theSwitchPageCallback
callback.Nested classes/interfaces inherited from class org.gnome.gtk.Widget
Widget.DestroyCallback, Widget.DirectionChangedCallback, Widget.HideCallback, Widget.KeynavFailedCallback, Widget.MapCallback, Widget.MnemonicActivateCallback, Widget.MoveFocusCallback, Widget.QueryTooltipCallback, Widget.RealizeCallback, Widget.ShowCallback, Widget.StateFlagsChangedCallback, Widget.UnmapCallback, Widget.UnrealizeCallback, Widget.WidgetClass, Widget.WidgetImpl
Nested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClass
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gtk.Accessible
Accessible.AccessibleImpl, Accessible.AccessibleInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.BuildableIface, Buildable.BuildableImpl
Nested classes/interfaces inherited from interface org.gnome.gtk.ConstraintTarget
ConstraintTarget.ConstraintTargetImpl, ConstraintTarget.ConstraintTargetInterface
-
Constructor Summary
ConstructorDescriptionNotebook()
Creates a newGtkNotebook
widget with no pages.Notebook
(MemorySegment address) Create a Notebook proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionint
appendPage
(Widget child, @Nullable Widget tabLabel) Appends a page to this Notebook.int
appendPageMenu
(Widget child, @Nullable Widget tabLabel, @Nullable Widget menuLabel) Appends a page to this Notebook, specifying the widget to use as the label in the popup menu.protected Notebook
asParent()
Returns this instance as if it were its parent type.static Notebook.Builder
<? extends Notebook.Builder> builder()
ANotebook.Builder
object constructs aNotebook
with the specified properties.void
Removes the child from the notebook.boolean
emitChangeCurrentPage
(int page) Emits the "change-current-page" signal.emitCreateWindow
(Widget page) Emits the "create-window" signal.boolean
emitFocusTab
(NotebookTab tab) Emits the "focus-tab" signal.void
emitMoveFocusOut
(DirectionType direction) Emits the "move-focus-out" signal.void
emitPageAdded
(Widget child, int pageNum) Emits the "page-added" signal.void
emitPageRemoved
(Widget child, int pageNum) Emits the "page-removed" signal.void
emitPageReordered
(Widget child, int pageNum) Emits the "page-reordered" signal.boolean
emitReorderTab
(DirectionType direction, boolean moveToLast) Emits the "reorder-tab" signal.boolean
emitSelectPage
(boolean moveFocus) Emits the "select-page" signal.void
emitSwitchPage
(Widget page, int pageNum) Emits the "switch-page" signal.getActionWidget
(PackType packType) Gets one of the action widgets.int
Returns the page number of the current page.Gets the current group name for this Notebook.getMenuLabel
(Widget child) Retrieves the menu label widget of the page containingchild
.getMenuLabelText
(Widget child) Retrieves the text of the menu label for the page containingchild
.int
Gets the number of pages in a notebook.getNthPage
(int pageNum) Returns the child widget contained in page numberpageNum
.Returns theGtkNotebookPage
forchild
.getPages()
Returns aGListModel
that contains the pages of the notebook.boolean
Returns whether the tab label area has arrows for scrolling.boolean
Returns whether a bevel will be drawn around the notebook pages.boolean
Returns whether the tabs of the notebook are shown.boolean
getTabDetachable
(Widget child) Returns whether the tab contents can be detached from this Notebook.getTabLabel
(Widget child) Returns the tab label widget for the pagechild
.getTabLabelText
(Widget child) Retrieves the text of the tab label for the page containingchild
.Gets the edge at which the tabs are drawn.boolean
getTabReorderable
(Widget child) Gets whether the tab can be reordered via drag and drop or not.static Type
getType()
Get the GType of the Notebook classint
insertPage
(Widget child, @Nullable Widget tabLabel, int position) Insert a page into this Notebook at the given position.int
insertPageMenu
(Widget child, @Nullable Widget tabLabel, @Nullable Widget menuLabel, int position) Insert a page into this Notebook at the given position, specifying the widget to use as the label in the popup menu.void
nextPage()
Switches to the next page.Emitted when the current page should be changed.The ::create-window signal is emitted when a detachable tab is dropped on the root window.onFocusTab
(Notebook.FocusTabCallback handler) Emitted when a tab should be focused.Emitted when focus was moved out.onPageAdded
(Notebook.PageAddedCallback handler) the ::page-added signal is emitted in the notebook right after a page is added to the notebook.the ::page-removed signal is emitted in the notebook right after a page is removed from the notebook.the ::page-reordered signal is emitted in the notebook right after a page has been reordered.onReorderTab
(Notebook.ReorderTabCallback handler) Emitted when the tab should be reordered.onSelectPage
(Notebook.SelectPageCallback handler) Emitted when a page should be selected.onSwitchPage
(Notebook.SwitchPageCallback handler) Emitted when the user or a function changes the current page.int
Finds the index of the page which contains the given child widget.void
Disables the popup menu.void
Enables the popup menu.int
prependPage
(Widget child, @Nullable Widget tabLabel) Prepends a page to this Notebook.int
prependPageMenu
(Widget child, @Nullable Widget tabLabel, @Nullable Widget menuLabel) Prepends a page to this 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
(Widget child, int position) Reorders the page containingchild
, so that it appears in positionposition
.void
setActionWidget
(Widget widget, PackType packType) Setswidget
as one of the action widgets.void
setCurrentPage
(int pageNum) Switches to the page numberpageNum
.void
setGroupName
(@Nullable String groupName) Sets a group name for this Notebook.void
setMenuLabel
(Widget child, @Nullable Widget menuLabel) Changes the menu label for the page containingchild
.void
setMenuLabelText
(Widget child, String menuText) Creates a new label and sets it as the menu label ofchild
.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.void
setShowBorder
(boolean showBorder) Sets whether a bevel will be drawn around the notebook pages.void
setShowTabs
(boolean showTabs) Sets whether to show the tabs for the notebook or not.void
setTabDetachable
(Widget child, boolean detachable) Sets whether the tab can be detached from this Notebook to another notebook or widget.void
setTabLabel
(Widget child, @Nullable Widget tabLabel) Changes the tab label forchild
.void
setTabLabelText
(Widget child, String tabText) Creates a new label and sets it as the tab label for the page containingchild
.void
setTabPos
(PositionType pos) Sets the edge at which the tabs are drawn.void
setTabReorderable
(Widget child, boolean reorderable) Sets whether the notebook tab can be reordered via drag and drop or not.Methods inherited from class org.gnome.gtk.Widget
actionSetEnabled, activateActionIfExists, activateDefault, activateWidget, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, cssChanged, directionChanged, disposeTemplate, dragCheckThreshold, emitDestroy, emitDirectionChanged, emitHide, emitKeynavFailed, emitMap, emitMnemonicActivate, emitMoveFocus, emitQueryTooltip, emitRealize, emitShow, emitStateFlagsChanged, emitUnmap, emitUnrealize, errorBell, focus, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBaseline, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, 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, getMemoryLayout, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, moveFocus, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, pick, queryTooltip, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, root, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, sizeAllocate, snapshot, snapshotChild, stateFlagsChanged, systemSettingChanged, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unroot, unsetStateFlags, unsetStateFlags
Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.gnome.gtk.Accessible
announce, getAccessibleParent, getAccessibleRole, getAtContext, getBounds, getFirstAccessibleChild, getNextAccessibleSibling, getPlatformState, resetProperty, resetRelation, resetState, setAccessibleParent, updateNextAccessibleSibling, updateProperty, updateRelation, updateState
Methods inherited from interface org.gnome.gtk.Buildable
getBuildableId
-
Constructor Details
-
Notebook
Create a Notebook proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Notebook
public Notebook()Creates a newGtkNotebook
widget with no pages.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
appendPage
Appends a page to this Notebook.- Parameters:
child
- theGtkWidget
to use as the contents of the pagetabLabel
- theGtkWidget
to be used as the label for the page, ornull
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(Widget child, @Nullable @Nullable Widget tabLabel, @Nullable @Nullable Widget menuLabel) Appends a page to this Notebook, specifying the widget to use as the label in the popup menu.- Parameters:
child
- theGtkWidget
to use as the contents of the pagetabLabel
- theGtkWidget
to be used as the label for the page, ornull
to use the default label, “page N”menuLabel
- the widget to use as a label for the page-switch menu, if that is enabled. Ifnull
, andtabLabel
is aGtkLabel
ornull
, then the menu label will be a newly created label with the same text astabLabel
; iftabLabel
is not aGtkLabel
,menuLabel
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
removePage(int)
, 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
setActionWidget(org.gnome.gtk.Widget, org.gnome.gtk.PackType)
.- Parameters:
packType
- pack type of the action widget to receive- Returns:
- The action widget
with the given
packType
ornull
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 this Notebook.- Returns:
- the group name,
or
null
if none is set
-
getMenuLabel
-
getMenuLabelText
Retrieves the text of the menu label for the page containingchild
.- 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 aGtkLabel
. 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 numberpageNum
.- Parameters:
pageNum
- the index of a page in the notebook, or -1 to get the last page- Returns:
- the child widget, or
null
ifpageNum
is out of bounds
-
getPage
Returns theGtkNotebookPage
forchild
.- Parameters:
child
- a child of this Notebook- Returns:
- the
GtkNotebookPage
forchild
-
getPages
Returns aGListModel
that contains the pages of the notebook.This can be used to keep an up-to-date view. The model also implements
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 this Notebook.- Parameters:
child
- a childGtkWidget
- Returns:
true
if the tab is detachable.
-
getTabLabel
-
getTabLabelText
Retrieves the text of the tab label for the page containingchild
.- Parameters:
child
- a widget contained in a page of this Notebook- Returns:
- the text of the tab label, or
null
if the tab label widget is not aGtkLabel
. The string is owned by the widget and must not be freed.
-
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 childGtkWidget
- Returns:
true
if the tab is reorderable.
-
insertPage
Insert a page into this Notebook at the given position.- Parameters:
child
- theGtkWidget
to use as the contents of the pagetabLabel
- theGtkWidget
to be used as the label for the page, ornull
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(Widget child, @Nullable @Nullable Widget tabLabel, @Nullable @Nullable Widget menuLabel, int position) Insert a page into this Notebook at the given position, specifying the widget to use as the label in the popup menu.- Parameters:
child
- theGtkWidget
to use as the contents of the pagetabLabel
- theGtkWidget
to be used as the label for the page, ornull
to use the default label, “page N”menuLabel
- the widget to use as a label for the page-switch menu, if that is enabled. Ifnull
, andtabLabel
is aGtkLabel
ornull
, then the menu label will be a newly created label with the same text astabLabel
; iftabLabel
is not aGtkLabel
,menuLabel
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
- aGtkWidget
- Returns:
- the index of the page containing
child
, or -1 ifchild
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 this Notebook.- Parameters:
child
- theGtkWidget
to use as the contents of the pagetabLabel
- theGtkWidget
to be used as the label for the page, ornull
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(Widget child, @Nullable @Nullable Widget tabLabel, @Nullable @Nullable Widget menuLabel) Prepends a page to this Notebook, specifying the widget to use as the label in the popup menu.- Parameters:
child
- theGtkWidget
to use as the contents of the pagetabLabel
- theGtkWidget
to be used as the label for the page, ornull
to use the default label, “page N”menuLabel
- the widget to use as a label for the page-switch menu, if that is enabled. Ifnull
, andtabLabel
is aGtkLabel
ornull
, then the menu label will be a newly created label with the same text astabLabel
; iftabLabel
is not aGtkLabel
,menuLabel
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 pageNum) Removes a page from the notebook given its index in the notebook.- Parameters:
pageNum
- the index of a notebook page, starting from 0. If -1, the last page will be removed.
-
reorderChild
Reorders the page containingchild
, so that it appears in positionposition
.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
Setswidget
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
- aGtkWidget
packType
- pack type of the action widget
-
setCurrentPage
public void setCurrentPage(int pageNum) Switches to the page numberpageNum
.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:
pageNum
- 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 this 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:
groupName
- the name of the notebook group, ornull
to unset it
-
setMenuLabel
-
setMenuLabelText
-
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 showBorder) Sets whether a bevel will be drawn around the notebook pages.This only has a visual effect when the tabs are not shown.
- Parameters:
showBorder
-true
if a bevel should be drawn around the notebook
-
setShowTabs
public void setShowTabs(boolean showTabs) Sets whether to show the tabs for the notebook or not.- Parameters:
showTabs
-true
if the tabs should be shown
-
setTabDetachable
Sets whether the tab can be detached from this Notebook to another notebook or widget.Note that two notebooks must share a common group identifier (see
setGroupName(java.lang.String)
) 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 by adding to it a
DropTarget
controller that accepts the GTypeGTK_TYPE_NOTEBOOK_PAGE
. The:value
of said drop target will be preloaded with aNotebookPage
object that corresponds to the dropped tab, so you can process the value via::accept
or::drop
signals.Note that you should use
detachTab(org.gnome.gtk.Widget)
instead ofremovePage(int)
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.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 childGtkWidget
detachable
- whether the tab is detachable or not
-
setTabLabel
-
setTabLabelText
-
setTabPos
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 childGtkWidget
reorderable
- whether the tab is reorderable or not
-
onChangeCurrentPage
public SignalConnection<Notebook.ChangeCurrentPageCallback> onChangeCurrentPage(Notebook.ChangeCurrentPageCallback handler) Emitted when the current page should be changed.The default bindings for this signal are
Ctrl
+Alt
+PgUp
,Ctrl
+Alt
+PgDn
,Ctrl
+PgUp
andCtrl
+PgDn
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitChangeCurrentPage
public boolean emitChangeCurrentPage(int page) Emits the "change-current-page" signal. SeeonChangeCurrentPage(org.gnome.gtk.Notebook.ChangeCurrentPageCallback)
. -
onCreateWindow
public SignalConnection<Notebook.CreateWindowCallback> onCreateWindow(Notebook.CreateWindowCallback handler) The ::create-window signal is emitted when a detachable tab is dropped on the root window.A handler for this signal can create a window containing a notebook where the tab will be attached. It is also responsible for moving/resizing the window and adding the necessary properties to the notebook (e.g. the
GtkNotebook
:group-name ).- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitCreateWindow
Emits the "create-window" signal. SeeonCreateWindow(org.gnome.gtk.Notebook.CreateWindowCallback)
. -
onFocusTab
Emitted when a tab should be focused.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitFocusTab
Emits the "focus-tab" signal. SeeonFocusTab(org.gnome.gtk.Notebook.FocusTabCallback)
. -
onMoveFocusOut
public SignalConnection<Notebook.MoveFocusOutCallback> onMoveFocusOut(Notebook.MoveFocusOutCallback handler) Emitted when focus was moved out.The default bindings for this signal are
Ctrl
+Tab
,Ctrl
+Shift
+Tab
,Ctrl
+←
,Ctrl
+→
,Ctrl
+↑
andCtrl
+↓
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitMoveFocusOut
Emits the "move-focus-out" signal. SeeonMoveFocusOut(org.gnome.gtk.Notebook.MoveFocusOutCallback)
. -
onPageAdded
the ::page-added signal is emitted in the notebook right after a page is added to the notebook.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitPageAdded
Emits the "page-added" signal. SeeonPageAdded(org.gnome.gtk.Notebook.PageAddedCallback)
. -
onPageRemoved
public SignalConnection<Notebook.PageRemovedCallback> onPageRemoved(Notebook.PageRemovedCallback handler) the ::page-removed signal is emitted in the notebook right after a page is removed from the notebook.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitPageRemoved
Emits the "page-removed" signal. SeeonPageRemoved(org.gnome.gtk.Notebook.PageRemovedCallback)
. -
onPageReordered
public SignalConnection<Notebook.PageReorderedCallback> onPageReordered(Notebook.PageReorderedCallback handler) the ::page-reordered signal is emitted in the notebook right after a page has been reordered.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitPageReordered
Emits the "page-reordered" signal. SeeonPageReordered(org.gnome.gtk.Notebook.PageReorderedCallback)
. -
onReorderTab
public SignalConnection<Notebook.ReorderTabCallback> onReorderTab(Notebook.ReorderTabCallback handler) Emitted when the tab should be reordered.The default bindings for this signal are
Alt
+Home
,Alt
+End
,Alt
+PgUp
,Alt
+PgDn
,Alt
+←
,Alt
+→
,Alt
+↑
andAlt
+↓
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitReorderTab
Emits the "reorder-tab" signal. SeeonReorderTab(org.gnome.gtk.Notebook.ReorderTabCallback)
. -
onSelectPage
public SignalConnection<Notebook.SelectPageCallback> onSelectPage(Notebook.SelectPageCallback handler) Emitted when a page should be selected.The default binding for this signal is
␣
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitSelectPage
public boolean emitSelectPage(boolean moveFocus) Emits the "select-page" signal. SeeonSelectPage(org.gnome.gtk.Notebook.SelectPageCallback)
. -
onSwitchPage
public SignalConnection<Notebook.SwitchPageCallback> onSwitchPage(Notebook.SwitchPageCallback handler) Emitted when the user or a function changes the current page.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitSwitchPage
Emits the "switch-page" signal. SeeonSwitchPage(org.gnome.gtk.Notebook.SwitchPageCallback)
. -
builder
ANotebook.Builder
object constructs aNotebook
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withNotebook.Builder.build()
.
-