gi-gtk4-4.0.12: Gtk 4.x bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gtk.Objects.HeaderBar

Contents

- Exported types
- Methods
  - getDecorationLayout
  - getShowTitleButtons
  - getTitleWidget
  - getUseNativeControls
  - new
  - packEnd
  - packStart
  - remove
  - setDecorationLayout
  - setShowTitleButtons
  - setTitleWidget
  - setUseNativeControls
- Properties
  - decorationLayout
  - showTitleButtons
  - titleWidget
  - useNativeControls

Description

Creates a custom titlebar for a window.

<picture> <source srcset="headerbar-dark.png" media="(prefers-color-scheme: dark)"> <img alt="An example GtkHeaderBar" src="headerbar.png"> </picture>

`GtkHeaderBar` is similar to a horizontal `GtkCenterBox`. 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.

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

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

## GtkHeaderBar as GtkBuildable

The `GtkHeaderBar` implementation of the `GtkBuildable` 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 `GtkHeaderBar` uses a `GtkLabel` displaying the title of the window it is contained in as the title widget, equivalent to the following UI definition:

### xml code

    <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 `GtkHeaderBar`'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

`GtkHeaderBar` uses the `AccessibleRoleGroup` role.

Synopsis

- newtype HeaderBar = HeaderBar (ManagedPtr HeaderBar)
- class (GObject o, IsDescendantOf HeaderBar o) => IsHeaderBar o
- toHeaderBar :: (MonadIO m, IsHeaderBar o) => o -> m HeaderBar
- headerBarGetDecorationLayout :: (HasCallStack, MonadIO m, IsHeaderBar a) => a -> m (Maybe Text)
- headerBarGetShowTitleButtons :: (HasCallStack, MonadIO m, IsHeaderBar a) => a -> m Bool
- headerBarGetTitleWidget :: (HasCallStack, MonadIO m, IsHeaderBar a) => a -> m (Maybe Widget)
- headerBarGetUseNativeControls :: (HasCallStack, MonadIO m, IsHeaderBar a) => a -> m Bool
- headerBarNew :: (HasCallStack, MonadIO m) => m HeaderBar
- headerBarPackEnd :: (HasCallStack, MonadIO m, IsHeaderBar a, IsWidget b) => a -> b -> m ()
- headerBarPackStart :: (HasCallStack, MonadIO m, IsHeaderBar a, IsWidget b) => a -> b -> m ()
- headerBarRemove :: (HasCallStack, MonadIO m, IsHeaderBar a, IsWidget b) => a -> b -> m ()
- headerBarSetDecorationLayout :: (HasCallStack, MonadIO m, IsHeaderBar a) => a -> Maybe Text -> m ()
- headerBarSetShowTitleButtons :: (HasCallStack, MonadIO m, IsHeaderBar a) => a -> Bool -> m ()
- headerBarSetTitleWidget :: (HasCallStack, MonadIO m, IsHeaderBar a, IsWidget b) => a -> Maybe b -> m ()
- headerBarSetUseNativeControls :: (HasCallStack, MonadIO m, IsHeaderBar a) => a -> Bool -> m ()
- clearHeaderBarDecorationLayout :: (MonadIO m, IsHeaderBar o) => o -> m ()
- constructHeaderBarDecorationLayout :: (IsHeaderBar o, MonadIO m) => Text -> m (GValueConstruct o)
- getHeaderBarDecorationLayout :: (MonadIO m, IsHeaderBar o) => o -> m (Maybe Text)
- setHeaderBarDecorationLayout :: (MonadIO m, IsHeaderBar o) => o -> Text -> m ()
- constructHeaderBarShowTitleButtons :: (IsHeaderBar o, MonadIO m) => Bool -> m (GValueConstruct o)
- getHeaderBarShowTitleButtons :: (MonadIO m, IsHeaderBar o) => o -> m Bool
- setHeaderBarShowTitleButtons :: (MonadIO m, IsHeaderBar o) => o -> Bool -> m ()
- clearHeaderBarTitleWidget :: (MonadIO m, IsHeaderBar o) => o -> m ()
- constructHeaderBarTitleWidget :: (IsHeaderBar o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o)
- getHeaderBarTitleWidget :: (MonadIO m, IsHeaderBar o) => o -> m (Maybe Widget)
- setHeaderBarTitleWidget :: (MonadIO m, IsHeaderBar o, IsWidget a) => o -> a -> m ()
- constructHeaderBarUseNativeControls :: (IsHeaderBar o, MonadIO m) => Bool -> m (GValueConstruct o)
- getHeaderBarUseNativeControls :: (MonadIO m, IsHeaderBar o) => o -> m Bool
- setHeaderBarUseNativeControls :: (MonadIO m, IsHeaderBar o) => o -> Bool -> m ()

