Package ch.bailu.gtk.gtk
Class Stack
- All Implemented Interfaces:
PointerInterface
`GtkStack` is a container which only shows one of its children
at a time.
In contrast to `GtkNotebook`, `GtkStack` does not provide a means
for users to change the visible child. Instead, a separate widget
such as [class@Gtk.StackSwitcher] or [class@Gtk.StackSidebar] can
be used with `GtkStack` to provide this functionality.
Transitions between pages can be animated as slides or fades. This
can be controlled with [method@Gtk.Stack.set_transition_type].
These animations respect the [property@Gtk.Settings:gtk-enable-animations]
setting.
`GtkStack` maintains a [class@Gtk.StackPage] object for each added
child, which holds additional per-child properties. You
obtain the `GtkStackPage` for a child with [method@Gtk.Stack.get_page]
and you can obtain a `GtkSelectionModel` containing all the pages
with [method@Gtk.Stack.get_pages].
# GtkStack as GtkBuildable
To set child-specific properties in a .ui file, create `GtkStackPage`
objects explicitly, and set the child widget as a property on it:
```xml
<object class="GtkStack" id="stack">
<child>
<object class="GtkStackPage">
<property name="name">page1</property>
<property name="title">In the beginning…</property>
<property name="child">
<object class="GtkLabel">
<property name="label">It was dark</property>
</object>
</property>
</object>
</child>
```
# CSS nodes
`GtkStack` has a single CSS node named stack.
# Accessibility
`GtkStack` uses the %GTK_ACCESSIBLE_ROLE_TAB_PANEL for the stack
pages, which are the accessible parent objects of the child widgets.
at a time.
In contrast to `GtkNotebook`, `GtkStack` does not provide a means
for users to change the visible child. Instead, a separate widget
such as [class@Gtk.StackSwitcher] or [class@Gtk.StackSidebar] can
be used with `GtkStack` to provide this functionality.
Transitions between pages can be animated as slides or fades. This
can be controlled with [method@Gtk.Stack.set_transition_type].
These animations respect the [property@Gtk.Settings:gtk-enable-animations]
setting.
`GtkStack` maintains a [class@Gtk.StackPage] object for each added
child, which holds additional per-child properties. You
obtain the `GtkStackPage` for a child with [method@Gtk.Stack.get_page]
and you can obtain a `GtkSelectionModel` containing all the pages
with [method@Gtk.Stack.get_pages].
# GtkStack as GtkBuildable
To set child-specific properties in a .ui file, create `GtkStackPage`
objects explicitly, and set the child widget as a property on it:
```xml
<object class="GtkStack" id="stack">
<child>
<object class="GtkStackPage">
<property name="name">page1</property>
<property name="title">In the beginning…</property>
<property name="child">
<object class="GtkLabel">
<property name="label">It was dark</property>
</object>
</property>
</object>
</child>
```
# CSS nodes
`GtkStack` has a single CSS node named stack.
# Accessibility
`GtkStack` uses the %GTK_ACCESSIBLE_ROLE_TAB_PANEL for the stack
pages, which are the accessible parent objects of the child widgets.
-
Nested Class Summary
Nested 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.OnUnrealize
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields 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_UNREALIZE
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds a child to @stack.Adds a child to @stack.Adds a child to @stack.Adds a child to @stack.Adds a child to @stack.Implements interfaceAccessible
.Implements interfaceBuildable
.Implements interfaceConstraintTarget
.getChildByName
(Str name) Finds the child with the name given as the argument.getChildByName
(String name) Finds the child with the name given as the argument.static ClassHandler
boolean
Gets whether @stack is horizontally homogeneous.static int
boolean
Returns whether the `GtkStack` is set up to interpolate between
the sizes of children on page switch.Returns the `GtkStackPage` object for @child.getPages()
Returns a `GListModel` that contains the pages of the stack.static long
static TypeSystem.TypeSize
int
Returns the amount of time (in milliseconds) that
transitions between pages in @stack will take.boolean
Returns whether the @stack is currently in a transition from one page to
another.int
Gets the type of animation that will be used
for transitions between pages in @stack.static long
static TypeSystem.TypeSize
boolean
Gets whether @stack is vertically homogeneous.Gets the currently visible child of @stack.Returns the name of the currently visible child of @stack.void
Removes a child widget from @stack.void
setHhomogeneous
(boolean hhomogeneous) Sets the `GtkStack` to be horizontally homogeneous or not.void
setInterpolateSize
(boolean interpolate_size) Sets whether or not @stack will interpolate its size when
changing the visible child.void
setTransitionDuration
(int duration) Sets the duration that transitions between pages in @stack
will take.void
setTransitionType
(int transition) Sets the type of animation that will be used for
transitions between pages in @stack.void
setVhomogeneous
(boolean vhomogeneous) Sets the `GtkStack` to be vertically homogeneous or not.void
setVisibleChild
(Widget child) Makes @child the visible child of @stack.void
setVisibleChildFull
(Str name, int transition) Makes the child with the given name visible.void
setVisibleChildFull
(String name, int transition) Makes the child with the given name visible.void
setVisibleChildName
(Str name) Makes the child with the given name visible.void
setVisibleChildName
(String name) Makes the child with the given name visible.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, unsetStateFlags
Methods 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, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
Stack
-
Stack
public Stack()Creates a new `GtkStack`.
-
-
Method Details
-
getClassHandler
-
addChild
Adds a child to @stack.- Parameters:
child
- the widget to add- Returns:
- the `GtkStackPage` for @child
-
addNamed
Adds a child to @stack.
The child is identified by the @name.- Parameters:
child
- the widget to addname
- the name for @child- Returns:
- the `GtkStackPage` for @child
-
addNamed
Adds a child to @stack.
The child is identified by the @name.- Parameters:
child
- the widget to addname
- the name for @child- Returns:
- the `GtkStackPage` for @child
-
addTitled
Adds a child to @stack.
The child is identified by the @name. The @title
will be used by `GtkStackSwitcher` to represent
@child in a tab bar, so it should be short.- Parameters:
child
- the widget to addname
- the name for @childtitle
- a human-readable title for @child- Returns:
- the `GtkStackPage` for @child
-
addTitled
Adds a child to @stack.
The child is identified by the @name. The @title
will be used by `GtkStackSwitcher` to represent
@child in a tab bar, so it should be short.- Parameters:
child
- the widget to addname
- the name for @childtitle
- a human-readable title for @child- Returns:
- the `GtkStackPage` for @child
-
getChildByName
Finds the child with the name given as the argument.
Returns %NULL if there is no child with this name.- Parameters:
name
- the name of the child to find- Returns:
- the requested child of the `GtkStack`
-
getChildByName
Finds the child with the name given as the argument.
Returns %NULL if there is no child with this name.- Parameters:
name
- the name of the child to find- Returns:
- the requested child of the `GtkStack`
-
getHhomogeneous
public boolean getHhomogeneous()Gets whether @stack is horizontally homogeneous.- Returns:
- whether @stack is horizontally homogeneous.
-
getInterpolateSize
public boolean getInterpolateSize()Returns whether the `GtkStack` is set up to interpolate between
the sizes of children on page switch.- Returns:
- %TRUE if child sizes are interpolated
-
getPage
Returns the `GtkStackPage` object for @child.- Parameters:
child
- a child of @stack- Returns:
- the `GtkStackPage` for @child
-
getPages
Returns a `GListModel` that contains the pages of the stack.
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 `GtkSelectionModel` for the stack's children
-
getTransitionDuration
public int getTransitionDuration()Returns the amount of time (in milliseconds) that
transitions between pages in @stack will take.- Returns:
- the transition duration
-
getTransitionRunning
public boolean getTransitionRunning()Returns whether the @stack is currently in a transition from one page to
another.- Returns:
- %TRUE if the transition is currently running, %FALSE otherwise.
-
getTransitionType
public int getTransitionType()Gets the type of animation that will be used
for transitions between pages in @stack.- Returns:
- the current transition type of @stack
-
getVhomogeneous
public boolean getVhomogeneous()Gets whether @stack is vertically homogeneous.- Returns:
- whether @stack is vertically homogeneous.
-
getVisibleChild
Gets the currently visible child of @stack.
Returns %NULL if there are no visible children.- Returns:
- the visible child of the `GtkStack`
-
getVisibleChildName
Returns the name of the currently visible child of @stack.
Returns %NULL if there is no visible child.- Returns:
- the name of the visible child of the `GtkStack`
-
remove
Removes a child widget from @stack.- Parameters:
child
- the child to remove
-
setHhomogeneous
public void setHhomogeneous(boolean hhomogeneous) Sets the `GtkStack` to be horizontally homogeneous or not.
If it is homogeneous, the `GtkStack` will request the same
width for all its children. If it isn't, the stack
may change width when a different child becomes visible.- Parameters:
hhomogeneous
- %TRUE to make @stack horizontally homogeneous
-
setInterpolateSize
public void setInterpolateSize(boolean interpolate_size) Sets whether or not @stack will interpolate its size when
changing the visible child.
If the [property@Gtk.Stack:interpolate-size] property is set
to %TRUE, @stack will interpolate its size between the current
one and the one it'll take after changing the visible child,
according to the set transition duration.- Parameters:
interpolate_size
- the new value
-
setTransitionDuration
public void setTransitionDuration(int duration) Sets the duration that transitions between pages in @stack
will take.- Parameters:
duration
- the new duration, in milliseconds
-
setTransitionType
public void setTransitionType(int transition) Sets the type of animation that will be used for
transitions between pages in @stack.
Available types include various kinds of fades and slides.
The transition type can be changed without problems
at runtime, so it is possible to change the animation
based on the page that is about to become current.- Parameters:
transition
- the new transition type
-
setVhomogeneous
public void setVhomogeneous(boolean vhomogeneous) Sets the `GtkStack` to be vertically homogeneous or not.
If it is homogeneous, the `GtkStack` will request the same
height for all its children. If it isn't, the stack
may change height when a different child becomes visible.- Parameters:
vhomogeneous
- %TRUE to make @stack vertically homogeneous
-
setVisibleChild
Makes @child the visible child of @stack.
If @child is different from the currently visible child,
the transition between the two will be animated with the
current transition type of @stack.
Note that the @child widget has to be visible itself
(see [method@Gtk.Widget.show]) in order to become the visible
child of @stack.- Parameters:
child
- a child of @stack
-
setVisibleChildFull
Makes the child with the given name visible.
Note that the child widget has to be visible itself
(see [method@Gtk.Widget.show]) in order to become the visible
child of @stack.- Parameters:
name
- the name of the child to make visibletransition
- the transition type to use
-
setVisibleChildFull
Makes the child with the given name visible.
Note that the child widget has to be visible itself
(see [method@Gtk.Widget.show]) in order to become the visible
child of @stack.- Parameters:
name
- the name of the child to make visibletransition
- the transition type to use
-
setVisibleChildName
Makes the child with the given name visible.
If @child is different from the currently visible child,
the transition between the two will be animated with the
current transition type of @stack.
Note that the child widget has to be visible itself
(see [method@Gtk.Widget.show]) in order to become the visible
child of @stack.- Parameters:
name
- the name of the child to make visible
-
setVisibleChildName
Makes the child with the given name visible.
If @child is different from the currently visible child,
the transition between the two will be animated with the
current transition type of @stack.
Note that the child widget has to be visible itself
(see [method@Gtk.Widget.show]) in order to become the visible
child of @stack.- Parameters:
name
- the name of the child to make visible
-
asAccessible
Implements interfaceAccessible
. Call this to get access to interface functions.- Overrides:
asAccessible
in classWidget
- Returns:
Accessible
-
asBuildable
Implements interfaceBuildable
. Call this to get access to interface functions.- Overrides:
asBuildable
in classWidget
- Returns:
Buildable
-
asConstraintTarget
Implements interfaceConstraintTarget
. Call this to get access to interface functions.- Overrides:
asConstraintTarget
in classWidget
- Returns:
ConstraintTarget
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-