CheckButtonProtocol

public protocol CheckButtonProtocol : ActionableProtocol

A GtkCheckButton places a label next to an indicator.

Example GtkCheckButtons

A GtkCheckButton is created by calling either [ctorGtk.CheckButton.new] or [ctorGtk.CheckButton.new_with_label].

The state of a GtkCheckButton can be set specifically using [methodGtk.CheckButton.set_active], and retrieved using [methodGtk.CheckButton.get_active].

Inconsistent state

In addition to “on” and “off”, check buttons can be an “in between” state that is neither on nor off. This can be used e.g. when the user has selected a range of elements (such as some text or spreadsheet cells) that are affected by a check button, and the current values in that range are inconsistent.

To set a GtkCheckButton to inconsistent state, use [methodGtk.CheckButton.set_inconsistent].

Grouping

Check buttons can be grouped together, to form mutually exclusive groups - only one of the buttons can be toggled at a time, and toggling another one will switch the currently toggled one off.

Grouped check buttons use a different indicator, and are commonly referred to as radio buttons.

Example GtkCheckButtons

To add a GtkCheckButton to a group, use [methodGtk.CheckButton.set_group].

CSS nodes

checkbutton[.text-button]
├── check
╰── [label]

A GtkCheckButton has a main node with name checkbutton. If the [propertyGtk.CheckButton:label] property is set, it contains a label child. The indicator node is named check when no group is set, and radio if the checkbutton is grouped together with other checkbuttons.

Accessibility

GtkCheckButton uses the GTK_ACCESSIBLE_ROLE_CHECKBOX role.

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

  • ptr

    Untyped pointer to the underlying GtkCheckButton instance.

    Declaration

    Swift

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

    Typed pointer to the underlying GtkCheckButton instance.

    Default Implementation

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

    Declaration

    Swift

    var check_button_ptr: UnsafeMutablePointer<GtkCheckButton>! { get }
  • Required Initialiser for types conforming to CheckButtonProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

CheckButton Class

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

CheckButton signals

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

    Declaration

    Swift

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

    Declaration

    Swift

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

  • onActivate(flags:handler:) Extension method

    Emitted to when the check button is activated.

    The activate signal on GtkCheckButton is an action signal and emitting it causes the button to animate press then release.

    Applications should never connect to this signal, but use the [signalGtk.CheckButton::toggled] signal.

    Note

    This represents the underlying activate signal

    Declaration

    Swift

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

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    handler

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

  • activateSignal Extension method

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

    Declaration

    Swift

    static var activateSignal: CheckButtonSignalName { get }
  • onToggled(flags:handler:) Extension method

    Emitted when the buttons’s [propertyGtk.CheckButton:active] property changes.

    Note

    This represents the underlying toggled signal

    Declaration

    Swift

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

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    handler

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

  • toggledSignal Extension method

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

    Declaration

    Swift

    static var toggledSignal: CheckButtonSignalName { 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::active signal

    Declaration

    Swift

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

  • notifyActiveSignal Extension method

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

    Declaration

    Swift

    static var notifyActiveSignal: CheckButtonSignalName { 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::group signal

    Declaration

    Swift

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

  • notifyGroupSignal Extension method

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

    Declaration

    Swift

    static var notifyGroupSignal: CheckButtonSignalName { 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::inconsistent signal

    Declaration

    Swift

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

  • notifyInconsistentSignal Extension method

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

    Declaration

    Swift

    static var notifyInconsistentSignal: CheckButtonSignalName { 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: CheckButtonRef, _ 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: CheckButtonSignalName { 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: CheckButtonRef, _ 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: CheckButtonSignalName { get }

CheckButton Class: CheckButtonProtocol extension (methods and fields)

  • getActive() Extension method

    Returns whether the check button is active.

    Declaration

    Swift

    @inlinable
    func getActive() -> Bool
  • getInconsistent() Extension method

    Returns whether the check button is in an inconsistent state.

    Declaration

    Swift

    @inlinable
    func getInconsistent() -> Bool
  • getLabel() Extension method

    Returns the label of the check button.

    Declaration

    Swift

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

    Returns whether underlines in the label indicate mnemonics.

    Declaration

    Swift

    @inlinable
    func getUseUnderline() -> Bool
  • setActive(setting:) Extension method

    Changes the check buttons active state.

    Declaration

    Swift

    @inlinable
    func setActive(setting: Bool)
  • set(group:) Extension method

    Adds self to the group of group.

    In a group of multiple check buttons, only one button can be active at a time. The behavior of a checkbutton in a group is also commonly known as a radio button.

    Setting the group of a check button also changes the css name of the indicator widget’s CSS node to ‘radio’.

    Setting up groups in a cycle leads to undefined behavior.

    Note that the same effect can be achieved via the [ifaceGtk.Actionable] API, by using the same action with parameter type and state type ‘s’ for all buttons in the group, and giving each button its own target value.

    Declaration

    Swift

    @inlinable
    func set(group: CheckButtonRef? = nil)
  • set(group:) Extension method

    Adds self to the group of group.

    In a group of multiple check buttons, only one button can be active at a time. The behavior of a checkbutton in a group is also commonly known as a radio button.

    Setting the group of a check button also changes the css name of the indicator widget’s CSS node to ‘radio’.

    Setting up groups in a cycle leads to undefined behavior.

    Note that the same effect can be achieved via the [ifaceGtk.Actionable] API, by using the same action with parameter type and state type ‘s’ for all buttons in the group, and giving each button its own target value.

    Declaration

    Swift

    @inlinable
    func set<CheckButtonT>(group: CheckButtonT?) where CheckButtonT : CheckButtonProtocol
  • set(inconsistent:) Extension method

    Sets the GtkCheckButton to inconsistent state.

    You shoud turn off the inconsistent state again if the user checks the check button. This has to be done manually.

    Declaration

    Swift

    @inlinable
    func set(inconsistent: Bool)
  • set(label:) Extension method

    Sets the text of self.

    If [propertyGtk.CheckButton:use-underline] is true, an underscore in label is interpreted as mnemonic indicator, see [methodGtk.CheckButton.set_use_underline] for details on this behavior.

    Declaration

    Swift

    @inlinable
    func set(label: UnsafePointer<CChar>? = nil)
  • setUseUnderline(setting:) Extension method

    Sets whether underlines in the label indicate mnemonics.

    If setting is true, an underscore character in self‘s label indicates a mnemonic accelerator key. This behavior is similar to [propertyGtk.Label:use-underline].

    Declaration

    Swift

    @inlinable
    func setUseUnderline(setting: Bool)
  • active Extension method

    If the check button is active.

    Setting active to true will add the :checked: state to both the check button and the indicator CSS node.

    Declaration

    Swift

    @inlinable
    var active: Bool { get nonmutating set }
  • inconsistent Extension method

    If the check button is in an “in between” state.

    The inconsistent state only affects visual appearance, not the semantics of the button.

    Declaration

    Swift

    @inlinable
    var inconsistent: Bool { get nonmutating set }
  • label Extension method

    Text of the label inside the check button, if it contains a label widget.

    Declaration

    Swift

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

    Returns whether underlines in the label indicate mnemonics.

    Declaration

    Swift

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

    Undocumented

    Declaration

    Swift

    @inlinable
    var parentInstance: GtkWidget { get }