# Exported types

newtype HeaderBar Source #

Memory-managed wrapper type.

Constructors

HeaderBar (ManagedPtr HeaderBar) |

#### Instances

Instances details

Eq HeaderBar Source # |
Instance details Defined in GI.Gtk.Objects.HeaderBar Methods (==) :: HeaderBar -> HeaderBar -> Bool Source # (/=) :: HeaderBar -> HeaderBar -> Bool Source #
GObject HeaderBar Source # |
Instance details Defined in GI.Gtk.Objects.HeaderBar
ManagedPtrNewtype HeaderBar Source # |
Instance details Defined in GI.Gtk.Objects.HeaderBar Methods toManagedPtr :: HeaderBar -> ManagedPtr HeaderBar Source #
TypedObject HeaderBar Source # |
Instance details Defined in GI.Gtk.Objects.HeaderBar Methods glibType :: IO GType Source #
HasParentTypes HeaderBar Source # |
Instance details Defined in GI.Gtk.Objects.HeaderBar
IsGValue (Maybe HeaderBar) Source # | Convert `HeaderBar` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gtk.Objects.HeaderBar Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe HeaderBar -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe HeaderBar) Source #
type ParentTypes HeaderBar Source # |
Instance details Defined in GI.Gtk.Objects.HeaderBar type ParentTypes HeaderBar = '[Widget, Object, Accessible, Buildable, ConstraintTarget]

class (GObject o, IsDescendantOf HeaderBar o) => IsHeaderBar o Source #

Type class for types which can be safely cast to `HeaderBar`, for instance with `toHeaderBar`.

#### Instances

Instances details

(GObject o, IsDescendantOf HeaderBar o) => IsHeaderBar o Source # |
Instance details Defined in GI.Gtk.Objects.HeaderBar

toHeaderBar :: (MonadIO m, IsHeaderBar o) => o -> m HeaderBar Source #

Cast to `HeaderBar`, for types for which this is known to be safe. For general casts, use `castTo`.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

actionSetEnabled, activate, activateAction, activateDefault, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, announce, bindProperty, bindPropertyFull, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, forceFloating, freezeNotify, getv, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFloating, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, notify, notifyByPspec, observeChildren, observeControllers, packEnd, packStart, pick, queueAllocate, queueDraw, queueResize, realize, ref, refSink, remove, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, resetProperty, resetRelation, resetState, runDispose, shouldLayout, show, sizeAllocate, snapshotChild, stealData, stealQdata, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unsetStateFlags, updateNextAccessibleSibling, updatePlatformState, updateProperty, updateRelation, updateState, watchClosure.

#### Getters

getAccessibleId, getAccessibleParent, getAccessibleRole, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getAtContext, getBaseline, getBounds, getBuildableId, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getData, getDecorationLayout, getDirection, getDisplay, getFirstAccessibleChild, getFirstChild, getFocusChild, getFocusOnClick, getFocusable, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getLimitEvents, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextAccessibleSibling, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPlatformState, getPreferredSize, getPrevSibling, getPrimaryClipboard, getProperty, getQdata, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getShowTitleButtons, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTitleWidget, getTooltipMarkup, getTooltipText, getUseNativeControls, getValign, getVexpand, getVexpandSet, getVisible, getWidth.

