ToolbarProtocol

public protocol ToolbarProtocol : ContainerProtocol, OrientableProtocol, ToolShellProtocol

A toolbar is created with a call to gtk_toolbar_new().

A toolbar can contain instances of a subclass of GtkToolItem. To add a GtkToolItem to the a toolbar, use gtk_toolbar_insert(). To remove an item from the toolbar use gtk_container_remove(). To add a button to the toolbar, add an instance of GtkToolButton.

Toolbar items can be visually grouped by adding instances of GtkSeparatorToolItem to the toolbar. If the GtkToolbar child property “expand” is TRUE and the property GtkSeparatorToolItem:draw is set to FALSE, the effect is to force all following items to the end of the toolbar.

By default, a toolbar can be shrunk, upon which it will add an arrow button to show an overflow menu offering access to any GtkToolItem child that has a proxy menu item. To disable this and request enough size for all children, call gtk_toolbar_set_show_arrow() to set GtkToolbar:show-arrow to false.

Creating a context menu for the toolbar can be done by connecting to the GtkToolbar::popup-context-menu signal.

CSS nodes

GtkToolbar has a single CSS node with name toolbar.

The ToolbarProtocol protocol exposes the methods and properties of an underlying GtkToolbar instance. The default implementation of these can be found in the protocol extension below. For a concrete class that implements these methods and properties, see Toolbar. Alternatively, use ToolbarRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying GtkToolbar instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • toolbar_ptr Default implementation

    Typed pointer to the underlying GtkToolbar instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GtkToolbar instance.

    Declaration

    Swift

    var toolbar_ptr: UnsafeMutablePointer<GtkToolbar>! { get }
  • Required Initialiser for types conforming to ToolbarProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

Toolbar Class

  • Bind a ToolbarPropertyName source property to a given target object.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: ToolbarPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol

    Parameters

    source_property

    the source property to bind

    target

    the target object to bind to

    target_property

    the target property to bind to

    flags

    the flags to pass to the Binding

    transform_from

    ValueTransformer to use for forward transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return Value

    binding reference or nil in case of an error

  • get(property:) Extension method

    Get the value of a Toolbar property

    Declaration

    Swift

    @inlinable
    func get(property: ToolbarPropertyName) -> GLibObject.Value

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

  • set(property:value:) Extension method

    Set the value of a Toolbar property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

    @inlinable
    func set(property: ToolbarPropertyName, value v: GLibObject.Value)

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

