GTK+ 3 Reference Manual: GtkHeaderBar

## GtkHeaderBar GtkHeaderBar — A box with a centered child |

## Synopsis

    #include <gtk/gtk.h>

    struct              GtkHeaderBar;
    GtkWidget *         gtk_header_bar_new                  (void);
    void                gtk_header_bar_set_title            (GtkHeaderBar *bar,
                                                             const gchar *title);
    const gchar *       gtk_header_bar_get_title            (GtkHeaderBar *bar);
    void                gtk_header_bar_set_subtitle         (GtkHeaderBar *bar,
                                                             const gchar *subtitle);
    const gchar *       gtk_header_bar_get_subtitle         (GtkHeaderBar *bar);
    void                gtk_header_bar_set_has_subtitle     (GtkHeaderBar *bar,
                                                             gboolean setting);
    gboolean            gtk_header_bar_get_has_subtitle     (GtkHeaderBar *bar);
    void                gtk_header_bar_set_custom_title     (GtkHeaderBar *bar,
                                                             GtkWidget *title_widget);
    GtkWidget *         gtk_header_bar_get_custom_title     (GtkHeaderBar *bar);
    void                gtk_header_bar_pack_start           (GtkHeaderBar *bar,
                                                             GtkWidget *child);
    void                gtk_header_bar_pack_end             (GtkHeaderBar *bar,
                                                             GtkWidget *child);
    void                gtk_header_bar_set_show_close_button
                                                            (GtkHeaderBar *bar,
                                                             gboolean setting);
    gboolean            gtk_header_bar_get_show_close_button
                                                            (GtkHeaderBar *bar);
    void                gtk_header_bar_set_decoration_layout
                                                            (GtkHeaderBar *bar,
                                                             const gchar *layout);
    const gchar *       gtk_header_bar_get_decoration_layout
                                                            (GtkHeaderBar *bar);

## Object Hierarchy

      GObject
       +----GInitiallyUnowned
             +----GtkWidget
                   +----GtkContainer
                         +----GtkHeaderBar

## Implemented Interfaces

GtkHeaderBar implements AtkImplementorIface and GtkBuildable.

## Properties

      "custom-title"             GtkWidget*            : Read / Write / Construct
      "decoration-layout"        gchar*                : Read / Write
      "decoration-layout-set"    gboolean              : Read / Write
      "has-subtitle"             gboolean              : Read / Write
      "show-close-button"        gboolean              : Read / Write
      "spacing"                  gint                  : Read / Write
      "subtitle"                 gchar*                : Read / Write
      "title"                    gchar*                : Read / Write

## Child Properties

      "pack-type"                GtkPackType           : Read / Write
      "position"                 gint                  : Read

## Description

GtkHeaderBar is similar to a horizontal GtkBox, it allows to place children 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 `gtk_header_bar_set_has_subtitle()`.

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

## Details

### struct GtkHeaderBar

    struct GtkHeaderBar;

### gtk_header_bar_new ()

    GtkWidget *         gtk_header_bar_new                  (void);

Creates a new GtkHeaderBar widget.

Returns : | a new GtkHeaderBar

Since 3.10

### gtk_header_bar_set_title ()

    void                gtk_header_bar_set_title            (GtkHeaderBar *bar,
                                                             const gchar *title);

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

`bar` : | a GtkHeaderBar
`title` : | a title, or `NULL`. [allow-none]

Since 3.10

### gtk_header_bar_get_title ()

    const gchar *       gtk_header_bar_get_title            (GtkHeaderBar *bar);

Retrieves the title of the header. See `gtk_header_bar_set_title()`.

`bar` : | a GtkHeaderBar
Returns : | the title of the header, or `NULL` if none has been set explicitely. The returned string is owned by the widget and must not be modified or freed.

Since 3.10

### gtk_header_bar_set_subtitle ()

    void                gtk_header_bar_set_subtitle         (GtkHeaderBar *bar,
                                                             const gchar *subtitle);

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

