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
GtkCheckButton
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
check_button_ptr
Default implementationTyped 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)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) 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 transformationtransform_to
ValueTransformer
to use for backwards transformationReturn 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:
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
property
the 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
CheckButtonSignalName
signalDeclaration
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 byuserData
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(signal:
Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
CheckButtonSignalName
signalDeclaration
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 byuserData
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:
Extension methodhandler: ) Emitted to when the check button is activated.
The
activate
signal onGtkCheckButton
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 [signal
Gtk.CheckButton::toggled
] signal.Note
This represents the underlyingactivate
signalDeclaration
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 methodTyped
activate
signal 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 underlyingtoggled
signalDeclaration
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 methodTyped
toggled
signal 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 innotify
being 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::active
signalDeclaration
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 methodTyped
notify::active
signal 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 innotify
being 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::group
signalDeclaration
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 methodTyped
notify::group
signal 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 innotify
being 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::inconsistent
signalDeclaration
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 methodTyped
notify::inconsistent
signal 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 innotify
being 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::label
signalDeclaration
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 methodTyped
notify::label
signal 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 innotify
being 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-underline
signalDeclaration
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 methodTyped
notify::use-underline
signal 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
self
to 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
self
to 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
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 [property
Gtk.CheckButton:use-underline
] istrue
, an underscore inlabel
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
istrue
, 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)
-
active
Extension methodIf the check button is active.
Setting
active
totrue
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 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 }
-
label
Extension methodText of the label inside the check button, if it contains a label widget.
Declaration
Swift
@inlinable var label: String! { get nonmutating set }
-
useUnderline
Extension methodReturns whether underlines in the label indicate mnemonics.
Declaration
Swift
@inlinable var useUnderline: Bool { get nonmutating set }
-
parentInstance
Extension methodUndocumented
Declaration
Swift
@inlinable var parentInstance: GtkWidget { get }