Toolbar signals

  • Connect a Swift signal handler to the given, typed ToolbarSignalName signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func connect(signal s: ToolbarSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int

    Parameters

    signal

    The signal to connect

    flags

    The connection flags to use

    data

    A pointer to user data to provide to the callback

    destroyData

    A GClosureNotify C function to destroy the data pointed to by userData

    handler

    The Swift signal handler (function or callback) to invoke on the given signal

    Return Value

    The signal handler ID (always greater than 0 for successful connections)

  • Connect a C signal handler to the given, typed ToolbarSignalName signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func connect(signal s: ToolbarSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int

    Parameters

    signal

    The signal to connect

    flags

    The connection flags to use

    data

    A pointer to user data to provide to the callback

    destroyData

    A GClosureNotify C function to destroy the data pointed to by userData

    signalHandler

    The C function to be called on the given signal

    Return Value

    The signal handler ID (always greater than 0 for successful connections)

  • A keybinding signal used internally by GTK+. This signal can’t be used in application code

    Note

    This represents the underlying focus-home-or-end signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onFocusHomeOrEnd(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ToolbarRef, _ focusHome: Bool) -> Bool) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    focusHome

    true if the first item should be focused

    handler

    true if the signal was handled, false if not Run the given callback whenever the focusHomeOrEnd signal is emitted

  • focusHomeOrEndSignal Extension method

    Typed focus-home-or-end signal for using the connect(signal:) methods

    Declaration

    Swift

    static var focusHomeOrEndSignal: ToolbarSignalName { get }
  • Emitted when the orientation of the toolbar changes.

    Note

    This represents the underlying orientation-changed signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onOrientationChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ToolbarRef, _ orientation: Orientation) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    orientation

    the new GtkOrientation of the toolbar

    handler

    The signal handler to call Run the given callback whenever the orientationChanged signal is emitted

  • orientationChangedSignal Extension method

    Typed orientation-changed signal for using the connect(signal:) methods

    Declaration

    Swift

    static var orientationChangedSignal: ToolbarSignalName { get }
  • Emitted when the user right-clicks the toolbar or uses the keybinding to display a popup menu.

    Application developers should handle this signal if they want to display a context menu on the toolbar. The context-menu should appear at the coordinates given by x and y. The mouse button number is given by the button parameter. If the menu was popped up using the keybaord, button is -1.

    Note

    This represents the underlying popup-context-menu signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onPopupContextMenu(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ToolbarRef, _ x: Int, _ y: Int, _ button: Int) -> Bool) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    x

    the x coordinate of the point where the menu should appear

    y

    the y coordinate of the point where the menu should appear

    button

    the mouse button the user pressed, or -1

    handler

    return true if the signal was handled, false if not Run the given callback whenever the popupContextMenu signal is emitted

  • popupContextMenuSignal Extension method

    Typed popup-context-menu signal for using the connect(signal:) methods

    Declaration

    Swift

    static var popupContextMenuSignal: ToolbarSignalName { get }
  • Emitted when the style of the toolbar changes.

    Note

    This represents the underlying style-changed signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onStyleChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ToolbarRef, _ style: ToolbarStyle) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    style

    the new GtkToolbarStyle of the toolbar

    handler

    The signal handler to call Run the given callback whenever the styleChanged signal is emitted

  • styleChangedSignal Extension method

    Typed style-changed signal for using the connect(signal:) methods

    Declaration

    Swift

    static var styleChangedSignal: ToolbarSignalName { get }
  • The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

    (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::icon-size signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyIconSize(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ToolbarRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifyIconSize signal is emitted

  • notifyIconSizeSignal Extension method

    Typed notify::icon-size signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyIconSizeSignal: ToolbarSignalName { get }
  • The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

    (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::icon-size-set signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyIconSizeSet(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ToolbarRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifyIconSizeSet signal is emitted

  • notifyIconSizeSetSignal Extension method

    Typed notify::icon-size-set signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyIconSizeSetSignal: ToolbarSignalName { get }
  • The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

    (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::show-arrow signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyShowArrow(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ToolbarRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifyShowArrow signal is emitted

  • notifyShowArrowSignal Extension method

    Typed notify::show-arrow signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyShowArrowSignal: ToolbarSignalName { get }
  • The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

    (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::toolbar-style signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyToolbarStyle(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ToolbarRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifyToolbarStyle signal is emitted

  • notifyToolbarStyleSignal Extension method

    Typed notify::toolbar-style signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyToolbarStyleSignal: ToolbarSignalName { get }

Toolbar Class: ToolbarProtocol extension (methods and fields)

  • getDropIndex(x:y:) Extension method

    Returns the position corresponding to the indicated point on toolbar. This is useful when dragging items to the toolbar: this function returns the position a new item should be inserted.

    x and y are in toolbar coordinates.

    Declaration

    Swift

    @inlinable
    func getDropIndex(x: Int, y: Int) -> Int
  • getIconSize() Extension method

    Retrieves the icon size for the toolbar. See gtk_toolbar_set_icon_size().

    Declaration

    Swift

    @inlinable
    func getIconSize() -> GtkIconSize
  • getItemIndex(item:) Extension method

    Returns the position of item on the toolbar, starting from 0. It is an error if item is not a child of the toolbar.

    Declaration

    Swift

    @inlinable
    func getItemIndex<ToolItemT>(item: ToolItemT) -> Int where ToolItemT : ToolItemProtocol
  • getNItems() Extension method

    Returns the number of items on the toolbar.

    Declaration

    Swift

    @inlinable
    func getNItems() -> Int
  • getNthItem(n:) Extension method

    Returns the n‘th item on toolbar, or nil if the toolbar does not contain an n'th item.

    Declaration

    Swift

    @inlinable
    func getNthItem(n: Int) -> ToolItemRef!
  • getReliefStyle() Extension method

    Returns the relief style of buttons on toolbar. See gtk_button_set_relief().

    Declaration

    Swift

    @inlinable
    func getReliefStyle() -> GtkReliefStyle
  • getShowArrow() Extension method

    Returns whether the toolbar has an overflow menu. See gtk_toolbar_set_show_arrow().

    Declaration

    Swift

    @inlinable
    func getShowArrow() -> Bool
  • getStyle() Extension method

    Retrieves whether the toolbar has text, icons, or both . See gtk_toolbar_set_style().

    Declaration

    Swift

    @inlinable
    func getStyle() -> GtkToolbarStyle
  • insert(item:pos:) Extension method

    Insert a GtkToolItem into the toolbar at position pos. If pos is 0 the item is prepended to the start of the toolbar. If pos is negative, the item is appended to the end of the toolbar.

    Declaration

    Swift

    @inlinable
    func insert<ToolItemT>(item: ToolItemT, pos: Int) where ToolItemT : ToolItemProtocol
  • Highlights toolbar to give an idea of what it would look like if item was added to toolbar at the position indicated by index_. If item is nil, highlighting is turned off. In that case index_ is ignored.

    The tool_item passed to this function must not be part of any widget hierarchy. When an item is set as drop highlight item it can not added to any widget hierarchy or used as highlight item for another toolbar.

    Declaration

    Swift

    @inlinable
    func setDropHighlightItem(toolItem: ToolItemRef? = nil, index: Int)
  • Highlights toolbar to give an idea of what it would look like if item was added to toolbar at the position indicated by index_. If item is nil, highlighting is turned off. In that case index_ is ignored.

    The tool_item passed to this function must not be part of any widget hierarchy. When an item is set as drop highlight item it can not added to any widget hierarchy or used as highlight item for another toolbar.

    Declaration

    Swift

    @inlinable
    func setDropHighlightItem<ToolItemT>(toolItem: ToolItemT?, index: Int) where ToolItemT : ToolItemProtocol
  • set(iconSize:) Extension method

    This function sets the size of stock icons in the toolbar. You can call it both before you add the icons and after they’ve been added. The size you set will override user preferences for the default icon size.

    This should only be used for special-purpose toolbars, normal application toolbars should respect the user preferences for the size of icons.

    Declaration

    Swift

    @inlinable
    func set(iconSize: GtkIconSize)
  • set(showArrow:) Extension method

    Sets whether to show an overflow menu when toolbar isn’t allocated enough size to show all of its items. If true, items which can’t fit in toolbar, and which have a proxy menu item set by gtk_tool_item_set_proxy_menu_item() or GtkToolItem::create-menu-proxy, will be available in an overflow menu, which can be opened by an added arrow button. If false, toolbar will request enough size to fit all of its child items without any overflow.

    Declaration

    Swift

    @inlinable
    func set(showArrow: Bool)
  • set(style:) Extension method

    Alters the view of toolbar to display either icons only, text only, or both.

    Declaration

    Swift

    @inlinable
    func set(style: GtkToolbarStyle)
  • unsetIconSize() Extension method

    Unsets toolbar icon size set with gtk_toolbar_set_icon_size(), so that user preferences will be used to determine the icon size.

    Declaration

    Swift

    @inlinable
    func unsetIconSize()
  • unsetStyle() Extension method

    Unsets a toolbar style set with gtk_toolbar_set_style(), so that user preferences will be used to determine the toolbar style.

    Declaration

    Swift

    @inlinable
    func unsetStyle()
  • iconSize Extension method

    Retrieves the icon size for the toolbar. See gtk_toolbar_set_icon_size().

    Declaration

    Swift

    @inlinable
    var iconSize: GtkIconSize { get nonmutating set }
  • nItems Extension method

    Returns the number of items on the toolbar.

    Declaration

    Swift

    @inlinable
    var nItems: Int { get }
  • reliefStyle Extension method

    Returns the relief style of buttons on toolbar. See gtk_button_set_relief().

    Declaration

    Swift

    @inlinable
    var reliefStyle: GtkReliefStyle { get }
  • showArrow Extension method

    Returns whether the toolbar has an overflow menu. See gtk_toolbar_set_show_arrow().

    Declaration

    Swift

    @inlinable
    var showArrow: Bool { get nonmutating set }
  • style Extension method

    Retrieves whether the toolbar has text, icons, or both . See gtk_toolbar_set_style().

    Declaration

    Swift

    @inlinable
    var style: GtkToolbarStyle { get nonmutating set }
  • container Extension method

    Undocumented

    Declaration

    Swift

    @inlinable
    var container: GtkContainer { get }