#### Setters

setAccessibleParent, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setData, setDataFull, setDecorationLayout, setDirection, setFocusChild, setFocusOnClick, setFocusable, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setLimitEvents, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setParent, setProperty, setReceivesDefault, setSensitive, setShowTitleButtons, setSizeRequest, setStateFlags, setTitleWidget, setTooltipMarkup, setTooltipText, setUseNativeControls, setValign, setVexpand, setVexpandSet, setVisible.

## getDecorationLayout

headerBarGetDecorationLayout Source #

Arguments

:: (HasCallStack, MonadIO m, IsHeaderBar a) |
=> a | `bar`: a header bar
-> m (Maybe Text) | Returns: the decoration layout

Gets the decoration layout of the header bar.

## getShowTitleButtons

headerBarGetShowTitleButtons Source #

Arguments

:: (HasCallStack, MonadIO m, IsHeaderBar a) |
=> a | `bar`: a header bar
-> m Bool | Returns: true if title buttons are shown

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

## getTitleWidget

headerBarGetTitleWidget Source #

Arguments

:: (HasCallStack, MonadIO m, IsHeaderBar a) |
=> a | `bar`: a header bar
-> m (Maybe Widget) | Returns: the title widget

Retrieves the title widget of the header bar.

See `headerBarSetTitleWidget`.

## getUseNativeControls

headerBarGetUseNativeControls Source #

Arguments

:: (HasCallStack, MonadIO m, IsHeaderBar a) |
=> a | `bar`: a header bar
-> m Bool | Returns: true if native window controls are shown

Returns whether this header bar shows platform native window controls.

Since: 4.18

## new

headerBarNew Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> m HeaderBar | Returns: a new `GtkHeaderBar`

Creates a new `GtkHeaderBar` widget.

## packEnd

headerBarPackEnd Source #

Arguments

:: (HasCallStack, MonadIO m, IsHeaderBar a, IsWidget b) |
=> a | `bar`: A header bar
-> b | `child`: the widget to be added to `bar`
-> m () |

Adds a child to the header bar, packed with reference to the end.

## packStart

headerBarPackStart Source #

Arguments

:: (HasCallStack, MonadIO m, IsHeaderBar a, IsWidget b) |
=> a | `bar`: A header bar
-> b | `child`: the widget to be added to `bar`
-> m () |

Adds a child to the header bar, packed with reference to the start.

## remove

headerBarRemove Source #

Arguments

:: (HasCallStack, MonadIO m, IsHeaderBar a, IsWidget b) |
=> a | `bar`: a header bar
-> b | `child`: the child to remove
-> m () |

Removes a child from the header bar.

The child must have been added with `headerBarPackStart`, `headerBarPackEnd` or `headerBarSetTitleWidget`.

## setDecorationLayout

headerBarSetDecorationLayout Source #

Arguments

:: (HasCallStack, MonadIO m, IsHeaderBar a) |
=> a | `bar`: a header bar
-> Maybe Text | `layout`: a decoration layout
-> m () |

Sets the decoration layout for this header bar.

This property overrides the Settings:gtkDecorationLayout 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 an icon on the left, and minimize, maximize and close buttons on the right.

## setShowTitleButtons

headerBarSetShowTitleButtons Source #

Arguments

:: (HasCallStack, MonadIO m, IsHeaderBar a) |
=> a | `bar`: a header bar
-> Bool | `setting`: true to show standard title buttons
-> m () |

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

## setTitleWidget

headerBarSetTitleWidget Source #

Arguments

:: (HasCallStack, MonadIO m, IsHeaderBar a, IsWidget b) |
=> a | `bar`: a header bar
-> Maybe b | `titleWidget`: a widget to use for a title
-> m () |

Sets the title for the header bar.

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

## setUseNativeControls

headerBarSetUseNativeControls Source #

Arguments

:: (HasCallStack, MonadIO m, IsHeaderBar a) |
=> a | `bar`: a header bar
-> Bool | `setting`: true to show native window controls
-> m () |

