1.187 <GtkStack>

Class: <GtkStack>

It derives from <GtkWidget>.

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 <GtkStackSwitcher> or <GtkStackSidebar> can be used with <GtkStack> to provide this functionality.

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

<GtkStack> maintains a <GtkStackPage> object for each added child, which holds additional per-child properties. You obtain the <GtkStackPage> for a child with stack:get-page and you can obtain a <GtkSelectionModel> containing all the pages with 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:

  <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.AccessibleRole.tab_panel role for the stack pages, which are the accessible parent objects of the child widgets.

Properties

Property: stack:hhomogeneous self

#t if the stack allocates the same width for all children.

Its value is a boolean.

Set it with (set! (stack:hhomogeneous self) value).

Property: stack:interpolate-size self

Whether or not the size should smoothly change during the transition.

Its value is a boolean.

Set it with (set! (stack:interpolate-size self) value).

Property: stack:pages self

A selection model with the stack pages.

Its value is a <GtkSelectionModel>, or #f.

It is read only.

Property: stack:transition-duration self

The animation duration, in milliseconds.

Its value is an unsigned 32-bit integer.

Set it with (set! (stack:transition-duration self) value).

Property: stack:transition-running self

Whether or not the transition is currently running.

Its value is a boolean.

It is read only.

Property: stack:transition-type self

The type of animation used to transition.

Its value is a <GtkStackTransitionType> (or, to set it, one of its symbols).

Set it with (set! (stack:transition-type self) value).

Property: stack:vhomogeneous self

#t if the stack allocates the same height for all children.

Its value is a boolean.

Set it with (set! (stack:vhomogeneous self) value).

Property: stack:visible-child self

The widget currently visible in the stack.

Its value is a <GtkWidget>, or #f.

Set it with (set! (stack:visible-child self) value).

Property: stack:visible-child-name self

The name of the widget currently visible in the stack.

Its value is a string, or #f.

Set it with (set! (stack:visible-child-name self) value).

Procedures

Method: stack:add-child self child ⇒ %return
Method: add-child self child ⇒ %return

Adds a child to self.

self

Passed: a <GtkStack>.

a <GtkStack>

child

Passed: a <GtkWidget>.

the widget to add

%return

Returned: a <GtkStackPage>.

the <GtkStackPage> for child

Method: stack:add-named self child [name] ⇒ %return
Method: add-named self child [name] ⇒ %return

Adds a child to self.

The child is identified by the name.

self

Passed: a <GtkStack>.

a <GtkStack>

child

Passed: a <GtkWidget>.

the widget to add

name

Passed, or left out: a string, or #f.

the name for child

%return

Returned: a <GtkStackPage>.

the <GtkStackPage> for child

Method: stack:add-titled self child name title ⇒ %return
Method: add-titled self child name title ⇒ %return

Adds a child to self.

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.

self

Passed: a <GtkStack>.

a <GtkStack>

child

Passed: a <GtkWidget>.

the widget to add

name

Passed: a string, or #f.

the name for child

title

Passed: a string.

a human-readable title for child

%return

Returned: a <GtkStackPage>.

the <GtkStackPage> for child

Method: stack:get-child-by-name self name ⇒ %return
Method: get-child-by-name self name ⇒ %return

Finds the child with the name given as the argument.

Returns #f if there is no child with this name.

self

Passed: a <GtkStack>.

a <GtkStack>

name

Passed: a string.

the name of the child to find

%return

Returned: a <GtkWidget>, or #f.

the requested child of the <GtkStack>

Method: stack:get-hhomogeneous? self ⇒ %return
Method: get-hhomogeneous? self ⇒ %return

Gets whether self is horizontally homogeneous.

self

Passed: a <GtkStack>.

a <GtkStack>

%return

Returned: a boolean.

whether self is horizontally homogeneous.

Method: stack:get-interpolate-size? self ⇒ %return
Method: get-interpolate-size? self ⇒ %return

Returns whether the <GtkStack> is set up to interpolate between the sizes of children on page switch.

self

Passed: a <GtkStack>.

A <GtkStack>

%return

Returned: a boolean.

#t if child sizes are interpolated

Method: stack:get-page self child ⇒ %return
Method: get-page self child ⇒ %return

Returns the <GtkStackPage> object for child.

self

Passed: a <GtkStack>.

a <GtkStack>

child

Passed: a <GtkWidget>.

a child of self

%return

Returned: a <GtkStackPage>.

the <GtkStackPage> for child

Method: stack:get-pages self ⇒ %return
Method: get-pages self ⇒ %return

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 <GtkSelectionModel> and can be used to track and modify the visible page.

self

Passed: a <GtkStack>.

a <GtkStack>

%return

Returned: a <GtkSelectionModel>.

