gtk.stack

Module for [Stack] class

Types 3

[gtk.stack.Stack] is a container which only shows one of its children at a time.

In contrast to [gtk.notebook.Notebook], [gtk.stack.Stack] does not provide a means for users to change the visible child. Instead, a separate widget such as [gtk.stack_switcher.StackSwitcher] or [gtk.stack_sidebar.StackSidebar] can be used with [gtk.stack.Stack] to provide this functionality.

Transitions between pages can be animated as slides or fades. This can be controlled with [gtk.stack.Stack.setTransitionType]. These animations respect the property@Gtk.Settings:gtk-enable-animations setting.

[gtk.stack.Stack] maintains a [gtk.stack_page.StackPage] object for each added child, which holds additional per-child properties. You obtain the [gtk.stack_page.StackPage] for a child with [gtk.stack.Stack.getPage] and you can obtain a [gtk.selection_model.SelectionModel] containing all the pages with [gtk.stack.Stack.getPages].

GtkStack as GtkBuildable

To set child-specific properties in a .ui file, create [gtk.stack_page.StackPage] objects explicitly, and set the child widget as a property on it:

<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

[gtk.stack.Stack] has a single CSS node named stack.

Accessibility

[gtk.stack.Stack] uses the [gtk.types.AccessibleRole.TabPanel] for the stack pages, which are the accessible parent objects of the child widgets.

Methods
GType _gType() @property
Stack self()Returns `this`, for use in `with` statements.
StackGidBuilder builder()Get builder for [gtk.stack.Stack] Returns: New builder object
bool hhomogeneous() @propertyGet `hhomogeneous` property. Returns: true if the stack allocates the same width for all children.
void hhomogeneous(bool propval) @propertySet `hhomogeneous` property. Params: propval = true if the stack allocates the same width for all children.
bool interpolateSize() @propertyGet `interpolateSize` property. Returns: Whether or not the size should smoothly change during the transition.
void interpolateSize(bool propval) @propertySet `interpolateSize` property. Params: propval = Whether or not the size should smoothly change during the transition.
gtk.selection_model.SelectionModel pages() @propertyGet `pages` property. Returns: A selection model with the stack pages.
uint transitionDuration() @propertyGet `transitionDuration` property. Returns: The animation duration, in milliseconds.
void transitionDuration(uint propval) @propertySet `transitionDuration` property. Params: propval = The animation duration, in milliseconds.
bool transitionRunning() @propertyGet `transitionRunning` property. Returns: Whether or not the transition is currently running.
gtk.types.StackTransitionType transitionType() @propertyGet `transitionType` property. Returns: The type of animation used to transition.
void transitionType(gtk.types.StackTransitionType propval) @propertySet `transitionType` property. Params: propval = The type of animation used to transition.
bool vhomogeneous() @propertyGet `vhomogeneous` property. Returns: true if the stack allocates the same height for all children.
void vhomogeneous(bool propval) @propertySet `vhomogeneous` property. Params: propval = true if the stack allocates the same height for all children.
gtk.widget.Widget visibleChild() @propertyGet `visibleChild` property. Returns: The widget currently visible in the stack.
void visibleChild(gtk.widget.Widget propval) @propertySet `visibleChild` property. Params: propval = The widget currently visible in the stack.
string visibleChildName() @propertyGet `visibleChildName` property. Returns: The name of the widget currently visible in the stack.
void visibleChildName(string propval) @propertySet `visibleChildName` property. Params: propval = The name of the widget currently visible in the stack.
gtk.stack_page.StackPage addNamed(gtk.widget.Widget child, string name = null)Adds a child to stack.
gtk.stack_page.StackPage addTitled(gtk.widget.Widget child, string name, string title)Adds a child to stack.
gtk.widget.Widget getChildByName(string name)Finds the child with the name given as the argument.
bool getHhomogeneous()Gets whether stack is horizontally homogeneous. Returns: whether stack is horizontally homogeneous.
bool getInterpolateSize()Returns whether the [gtk.stack.Stack] is set up to interpolate between the sizes of children on page switch. Returns: true if child sizes are interpolated
gtk.stack_page.StackPage getPage(gtk.widget.Widget child)Returns the [gtk.stack_page.StackPage] object for child.
gtk.selection_model.SelectionModel getPages()Returns a [gio.list_model.ListModel] that contains the pages of the stack.
uint getTransitionDuration()Returns the amount of time (in milliseconds) that transitions between pages in stack will take. Returns: the transition duration
bool 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.
gtk.types.StackTransitionType getTransitionType()Gets the type of animation that will be used for transitions between pages in stack. Returns: the current transition type of stack
bool getVhomogeneous()Gets whether stack is vertically homogeneous. Returns: whether stack is vertically homogeneous.
gtk.widget.Widget getVisibleChild()Gets the currently visible child of stack.
string getVisibleChildName()Returns the name of the currently visible child of stack.
void remove(gtk.widget.Widget child)Removes a child widget from stack.
void setHhomogeneous(bool hhomogeneous)Sets the [gtk.stack.Stack] to be horizontally homogeneous or not.
void setInterpolateSize(bool interpolateSize)Sets whether or not stack will interpolate its size when changing the visible child.
void setTransitionDuration(uint duration)Sets the duration that transitions between pages in stack will take.
void setTransitionType(gtk.types.StackTransitionType transition)Sets the type of animation that will be used for transitions between pages in stack.
void setVhomogeneous(bool vhomogeneous)Sets the [gtk.stack.Stack] to be vertically homogeneous or not.
void setVisibleChild(gtk.widget.Widget child)Makes child the visible child of stack.
void setVisibleChildFull(string name, gtk.types.StackTransitionType transition)Makes the child with the given name visible.
void setVisibleChildName(string name)Makes the child with the given name visible.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new [gtk.stack.Stack]. Returns: a new [gtk.stack.Stack]
Methods
T hhomogeneous(bool propval)Set `hhomogeneous` property. Params: propval = true if the stack allocates the same width for all children. Returns: Builder instance for fluent chaining
T interpolateSize(bool propval)Set `interpolateSize` property. Params: propval = Whether or not the size should smoothly change during the transition. Returns: Builder instance for fluent chaining
T transitionDuration(uint propval)Set `transitionDuration` property. Params: propval = The animation duration, in milliseconds. Returns: Builder instance for fluent chaining
T transitionType(gtk.types.StackTransitionType propval)Set `transitionType` property. Params: propval = The type of animation used to transition. Returns: Builder instance for fluent chaining
T vhomogeneous(bool propval)Set `vhomogeneous` property. Params: propval = true if the stack allocates the same height for all children. Returns: Builder instance for fluent chaining
T visibleChild(gtk.widget.Widget propval)Set `visibleChild` property. Params: propval = The widget currently visible in the stack. Returns: Builder instance for fluent chaining
T visibleChildName(string propval)Set `visibleChildName` property. Params: propval = The name of the widget currently visible in the stack. Returns: Builder instance for fluent chaining

Fluent builder for [gtk.stack.Stack]

Methods