Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: Stack

[36:7] extends: object

Shows one of its children at a time. An
example GtkStack 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 [enum@Gtk.AccessibleRole.tab_panel] role for the stack pages, which are the accessible parent objects of the child widgets.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • Stack ()

    Creates a new GtkStack.

  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • asWidget ()

    Wraps this handle as Widget.

    • @r A Widget object.
  • asAccessible ()

    Wraps this handle as Accessible.

    • @r A Accessible object.
  • asBuildable ()

    Wraps this handle as Buildable.

    • @r A Buildable object.
  • asConstraintTarget ()

    Wraps this handle as ConstraintTarget.

    • @r A ConstraintTarget object.
  • getProperty (string Name)

    Reads one generated property by name.

  • setProperty (string Name, Value)

    Writes one generated property by name.

  • setHhomogeneous (bool Value)

    %TRUE if the stack allocates the same width for all children.

    • @p Value is the new property value.
    • @r None.
  • setInterpolatesize (bool Value)

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

    • @p Value is the new property value.
    • @r None.
  • setTransitionduration (int Value)

    The animation duration, in milliseconds.

    • @p Value is the new property value.
    • @r None.
  • setTransitiontype (string Value)

    The type of animation used to transition.

    • @p Value is the new property value.
    • @r None.
  • setVhomogeneous (bool Value)

    %TRUE if the stack allocates the same height for all children.

    • @p Value is the new property value.
    • @r None.
  • setVisiblechild (object Value)

    The widget currently visible in the stack.

    • @p Value is the new property value.
    • @r None.
  • setVisiblechildname (string Value)

    The name of the widget currently visible in the stack.

    • @p Value is the new property value.
    • @r None.
  • add_child (object child)

    Adds a child to @stack.

    • @p child is the widget to add.
  • add_named (object child, string name)

    Adds a child to @stack. The child is identified by the @name.

    • @p child is the widget to add.
    • @p name is the name for @child.
  • add_titled (object child, string name, string title)

    Adds a child to @stack. 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.

    • @p child is the widget to add.
    • @p name is the name for @child.
    • @p title is a human-readable title for @child.
  • get_child_by_name (string name)

    Finds the child with the name given as the argument. Returns %NULL if there is no child with this name.

    • @p name is the name of the child to find.
  • get_hhomogeneous ()

    Gets whether @stack is horizontally homogeneous.

  • get_interpolate_size ()

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

  • get_page (object child)

    Returns the GtkStackPage object for @child.

    • @p child is a child of @stack.
  • get_pages ()

    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 [iface@Gtk.SelectionModel] and can be used to track and modify the visible page.

  • get_transition_duration ()

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

  • get_transition_running ()

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

  • get_transition_type ()

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

  • get_vhomogeneous ()

    Gets whether @stack is vertically homogeneous.

  • get_visible_child ()

    Gets the currently visible child of @stack. Returns %NULL if there are no visible children.

  • get_visible_child_name ()

    Returns the name of the currently visible child of @stack. Returns %NULL if there is no visible child.

  • remove (object child)

    Removes a child widget from @stack.

    • @p child is the child to remove.
    • @r None.
  • set_hhomogeneous (bool 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.

    • @p hhomogeneous is %TRUE to make @stack horizontally homogeneous.
    • @r None.
  • set_interpolate_size (bool interpolate_size)

    Sets whether or not @stack will interpolate its size when changing the visible child. If the [property@Gtk.Stack:interpolate-size] property is set to %TRUE, @stack 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.

    • @p interpolate_size is the new value.
    • @r None.
  • set_transition_duration (int duration)

    Sets the duration that transitions between pages in @stack will take.

    • @p duration is the new duration, in milliseconds.
    • @r None.
  • set_transition_type (string transition)

    Sets the type of animation that will be used for transitions between pages in @stack. 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.

    • @p transition is the new transition type.
    • @r None.
  • set_vhomogeneous (bool 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.

    • @p vhomogeneous is %TRUE to make @stack vertically homogeneous.
    • @r None.
  • set_visible_child (object child)

    Makes @child the visible child of @stack. If @child is different from the currently visible child, the transition between the two will be animated with the current transition type of @stack. Note that the @child widget has to be visible itself (see [method@Gtk.Widget.show]) in order to become the visible child of @stack.

    • @p child is a child of @stack.
    • @r None.
  • set_visible_child_full (string name, string transition)

    Makes the child with the given name visible. Note that the child widget has to be visible itself (see [method@Gtk.Widget.show]) in order to become the visible child of @stack.

    • @p name is the name of the child to make visible.
    • @p transition is the transition type to use.
    • @r None.
  • set_visible_child_name (string 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 @stack. Note that the child widget has to be visible itself (see [method@Gtk.Widget.show]) in order to become the visible child of @stack.

    • @p name is the name of the child to make visible.
    • @r None.

class: StackMeta

[534:14] static extends: object

Generated metadata helpers for Stack class surfaces.

Methods

  • properties ()

    Returns property metadata for Stack.

    • @r A list.