HeaderBarProtocol

public protocol HeaderBarProtocol : WidgetProtocol

GtkHeaderBar is a widget for creating custom title bars for windows.

An example GtkHeaderBar

GtkHeaderBar is similar to a horizontal GtkCenterBox. It allows children to be placed at the start or the end. In addition, it allows the window title to be displayed. The title will be centered with respect to the width of the box, even if the children at either side take up different amounts of space.

GtkHeaderBar can add typical window frame controls, such as minimize, maximize and close buttons, or the window icon.

For these reasons, GtkHeaderBar is the natural choice for use as the custom titlebar widget of a GtkWindow (see [methodGtk.Window.set_titlebar`]), as it gives features typical of titlebars while allowing the addition of child widgets.

GtkHeaderBar as GtkBuildable

The GtkHeaderBar implementation of the GtkBuildable interface supports adding children at the start or end sides by specifying “start” or “end” as the “type” attribute of a <child> element, or setting the title widget by specifying “title” value.

By default the GtkHeaderBar uses a GtkLabel displaying the title of the window it is contained in as the title widget, equivalent to the following UI definition:

&lt;object class="GtkHeaderBar"&gt;
  &lt;property name="title-widget"&gt;
    &lt;object class="GtkLabel"&gt;
      &lt;property name="label" translatable="yes"&gt;Label&lt;/property&gt;
      &lt;property name="single-line-mode"&gt;True&lt;/property&gt;
      &lt;property name="ellipsize"&gt;end&lt;/property&gt;
      &lt;property name="width-chars"&gt;5&lt;/property&gt;
      &lt;style&gt;
        &lt;class name="title"/&gt;
      &lt;/style&gt;
    &lt;/object&gt;
  &lt;/property&gt;
&lt;/object&gt;

CSS nodes

headerbar
╰── windowhandle
    ╰── box
        ├── box.start
           ├── windowcontrols.start
           ╰── [other children]
        ├── [Title Widget]
        ╰── box.end
            ├── [other children]
            ╰── windowcontrols.end

A GtkHeaderBar‘s CSS node is called headerbar. It contains a windowhandle subnode, which contains a box subnode, which contains two box subnodes at the start and end of the header bar, as well as a center node that represents the title.

Each of the boxes contains a windowcontrols subnode, see [classGtk.WindowControls] for details, as well as other children.

Accessibility

GtkHeaderBar uses the GTK_ACCESSIBLE_ROLE_GROUP role.

The HeaderBarProtocol protocol exposes the methods and properties of an underlying GtkHeaderBar 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 HeaderBar. Alternatively, use HeaderBarRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying GtkHeaderBar instance.

    Declaration

    Swift

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

    Typed pointer to the underlying GtkHeaderBar instance.

    Default Implementation

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

    Declaration

    Swift

    var header_bar_ptr: UnsafeMutablePointer<GtkHeaderBar>! { get }
  • Required Initialiser for types conforming to HeaderBarProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

HeaderBar Class

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

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: HeaderBarPropertyName, 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 HeaderBar property

    Declaration

    Swift

    @inlinable
    func get(property: HeaderBarPropertyName) -> 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 HeaderBar property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

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

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

HeaderBar Class: HeaderBarProtocol extension (methods and fields)

  • getDecorationLayout() Extension method

    Gets the decoration layout of the GtkHeaderBar.

    Declaration

    Swift

    @inlinable
    func getDecorationLayout() -> String!
  • getShowTitleButtons() Extension method

    Returns whether this header bar shows the standard window title buttons.

    Declaration

    Swift

    @inlinable
    func getShowTitleButtons() -> Bool
  • getTitleWidget() Extension method

    Retrieves the title widget of the header.

    See [methodGtk.HeaderBar.set_title_widget].

    Declaration

    Swift

    @inlinable
    func getTitleWidget() -> WidgetRef!
  • packEnd(child:) Extension method

    Adds child to bar, packed with reference to the end of the bar.

    Declaration

    Swift

    @inlinable
    func packEnd<WidgetT>(child: WidgetT) where WidgetT : WidgetProtocol
  • packStart(child:) Extension method

    Adds child to bar, packed with reference to the start of the bar.

    Declaration

    Swift

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

    Removes a child from the GtkHeaderBar.

    The child must have been added with [methodGtk.HeaderBar.pack_start], [methodGtk.HeaderBar.pack_end] or [methodGtk.HeaderBar.set_title_widget].

    Declaration

    Swift

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

    Sets the decoration layout for this header bar.

    This property overrides the [propertyGtk.Settings:gtk-decoration-layout] setting.

    There can be valid reasons for overriding the setting, such as a header bar design that does not allow for buttons to take room on the right, or only offers room for a single close button. Split header bars are another example for overriding the setting.

    The format of the string is button names, separated by commas. A colon separates the buttons that should appear on the left from those on the right. Recognized button names are minimize, maximize, close and icon (the window icon).

    For example, “icon:minimize,maximize,close” specifies a icon on the left, and minimize, maximize and close buttons on the right.

    Declaration

    Swift

    @inlinable
    func setDecoration(layout: UnsafePointer<CChar>? = nil)
  • Sets whether this header bar shows the standard window title buttons.

    Declaration

    Swift

    @inlinable
    func setShowTitleButtons(setting: Bool)
  • set(titleWidget:) Extension method

    Sets the title for the GtkHeaderBar.

    When set to nil, the headerbar will display the title of the window it is contained in.

    The title should help a user identify the current view. To achieve the same style as the builtin title, use the “title” style class.

    You should set the title widget to nil, for the window title label to be visible again.

    Declaration

    Swift

    @inlinable
    func set(titleWidget: WidgetRef? = nil)
  • set(titleWidget:) Extension method

    Sets the title for the GtkHeaderBar.

    When set to nil, the headerbar will display the title of the window it is contained in.

    The title should help a user identify the current view. To achieve the same style as the builtin title, use the “title” style class.

    You should set the title widget to nil, for the window title label to be visible again.

    Declaration

    Swift

    @inlinable
    func set<WidgetT>(titleWidget: WidgetT?) where WidgetT : WidgetProtocol
  • decorationLayout Extension method

    Gets the decoration layout of the GtkHeaderBar.

    Declaration

    Swift

    @inlinable
    var decorationLayout: String! { get nonmutating set }
  • showTitleButtons Extension method

    Returns whether this header bar shows the standard window title buttons.

    Declaration

    Swift

    @inlinable
    var showTitleButtons: Bool { get nonmutating set }
  • titleWidget Extension method

    Retrieves the title widget of the header.

    See [methodGtk.HeaderBar.set_title_widget].

    Declaration

    Swift

    @inlinable
    var titleWidget: WidgetRef! { get nonmutating set }