portico/Sources/Portico/Generated/CheckButton.swift

682 lines
40 KiB
Swift

// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
import Adw
import Gtk
import Gio
import Gdk
// PorticoGen: generateStruct | source: Gtk.CheckButton
/// Places a label next to an indicator.
///
/// <picture>
/// <source srcset="check-button-dark.png" media="(prefers-color-scheme: dark)">
/// <img alt="Example GtkCheckButtons" src="check-button.png">
/// </picture>
///
/// A `GtkCheckButton` is created by calling either [ctor`Gtk`.CheckButton.new]
/// or [ctor`Gtk`.CheckButton.new_with_label].
///
/// The state of a `GtkCheckButton` can be set specifically using
/// [method`Gtk`.CheckButton.set_active], and retrieved using
/// [method`Gtk`.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
/// [method`Gtk`.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*.
///
/// <picture>
/// <source srcset="radio-button-dark.png" media="(prefers-color-scheme: dark)">
/// <img alt="Example GtkRadioButtons" src="radio-button.png">
/// </picture>
///
/// To add a `GtkCheckButton` to a group, use [method`Gtk`.CheckButton.set_group].
///
/// When the code must keep track of the state of a group of radio buttons, it
/// is recommended to keep track of such state through a stateful
/// `GAction` with a target for each button. Using the `toggled` signals to keep
/// track of the group changes and state is discouraged.
///
/// # Shortcuts and Gestures
///
/// `GtkCheckButton` supports the following keyboard shortcuts:
///
/// - <kbd></kbd> or <kbd>Enter</kbd> activates the button.
///
/// # CSS nodes
///
/// ```
/// checkbutton[.text-button][.grouped]
/// check
/// [label]
/// ```
///
/// A `GtkCheckButton` has a main node with name checkbutton. If the
/// [property`Gtk`.CheckButton:label] or [property`Gtk`.CheckButton:child]
/// properties are set, it contains a child widget. 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 [enum`Gtk`.AccessibleRole.checkbox] role.
///
/// A Portico view that mounts a `Gtk.CheckButton`.
@MainActor public struct CheckButton: View {
private let make: (MountContext) -> Gtk.CheckButton
private var configure: [(Gtk.CheckButton, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.CheckButton.init()
/// Creates a new `GtkCheckButton`.
///
/// Applied once at mount; use the `Binding` or closure overload for values that change.
/// Each closure is evaluated once; children are added in order and slot closures mount their first view.
/// An empty closure adds no children and leaves slots unset.
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
///
/// - Parameter active: If the check button is active.
/// - Parameter inconsistent: If the check button is in an in between state.
/// - Parameter useUnderline: If set, an underline in the text indicates that the following character is to be used as mnemonic.
/// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot.
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
/// - Parameter onToggled: Invoked when the widget emits the `toggled` signal.
public init(active: Bool? = nil, inconsistent: Bool? = nil, useUnderline: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil, onToggled: (() -> Void)? = nil) {
make = { _ in Gtk.CheckButton() }
configure.append { w, ctx in
if let active { w.setActive(setting: active) }
if let inconsistent { w.setInconsistent(inconsistent: inconsistent) }
if let useUnderline { w.setUseUnderline(setting: useUnderline) }
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
if let onToggled { ctx.registry.add(w.connectToggled { _ in onToggled() }) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.CheckButton.init(label:)
/// Creates a new `GtkCheckButton` with the given text.
///
/// Applied once at mount; use the `Binding`, closure, or `InterpolatedText` overload for values that change.
/// A string literal containing interpolation selects the `InterpolatedText` overload instead, which updates live.
/// Each closure is evaluated once; children are added in order and slot closures mount their first view.
/// An empty closure adds no children and leaves slots unset.
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
///
/// - Parameter label: Text of the label inside the check button, if it contains a label widget.
/// - Parameter active: If the check button is active.
/// - Parameter inconsistent: If the check button is in an in between state.
/// - Parameter useUnderline: If set, an underline in the text indicates that the following character is to be used as mnemonic.
/// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot.
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
/// - Parameter onToggled: Invoked when the widget emits the `toggled` signal.
@_disfavoredOverload
public init<S: StringProtocol>(label: S?, active: Bool? = nil, inconsistent: Bool? = nil, useUnderline: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil, onToggled: (() -> Void)? = nil) {
make = { _ in Gtk.CheckButton(label: label.map { String($0) }) }
configure.append { w, ctx in
if let active { w.setActive(setting: active) }
if let inconsistent { w.setInconsistent(inconsistent: inconsistent) }
if let useUnderline { w.setUseUnderline(setting: useUnderline) }
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
if let onToggled { ctx.registry.add(w.connectToggled { _ in onToggled() }) }
}
}
// PorticoGen: generateInits(binding) | source: Gtk.CheckButton.init(label:), Gtk.CheckButton.setLabel(label:)
/// Creates a new `GtkCheckButton` with the given text.
///
/// The initial value is the binding's current value; every later change is pushed into the widget through `Gtk.CheckButton.setLabel(label:)` without rebuilding the view.
/// Each closure is evaluated once; children are added in order and slot closures mount their first view.
/// An empty closure adds no children and leaves slots unset.
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
/// Optional `Binding` parameters bind through `Portico.bindProperty`, so they are two-way wherever the wrapper exposes a safe getter.
///
/// - Parameter label: Text of the label inside the check button, if it contains a label widget.
/// - Parameter active: If the check button is active.
/// - Parameter inconsistent: If the check button is in an in between state.
/// - Parameter useUnderline: If set, an underline in the text indicates that the following character is to be used as mnemonic.
/// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot.
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
/// - Parameter onToggled: Invoked when the widget emits the `toggled` signal.
public init(label: Portico.Binding<String?>, active: Portico.Binding<Bool>? = nil, inconsistent: Portico.Binding<Bool>? = nil, useUnderline: Portico.Binding<Bool>? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil, onToggled: (() -> Void)? = nil) {
make = { _ in Gtk.CheckButton(label: label.wrappedValue) }
configure.append { w, ctx in
ctx.registry.add(label.subscribe { [w] v in w.setLabel(label: v) })
if let active {
Portico.bindProperty(w, active, registry: ctx.registry, notifyDetail: "active", read: { [w] in w.getActive() }, write: { [w] v in w.setActive(setting: v) })
}
if let inconsistent {
Portico.bindProperty(w, inconsistent, registry: ctx.registry, notifyDetail: "inconsistent", read: { [w] in w.getInconsistent() }, write: { [w] v in w.setInconsistent(inconsistent: v) })
}
if let useUnderline {
Portico.bindProperty(w, useUnderline, registry: ctx.registry, notifyDetail: "use-underline", read: { [w] in w.getUseUnderline() }, write: { [w] v in w.setUseUnderline(setting: v) })
}
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
if let onToggled { ctx.registry.add(w.connectToggled { _ in onToggled() }) }
}
}
// PorticoGen: generateInits(closure) | source: Gtk.CheckButton.init(label:), Gtk.CheckButton.setLabel(label:)
/// Creates a new `GtkCheckButton` with the given text.
///
/// Each closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.CheckButton.setLabel(label:)`.
/// Each closure is evaluated once; children are added in order and slot closures mount their first view.
/// An empty closure adds no children and leaves slots unset.
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
///
/// - Parameter label: Text of the label inside the check button, if it contains a label widget.
/// - Parameter active: If the check button is active.
/// - Parameter inconsistent: If the check button is in an in between state.
/// - Parameter useUnderline: If set, an underline in the text indicates that the following character is to be used as mnemonic.
/// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot.
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
/// - Parameter onToggled: Invoked when the widget emits the `toggled` signal.
public init(label: @escaping () -> String?, active: Bool? = nil, inconsistent: Bool? = nil, useUnderline: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil, onToggled: (() -> Void)? = nil) {
make = { _ in Gtk.CheckButton(label: label()) }
configure.append { w, ctx in
let t0 = DependencyTracker { [w] in w.setLabel(label: label()) }
t0.run()
ctx.registry.add(t0)
if let active { w.setActive(setting: active) }
if let inconsistent { w.setInconsistent(inconsistent: inconsistent) }
if let useUnderline { w.setUseUnderline(setting: useUnderline) }
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
if let onToggled { ctx.registry.add(w.connectToggled { _ in onToggled() }) }
}
}
// PorticoGen: generateInits(interpolation) | source: Gtk.CheckButton.init(label:), Gtk.CheckButton.setLabel(label:)
/// Creates a new `GtkCheckButton` with the given text.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.CheckButton.setLabel(label:)`. A literal with no interpolation is applied once, with no subscription.
/// Each closure is evaluated once; children are added in order and slot closures mount their first view.
/// An empty closure adds no children and leaves slots unset.
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
///
/// - Parameter label: Text of the label inside the check button, if it contains a label widget.
/// - Parameter active: If the check button is active.
/// - Parameter inconsistent: If the check button is in an in between state.
/// - Parameter useUnderline: If set, an underline in the text indicates that the following character is to be used as mnemonic.
/// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot.
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
/// - Parameter onToggled: Invoked when the widget emits the `toggled` signal.
public init(label: Portico.InterpolatedText?, active: Bool? = nil, inconsistent: Bool? = nil, useUnderline: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil, onToggled: (() -> Void)? = nil) {
make = { _ in Gtk.CheckButton(label: label?.untrackedText) }
configure.append { w, ctx in
Portico.bindOptionalInterpolation(label, registry: ctx.registry) { [w] v in w.setLabel(label: v) }
if let active { w.setActive(setting: active) }
if let inconsistent { w.setInconsistent(inconsistent: inconsistent) }
if let useUnderline { w.setUseUnderline(setting: useUnderline) }
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
if let onToggled { ctx.registry.add(w.connectToggled { _ in onToggled() }) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.CheckButton.init(withMnemonicLabel:)
/// Creates a new `GtkCheckButton` with the given text and a mnemonic.
///
/// Applied once at mount; use the `Binding` or closure overload for values that change.
/// Each closure is evaluated once; children are added in order and slot closures mount their first view.
/// An empty closure adds no children and leaves slots unset.
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
///
/// - Parameter withMnemonicLabel: The `withMnemonicLabel` value forwarded to `Gtk.CheckButton`.
/// - Parameter active: If the check button is active.
/// - Parameter inconsistent: If the check button is in an in between state.
/// - Parameter useUnderline: If set, an underline in the text indicates that the following character is to be used as mnemonic.
/// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot.
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
/// - Parameter onToggled: Invoked when the widget emits the `toggled` signal.
public init(withMnemonicLabel: String?, active: Bool? = nil, inconsistent: Bool? = nil, useUnderline: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil, onToggled: (() -> Void)? = nil) {
make = { _ in Gtk.CheckButton(withMnemonicLabel: withMnemonicLabel) }
configure.append { w, ctx in
if let active { w.setActive(setting: active) }
if let inconsistent { w.setInconsistent(inconsistent: inconsistent) }
if let useUnderline { w.setUseUnderline(setting: useUnderline) }
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
if let onToggled { ctx.registry.add(w.connectToggled { _ in onToggled() }) }
}
}
}
extension CheckButton: WidgetView {
public typealias Target = Gtk.CheckButton
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.CheckButton, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension CheckButton: Mountable {
@_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget {
let w = make(ctx)
for step in configure { step(w, ctx) }
return w
}
}
// PorticoGen: generateModifierExtension | source: Gtk.CheckButton
/// Modifiers for `Gtk.CheckButton`, available on every Portico view whose
/// backing widget is `Gtk.CheckButton` or one of its subclasses.
extension WidgetView where Target: Gtk.CheckButton {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.CheckButton.setActive(setting:)
/// Changes the check buttons active state.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter active: If the check button is active.
/// - Returns: A copy of this view with the modifier applied.
public func active(_ active: Bool) -> Self {
appending { w, _ in
w.setActive(setting: active)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.CheckButton.setActive(setting:), GObject.Object.connectNotify(detail:_:), Gtk.CheckButton.getActive()
/// Changes the check buttons active state.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func active(_ active: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, active, registry: ctx.registry, notifyDetail: "active",
read: { [w] in w.getActive() },
write: { [w] v in w.setActive(setting: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.CheckButton.setActive(setting:)
/// Changes the check buttons active state.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.CheckButton.setActive(setting:)`.
///
/// - Parameter active: If the check button is active.
/// - Returns: A copy of this view with the modifier applied.
public func active(_ active: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setActive(setting: active()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.CheckButton.setChild(child:)
/// Sets the child widget of `button`.
///
/// Note that by using this API, you take full responsibility for setting
/// up the proper accessibility label and description information for `button`.
/// Most likely, you'll either set the accessibility label or description
/// for `button` explicitly, or you'll set a labelled-by or described-by
/// relations from `child` to `button`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter child: The child widget.
/// - Returns: A copy of this view with the modifier applied.
public func child(_ child: Gtk.Widget?) -> Self {
appending { w, _ in
w.setChild(child: child)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Gtk.CheckButton.setChild(child:)
/// Sets the child widget of `button`.
///
/// Note that by using this API, you take full responsibility for setting
/// up the proper accessibility label and description information for `button`.
/// Most likely, you'll either set the accessibility label or description
/// for `button` explicitly, or you'll set a labelled-by or described-by
/// relations from `child` to `button`.
///
/// The closure is evaluated once when the modifier is applied. Its first view is mounted into the slot.
/// Additional views are ignored; an empty closure leaves the slot unset.
///
/// - Parameter child: The child widget.
/// - Returns: A copy of this view with the modifier applied.
public func child(@ViewBuilder _ child: () -> [AnyView]) -> Self {
let childViews = child()
return appending { w, ctx in
guard let v = childViews.first else { return }
w.setChild(child: v.makeWidget(ctx))
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.CheckButton.setChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.CheckButton.getChild()
/// Sets the child widget of `button`.
///
/// Note that by using this API, you take full responsibility for setting
/// up the proper accessibility label and description information for `button`.
/// Most likely, you'll either set the accessibility label or description
/// for `button` explicitly, or you'll set a labelled-by or described-by
/// relations from `child` to `button`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.Widget?` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func child<W: Gtk.Widget>(_ child: Portico.Binding<W?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, child, registry: ctx.registry, notifyDetail: "child",
read: { [w] in w.getChild() as? W },
write: { [w] v in w.setChild(child: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.CheckButton.setChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.CheckButton.getChild()
/// Sets the child widget of `button`.
///
/// Note that by using this API, you take full responsibility for setting
/// up the proper accessibility label and description information for `button`.
/// Most likely, you'll either set the accessibility label or description
/// for `button` explicitly, or you'll set a labelled-by or described-by
/// relations from `child` to `button`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Gtk.Widget>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.Widget?>` to be able to clear the property.
/// When `Gtk.Widget` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
/// A `nil` widget value is never written back into the binding.
///
/// - Returns: A copy of this view with the modifier applied.
public func child<W: Gtk.Widget>(_ child: Portico.Binding<W>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, child, registry: ctx.registry, notifyDetail: "child",
read: { [w] in w.getChild() as? W },
write: { [w] v in w.setChild(child: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.CheckButton.setChild(child:)
/// Sets the child widget of `button`.
///
/// Note that by using this API, you take full responsibility for setting
/// up the proper accessibility label and description information for `button`.
/// Most likely, you'll either set the accessibility label or description
/// for `button` explicitly, or you'll set a labelled-by or described-by
/// relations from `child` to `button`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.CheckButton.setChild(child:)`.
///
/// - Parameter child: The child widget.
/// - Returns: A copy of this view with the modifier applied.
public func child(_ child: @escaping () -> Gtk.Widget?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setChild(child: child()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.CheckButton.setInconsistent(inconsistent:)
/// Sets the `GtkCheckButton` to inconsistent state.
///
/// You should turn off the inconsistent state again if the user checks
/// the check button. This has to be done manually.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter inconsistent: If the check button is in an in between state.
/// - Returns: A copy of this view with the modifier applied.
public func inconsistent(_ inconsistent: Bool) -> Self {
appending { w, _ in
w.setInconsistent(inconsistent: inconsistent)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.CheckButton.setInconsistent(inconsistent:), GObject.Object.connectNotify(detail:_:), Gtk.CheckButton.getInconsistent()
/// Sets the `GtkCheckButton` to inconsistent state.
///
/// You should turn off the inconsistent state again if the user checks
/// the check button. This has to be done manually.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func inconsistent(_ inconsistent: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, inconsistent, registry: ctx.registry, notifyDetail: "inconsistent",
read: { [w] in w.getInconsistent() },
write: { [w] v in w.setInconsistent(inconsistent: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.CheckButton.setInconsistent(inconsistent:)
/// Sets the `GtkCheckButton` to inconsistent state.
///
/// You should turn off the inconsistent state again if the user checks
/// the check button. This has to be done manually.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.CheckButton.setInconsistent(inconsistent:)`.
///
/// - Parameter inconsistent: If the check button is in an in between state.
/// - Returns: A copy of this view with the modifier applied.
public func inconsistent(_ inconsistent: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setInconsistent(inconsistent: inconsistent()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.CheckButton.setLabel(label:)
/// Sets the text of `self`.
///
/// If [property`Gtk`.CheckButton:use-underline] is `true`, an underscore
/// in `label` is interpreted as mnemonic indicator, see
/// [method`Gtk`.CheckButton.set_use_underline] for details on this behavior.
///
/// Applied once at mount; use the `Binding`, closure, or `InterpolatedText` overload for a value that changes.
/// A string literal containing interpolation selects the `InterpolatedText` overload instead, which updates live.
///
/// - Parameter label: Text of the label inside the check button, if it contains a label widget.
/// - Returns: A copy of this view with the modifier applied.
@_disfavoredOverload
public func label<S: StringProtocol>(_ label: S?) -> Self {
appending { w, _ in
w.setLabel(label: label.map { String($0) })
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.CheckButton.setLabel(label:), GObject.Object.connectNotify(detail:_:), Gtk.CheckButton.getLabel()
/// Sets the text of `self`.
///
/// If [property`Gtk`.CheckButton:use-underline] is `true`, an underscore
/// in `label` is interpreted as mnemonic indicator, see
/// [method`Gtk`.CheckButton.set_use_underline] for details on this behavior.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `String?` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func label(_ label: Portico.Binding<String?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, label, registry: ctx.registry, notifyDetail: "label",
read: { [w] in w.getLabel() },
write: { [w] v in w.setLabel(label: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.CheckButton.setLabel(label:), GObject.Object.connectNotify(detail:_:), Gtk.CheckButton.getLabel()
/// Sets the text of `self`.
///
/// If [property`Gtk`.CheckButton:use-underline] is `true`, an underscore
/// in `label` is interpreted as mnemonic indicator, see
/// [method`Gtk`.CheckButton.set_use_underline] for details on this behavior.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<String>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<String?>` to be able to clear the property.
/// When `String` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
/// A `nil` widget value is never written back into the binding.
///
/// - Returns: A copy of this view with the modifier applied.
public func label(_ label: Portico.Binding<String>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, label, registry: ctx.registry, notifyDetail: "label",
read: { [w] in w.getLabel() },
write: { [w] v in w.setLabel(label: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.CheckButton.setLabel(label:)
/// Sets the text of `self`.
///
/// If [property`Gtk`.CheckButton:use-underline] is `true`, an underscore
/// in `label` is interpreted as mnemonic indicator, see
/// [method`Gtk`.CheckButton.set_use_underline] for details on this behavior.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.CheckButton.setLabel(label:)`.
///
/// - Parameter label: Text of the label inside the check button, if it contains a label widget.
/// - Returns: A copy of this view with the modifier applied.
public func label(_ label: @escaping () -> String?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setLabel(label: label()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Gtk.CheckButton.setLabel(label:)
/// Sets the text of `self`.
///
/// If [property`Gtk`.CheckButton:use-underline] is `true`, an underscore
/// in `label` is interpreted as mnemonic indicator, see
/// [method`Gtk`.CheckButton.set_use_underline] for details on this behavior.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.CheckButton.setLabel(label:)`. A literal with no interpolation is applied once, with no subscription.
///
/// - Parameter label: Text of the label inside the check button, if it contains a label widget.
/// - Returns: A copy of this view with the modifier applied.
public func label(_ label: Portico.InterpolatedText?) -> Self {
appending { w, ctx in
Portico.bindOptionalInterpolation(label, registry: ctx.registry) { [w] v in w.setLabel(label: v) }
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.CheckButton.setUseUnderline(setting:)
/// 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 [property`Gtk`.Label:use-underline].
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter useUnderline: If set, an underline in the text indicates that the following character is to be used as mnemonic.
/// - Returns: A copy of this view with the modifier applied.
public func useUnderline(_ useUnderline: Bool) -> Self {
appending { w, _ in
w.setUseUnderline(setting: useUnderline)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.CheckButton.setUseUnderline(setting:), GObject.Object.connectNotify(detail:_:), Gtk.CheckButton.getUseUnderline()
/// 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 [property`Gtk`.Label:use-underline].
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func useUnderline(_ useUnderline: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, useUnderline, registry: ctx.registry, notifyDetail: "use-underline",
read: { [w] in w.getUseUnderline() },
write: { [w] v in w.setUseUnderline(setting: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.CheckButton.setUseUnderline(setting:)
/// 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 [property`Gtk`.Label:use-underline].
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.CheckButton.setUseUnderline(setting:)`.
///
/// - Parameter useUnderline: If set, an underline in the text indicates that the following character is to be used as mnemonic.
/// - Returns: A copy of this view with the modifier applied.
public func useUnderline(_ useUnderline: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setUseUnderline(setting: useUnderline()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.CheckButton.connectActivate(_:)
/// 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
/// [signal`Gtk`.CheckButton::toggled] signal.
///
/// The default bindings for this signal are all forms of the
/// <kbd></kbd> and <kbd>Enter</kbd> keys.
///
/// - Parameter handler: Invoked when the widget emits the `activate` signal.
/// - Returns: A copy of this view with the modifier applied.
public func onActivate(_ handler: @escaping () -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectActivate { _ in handler() })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.CheckButton.connectToggled(_:)
/// Emitted when the buttons's [property`Gtk`.CheckButton:active]
/// property changes.
///
/// - Parameter handler: Invoked when the widget emits the `toggled` signal.
/// - Returns: A copy of this view with the modifier applied.
public func onToggled(_ handler: @escaping () -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectToggled { _ in handler() })
}
}
}