Struct gtk4::HeaderBar[][src]

pub struct HeaderBar(_);
Expand description

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

An example GtkHeaderBar

HeaderBar is similar to a horizontal 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.

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

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

GtkHeaderBar as GtkBuildable

The HeaderBar implementation of the 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 HeaderBar uses a Label 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 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 WindowControls for details, as well as other children.

Accessibility

HeaderBar uses the AccessibleRole::Group role.

Implements

WidgetExt, glib::ObjectExt, AccessibleExt, BuildableExt, ConstraintTargetExt, WidgetExtManual, AccessibleExtManual

Implementations

Creates a new HeaderBar widget.

Returns

a new HeaderBar

Creates a new builder-pattern struct instance to construct HeaderBar objects.

This method returns an instance of HeaderBarBuilder which can be used to create HeaderBar objects.

Gets the decoration layout of the HeaderBar.

Returns

the decoration layout

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

Returns

true if title buttons are shown

Retrieves the title widget of the header.

See set_title_widget().

Returns

the title widget of the header

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

child

the Widget to be added to self

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

child

the Widget to be added to self

Removes a child from the HeaderBar.

The child must have been added with pack_start(), pack_end() or set_title_widget().

child

the child to remove

Sets the decoration layout for this header bar.

This property overrides the property::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.

layout

a decoration layout, or None to unset the layout

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

setting

true to show standard title buttons

Sets the title for the HeaderBar.

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

title_widget

a widget to use for a title

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Returns the type identifier of Self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Upcasts an object to a superclass or interface T. Read more

Upcasts an object to a reference of its superclass or interface T. Read more

Tries to downcast to a subclass or interface implementor T. Read more

Tries to downcast to a reference of its subclass or interface implementor T. Read more

Tries to cast to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

Tries to cast to reference to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

Casts to T unconditionally. Read more

Casts to &T unconditionally. Read more

Performs the conversion.

Performs the conversion.

Returns true if the object is an instance of (can be cast to) T.

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Same as connect but takes a SignalId instead of a signal name.

Same as connect_local but takes a SignalId instead of a signal name.

Same as connect_unsafe but takes a SignalId instead of a signal name.

Emit signal by signal id.

Same as emit but takes Value for the arguments.

Emit signal by its name.

Same as emit_by_name but takes Value for the arguments.

Emit signal with details by signal id.

Same as emit_with_details but takes Value for the arguments.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Returns a SendValue clone of self.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.