1.72 <AdwViewStack>

Class: <AdwViewStack>

It derives from <GtkWidget>.

A view container for ViewSwitcher.

<AdwViewStack> is a container which only shows one page at a time. It is typically used to hold an application’s main views.

It doesn’t provide a way to transition between pages. Instead, a separate widget such as ViewSwitcher, InlineViewSwitcher or ViewSwitcherSidebar can be used with <AdwViewStack> to provide this functionality.

<AdwViewStack> pages can have a title, an icon, an attention request, and a numbered badge that ViewSwitcher will use to let users identify which page is which. Set them using the ViewStackPage:title, ViewStackPage:icon-name, ViewStackPage:needs-attention, and ViewStackPage:badge-number properties.

<AdwViewStack> pages can also be grouped into sections, using the ViewStackPage:starts-section and ViewStackPage:section-title properties. Currently, only ViewSwitcherSidebar displays groups.

Unlike <GtkStack>, transitions between views can only be animated via a crossfade and size changes are always interpolated. Animations are disabled by default. Use ViewStack:enable-transitions to enable them.

<AdwViewStack> maintains a ViewStackPage object for each added child, which holds additional per-child properties. You obtain the ViewStackPage for a child with ViewStack.get_page and you can obtain a <GtkSelectionModel> containing all the pages with ViewStack.get_pages.

AdwViewStack as GtkBuildable

To set child-specific properties in a .ui file, create ViewStackPage objects explicitly, and set the child widget as a property on it:

  <object class="AdwViewStack" id="stack">
    <child>
      <object class="AdwViewStackPage">
        <property name="name">overview</property>
        <property name="title">Overview</property>
        <property name="child">
          <object class="AdwStatusPage">
            <property name="title">Welcome!</property>
          </object>
        </property>
      </object>
    </child>
  </object>

CSS nodes

<AdwViewStack> has a single CSS node named stack.

Accessibility

<AdwViewStack> uses the Gtk.AccessibleRole.tab-panel for the stack pages which are the accessible parent objects of the child widgets.

Properties

Property: view-stack:enable-transitions self

Whether the stack uses a crossfade transition between pages.

Use ViewStack:transition-duration to control the duration, and ViewStack:transition-running to know when the transition is running.

Its value is a boolean.

Set it with (set! (view-stack:enable-transitions self) value).

Property: view-stack:hhomogeneous self

Whether the stack is horizontally homogeneous.

If the stack is horizontally homogeneous, it allocates the same width for all children.

If it’s FALSE, the stack may change width when a different child becomes visible.

Its value is a boolean.

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

Property: view-stack:pages self

A selection model with the stack’s pages.

This can be used to keep an up-to-date view.

The model implements <GtkSectionModel> and creates sections based on ViewStackPage:starts-section values.

The model also implements <GtkSelectionModel> and can be used to track and change the visible page.

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

It is read only.

Property: view-stack:transition-duration self

The transition animation duration, in milliseconds.

Only used when ViewStack:enable-transitions is set to TRUE.

Its value is an unsigned 32-bit integer.

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

Property: view-stack:transition-running self

Whether a transition is currently running.

If a transition is impossible, the property value will be set to TRUE and then immediately to FALSE, so it’s possible to rely on its notifications to know that a transition has happened.

Its value is a boolean.

It is read only.

Property: view-stack:vhomogeneous self

Whether the stack is vertically homogeneous.

If the stack is vertically homogeneous, it allocates the same height for all children.

If it’s FALSE, the stack may change height when a different child becomes visible.

Its value is a boolean.

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

Property: view-stack:visible-child self

The widget currently visible in the stack.

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

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

Property: view-stack:visible-child-name self

The name of the widget currently visible in the stack.

See ViewStack:visible-child.

Its value is a string, or #f.

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

Procedures

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

Adds a child to self.

self

Passed: a <AdwViewStack>.

a view stack

child

Passed: a <GtkWidget>.

the widget to add

%return

Returned: a <AdwViewStackPage>.

the ViewStackPage for child

Method: view-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 <AdwViewStack>.

a view stack

child

Passed: a <GtkWidget>.

the widget to add

name

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

the name for child

%return

Returned: a <AdwViewStackPage>.

the <AdwViewStackPage> for child

Method: view-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 ViewSwitcher to represent child, so it should be short.

self

Passed: a <AdwViewStack>.

a view stack

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

the <AdwViewStackPage> for child

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

Adds a child to self.

The child is identified by the name. The title and icon-name will be used by ViewSwitcher to represent child.

self

Passed: a <AdwViewStack>.

