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 gtk.settings.Settings.gtkEnableAnimations 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 _getGType() static nothrow
GType _gType() @property nothrow
Stack self() nothrowReturns `this`, for use in `with` statements.
StackGidBuilder builder() static nothrowGet builder for [gtk.stack.Stack] Returns: New builder object
bool hhomogeneous() @property nothrowGet `hhomogeneous` property. Returns: true if the stack allocates the same width for all children.
void hhomogeneous(bool propval) @property nothrowSet `hhomogeneous` property. Params: propval = true if the stack allocates the same width for all children.
bool interpolateSize() @property nothrowGet `interpolateSize` property. Returns: Whether or not the size should smoothly change during the transition.
void interpolateSize(bool propval) @property nothrowSet `interpolateSize` property. Params: propval = Whether or not the size should smoothly change during the transition.
gtk.selection_model.SelectionModel pages() @property nothrowGet `pages` property. Returns: A selection model with the stack pages.
uint transitionDuration() @property nothrowGet `transitionDuration` property. Returns: The animation duration, in milliseconds.
void transitionDuration(uint propval) @property nothrowSet `transitionDuration` property. Params: propval = The animation duration, in milliseconds.
bool transitionRunning() @property nothrowGet `transitionRunning` property. Returns: Whether or not the transition is currently running.
gtk.types.StackTransitionType transitionType() @property nothrowGet `transitionType` property. Returns: The type of animation used to transition.
void transitionType(gtk.types.StackTransitionType propval) @property nothrowSet `transitionType` property. Params: propval = The type of animation used to transition.
bool vhomogeneous() @property nothrowGet `vhomogeneous` property. Returns: true if the stack allocates the same height for all children.
void vhomogeneous(bool propval) @property nothrowSet `vhomogeneous` property. Params: propval = true if the stack allocates the same height for all children.
gtk.widget.Widget visibleChild() @property nothrowGet `visibleChild` property. Returns: The widget currently visible in the stack.
void visibleChild(gtk.widget.Widget propval) @property nothrowSet `visibleChild` property. Params: propval = The widget currently visible in the stack.
string visibleChildName() @property nothrowGet `visibleChildName` property. Returns: The name of the widget currently visible in the stack.
void visibleChildName(string propval) @property nothrowSet `visibleChildName` property. Params: propval = The name of the widget currently visible in the stack.
gtk.stack_page.StackPage addChild(gtk.widget.Widget child) nothrowAdds a child to stack.
gtk.stack_page.StackPage addNamed(gtk.widget.Widget child, string name = null) nothrowAdds a child to stack.
gtk.stack_page.StackPage addTitled(gtk.widget.Widget child, string name, string title) nothrowAdds a child to stack.
gtk.widget.Widget getChildByName(string name) nothrowFinds the child with the name given as the argument.
bool getHhomogeneous() nothrowGets whether stack is horizontally homogeneous. Returns: whether stack is horizontally homogeneous.
bool getInterpolateSize() nothrowReturns 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) nothrowReturns the [gtk.stack_page.StackPage] object for child.
gtk.selection_model.SelectionModel getPages() nothrowReturns a [gio.list_model.ListModel] that contains the pages of the stack.
uint getTransitionDuration() nothrowReturns the amount of time (in milliseconds) that transitions between pages in stack will take. Returns: the transition duration
bool getTransitionRunning() nothrowReturns 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() nothrowGets the type of animation that will be used for transitions between pages in stack. Returns: the current transition type of stack
bool getVhomogeneous() nothrowGets whether stack is vertically homogeneous. Returns: whether stack is vertically homogeneous.
gtk.widget.Widget getVisibleChild() nothrowGets the currently visible child of stack.
string getVisibleChildName() nothrowReturns the name of the currently visible child of stack.
void remove(gtk.widget.Widget child) nothrowRemoves a child widget from stack.
void setHhomogeneous(bool hhomogeneous) nothrowSets the [gtk.stack.Stack] to be horizontally homogeneous or not.
void setInterpolateSize(bool interpolateSize) nothrowSets whether or not stack will interpolate its size when changing the visible child.
void setTransitionDuration(uint duration) nothrowSets the duration that transitions between pages in stack will take.
void setTransitionType(gtk.types.StackTransitionType transition) nothrowSets the type of animation that will be used for transitions between pages in stack.
void setVhomogeneous(bool vhomogeneous) nothrowSets the [gtk.stack.Stack] to be vertically homogeneous or not.
void setVisibleChild(gtk.widget.Widget child) nothrowMakes child the visible child of stack.
void setVisibleChildFull(string name, gtk.types.StackTransitionType transition) nothrowMakes the child with the given name visible.
void setVisibleChildName(string name) nothrowMakes 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]

Fluent builder implementation template for gtk.stack.Stack

Methods
T hhomogeneous(bool propval) nothrowSet `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) nothrowSet `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) nothrowSet `transitionDuration` property. Params: propval = The animation duration, in milliseconds. Returns: Builder instance for fluent chaining
T transitionType(gtk.types.StackTransitionType propval) nothrowSet `transitionType` property. Params: propval = The type of animation used to transition. Returns: Builder instance for fluent chaining
T vhomogeneous(bool propval) nothrowSet `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) nothrowSet `visibleChild` property. Params: propval = The widget currently visible in the stack. Returns: Builder instance for fluent chaining
T visibleChildName(string propval) nothrowSet `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
Stack build() nothrowCreate object from builder. Returns: New object