Stack


Object Hierarchy:

Gtk.Stack Gtk.Stack Gtk.Stack Gtk.Widget Gtk.Widget Gtk.Widget->Gtk.Stack GLib.InitiallyUnowned GLib.InitiallyUnowned GLib.InitiallyUnowned->Gtk.Widget GLib.Object GLib.Object GLib.Object->GLib.InitiallyUnowned Gtk.Accessible Gtk.Accessible Gtk.Accessible->Gtk.Stack Gtk.Accessible->Gtk.Widget Gtk.Buildable Gtk.Buildable Gtk.Buildable->Gtk.Stack Gtk.Buildable->Gtk.Widget Gtk.ConstraintTarget Gtk.ConstraintTarget Gtk.ConstraintTarget->Gtk.Stack Gtk.ConstraintTarget->Gtk.Widget

Description:

[ CCode ( type_id = "gtk_stack_get_type ()" ) ]
public sealed class Stack : Widget, Accessible, Buildable, ConstraintTarget

`GtkStack` is a container which only 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 [ class@Gtk.StackSwitcher] or [class@Gtk.StackSidebar] can be used with `GtkStack` to provide this functionality.

Transitions between pages can be animated as slides or fades. This can be controlled with [method@Gtk.Stack.set_transition_type]. These animations respect the [property@Gtk.Settings:gtk-enable-animations] setting.

`GtkStack` maintains a [class@Gtk.StackPage] object for each added child, which holds additional per-child properties. You obtain the `GtkStackPage` for a child with [method@Gtk.Stack.get_page] and you can obtain a `GtkSelectionModel` containing all the pages with [ method@Gtk.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:

```xml <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_accessible_role_tab_panel for the stack pages, which are the accessible parent objects of the child widgets.


Namespace: Gtk
Package: gtk4

Content:

Properties:

Creation methods:

Methods:

Inherited Members:

All known members inherited from class Gtk.Widget