CtkHeaderBar

CtkHeaderBar — A box with a centered child

Functions

Properties

CtkWidget * custom-title Read / Write
char * decoration-layout Read / Write
gboolean decoration-layout-set Read / Write
gboolean has-subtitle Read / Write
gboolean show-close-button Read / Write
int spacing Read / Write
char * subtitle Read / Write
char * title Read / Write

Types and Values

struct CtkHeaderBar

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── CtkWidget
            ╰── CtkContainer
                ╰── CtkHeaderBar

Implemented Interfaces

CtkHeaderBar implements AtkImplementorIface and CtkBuildable.

Includes

#include <ctk/ctk.h>

Description

CtkHeaderBar is similar to a horizontal CtkBox. It allows children to be placed at the start or the end. In addition, it allows a title and subtitle 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. The height of the titlebar will be set to provide sufficient space for the subtitle, even if none is currently set. If a subtitle is not needed, the space reservation can be turned off with ctk_header_bar_set_has_subtitle().

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

For these reasons, CtkHeaderBar is the natural choice for use as the custom titlebar widget of a CtkWindow (see ctk_window_set_titlebar()), as it gives features typical of titlebars while allowing the addition of child widgets.

Functions

ctk_header_bar_new ()

CtkWidget *
ctk_header_bar_new (void);

Creates a new CtkHeaderBar widget.

Returns

a new CtkHeaderBar

Since: 3.10


ctk_header_bar_set_title ()

void
ctk_header_bar_set_title (CtkHeaderBar *bar,
                          const gchar *title);

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

Parameters

bar

a CtkHeaderBar

 

title

a title, or NULL.

[allow-none]

Since: 3.10


ctk_header_bar_get_title ()

const gchar *
ctk_header_bar_get_title (CtkHeaderBar *bar);

Retrieves the title of the header. See ctk_header_bar_set_title().

Parameters

bar

a CtkHeaderBar

 

Returns

the title of the header, or NULL if none has been set explicitly. The returned string is owned by the widget and must not be modified or freed.

[nullable]

Since: 3.10


ctk_header_bar_set_subtitle ()

void
ctk_header_bar_set_subtitle (CtkHeaderBar *bar,
                             const gchar *subtitle);

Sets the subtitle of the CtkHeaderBar. The title should give a user an additional detail to help him identify the current view.

Note that CtkHeaderBar by default reserves room for the subtitle, even if none is currently set. If this is not desired, set the “has-subtitle” property to FALSE.

Parameters

bar

a CtkHeaderBar

 

subtitle

a subtitle, or NULL.

[allow-none]

Since: 3.10


ctk_header_bar_get_subtitle ()

const gchar *
ctk_header_bar_get_subtitle (CtkHeaderBar *bar);

Retrieves the subtitle of the header. See ctk_header_bar_set_subtitle().

Parameters

bar

a CtkHeaderBar

 

Returns

the subtitle of the header, or NULL if none has been set explicitly. The returned string is owned by the widget and must not be modified or freed.

[nullable]

Since: 3.10


ctk_header_bar_set_has_subtitle ()

void
ctk_header_bar_set_has_subtitle (CtkHeaderBar *bar,
                                 gboolean setting);

Sets whether the header bar should reserve space for a subtitle, even if none is currently set.

Parameters

bar

a CtkHeaderBar

 

setting

TRUE to reserve space for a subtitle

 

Since: 3.12


ctk_header_bar_get_has_subtitle ()

gboolean
ctk_header_bar_get_has_subtitle (CtkHeaderBar *bar);

Retrieves whether the header bar reserves space for a subtitle, regardless if one is currently set or not.

Parameters

bar

a CtkHeaderBar

 

Returns

TRUE if the header bar reserves space for a subtitle

Since: 3.12


ctk_header_bar_set_custom_title ()

void
ctk_header_bar_set_custom_title (CtkHeaderBar *bar,
                                 CtkWidget *title_widget);

Sets a custom title for the CtkHeaderBar.

The title should help a user identify the current view. This supersedes any title set by ctk_header_bar_set_title() or ctk_header_bar_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.

Parameters

bar

a CtkHeaderBar

 

