Package: gtk

Class gtk:stack

Superclasses

Documented Subclasses

None

Direct Slots

hhomogeneous
The hhomogeneous property of type :boolean (Read / Write)
True if the stack allocates the same width for all children.
Default value: true
interpolate-size
The interpolate-size property of type :boolean (Read / Write)
Whether or not the size should smoothly change when changing between differently sized children.
Default value: false
pages
The pages property of type gtk:selection-model (Read)
The selection model with the pages of the stack. Returns a g:list-model object that contains the pages of the stack, and can be used to keep an up-to-date view. The model also implements the gtk:selection-model object and can be used to track and modify the visible page.
transition-duration
The transition-duration property of type :uint (Read / Write)
The animation duration, in milliseconds.
Default value: 200
transition-running
The transition-running property of type :boolean (Read)
Whether or not the transition is currently running.
Default value: false
transition-type
The transition-type property of type gtk:stack-transition-type (Read / Write)
The type of animation used to transition.
Default value: :none
vhomogeneous
The vhomogeneous property of type :boolean (Read / Write)
True if the stack allocates the same height for all children.
Default value: true
visible-child
The visible-child property of type gtk:widget (Read / Write)
The widget currently visible in the stack.
visible-child-name
The visible-child-name property of type :string (Read / Write)
The name of the widget currently visible in the stack.
Default value: nil

Details

The gtk:stack widget is a container which only shows one of its children at a time. In contrast to the gtk:notebook widget, the gtk:stack widget does not provide a means for users to change the visible child. Instead, the gtk:stack-switcher widget can be used with the gtk:stack widget to provide this functionality.

Figure: GtkStack

Transitions between pages can be animated as slides or fades. This can be controlled with the gtk:stack-transition-type function. These animations respect the gtk-enable-animations setting.

The gtk:stack widget maintains a gtk:stack-page object for each added child widget, which holds additional per-child properties. You obtain the gtk:stack-page object for a child widget with the gtk:stack-page function.

GtkStack as GtkBuildable

To set child-specific properties in a .ui file, create gtk:stack-page 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

The gtk:stack implementation has a single CSS node named stack.

Accessibility

The gtk:stack implementation uses the :tab-panel role of the gtk:accessible-role enumeration for the stack pages, which are the accessible parent objects of the child widgets.
 

Returned by

Slot Access Functions

Inherited Slot Access Functions

See also

2025-4-23