Struct gtk4::HeaderBar [−][src]
pub struct HeaderBar(_);
Expand description
HeaderBar
is a widget for creating custom title bars for windows.
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 builder-pattern struct instance to construct HeaderBar
objects.
This method returns an instance of HeaderBarBuilder
which can be used to create HeaderBar
objects.
Retrieves the title widget of the header.
See set_title_widget()
.
Returns
the title widget of the header
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 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
pub fn connect_decoration_layout_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
Trait Implementations
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
Returns the type identifier of Self
.
Auto Trait Implementations
impl RefUnwindSafe for HeaderBar
impl UnwindSafe for HeaderBar
Blanket Implementations
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
Returns true
if the object is an instance of (can be cast to) T
.
pub fn set_property<'a, N, V>(
&self,
property_name: N,
value: V
) -> Result<(), BoolError> where
N: Into<&'a str>,
V: ToValue,
pub fn set_property_from_value<'a, N>(
&self,
property_name: N,
value: &Value
) -> Result<(), BoolError> where
N: Into<&'a str>,
pub fn set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>
pub fn has_property<'a, N>(&self, property_name: N, type_: Option<Type>) -> bool where
N: Into<&'a str>,
pub fn find_property<'a, N>(&self, property_name: N) -> Option<ParamSpec> where
N: Into<&'a str>,
Safety Read more
Safety Read more
Safety Read more
Safety Read more
pub fn connect<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
Same as connect
but takes a SignalId
instead of a signal name.
pub fn connect_local<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: 'static + Fn(&[Value]) -> Option<Value>,
Same as connect_local
but takes a SignalId
instead of a signal name.
pub unsafe fn connect_unsafe<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: Fn(&[Value]) -> Option<Value>,
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.
pub fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
pub fn connect_notify_local<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec),
pub unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: Fn(&T, &ParamSpec),
pub fn bind_property<'a, O, N, M>(
&'a self,
source_property: N,
target: &'a O,
target_property: M
) -> BindingBuilder<'a> where
O: ObjectType,
N: Into<&'a str>,
M: Into<&'a str>,
Returns a SendValue
clone of self
.