adw.view_stack

Module for [ViewStack] class

Types 3

A view container for adw.view_switcher.ViewSwitcher.

adw.view_stack.ViewStack 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 adw.view_switcher.ViewSwitcher can be used with adw.view_stack.ViewStack to provide this functionality.

adw.view_stack.ViewStack pages can have a title, an icon, an attention request, and a numbered badge that adw.view_switcher.ViewSwitcher will use to let users identify which page is which. Set them using the adw.view_stack_page.ViewStackPage.title, adw.view_stack_page.ViewStackPage.iconName, adw.view_stack_page.ViewStackPage.needsAttention, and adw.view_stack_page.ViewStackPage.badgeNumber properties.

Unlike gtk.stack.Stack, transitions between views are not animated.

adw.view_stack.ViewStack maintains a adw.view_stack_page.ViewStackPage object for each added child, which holds additional per-child properties. You obtain the adw.view_stack_page.ViewStackPage for a child with adw.view_stack.ViewStack.getPage and you can obtain a gtk.selection_model.SelectionModel containing all the pages with adw.view_stack.ViewStack.getPages.

AdwViewStack as GtkBuildable

To set child-specific properties in a .ui file, create adw.view_stack_page.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

adw.view_stack.ViewStack has a single CSS node named stack.

Accessibility

adw.view_stack.ViewStack 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
ViewStack self() nothrowReturns `this`, for use in `with` statements.
ViewStackGidBuilder builder() static nothrowGet builder for [adw.view_stack.ViewStack] Returns: New builder object
bool hhomogeneous() @property nothrowGet `hhomogeneous` property. Returns: Whether the stack is horizontally homogeneous.
void hhomogeneous(bool propval) @property nothrowSet `hhomogeneous` property. Params: propval = Whether the stack is horizontally homogeneous.
gtk.selection_model.SelectionModel pages() @property nothrowGet `pages` property. Returns: A selection model with the stack's pages.
bool vhomogeneous() @property nothrowGet `vhomogeneous` property. Returns: Whether the stack is vertically homogeneous.
void vhomogeneous(bool propval) @property nothrowSet `vhomogeneous` property. Params: propval = Whether the stack is vertically homogeneous.
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.
adw.view_stack_page.ViewStackPage add(gtk.widget.Widget child) nothrowAdds a child to self.
adw.view_stack_page.ViewStackPage addNamed(gtk.widget.Widget child, string name = null) nothrowAdds a child to self.
adw.view_stack_page.ViewStackPage addTitled(gtk.widget.Widget child, string name, string title) nothrowAdds a child to self.
adw.view_stack_page.ViewStackPage addTitledWithIcon(gtk.widget.Widget child, string name, string title, string iconName) nothrowAdds a child to self.
gtk.widget.Widget getChildByName(string name) nothrowFinds the child with name in self.
bool getHhomogeneous() nothrowGets whether self is horizontally homogeneous. Returns: whether self is horizontally homogeneous
adw.view_stack_page.ViewStackPage getPage(gtk.widget.Widget child) nothrowGets the [adw.view_stack_page.ViewStackPage] object for child.
gtk.selection_model.SelectionModel getPages() nothrowReturns a [gio.list_model.ListModel] that contains the pages of the stack.
bool getVhomogeneous() nothrowGets whether self is vertically homogeneous. Returns: whether self is vertically homogeneous
gtk.widget.Widget getVisibleChild() nothrowGets the currently visible child of self. Returns: the visible child
string getVisibleChildName() nothrowReturns the name of the currently visible child of self. Returns: the name of the visible child
void remove(gtk.widget.Widget child) nothrowRemoves a child widget from self.
void setHhomogeneous(bool hhomogeneous) nothrowSets self to be horizontally homogeneous or not.
void setVhomogeneous(bool vhomogeneous) nothrowSets self to be vertically homogeneous or not.
void setVisibleChild(gtk.widget.Widget child) nothrowMakes child the visible child of self.
void setVisibleChildName(string name) nothrowMakes the child with name visible.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new [adw.view_stack.ViewStack]. Returns: the newly created [adw.view_stack.ViewStack]

Fluent builder implementation template for adw.view_stack.ViewStack

Methods
T hhomogeneous(bool propval) nothrowSet `hhomogeneous` property. Params: propval = Whether the stack is horizontally homogeneous.
T vhomogeneous(bool propval) nothrowSet `vhomogeneous` property. Params: propval = Whether the stack is vertically homogeneous.
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.

Fluent builder for adw.view_stack.ViewStack

Methods
ViewStack build() nothrowCreate object from builder. Returns: New object