Sets whether this header bar shows native window controls.

This option shows the "stoplight" buttons on macOS. For Linux, this option has no effect.

See also Using GTK on Apple macOS.

Since: 4.18

# Properties

## decorationLayout

The decoration layout for buttons.

If this property is not set, the Settings:gtkDecorationLayout setting is used.

clearHeaderBarDecorationLayout :: (MonadIO m, IsHeaderBar o) => o -> m () Source #

Set the value of the “`decoration-layout`” property to `Nothing`. When overloading is enabled, this is equivalent to

    clear #decorationLayout

constructHeaderBarDecorationLayout :: (IsHeaderBar o, MonadIO m) => Text -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`decoration-layout`” property. This is rarely needed directly, but it is used by `new`.

getHeaderBarDecorationLayout :: (MonadIO m, IsHeaderBar o) => o -> m (Maybe Text) Source #

Get the value of the “`decoration-layout`” property. When overloading is enabled, this is equivalent to

    get headerBar #decorationLayout

setHeaderBarDecorationLayout :: (MonadIO m, IsHeaderBar o) => o -> Text -> m () Source #

Set the value of the “`decoration-layout`” property. When overloading is enabled, this is equivalent to

    set headerBar [ #decorationLayout := value ]

## showTitleButtons

Whether to show title buttons like close, minimize, maximize.

Which buttons are actually shown and where is determined by the HeaderBar:decorationLayout property, and by the state of the window (e.g. a close button will not be shown if the window can't be closed).

constructHeaderBarShowTitleButtons :: (IsHeaderBar o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`show-title-buttons`” property. This is rarely needed directly, but it is used by `new`.

getHeaderBarShowTitleButtons :: (MonadIO m, IsHeaderBar o) => o -> m Bool Source #

Get the value of the “`show-title-buttons`” property. When overloading is enabled, this is equivalent to

    get headerBar #showTitleButtons

setHeaderBarShowTitleButtons :: (MonadIO m, IsHeaderBar o) => o -> Bool -> m () Source #

Set the value of the “`show-title-buttons`” property. When overloading is enabled, this is equivalent to

    set headerBar [ #showTitleButtons := value ]

## titleWidget

The title widget to display.

clearHeaderBarTitleWidget :: (MonadIO m, IsHeaderBar o) => o -> m () Source #

Set the value of the “`title-widget`” property to `Nothing`. When overloading is enabled, this is equivalent to

    clear #titleWidget

constructHeaderBarTitleWidget :: (IsHeaderBar o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`title-widget`” property. This is rarely needed directly, but it is used by `new`.

getHeaderBarTitleWidget :: (MonadIO m, IsHeaderBar o) => o -> m (Maybe Widget) Source #

Get the value of the “`title-widget`” property. When overloading is enabled, this is equivalent to

    get headerBar #titleWidget

setHeaderBarTitleWidget :: (MonadIO m, IsHeaderBar o, IsWidget a) => o -> a -> m () Source #

Set the value of the “`title-widget`” property. When overloading is enabled, this is equivalent to

    set headerBar [ #titleWidget := value ]

## useNativeControls

Whether to show platform native close/minimize/maximize buttons.

For macOS, the HeaderBar:decorationLayout property can be used to enable/disable controls.

On Linux, this option has no effect.

See also Using GTK on Apple macOS.

Since: 4.18

constructHeaderBarUseNativeControls :: (IsHeaderBar o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`use-native-controls`” property. This is rarely needed directly, but it is used by `new`.

getHeaderBarUseNativeControls :: (MonadIO m, IsHeaderBar o) => o -> m Bool Source #

Get the value of the “`use-native-controls`” property. When overloading is enabled, this is equivalent to

    get headerBar #useNativeControls

setHeaderBarUseNativeControls :: (MonadIO m, IsHeaderBar o) => o -> Bool -> m () Source #

Set the value of the “`use-native-controls`” property. When overloading is enabled, this is equivalent to

    set headerBar [ #useNativeControls := value ]