Handy.HeaderBar

g Atk.ImplementorIface Atk.ImplementorIface Gtk.Widget Gtk.Widget Atk.ImplementorIface->Gtk.Widget GObject.GInterface GObject.GInterface GObject.GInterface->Atk.ImplementorIface Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Buildable->Gtk.Widget Gtk.Container Gtk.Container Handy.HeaderBar Handy.HeaderBar Gtk.Container->Handy.HeaderBar Gtk.Widget->Gtk.Container

Subclasses:

None

Methods

Inherited:

Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10)

Structs:

Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)

class

new ()

get_centering_policy ()

get_custom_title ()

get_decoration_layout ()

get_has_subtitle ()

get_interpolate_size ()

get_show_close_button ()

get_subtitle ()

get_title ()

get_transition_duration ()

get_transition_running ()

pack_end (child)

pack_start (child)

set_centering_policy (centering_policy)

set_custom_title (title_widget)

set_decoration_layout (layout)

set_has_subtitle (setting)

set_interpolate_size (interpolate_size)

set_show_close_button (setting)

set_subtitle (subtitle)

set_title (title)

set_transition_duration (duration)

Virtual Methods

Inherited:

Gtk.Container (10), Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10)

Properties

Inherited:

Gtk.Container (3), Gtk.Widget (39)

Name

Type

Flags

Short Description

centering-policy

Handy.CenteringPolicy

r/w/en

The policy to horizontally align the center widget

custom-title

Gtk.Widget

r/w

Custom title widget to display

decoration-layout

str

r/w

The layout for window decorations

decoration-layout-set

bool

r/w

Whether the decoration-layout property has been set

has-subtitle

bool

r/w/en

Whether to reserve space for a subtitle

interpolate-size

bool

r/w/en

Whether or not the size should smoothly change when changing between differently sized children

show-close-button

bool

r/w/en

Whether to show window decorations

spacing

int

r/w/en

The amount of space between children

subtitle

str

r/w

The subtitle to display

title

str

r/w

The title to display

transition-duration

int

r/w/en

The animation duration, in milliseconds

transition-running

bool

r

Whether or not the transition is currently running

Child Properties

Name

Type

Default

Flags

Short Description

pack-type

Gtk.PackType

Gtk.PackType.START

r/w

A Gtk.PackType indicating whether the child is packed with reference to the start or end of the parent

position

int

0

r/w

The index of the child in the parent

Style Properties

Inherited:

Gtk.Widget (17)

Signals

Inherited:

Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)

Fields

Inherited:

Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)

Name

Type

Access

Description

parent_instance

Gtk.Container

r

Class Details

class Handy.HeaderBar(**kwargs)
Bases:

Gtk.Container

Abstract:

No

Structure:

Handy.HeaderBarClass

A title bar widget.

HdyHeaderBar is similar to [class`Gtk`.HeaderBar] but is designed to fix some of its shortcomings for adaptive applications.

HdyHeaderBar doesn’t force the custom title widget to be vertically centered, hence allowing it to fill up the whole height, which is e.g. needed for [class`ViewSwitcher`].

When used in a mobile dialog, HdyHeaderBar will replace its window decorations by a back button allowing to close it. It doesn’t have to be its direct child and you can use any complex contraption you like as the dialog’s titlebar.

HdyHeaderBar can be used in window’s content area rather than titlebar, and will still be draggable and will handle right click, middle click and double click as expected from a titlebar. This is particularly useful with [class`Window`] or [class`ApplicationWindow`].

CSS nodes

HdyHeaderBar has a single CSS node with name headerbar.

Added in version 1.0.

classmethod new()
Returns:

the newly created HdyHeaderBar.

Return type:

Gtk.Widget

Creates a new HdyHeaderBar.

Added in version 1.0.

get_centering_policy()
Returns:

the centering policy

Return type:

Handy.CenteringPolicy

Gets the policy self follows to horizontally align its center widget.

Added in version 1.0.

get_custom_title()
Returns:

the custom title widget of the header

Return type:

Gtk.Widget or None

Retrieves the custom title widget of the header.

Added in version 1.0.

get_decoration_layout()
Returns:

the decoration layout

Return type:

str

Gets the decoration layout.

Added in version 1.0.

get_has_subtitle()
Returns:

TRUE if the header bar reserves space for a subtitle

Return type:

bool

Gets whether space is reserved for a subtitle, regardless if one is currently set or not.

Added in version 1.0.

get_interpolate_size()
Returns:

whether self interpolates its size on visible child change

Return type:

bool

Gets whether self should interpolate its size on visible child change.

Added in version 1.0.

get_show_close_button()
Returns:

whether decorations are shown

Return type:

bool

Gets whether this header bar shows the standard window decorations.

Added in version 1.0.

get_subtitle()
Returns:

the subtitle of the header

Return type:

str or None

Gets the subtitle of the header.

Added in version 1.0.

get_title()
Returns:

the title of the header.

Return type:

str or None

Retrieves the title of the header.

Added in version 1.0.

get_transition_duration()
Returns:

the transition duration, in milliseconds

Return type:

int

Gets the amount of time that transitions between pages will take.

Added in version 1.0.

get_transition_running()
Returns:

whether the transition is currently running

Return type:

bool

Gets whether the self is currently in a transition from one page to another.

Added in version 1.0.

pack_end(child)
Parameters:

child (Gtk.Widget) – the widget to be added to self

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

Added in version 1.0.

pack_start(child)
Parameters:

child (Gtk.Widget) – the widget to be added to self

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

Added in version 1.0.

set_centering_policy(centering_policy)
Parameters:

centering_policy (Handy.CenteringPolicy) – the centering policy

Sets the policy self must follow to horizontally align its center widget.

Added in version 1.0.

set_custom_title(title_widget)
Parameters:

title_widget (Gtk.Widget or None) – a custom widget to use for a title

Sets a custom title for the header bar.

The title should help a user identify the current view. This supersedes any title set by [method`HeaderBar`.set_title] or [method`HeaderBar`.set_subtitle]. To achieve the same style as the builtin title and subtitle, use the .title and .subtitle style classes.

You should set the custom title to NULL, for the header title label to be visible again.

Added in version 1.0.

set_decoration_layout(layout)
Parameters:

layout (str or None) – a decoration layout

Sets the decoration layout for this header bar.

Added in version 1.0.

set_has_subtitle(setting)
Parameters:

setting (bool) – TRUE to reserve space for a subtitle

Sets whether space is reserved for a subtitle, even if none is currently set.

Added in version 1.0.

set_interpolate_size(interpolate_size)
Parameters:

interpolate_size (bool) – TRUE to interpolate the size

Sets whether self should interpolate its size on visible child change.

Added in version 1.0.

set_show_close_button(setting)
Parameters:

setting (bool) – TRUE to show standard window decorations

Sets whether this header bar shows the standard window decorations.

Added in version 1.0.

set_subtitle(subtitle)
Parameters:

subtitle (str or None) – a subtitle

Sets the subtitle of the header bar.

The title should give a user an additional detail to help them identify the current view.

Note that [class`HeaderBar`] by default reserves room for the subtitle, even if none is currently set. If this is not desired, set the [property`HeaderBar`:py:data::has-subtitle<Handy.HeaderBar.props.has_subtitle>] property to FALSE.

Added in version 1.0.

set_title(title)
Parameters:

title (str or None) – a title

Sets the title of the [class`HeaderBar`].

The title should help a user identify the current view. A good title should not include the application name.

Added in version 1.0.

set_transition_duration(duration)
Parameters:

duration (int) – the new duration, in milliseconds

Sets the duration that transitions between pages will take.

Added in version 1.0.

Property Details

Handy.HeaderBar.props.centering_policy
Name:

centering-policy

Type:

Handy.CenteringPolicy

Default Value:

Handy.CenteringPolicy.LOOSE

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The policy for aligning the center widget.

Added in version 1.0.

Handy.HeaderBar.props.custom_title
Name:

custom-title

Type:

Gtk.Widget

Default Value:

None

Flags:

READABLE, WRITABLE

Custom title widget to display.

Added in version 1.0.

Handy.HeaderBar.props.decoration_layout
Name:

decoration-layout

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

The decoration layout for buttons.

If this property is not set, the [property`Gtk`.Settings:gtk-decoration-layout] setting is used.

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 start from those on the end. Recognized button names are minimize, maximize, close, icon (the window icon) and menu (a menu button for the fallback app menu).

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

Added in version 1.0.

Handy.HeaderBar.props.decoration_layout_set
Name:

decoration-layout-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether [property`HeaderBar`:py:data::decoration-layout<Handy.HeaderBar.props.decoration_layout>] is set.

Added in version 1.0.

Handy.HeaderBar.props.has_subtitle
Name:

has-subtitle

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether to reserve space for a subtitle, even if none is currently set.

Added in version 1.0.

Handy.HeaderBar.props.interpolate_size
Name:

interpolate-size

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether the size should smoothly change when changing between children.

If TRUE, the header bar will interpolate its size between the one of the previous visible child and the one of the new visible child, according to the set transition duration and the orientation, e.g. if the orientation is horizontal, it will interpolate the its height.

Added in version 1.0.

Handy.HeaderBar.props.show_close_button
Name:

show-close-button

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether to show window decorations.

Which buttons are actually shown and where is determined by the [property`HeaderBar`:py:data::decoration-layout<Handy.HeaderBar.props.decoration_layout>] property, and by the state of the window (e.g. a close button will not be shown if the window can’t be closed).

Added in version 1.0.

Handy.HeaderBar.props.spacing
Name:

spacing

Type:

int

Default Value:

6

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The amount of space between children.

Added in version 1.0.

Handy.HeaderBar.props.subtitle
Name:

subtitle

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

The subtitle to display.

Added in version 1.0.

Handy.HeaderBar.props.title
Name:

title

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

The title to display.

Added in version 1.0.

Handy.HeaderBar.props.transition_duration
Name:

transition-duration

Type:

int

Default Value:

200

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The transition duration, in milliseconds.

Added in version 1.0.

Handy.HeaderBar.props.transition_running
Name:

transition-running

Type:

bool

Default Value:

False

Flags:

READABLE

Whether or not the transition is currently running.

Added in version 1.0.