a <GtkSelectionModel> for the stack’s children

Method: stack:get-transition-duration self ⇒ %return
Method: get-transition-duration self ⇒ %return

Returns the amount of time (in milliseconds) that transitions between pages in self will take.

self

Passed: a <GtkStack>.

a <GtkStack>

%return

Returned: an unsigned 32-bit integer.

the transition duration

Method: stack:get-transition-running? self ⇒ %return
Method: get-transition-running? self ⇒ %return

Returns whether the self is currently in a transition from one page to another.

self

Passed: a <GtkStack>.

a <GtkStack>

%return

Returned: a boolean.

#t if the transition is currently running, #f otherwise.

Method: stack:get-transition-type self ⇒ %return
Method: get-transition-type self ⇒ %return

Gets the type of animation that will be used for transitions between pages in self.

self

Passed: a <GtkStack>.

a <GtkStack>

%return

Returned: a <GtkStackTransitionType>.

the current transition type of self

Method: stack:get-vhomogeneous? self ⇒ %return
Method: get-vhomogeneous? self ⇒ %return

Gets whether self is vertically homogeneous.

self

Passed: a <GtkStack>.

a <GtkStack>

%return

Returned: a boolean.

whether self is vertically homogeneous.

Method: stack:get-visible-child self ⇒ %return
Method: get-visible-child self ⇒ %return

Gets the currently visible child of self.

Returns #f if there are no visible children.

self

Passed: a <GtkStack>.

a <GtkStack>

%return

Returned: a <GtkWidget>, or #f.

the visible child of the <GtkStack>

Method: stack:get-visible-child-name self ⇒ %return
Method: get-visible-child-name self ⇒ %return

Returns the name of the currently visible child of self.

Returns #f if there is no visible child.

self

Passed: a <GtkStack>.

a <GtkStack>

%return

Returned: a string, or #f.

the name of the visible child of the <GtkStack>

Procedure: stack:new ⇒ %return

Creates a new <GtkStack>.

%return

Returned: a <GtkWidget>.

a new <GtkStack>

Method: stack:remove self child
Method: remove self child

Removes a child widget from self.

self

Passed: a <GtkStack>.

a <GtkStack>

child

Passed: a <GtkWidget>.

the child to remove

Method: stack:set-hhomogeneous self hhomogeneous
Method: set-hhomogeneous self 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.

self

Passed: a <GtkStack>.

a <GtkStack>

hhomogeneous

Passed: a boolean.

#t to make self horizontally homogeneous

Method: stack:set-interpolate-size self interpolate-size
Method: set-interpolate-size self interpolate-size

Sets whether or not self will interpolate its size when changing the visible child.

If the stack:interpolate-size property is set to #t, self 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.

self

Passed: a <GtkStack>.

A <GtkStack>

interpolate-size

Passed: a boolean.

the new value

Method: stack:set-transition-duration self duration
Method: set-transition-duration self duration

Sets the duration that transitions between pages in self will take.

self

Passed: a <GtkStack>.

a <GtkStack>

duration

Passed: an unsigned 32-bit integer.

the new duration, in milliseconds

Method: stack:set-transition-type self transition
Method: set-transition-type self transition

Sets the type of animation that will be used for transitions between pages in self.

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.

self

Passed: a <GtkStack>.

a <GtkStack>

transition

Passed: a <GtkStackTransitionType>, or one of its symbols.

the new transition type

Method: stack:set-vhomogeneous self vhomogeneous
Method: set-vhomogeneous self 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.

self

Passed: a <GtkStack>.

a <GtkStack>

vhomogeneous

Passed: a boolean.

#t to make self vertically homogeneous

Method: stack:set-visible-child self child
Method: set-visible-child self child

Makes child the visible child of self.

If child is different from the currently visible child, the transition between the two will be animated with the current transition type of self.

Note that the child widget has to be visible itself (see widget:show) in order to become the visible child of self.

self

Passed: a <GtkStack>.

a <GtkStack>

child

Passed: a <GtkWidget>.

a child of self

Method: stack:set-visible-child-full self name transition
Method: set-visible-child-full self name transition

Makes the child with the given name visible.

Note that the child widget has to be visible itself (see widget:show) in order to become the visible child of self.

self

Passed: a <GtkStack>.

a <GtkStack>

name

Passed: a string.

the name of the child to make visible

transition

Passed: a <GtkStackTransitionType>, or one of its symbols.

the transition type to use

Method: stack:set-visible-child-name self name
Method: set-visible-child-name self name

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 self.

Note that the child widget has to be visible itself (see widget:show) in order to become the visible child of self.

self

Passed: a <GtkStack>.

a <GtkStack>

name

Passed: a string.

the name of the child to make visible