a view stack

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

icon-name

Passed: a string.

an icon name for child

%return

Returned: a <AdwViewStackPage>.

the <AdwViewStackPage> for child

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

Finds the child with name in self.

self

Passed: a <AdwViewStack>.

a view stack

name

Passed: a string.

the name of the child to find

%return

Returned: a <GtkWidget>, or #f.

the requested child

Method: view-stack:get-enable-transitions? self ⇒ %return
Method: get-enable-transitions? self ⇒ %return

Gets whether self uses a crossfade transition between pages.

Use ViewStack:transition-duration to control the duration, and ViewStack:transition-running to know when the transition is running.

self

Passed: a <AdwViewStack>.

a view stack

%return

Returned: a boolean.

whether to enable page transitions

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

Gets whether self is horizontally homogeneous.

self

Passed: a <AdwViewStack>.

a view stack

%return

Returned: a boolean.

whether self is horizontally homogeneous

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

Gets the ViewStackPage object for child.

self

Passed: a <AdwViewStack>.

a view stack

child

Passed: a <GtkWidget>.

a child of self

%return

Returned: a <AdwViewStackPage>.

the page object for child

Method: view-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 implements <GtkSectionModel> and creates sections based on ViewStackPage:starts-section values.

The model also implements <GtkSelectionModel> and can be used to track and change the visible page.

self

Passed: a <AdwViewStack>.

a view stack

%return

Returned: a <GtkSelectionModel>.

a <GtkSelectionModel> for the stack’s children

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

Gets the transition animation duration for self.

self

Passed: a <AdwViewStack>.

a view stack

%return

Returned: an unsigned 32-bit integer.

the transition duration, in milliseconds

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

Gets whether a transition is currently running for self.

If a transition is impossible, the property value will be set to TRUE and then immediately to FALSE, so it’s possible to rely on its notifications to know that a transition has happened.

self

Passed: a <AdwViewStack>.

a view stack

%return

Returned: a boolean.

whether a transition is currently running

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

Gets whether self is vertically homogeneous.

self

Passed: a <AdwViewStack>.

a view stack

%return

Returned: a boolean.

whether self is vertically homogeneous

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

Gets the currently visible child of self.

self

Passed: a <AdwViewStack>.

a view stack

%return

Returned: a <GtkWidget>, or #f.

the visible child

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

Returns the name of the currently visible child of self.

self

Passed: a <AdwViewStack>.

a view stack

%return

Returned: a string, or #f.

the name of the visible child

Procedure: view-stack:new ⇒ %return

Creates a new <AdwViewStack>.

%return

Returned: a <GtkWidget>.

the newly created <AdwViewStack>

Method: view-stack:remove self child
Method: remove self child

Removes a child widget from self.

self

Passed: a <AdwViewStack>.

a view stack

child

Passed: a <GtkWidget>.

the child to remove

Method: view-stack:set-enable-transitions self enable-transitions
Method: set-enable-transitions self enable-transitions

Sets whether self uses a crossfade transition between pages.

self

Passed: a <AdwViewStack>.

a view stack

enable-transitions

Passed: a boolean.

whether to enable page transitions

Method: view-stack:set-hhomogeneous self hhomogeneous
Method: set-hhomogeneous self hhomogeneous

Sets self to be horizontally homogeneous or not.

If the stack is horizontally homogeneous, it allocates the same width for all children.

If it’s FALSE, the stack may change width when a different child becomes visible.

self

Passed: a <AdwViewStack>.

a view stack

hhomogeneous

Passed: a boolean.

whether to make self horizontally homogeneous

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

Sets the transition animation duration for self.

Only used when ViewStack:enable-transitions is set to TRUE.

self

Passed: a <AdwViewStack>.

a view stack

duration

Passed: an unsigned 32-bit integer.

the new duration, in milliseconds

Method: view-stack:set-vhomogeneous self vhomogeneous
Method: set-vhomogeneous self vhomogeneous

Sets self to be vertically homogeneous or not.

If the stack is vertically homogeneous, it allocates the same height for all children.

If it’s FALSE, the stack may change height when a different child becomes visible.

self

Passed: a <AdwViewStack>.

a view stack

vhomogeneous

Passed: a boolean.

whether to make self vertically homogeneous

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

Makes child the visible child of self.

self

Passed: a <AdwViewStack>.

a view stack

child

Passed: a <GtkWidget>.

a child of self

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

Makes the child with name visible.

See ViewStack:visible-child.

self

Passed: a <AdwViewStack>.

a view stack

name

Passed: a string.

the name of the child