CheckButtonProtocol
public protocol CheckButtonProtocol : ActionableProtocol
A GtkCheckButton places a label next to an indicator.

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.

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.
-
Untyped pointer to the underlying
GtkCheckButtoninstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
check_button_ptrDefault implementationTyped pointer to the underlying
GtkCheckButtoninstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkCheckButtoninstance.Declaration
Swift
var check_button_ptr: UnsafeMutablePointer<GtkCheckButton>! { get } -
Required Initialiser for types conforming to
CheckButtonProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
CheckButtonPropertyNamesource 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 : ObjectProtocolParameters
source_propertythe source property to bind
targetthe target object to bind to
target_propertythe target property to bind to
flagsthe flags to pass to the
Bindingtransform_fromValueTransformerto use for forward transformationtransform_toValueTransformerto use for backwards transformationReturn Value
binding reference or
nilin case of an error -
get(property:Extension method) Get the value of a CheckButton property
Declaration
Swift
@inlinable func get(property: CheckButtonPropertyName) -> GLibObject.ValueParameters
propertythe property to get the value for
Return Value
the value of the named property
-
set(property:Extension methodvalue: ) 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
propertythe property to get the value for
Return Value
the value of the named property
-
connect(signal:Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
CheckButtonSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: CheckButtonSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatahandlerThe 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(signal:Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
CheckButtonSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: CheckButtonSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatasignalHandlerThe C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
onActivate(flags:Extension methodhandler: ) Emitted to when the check button is activated.
The
activatesignal onGtkCheckButtonis an action signal and emitting it causes the button to animate press then release.Applications should never connect to this signal, but use the [signal
Gtk.CheckButton::toggled] signal.Note
This represents the underlyingactivatesignalDeclaration
Swift
@discardableResult @inlinable func onActivate(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CheckButtonRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
handlerThe signal handler to call Run the given callback whenever the
activatesignal is emitted -
activateSignalExtension methodTyped
activatesignal for using theconnect(signal:)methodsDeclaration
Swift
static var activateSignal: CheckButtonSignalName { get } -
onToggled(flags:Extension methodhandler: ) Emitted when the buttons’s [property
Gtk.CheckButton:active] property changes.Note
This represents the underlyingtoggledsignalDeclaration
Swift
@discardableResult @inlinable func onToggled(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CheckButtonRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
handlerThe signal handler to call Run the given callback whenever the
toggledsignal is emitted -
toggledSignalExtension methodTyped
toggledsignal for using theconnect(signal:)methodsDeclaration
Swift
static var toggledSignal: CheckButtonSignalName { get } -
onNotifyActive(flags:Extension methodhandler: ) 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 tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_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 underlyingnotify::activesignalDeclaration
Swift
@discardableResult @inlinable func onNotifyActive(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CheckButtonRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyActivesignal is emitted -
notifyActiveSignalExtension methodTyped
notify::activesignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyActiveSignal: CheckButtonSignalName { get } -
onNotifyGroup(flags:Extension methodhandler: ) 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 tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_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 underlyingnotify::groupsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyGroup(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CheckButtonRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyGroupsignal is emitted -
notifyGroupSignalExtension methodTyped
notify::groupsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyGroupSignal: CheckButtonSignalName { get } -
onNotifyInconsistent(flags:Extension methodhandler: ) 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 tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_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 underlyingnotify::inconsistentsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyInconsistent(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CheckButtonRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyInconsistentsignal is emitted -
notifyInconsistentSignalExtension methodTyped
notify::inconsistentsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyInconsistentSignal: CheckButtonSignalName { get } -
onNotifyLabel(flags:Extension methodhandler: ) 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 tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_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 underlyingnotify::labelsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyLabel(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CheckButtonRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyLabelsignal is emitted -
notifyLabelSignalExtension methodTyped
notify::labelsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyLabelSignal: CheckButtonSignalName { get } -
onNotifyUseUnderline(flags:Extension methodhandler: ) 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 tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_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 underlyingnotify::use-underlinesignalDeclaration
Swift
@discardableResult @inlinable func onNotifyUseUnderline(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: CheckButtonRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyUseUnderlinesignal is emitted -
notifyUseUnderlineSignalExtension methodTyped
notify::use-underlinesignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyUseUnderlineSignal: CheckButtonSignalName { get }
-
getActive()Extension methodReturns whether the check button is active.
Declaration
Swift
@inlinable func getActive() -> Bool -
getInconsistent()Extension methodReturns whether the check button is in an inconsistent state.
Declaration
Swift
@inlinable func getInconsistent() -> Bool -
getLabel()Extension methodReturns the label of the check button.
Declaration
Swift
@inlinable func getLabel() -> String! -
getUseUnderline()Extension methodReturns 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
selfto the group ofgroup.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 [iface
Gtk.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
selfto the group ofgroup.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 [iface
Gtk.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
GtkCheckButtonto 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 [property
Gtk.CheckButton:use-underline] istrue, an underscore inlabelis 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
settingistrue, an underscore character inself‘s label indicates a mnemonic accelerator key. This behavior is similar to [propertyGtk.Label:use-underline].Declaration
Swift
@inlinable func setUseUnderline(setting: Bool) -
activeExtension methodIf the check button is active.
Setting
activetotruewill add the:checked:state to both the check button and the indicator CSS node.Declaration
Swift
@inlinable var active: Bool { get nonmutating set } -
inconsistentExtension methodIf 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 } -
labelExtension methodText of the label inside the check button, if it contains a label widget.
Declaration
Swift
@inlinable var label: String! { get nonmutating set } -
useUnderlineExtension methodReturns whether underlines in the label indicate mnemonics.
Declaration
Swift
@inlinable var useUnderline: Bool { get nonmutating set } -
parentInstanceExtension methodUndocumented
Declaration
Swift
@inlinable var parentInstance: GtkWidget { get }
View on GitHub
Install in Dash
CheckButtonProtocol Protocol Reference