Note that GtkHeaderBar 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`.

`bar` : | a GtkHeaderBar
`subtitle` : | a subtitle, or `NULL`. [allow-none]

Since 3.10

### gtk_header_bar_get_subtitle ()

    const gchar *       gtk_header_bar_get_subtitle         (GtkHeaderBar *bar);

Retrieves the subtitle of the header. See `gtk_header_bar_set_subtitle()`.

`bar` : | a GtkHeaderBar
Returns : | the subtitle of the header, or `NULL` if none has been set explicitely. The returned string is owned by the widget and must not be modified or freed.

Since 3.10

### gtk_header_bar_set_has_subtitle ()

    void                gtk_header_bar_set_has_subtitle     (GtkHeaderBar *bar,
                                                             gboolean setting);

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

`bar` : | a GtkHeaderBar
`setting` : | `TRUE` to reserve space for a subtitle

Since 3.12

### gtk_header_bar_get_has_subtitle ()

    gboolean            gtk_header_bar_get_has_subtitle     (GtkHeaderBar *bar);

`bar` : | a GtkHeaderBar
Returns : | whether the header bar reserves space for a subtitle.

Since 3.12

### gtk_header_bar_set_custom_title ()

    void                gtk_header_bar_set_custom_title     (GtkHeaderBar *bar,
                                                             GtkWidget *title_widget);

Sets a custom title for the GtkHeaderBar.

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

`bar` : | a GtkHeaderBar
`title_widget` : | a custom widget to use for a title. [allow-none]

Since 3.10

### gtk_header_bar_get_custom_title ()

    GtkWidget *         gtk_header_bar_get_custom_title     (GtkHeaderBar *bar);

Retrieves the custom title widget of the header. See `gtk_header_bar_set_custom_title()`.

`bar` : | a GtkHeaderBar
Returns : | the custom title widget of the header, or `NULL` if none has been set explicitely. [transfer none]

Since 3.10

### gtk_header_bar_pack_start ()

    void                gtk_header_bar_pack_start           (GtkHeaderBar *bar,
                                                             GtkWidget *child);

Adds `child` to `box`, packed with reference to the start of the `box`.

`bar` : | A GtkHeaderBar
`child` : | the GtkWidget to be added to `bar`

Since 3.10

### gtk_header_bar_pack_end ()

    void                gtk_header_bar_pack_end             (GtkHeaderBar *bar,
                                                             GtkWidget *child);

Adds `child` to `box`, packed with reference to the end of the `box`.

`bar` : | A GtkHeaderBar
`child` : | the GtkWidget to be added to `bar`

Since 3.10

### gtk_header_bar_set_show_close_button ()

    void                gtk_header_bar_set_show_close_button
                                                            (GtkHeaderBar *bar,
                                                             gboolean setting);

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

`bar` : | a GtkHeaderBar
`setting` : | `TRUE` to show standard widow decorations

Since 3.10

### gtk_header_bar_get_show_close_button ()

    gboolean            gtk_header_bar_get_show_close_button
                                                            (GtkHeaderBar *bar);

Returns whether this header bar shows the standard window decorations.

`bar` : | a GtkHeaderBar
Returns : | `TRUE` if the decorations are shown

Since 3.10

### gtk_header_bar_set_decoration_layout ()

    void                gtk_header_bar_set_decoration_layout
                                                            (GtkHeaderBar *bar,
                                                             const gchar *layout);

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

`bar` : | a GtkHeaderBar
`layout` : | a decoration layout, or `NULL` to unset the layout. [allow-none]

Since 3.12

### gtk_header_bar_get_decoration_layout ()

    const gchar *       gtk_header_bar_get_decoration_layout
                                                            (GtkHeaderBar *bar);

Gets the decoration layout set with `gtk_header_bar_set_decoration_layout()`.

`bar` : | a GtkHeaderBar
Returns : | the decoration layout

Since 3.12

## Property Details

### The `"custom-title"` property

      "custom-title"             GtkWidget*            : Read / Write / Construct

Custom title widget to display.

### The `"decoration-layout"` property

      "decoration-layout"        gchar*                : Read / Write

The decoration layout for buttons. If this property is not set, the "gtk-decoration-layout" setting is used.

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

Default value: NULL

Since 3.12

### The `"decoration-layout-set"` property

      "decoration-layout-set"    gboolean              : Read / Write

Set to `TRUE` if "decoration-layout" is set.

Default value: FALSE

Since 3.12

### The `"has-subtitle"` property

      "has-subtitle"             gboolean              : Read / Write

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

Default value: TRUE

Since 3.12

### The `"show-close-button"` property

      "show-close-button"        gboolean              : Read / Write

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).

Default value: FALSE

### The `"spacing"` property

      "spacing"                  gint                  : Read / Write

The amount of space between children.

Allowed values: >= 0

Default value: 6

### The `"subtitle"` property

      "subtitle"                 gchar*                : Read / Write

The subtitle to display.

Default value: NULL

### The `"title"` property

      "title"                    gchar*                : Read / Write

The title to display.

Default value: NULL

## Child Property Details

### The `"pack-type"` child property

      "pack-type"                GtkPackType           : Read / Write

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

Default value: GTK_PACK_START

### The `"position"` child property

      "position"                 gint                  : Read

The index of the child in the parent.

Allowed values: >= -1

Default value: 0

## See Also

GtkBox