title_widget

a custom widget to use for a title.

[allow-none]

Since: 3.10


ctk_header_bar_get_custom_title ()

CtkWidget *
ctk_header_bar_get_custom_title (CtkHeaderBar *bar);

Retrieves the custom title widget of the header. See ctk_header_bar_set_custom_title().

Parameters

bar

a CtkHeaderBar

 

Returns

the custom title widget of the header, or NULL if none has been set explicitly.

[nullable][transfer none]

Since: 3.10


ctk_header_bar_pack_start ()

void
ctk_header_bar_pack_start (CtkHeaderBar *bar,
                           CtkWidget *child);

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

Parameters

bar

A CtkHeaderBar

 

child

the CtkWidget to be added to bar

 

Since: 3.10


ctk_header_bar_pack_end ()

void
ctk_header_bar_pack_end (CtkHeaderBar *bar,
                         CtkWidget *child);

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

Parameters

bar

A CtkHeaderBar

 

child

the CtkWidget to be added to bar

 

Since: 3.10


ctk_header_bar_set_show_close_button ()

void
ctk_header_bar_set_show_close_button (CtkHeaderBar *bar,
                                      gboolean setting);

Sets whether this header bar shows the standard window decorations, including close, maximize, and minimize.

Parameters

bar

a CtkHeaderBar

 

setting

TRUE to show standard window decorations

 

Since: 3.10


ctk_header_bar_get_show_close_button ()

gboolean
ctk_header_bar_get_show_close_button (CtkHeaderBar *bar);

Returns whether this header bar shows the standard window decorations.

Parameters

bar

a CtkHeaderBar

 

Returns

TRUE if the decorations are shown

Since: 3.10


ctk_header_bar_set_decoration_layout ()

void
ctk_header_bar_set_decoration_layout (CtkHeaderBar *bar,
                                      const gchar *layout);

Sets the decoration layout for this header bar, overriding the “ctk-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, 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.

Parameters

bar

a CtkHeaderBar

 

layout

a decoration layout, or NULL to unset the layout.

[allow-none]

Since: 3.12


ctk_header_bar_get_decoration_layout ()

const gchar *
ctk_header_bar_get_decoration_layout (CtkHeaderBar *bar);

Gets the decoration layout set with ctk_header_bar_set_decoration_layout().

Parameters

bar

a CtkHeaderBar

 

Returns

the decoration layout

Since: 3.12

Types and Values

struct CtkHeaderBar

struct CtkHeaderBar;

Property Details

The “custom-title” property

  “custom-title”             CtkWidget *

Custom title widget to display.

Owner: CtkHeaderBar

Flags: Read / Write


The “decoration-layout” property

  “decoration-layout”        char *

The decoration layout for buttons. If this property is not set, the “ctk-decoration-layout” setting is used.

See ctk_header_bar_set_decoration_layout() for information about the format of this string.

Owner: CtkHeaderBar

Flags: Read / Write

Default value: NULL

Since: 3.12


The “decoration-layout-set” property

  “decoration-layout-set”    gboolean

Set to TRUE if “decoration-layout” is set.

Owner: CtkHeaderBar

Flags: Read / Write

Default value: FALSE

Since: 3.12


The “has-subtitle” property

  “has-subtitle”             gboolean

If TRUE, reserve space for a subtitle, even if none is currently set.

Owner: CtkHeaderBar

Flags: Read / Write

Default value: TRUE

Since: 3.12


The “show-close-button” property

  “show-close-button”        gboolean

Whether to show window decorations.

Which buttons are actually shown and where is determined by the “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).

Owner: CtkHeaderBar

Flags: Read / Write

Default value: FALSE


The “spacing” property

  “spacing”                  int

The amount of space between children.

Owner: CtkHeaderBar

Flags: Read / Write

Allowed values: >= 0

Default value: 6


The “subtitle” property

  “subtitle”                 char *

The subtitle to display.

Owner: CtkHeaderBar

Flags: Read / Write

Default value: NULL


The “title” property

  “title”                    char *

The title to display.

Owner: CtkHeaderBar

Flags: Read / Write

Default value: NULL

See Also

CtkBox, CtkActionBar