ToolButtonProtocol

public protocol ToolButtonProtocol : ActionableProtocol, ToolItemProtocol

GtkToolButtons are GtkToolItems containing buttons.

Use gtk_tool_button_new() to create a new GtkToolButton.

The label of a GtkToolButton is determined by the properties GtkToolButton:label-widget, GtkToolButton:label, and GtkToolButton:stock-id. If GtkToolButton:label-widget is non-nil, then that widget is used as the label. Otherwise, if GtkToolButton:label is non-nil, that string is used as the label. Otherwise, if GtkToolButton:stock-id is non-nil, the label is determined by the stock item. Otherwise, the button does not have a label.

The icon of a GtkToolButton is determined by the properties GtkToolButton:icon-widget and GtkToolButton:stock-id. If GtkToolButton:icon-widget is non-nil, then that widget is used as the icon. Otherwise, if GtkToolButton:stock-id is non-nil, the icon is determined by the stock item. Otherwise, the button does not have a icon.

CSS nodes

GtkToolButton has a single CSS node with name toolbutton.

The ToolButtonProtocol protocol exposes the methods and properties of an underlying GtkToolButton 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 ToolButton. Alternatively, use ToolButtonRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying GtkToolButton instance.

    Declaration

    Swift

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

    Typed pointer to the underlying GtkToolButton instance.

    Default Implementation

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

    Declaration

    Swift

    var tool_button_ptr: UnsafeMutablePointer<GtkToolButton>! { get }
  • Required Initialiser for types conforming to ToolButtonProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

ToolButton Class

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

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: ToolButtonPropertyName, 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 ToolButton property

    Declaration

    Swift

    @inlinable
    func get(property: ToolButtonPropertyName) -> 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 ToolButton property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

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

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

