StackProtocol

public protocol StackProtocol : WidgetProtocol

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 [classGtk.StackSwitcher] or [classGtk.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 [methodGtk.Stack.set_transition_type]. These animations respect the [propertyGtk.Settings:gtk-enable-animations] setting.

GtkStack maintains a [classGtk.StackPage] object for each added child, which holds additional per-child properties. You obtain the GtkStackPage for a child with [methodGtk.Stack.get_page] and you can obtain a GtkSelectionModel containing all the pages with [methodGtk.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_ACCESSIBLE_ROLE_TAB_PANEL for the stack pages, which are the accessible parent objects of the child widgets.

The StackProtocol protocol exposes the methods and properties of an underlying GtkStack instance. The default implementation of these can be found in the protocol extension below. For a concrete class that implements these methods and properties, see Stack. Alternatively, use StackRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying GtkStack instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • stack_ptr Default implementation

    Typed pointer to the underlying GtkStack instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GtkStack instance.

    Declaration

    Swift

    var stack_ptr: UnsafeMutablePointer<GtkStack>! { get }
  • Required Initialiser for types conforming to StackProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

Stack Class

  • Bind a StackPropertyName source property to a given target object.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: StackPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol

    Parameters

    source_property

    the source property to bind

    target

    the target object to bind to

    target_property

    the target property to bind to

    flags

    the flags to pass to the Binding

    transform_from

    ValueTransformer to use for forward transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return Value

    binding reference or nil in case of an error

  • get(property:) Extension method

    Get the value of a Stack property

    Declaration

    Swift

    @inlinable
    func get(property: StackPropertyName) -> GLibObject.Value

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

  • set(property:value:) Extension method

    Set the value of a Stack property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

    @inlinable
    func set(property: StackPropertyName, value v: GLibObject.Value)

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

Stack Class: StackProtocol extension (methods and fields)

  • add(child:) Extension method

    Adds a child to stack.

    Declaration

    Swift

    @inlinable
    func add<WidgetT>(child: WidgetT) -> StackPageRef! where WidgetT : WidgetProtocol
  • addNamed(child:name:) Extension method

    Adds a child to stack.

    The child is identified by the name.

    Declaration

    Swift

    @inlinable
    func addNamed<WidgetT>(child: WidgetT, name: UnsafePointer<CChar>? = nil) -> StackPageRef! where WidgetT : WidgetProtocol
  • addTitled(child:name:title:) Extension method

    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.

    Declaration

    Swift

    @inlinable
    func addTitled<WidgetT>(child: WidgetT, name: UnsafePointer<CChar>? = nil, title: UnsafePointer<CChar>!) -> StackPageRef! where WidgetT : WidgetProtocol
  • getChildBy(name:) Extension method

    Finds the child with the name given as the argument.

    Returns nil if there is no child with this name.

    Declaration

    Swift

    @inlinable
    func getChildBy(name: UnsafePointer<CChar>!) -> WidgetRef!
  • getHhomogeneous() Extension method

    Gets whether stack is horizontally homogeneous.

    Declaration

    Swift

    @inlinable
    func getHhomogeneous() -> Bool
  • getInterpolateSize() Extension method

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

    Declaration

    Swift

    @inlinable
    func getInterpolateSize() -> Bool
  • getPage(child:) Extension method

    Returns the GtkStackPage object for child.

    Declaration

    Swift

    @inlinable
    func getPage<WidgetT>(child: WidgetT) -> StackPageRef! where WidgetT : WidgetProtocol
  • getPages() Extension method

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

    Declaration

    Swift

    @inlinable
    func getPages() -> SelectionModelRef!
  • getTransitionDuration() Extension method

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

    Declaration

    Swift

    @inlinable
    func getTransitionDuration() -> Int
  • getTransitionRunning() Extension method

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

    Declaration

    Swift

    @inlinable
    func getTransitionRunning() -> Bool
  • getTransitionType() Extension method

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

    Declaration

    Swift

    @inlinable
    func getTransitionType() -> GtkStackTransitionType
  • getVhomogeneous() Extension method

    Gets whether stack is vertically homogeneous.

    Declaration

    Swift

    @inlinable
    func getVhomogeneous() -> Bool
  • getVisibleChild() Extension method

    Gets the currently visible child of stack.

    Returns nil if there are no visible children.

    Declaration

    Swift

    @inlinable
    func getVisibleChild() -> WidgetRef!
  • getVisibleChildName() Extension method

    Returns the name of the currently visible child of stack.

    Returns nil if there is no visible child.

    Declaration

    Swift

    @inlinable
    func getVisibleChildName() -> String!
  • remove(child:) Extension method

    Removes a child widget from stack.

    Declaration

    Swift

    @inlinable
    func remove<WidgetT>(child: WidgetT) where WidgetT : WidgetProtocol
  • set(hhomogeneous:) Extension method

    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.

    Declaration

    Swift

    @inlinable
    func set(hhomogeneous: Bool)
  • set(interpolateSize:) Extension method

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

    If the [propertyGtk.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.

    Declaration

    Swift

    @inlinable
    func set(interpolateSize: Bool)
  • setTransition(duration:) Extension method

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

    Declaration

    Swift

    @inlinable
    func setTransition(duration: Int)
  • 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.

    Declaration

    Swift

    @inlinable
    func setTransitionType(transition: GtkStackTransitionType)
  • set(vhomogeneous:) Extension method

    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.

    Declaration

    Swift

    @inlinable
    func set(vhomogeneous: Bool)
  • setVisible(child:) Extension method

    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 [methodGtk.Widget.show]) in order to become the visible child of stack.

    Declaration

    Swift

    @inlinable
    func setVisible<WidgetT>(child: WidgetT) where WidgetT : WidgetProtocol
  • Makes the child with the given name visible.

    Note that the child widget has to be visible itself (see [methodGtk.Widget.show]) in order to become the visible child of stack.

    Declaration

    Swift

    @inlinable
    func setVisibleChildFull(name: UnsafePointer<CChar>!, transition: GtkStackTransitionType)
  • setVisibleChild(name:) Extension method

    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 [methodGtk.Widget.show]) in order to become the visible child of stack.

    Declaration

    Swift

    @inlinable
    func setVisibleChild(name: UnsafePointer<CChar>!)
  • hhomogeneous Extension method

    true if the stack allocates the same width for all children.

    Declaration

    Swift

    @inlinable
    var hhomogeneous: Bool { get nonmutating set }
  • interpolateSize Extension method

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

    Declaration

    Swift

    @inlinable
    var interpolateSize: Bool { get nonmutating set }
  • pages Extension method

    A selection model with the stack pages.

    Declaration

    Swift

    @inlinable
    var pages: SelectionModelRef! { get }
  • transitionDuration Extension method

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

    Declaration

    Swift

    @inlinable
    var transitionDuration: Int { get nonmutating set }
  • transitionRunning Extension method

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

    Declaration

    Swift

    @inlinable
    var transitionRunning: Bool { get }
  • transitionType Extension method

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

    Declaration

    Swift

    @inlinable
    var transitionType: GtkStackTransitionType { get nonmutating set }
  • vhomogeneous Extension method

    true if the stack allocates the same height for all children.

    Declaration

    Swift

    @inlinable
    var vhomogeneous: Bool { get nonmutating set }
  • visibleChild Extension method

    Gets the currently visible child of stack.

    Returns nil if there are no visible children.

    Declaration

    Swift

    @inlinable
    var visibleChild: WidgetRef! { get nonmutating set }
  • visibleChildName Extension method

    Returns the name of the currently visible child of stack.

    Returns nil if there is no visible child.

    Declaration

    Swift

    @inlinable
    var visibleChildName: String! { get nonmutating set }