About all my projects
Gnome::Gtk4::HeaderBar

Gnome::Gtk4::HeaderBar

Description

Gnome::Gtk4::HeaderBar is a widget for creating custom title bars for windows.

No caption

Gnome::Gtk4::HeaderBar is similar to a horizontal Gnome::Gtk4::CenterBox. 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.

Gnome::Gtk4::HeaderBar can add typical window frame controls, such as minimize, maximize and close buttons, or the window icon.

For these reasons, Gnome::Gtk4::HeaderBar is the natural choice for use as the custom titlebar widget of a Gnome::Gtk4::Window (see .set-titlebar() in class Gnome::Gtk4::Window), as it gives features typical of titlebars while allowing the addition of child widgets.

GtkHeaderBar as GtkBuildable

The Gnome::Gtk4::HeaderBar implementation of the Gnome::Gtk4::R-Buildable 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 Gnome::Gtk4::HeaderBar uses a Gnome::Gtk4::Label displaying the title of the window it is contained in as the title widget, equivalent to the following UI definition:

CSS nodes

A Gnome::Gtk4::HeaderBar'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 Gnome::Gtk4::WindowControls for details, as well as other children.

Accessibility

Gnome::Gtk4::HeaderBar uses the GTK_ACCESSIBLE_ROLE_GROUP role.

Class initialization

new

:native-object

Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.

multi method new ( N-Object :$native-object! )

new-headerbar

Creates a new Gnome::Gtk4::HeaderBar widget.

method new-headerbar ( --> Gnome::Gtk4::HeaderBar \)

Methods

get-decoration-layout

Gets the decoration layout of the Gnome::Gtk4::HeaderBar.

method get-decoration-layout (--> Str )

Return value; the decoration layout.

get-show-title-buttons

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

method get-show-title-buttons (--> Bool )

Return value; True if title buttons are shown.

get-title-widget

Retrieves the title widget of the header.

See .set-title-widget().

method get-title-widget (--> N-Object )

Return value; the title widget of the header.

pack-end

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

method pack-end ( N-Object() $child )
  • $child; the Gnome::Gtk4::Widget to be added to $bar.

pack-start

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

method pack-start ( N-Object() $child )
  • $child; the Gnome::Gtk4::Widget to be added to $bar.

remove

Removes a child from the Gnome::Gtk4::HeaderBar.

The child must have been added with .pack-start(), .pack-end() or .set-title-widget().

method remove ( N-Object() $child )
  • $child; the child to remove.

set-decoration-layout

Sets the decoration layout for this header bar.

This property overrides the gtk-decoration-layout defined in Gnome::Gtk4::Settings 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 an icon on the left, and minimize, maximize and close buttons on the right.

method set-decoration-layout ( Str $layout )
  • $layout; a decoration layout, or undefined to unset the layout.

set-show-title-buttons

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

method set-show-title-buttons ( Bool() $setting )
  • $setting; True to show standard title buttons.

set-title-widget

Sets the title for the Gnome::Gtk4::HeaderBar.

When set to undefined, 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 undefined, for the window title label to be visible again.

method set-title-widget ( N-Object() $title-widget )
  • $title-widget; a widget to use for a title.