ToolButton signals

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

    Declaration

    Swift

    @discardableResult
    @inlinable
    func connect(signal s: ToolButtonSignalName, 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 ToolButtonSignalName signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func connect(signal s: ToolButtonSignalName, 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)

  • onClicked(flags:handler:) Extension method

    This signal is emitted when the tool button is clicked with the mouse or activated with the keyboard.

    Note

    This represents the underlying clicked signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onClicked(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ToolButtonRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    handler

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

  • clickedSignal Extension method

    Typed clicked signal for using the connect(signal:) methods

    Declaration

    Swift

    static var clickedSignal: ToolButtonSignalName { 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-name signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyIconName(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ToolButtonRef, _ 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 notifyIconName signal is emitted

  • notifyIconNameSignal Extension method

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

    Declaration

    Swift

    static var notifyIconNameSignal: ToolButtonSignalName { 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-widget signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyIconWidget(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ToolButtonRef, _ 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 notifyIconWidget signal is emitted

  • notifyIconWidgetSignal Extension method

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

    Declaration

    Swift

    static var notifyIconWidgetSignal: ToolButtonSignalName { 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::label signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyLabel(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ToolButtonRef, _ 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 notifyLabel signal is emitted

  • notifyLabelSignal Extension method

    Typed notify::label signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyLabelSignal: ToolButtonSignalName { 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::label-widget signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyLabelWidget(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ToolButtonRef, _ 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 notifyLabelWidget signal is emitted

  • notifyLabelWidgetSignal Extension method

    Typed notify::label-widget signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyLabelWidgetSignal: ToolButtonSignalName { 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::stock-id signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyStockID(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ToolButtonRef, _ 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 notifyStockID signal is emitted

  • notifyStockIDSignal Extension method

    Typed notify::stock-id signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyStockIDSignal: ToolButtonSignalName { 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::use-underline signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyUseUnderline(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ToolButtonRef, _ 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 notifyUseUnderline signal is emitted

  • notifyUseUnderlineSignal Extension method

    Typed notify::use-underline signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyUseUnderlineSignal: ToolButtonSignalName { get }

ToolButton Class: ToolButtonProtocol extension (methods and fields)

  • getIconName() Extension method

    Returns the name of the themed icon for the tool button, see gtk_tool_button_set_icon_name().

    Declaration

    Swift

    @inlinable
    func getIconName() -> String!
  • getIconWidget() Extension method

    Return the widget used as icon widget on button. See gtk_tool_button_set_icon_widget().

    Declaration

    Swift

    @inlinable
    func getIconWidget() -> WidgetRef!
  • getLabel() Extension method

    Returns the label used by the tool button, or nil if the tool button doesn’t have a label. or uses a the label from a stock item. The returned string is owned by GTK+, and must not be modified or freed.

    Declaration

    Swift

    @inlinable
    func getLabel() -> String!
  • getLabelWidget() Extension method

    Returns the widget used as label on button. See gtk_tool_button_set_label_widget().

    Declaration

    Swift

    @inlinable
    func getLabelWidget() -> WidgetRef!
  • getStockID() Extension method

    Returns the name of the stock item. See gtk_tool_button_set_stock_id(). The returned string is owned by GTK+ and must not be freed or modifed.

    get_stock_id is deprecated: Use gtk_tool_button_get_icon_name() instead.

    Declaration

    Swift

    @available(*, deprecated)
    @inlinable
    func getStockID() -> String!
  • getUseUnderline() Extension method

    Returns whether underscores in the label property are used as mnemonics on menu items on the overflow menu. See gtk_tool_button_set_use_underline().

    Declaration

    Swift

    @inlinable
    func getUseUnderline() -> Bool
  • set(iconName:) Extension method

    Sets the icon for the tool button from a named themed icon. See the docs for GtkIconTheme for more details. The GtkToolButton:icon-name property only has an effect if not overridden by non-nil GtkToolButton:label-widget, GtkToolButton:icon-widget and GtkToolButton:stock-id properties.

    Declaration

    Swift

    @inlinable
    func set(iconName: UnsafePointer<gchar>? = nil)
  • set(iconWidget:) Extension method

    Sets icon as the widget used as icon on button. If icon_widget is nil the icon is determined by the GtkToolButton:stock-id property. If the GtkToolButton:stock-id property is also nil, button will not have an icon.

    Declaration

    Swift

    @inlinable
    func set(iconWidget: WidgetRef? = nil)
  • set(iconWidget:) Extension method

    Sets icon as the widget used as icon on button. If icon_widget is nil the icon is determined by the GtkToolButton:stock-id property. If the GtkToolButton:stock-id property is also nil, button will not have an icon.

    Declaration

    Swift

    @inlinable
    func set<WidgetT>(iconWidget: WidgetT?) where WidgetT : WidgetProtocol
  • set(label:) Extension method

    Sets label as the label used for the tool button. The GtkToolButton:label property only has an effect if not overridden by a non-nil GtkToolButton:label-widget property. If both the GtkToolButton:label-widget and GtkToolButton:label properties are nil, the label is determined by the GtkToolButton:stock-id property. If the GtkToolButton:stock-id property is also nil, button will not have a label.

    Declaration

    Swift

    @inlinable
    func set(label: UnsafePointer<gchar>? = nil)
  • set(labelWidget:) Extension method

    Sets label_widget as the widget that will be used as the label for button. If label_widget is nil the GtkToolButton:label property is used as label. If GtkToolButton:label is also nil, the label in the stock item determined by the GtkToolButton:stock-id property is used as label. If GtkToolButton:stock-id is also nil, button does not have a label.

    Declaration

    Swift

    @inlinable
    func set(labelWidget: WidgetRef? = nil)
  • set(labelWidget:) Extension method

    Sets label_widget as the widget that will be used as the label for button. If label_widget is nil the GtkToolButton:label property is used as label. If GtkToolButton:label is also nil, the label in the stock item determined by the GtkToolButton:stock-id property is used as label. If GtkToolButton:stock-id is also nil, button does not have a label.

    Declaration

    Swift

    @inlinable
    func set<WidgetT>(labelWidget: WidgetT?) where WidgetT : WidgetProtocol
  • set(stockID:) Extension method

    Sets the name of the stock item. See gtk_tool_button_new_from_stock(). The stock_id property only has an effect if not overridden by non-nil GtkToolButton:label-widget and GtkToolButton:icon-widget properties.

    set_stock_id is deprecated: Use gtk_tool_button_set_icon_name() instead.

    Declaration

    Swift

    @available(*, deprecated)
    @inlinable
    func set(stockID: UnsafePointer<gchar>? = nil)
  • set(useUnderline:) Extension method

    If set, an underline in the label property indicates that the next character should be used for the mnemonic accelerator key in the overflow menu. For example, if the label property is “_Open” and use_underline is true, the label on the tool button will be “Open” and the item on the overflow menu will have an underlined “O”.

    Labels shown on tool buttons never have mnemonics on them; this property only affects the menu item on the overflow menu.

    Declaration

    Swift

    @inlinable
    func set(useUnderline: Bool)
  • iconName Extension method

    Returns the name of the themed icon for the tool button, see gtk_tool_button_set_icon_name().

    Declaration

    Swift

    @inlinable
    var iconName: String! { get nonmutating set }
  • iconWidget Extension method

    Return the widget used as icon widget on button. See gtk_tool_button_set_icon_widget().

    Declaration

    Swift

    @inlinable
    var iconWidget: WidgetRef! { get nonmutating set }
  • label Extension method

    Undocumented

    Declaration

    Swift

    @inlinable
    var label: String! { get nonmutating set }
  • labelWidget Extension method

    Returns the widget used as label on button. See gtk_tool_button_set_label_widget().

    Declaration

    Swift

    @inlinable
    var labelWidget: WidgetRef! { get nonmutating set }
  • stockID Extension method

    Returns the name of the stock item. See gtk_tool_button_set_stock_id(). The returned string is owned by GTK+ and must not be freed or modifed.

    get_stock_id is deprecated: Use gtk_tool_button_get_icon_name() instead.

    Declaration

    Swift

    @inlinable
    var stockID: String! { get nonmutating set }
  • useUnderline Extension method

    Returns whether underscores in the label property are used as mnemonics on menu items on the overflow menu. See gtk_tool_button_set_use_underline().

    Declaration

    Swift

    @inlinable
    var useUnderline: Bool { get nonmutating set }
  • parent Extension method

    Undocumented

    Declaration

    Swift

    @inlinable
    var parent: GtkToolItem { get }