HeaderBarProtocol
public protocol HeaderBarProtocol : WidgetProtocol
GtkHeaderBar
is a widget for creating custom title bars for windows.
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 [method
Gtk.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:
<object class="GtkHeaderBar">
<property name="title-widget">
<object class="GtkLabel">
<property name="label" translatable="yes">Label</property>
<property name="single-line-mode">True</property>
<property name="ellipsize">end</property>
<property name="width-chars">5</property>
<style>
<class name="title"/>
</style>
</object>
</property>
</object>
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.
-
Untyped pointer to the underlying
GtkHeaderBar
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
header_bar_ptr
Default implementationTyped 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)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) 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 transformationtransform_to
ValueTransformer
to use for backwards transformationReturn 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:
Extension methodvalue: ) 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
-
getDecorationLayout()
Extension methodGets the decoration layout of the
GtkHeaderBar
.Declaration
Swift
@inlinable func getDecorationLayout() -> String!
-
getShowTitleButtons()
Extension methodReturns whether this header bar shows the standard window title buttons.
Declaration
Swift
@inlinable func getShowTitleButtons() -> Bool
-
getTitleWidget()
Extension methodRetrieves the title widget of the header.
See [method
Gtk.HeaderBar.set_title_widget
].Declaration
Swift
@inlinable func getTitleWidget() -> WidgetRef!
-
packEnd(child:
Extension method) Adds
child
tobar
, packed with reference to the end of thebar
.Declaration
Swift
@inlinable func packEnd<WidgetT>(child: WidgetT) where WidgetT : WidgetProtocol
-
packStart(child:
Extension method) Adds
child
tobar
, packed with reference to the start of thebar
.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 [method
Gtk.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 [property
Gtk.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)
-
setShowTitleButtons(setting:
Extension method) 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 methodGets the decoration layout of the
GtkHeaderBar
.Declaration
Swift
@inlinable var decorationLayout: String! { get nonmutating set }
-
showTitleButtons
Extension methodReturns whether this header bar shows the standard window title buttons.
Declaration
Swift
@inlinable var showTitleButtons: Bool { get nonmutating set }
-
titleWidget
Extension methodRetrieves the title widget of the header.
See [method
Gtk.HeaderBar.set_title_widget
].Declaration
Swift
@inlinable var titleWidget: WidgetRef! { get nonmutating set }