portico/Sources/Portico/Generated/SpinRow.swift

579 lines
34 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: Adw.SpinRow
/// An [class`ActionRow`] with an embedded spin button.
///
/// <picture>
/// <source srcset="spin-row-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="spin-row.png" alt="spin-row">
/// </picture>
///
/// Example of an `AdwSpinRow` UI definition:
///
/// ```xml
/// <object class="AdwSpinRow">
/// <property name="title" translatable="yes">Spin Row</property>
/// <property name="adjustment">
/// <object class="GtkAdjustment">
/// <property name="lower">0</property>
/// <property name="upper">100</property>
/// <property name="value">50</property>
/// <property name="page-increment">10</property>
/// <property name="step-increment">1</property>
/// </object>
/// </property>
/// </object>
/// ```
///
/// See [class`Gtk`.SpinButton] for details.
///
/// ## CSS nodes
///
/// `AdwSpinRow` has the same structure as [class`ActionRow`], as well as the
/// `.spin` style class on the main node.
///
/// ## Accessibility
///
/// `AdwSpinRow` uses an internal `GtkSpinButton` with the
/// [enum`Gtk`.AccessibleRole.spin-button] role.
///
/// A Portico view that mounts a `Adw.SpinRow`.
@MainActor public struct SpinRow: View {
private let make: (MountContext) -> Adw.SpinRow
private var configure: [(Adw.SpinRow, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Adw.SpinRow.init(adjustment:climbRate:digits:)
/// Creates a new `AdwSpinRow`.
///
/// 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 adjustment: The adjustment that holds the value of the spin row.
/// - Parameter climbRate: The acceleration rate when you hold down a button or key.
/// - Parameter digits: The number of decimal places to display.
/// - Parameter numeric: Whether non-numeric characters should be ignored.
/// - Parameter snapToTicks: Whether invalid values are snapped to the nearest step increment.
/// - Parameter updatePolicy: The policy for updating the spin row.
/// - Parameter value: The current value.
/// - Parameter wrap: Whether the spin row should wrap upon reaching its limits.
/// - Parameter iconName: The icon name for this row.
/// - Parameter subtitle: The subtitle for this row.
/// - Parameter subtitleLines: The number of lines at the end of which the subtitle label will be ellipsized.
/// - Parameter subtitleSelectable: Whether the user can copy the subtitle from the label.
/// - Parameter titleLines: The number of lines at the end of which the title label will be ellipsized.
/// - Parameter title: The title of the preference represented by this row.
/// - Parameter titleSelectable: Whether the user can copy the title from the label.
/// - Parameter useMarkup: Whether to use Pango markup for the title label.
/// - Parameter useUnderline: Whether an embedded underline in the title indicates a mnemonic.
/// - Parameter activatable: Determines whether the ::row-activated signal will be emitted for this row.
/// - Parameter selectable: Determines whether this row can be selected.
/// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot.
/// - Parameter activatableWidget: A `ViewBuilder` closure whose first view is mounted into the `activatableWidget` slot.
/// - Parameter onInput: Invoked when the widget emits the `input` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
/// - Parameter onOutput: Invoked when the widget emits the `output` signal. Its return value is forwarded to GTK as the signal's result.
/// - Parameter onWrapped: Invoked when the widget emits the `wrapped` signal.
/// - Parameter onActivated: Invoked when the widget emits the `activated` signal.
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
public init(adjustment: Adw.Adjustment?, climbRate: Double, digits: UInt32, numeric: Bool? = nil, snapToTicks: Bool? = nil, updatePolicy: Adw.SpinButtonUpdatePolicy? = nil, value: Double? = nil, wrap: Bool? = nil, iconName: String? = nil, subtitle: String? = nil, subtitleLines: Int32? = nil, subtitleSelectable: Bool? = nil, titleLines: Int32? = nil, title: String? = nil, titleSelectable: Bool? = nil, useMarkup: Bool? = nil, useUnderline: Bool? = nil, activatable: Bool? = nil, selectable: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, @ViewBuilder activatableWidget: @escaping () -> [AnyView] = { [] }, onInput: ((Double) -> Int32)? = nil, onOutput: (() -> Bool)? = nil, onWrapped: (() -> Void)? = nil, onActivated: (() -> Void)? = nil, onActivate: (() -> Void)? = nil) {
make = { _ in Adw.SpinRow(adjustment: adjustment, climbRate: climbRate, digits: digits) }
configure.append { w, ctx in
if let numeric { w.setNumeric(numeric: numeric) }
if let snapToTicks { w.setSnapToTicks(snapToTicks: snapToTicks) }
if let updatePolicy { w.setUpdatePolicy(policy: updatePolicy) }
if let value { w.setValue(value: value) }
if let wrap { w.setWrap(wrap: wrap) }
if let iconName { w.setIconName(iconName: iconName) }
if let subtitle { w.setSubtitle(subtitle: subtitle) }
if let subtitleLines { w.setSubtitleLines(subtitleLines: subtitleLines) }
if let subtitleSelectable { w.setSubtitleSelectable(subtitleSelectable: subtitleSelectable) }
if let titleLines { w.setTitleLines(titleLines: titleLines) }
if let title { w.setTitle(title: title) }
if let titleSelectable { w.setTitleSelectable(titleSelectable: titleSelectable) }
if let useMarkup { w.setUseMarkup(useMarkup: useMarkup) }
if let useUnderline { w.setUseUnderline(useUnderline: useUnderline) }
if let activatable { w.setActivatable(activatable: activatable) }
if let selectable { w.setSelectable(selectable: selectable) }
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
if let v = Portico.mountSlotChild(activatableWidget, ctx, onUpdate: { v in w.setActivatableWidget(widget: v) }) { w.setActivatableWidget(widget: v) }
if let onInput { ctx.registry.add(w.connectInput { _, a0 in onInput(a0) }) }
if let onOutput { ctx.registry.add(w.connectOutput { _ in onOutput() }) }
if let onWrapped { ctx.registry.add(w.connectWrapped { _ in onWrapped() }) }
if let onActivated { ctx.registry.add(w.connectActivated { _ in onActivated() }) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
}
}
// PorticoGen: generateInits(static) | source: Adw.SpinRow.init(min:max:step:)
/// Creates a new `AdwSpinRow` with the given properties.
///
/// This is a convenience constructor that allows creation of a numeric
/// `AdwSpinRow` without manually creating an adjustment. The value is initially
/// set to the minimum value and a page increment of 10 * `step` is the default.
/// The precision of the spin row is equivalent to the precisions of `step`.
///
/// ::: note
/// The way in which the precision is derived works best if `step` is a power
/// of ten. If the resulting precision is not suitable for your needs, use
/// [method`SpinRow`.set_digits] to correct it.
///
/// 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 min: The `min` value forwarded to `Adw.SpinRow`.
/// - Parameter max: The `max` value forwarded to `Adw.SpinRow`.
/// - Parameter step: The `step` value forwarded to `Adw.SpinRow`.
/// - Parameter numeric: Whether non-numeric characters should be ignored.
/// - Parameter snapToTicks: Whether invalid values are snapped to the nearest step increment.
/// - Parameter updatePolicy: The policy for updating the spin row.
/// - Parameter value: The current value.
/// - Parameter wrap: Whether the spin row should wrap upon reaching its limits.
/// - Parameter iconName: The icon name for this row.
/// - Parameter subtitle: The subtitle for this row.
/// - Parameter subtitleLines: The number of lines at the end of which the subtitle label will be ellipsized.
/// - Parameter subtitleSelectable: Whether the user can copy the subtitle from the label.
/// - Parameter titleLines: The number of lines at the end of which the title label will be ellipsized.
/// - Parameter title: The title of the preference represented by this row.
/// - Parameter titleSelectable: Whether the user can copy the title from the label.
/// - Parameter useMarkup: Whether to use Pango markup for the title label.
/// - Parameter useUnderline: Whether an embedded underline in the title indicates a mnemonic.
/// - Parameter activatable: Determines whether the ::row-activated signal will be emitted for this row.
/// - Parameter selectable: Determines whether this row can be selected.
/// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot.
/// - Parameter activatableWidget: A `ViewBuilder` closure whose first view is mounted into the `activatableWidget` slot.
/// - Parameter onInput: Invoked when the widget emits the `input` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
/// - Parameter onOutput: Invoked when the widget emits the `output` signal. Its return value is forwarded to GTK as the signal's result.
/// - Parameter onWrapped: Invoked when the widget emits the `wrapped` signal.
/// - Parameter onActivated: Invoked when the widget emits the `activated` signal.
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
public init(min: Double, max: Double, step: Double, numeric: Bool? = nil, snapToTicks: Bool? = nil, updatePolicy: Adw.SpinButtonUpdatePolicy? = nil, value: Double? = nil, wrap: Bool? = nil, iconName: String? = nil, subtitle: String? = nil, subtitleLines: Int32? = nil, subtitleSelectable: Bool? = nil, titleLines: Int32? = nil, title: String? = nil, titleSelectable: Bool? = nil, useMarkup: Bool? = nil, useUnderline: Bool? = nil, activatable: Bool? = nil, selectable: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, @ViewBuilder activatableWidget: @escaping () -> [AnyView] = { [] }, onInput: ((Double) -> Int32)? = nil, onOutput: (() -> Bool)? = nil, onWrapped: (() -> Void)? = nil, onActivated: (() -> Void)? = nil, onActivate: (() -> Void)? = nil) {
make = { _ in Adw.SpinRow(min: min, max: max, step: step) }
configure.append { w, ctx in
if let numeric { w.setNumeric(numeric: numeric) }
if let snapToTicks { w.setSnapToTicks(snapToTicks: snapToTicks) }
if let updatePolicy { w.setUpdatePolicy(policy: updatePolicy) }
if let value { w.setValue(value: value) }
if let wrap { w.setWrap(wrap: wrap) }
if let iconName { w.setIconName(iconName: iconName) }
if let subtitle { w.setSubtitle(subtitle: subtitle) }
if let subtitleLines { w.setSubtitleLines(subtitleLines: subtitleLines) }
if let subtitleSelectable { w.setSubtitleSelectable(subtitleSelectable: subtitleSelectable) }
if let titleLines { w.setTitleLines(titleLines: titleLines) }
if let title { w.setTitle(title: title) }
if let titleSelectable { w.setTitleSelectable(titleSelectable: titleSelectable) }
if let useMarkup { w.setUseMarkup(useMarkup: useMarkup) }
if let useUnderline { w.setUseUnderline(useUnderline: useUnderline) }
if let activatable { w.setActivatable(activatable: activatable) }
if let selectable { w.setSelectable(selectable: selectable) }
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
if let v = Portico.mountSlotChild(activatableWidget, ctx, onUpdate: { v in w.setActivatableWidget(widget: v) }) { w.setActivatableWidget(widget: v) }
if let onInput { ctx.registry.add(w.connectInput { _, a0 in onInput(a0) }) }
if let onOutput { ctx.registry.add(w.connectOutput { _ in onOutput() }) }
if let onWrapped { ctx.registry.add(w.connectWrapped { _ in onWrapped() }) }
if let onActivated { ctx.registry.add(w.connectActivated { _ in onActivated() }) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
}
}
}
extension SpinRow: WidgetView {
public typealias Target = Adw.SpinRow
@_spi(Portico) public func appending(
_ step: @escaping (Adw.SpinRow, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension SpinRow: 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: Adw.SpinRow
/// Modifiers for `Adw.SpinRow`, available on every Portico view whose
/// backing widget is `Adw.SpinRow` or one of its subclasses.
extension WidgetView where Target: Adw.SpinRow {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.SpinRow.setClimbRate(climbRate:)
/// Sets the acceleration rate when you hold down a button or key.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter climbRate: The acceleration rate when you hold down a button or key.
/// - Returns: A copy of this view with the modifier applied.
public func climbRate(_ climbRate: Double) -> Self {
appending { w, _ in
w.setClimbRate(climbRate: climbRate)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.SpinRow.setClimbRate(climbRate:), GObject.Object.connectNotify(detail:_:), Adw.SpinRow.getClimbRate()
/// Sets the acceleration rate when you hold down a button or key.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Double` 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 climbRate(_ climbRate: Portico.Binding<Double>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, climbRate, registry: ctx.registry, notifyDetail: "climb-rate",
read: { [w] in w.getClimbRate() },
write: { [w] v in w.setClimbRate(climbRate: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.SpinRow.setClimbRate(climbRate:)
/// Sets the acceleration rate when you hold down a button or key.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.SpinRow.setClimbRate(climbRate:)`.
///
/// - Parameter climbRate: The acceleration rate when you hold down a button or key.
/// - Returns: A copy of this view with the modifier applied.
public func climbRate(_ climbRate: @escaping () -> Double) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setClimbRate(climbRate: climbRate()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.SpinRow.setDigits(digits:)
/// Sets the number of decimal places to display.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter digits: The number of decimal places to display.
/// - Returns: A copy of this view with the modifier applied.
public func digits(_ digits: UInt32) -> Self {
appending { w, _ in
w.setDigits(digits: digits)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.SpinRow.setDigits(digits:), GObject.Object.connectNotify(detail:_:), Adw.SpinRow.getDigits()
/// Sets the number of decimal places to display.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `UInt32` 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 digits(_ digits: Portico.Binding<UInt32>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, digits, registry: ctx.registry, notifyDetail: "digits",
read: { [w] in w.getDigits() },
write: { [w] v in w.setDigits(digits: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.SpinRow.setDigits(digits:)
/// Sets the number of decimal places to display.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.SpinRow.setDigits(digits:)`.
///
/// - Parameter digits: The number of decimal places to display.
/// - Returns: A copy of this view with the modifier applied.
public func digits(_ digits: @escaping () -> UInt32) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setDigits(digits: digits()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.SpinRow.setNumeric(numeric:)
/// Sets whether non-numeric characters should be ignored.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter numeric: Whether non-numeric characters should be ignored.
/// - Returns: A copy of this view with the modifier applied.
public func numeric(_ numeric: Bool) -> Self {
appending { w, _ in
w.setNumeric(numeric: numeric)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.SpinRow.setNumeric(numeric:), GObject.Object.connectNotify(detail:_:), Adw.SpinRow.getNumeric()
/// Sets whether non-numeric characters should be ignored.
///
/// 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 numeric(_ numeric: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, numeric, registry: ctx.registry, notifyDetail: "numeric",
read: { [w] in w.getNumeric() },
write: { [w] v in w.setNumeric(numeric: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.SpinRow.setNumeric(numeric:)
/// Sets whether non-numeric characters should be ignored.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.SpinRow.setNumeric(numeric:)`.
///
/// - Parameter numeric: Whether non-numeric characters should be ignored.
/// - Returns: A copy of this view with the modifier applied.
public func numeric(_ numeric: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setNumeric(numeric: numeric()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.SpinRow.setSnapToTicks(snapToTicks:)
/// Sets whether invalid values are snapped to the nearest step increment.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter snapToTicks: Whether invalid values are snapped to the nearest step increment.
/// - Returns: A copy of this view with the modifier applied.
public func snapToTicks(_ snapToTicks: Bool) -> Self {
appending { w, _ in
w.setSnapToTicks(snapToTicks: snapToTicks)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.SpinRow.setSnapToTicks(snapToTicks:), GObject.Object.connectNotify(detail:_:), Adw.SpinRow.getSnapToTicks()
/// Sets whether invalid values are snapped to the nearest step increment.
///
/// 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 snapToTicks(_ snapToTicks: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, snapToTicks, registry: ctx.registry, notifyDetail: "snap-to-ticks",
read: { [w] in w.getSnapToTicks() },
write: { [w] v in w.setSnapToTicks(snapToTicks: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.SpinRow.setSnapToTicks(snapToTicks:)
/// Sets whether invalid values are snapped to the nearest step increment.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.SpinRow.setSnapToTicks(snapToTicks:)`.
///
/// - Parameter snapToTicks: Whether invalid values are snapped to the nearest step increment.
/// - Returns: A copy of this view with the modifier applied.
public func snapToTicks(_ snapToTicks: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setSnapToTicks(snapToTicks: snapToTicks()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.SpinRow.setUpdatePolicy(policy:)
/// Sets the policy for updating the spin row.
///
/// The options are always, or only when the value is invalid.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter updatePolicy: The policy for updating the spin row.
/// - Returns: A copy of this view with the modifier applied.
public func updatePolicy(_ updatePolicy: Adw.SpinButtonUpdatePolicy) -> Self {
appending { w, _ in
w.setUpdatePolicy(policy: updatePolicy)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.SpinRow.setUpdatePolicy(policy:), GObject.Object.connectNotify(detail:_:), Adw.SpinRow.getUpdatePolicy()
/// Sets the policy for updating the spin row.
///
/// The options are always, or only when the value is invalid.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.SpinButtonUpdatePolicy` 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 updatePolicy(_ updatePolicy: Portico.Binding<Adw.SpinButtonUpdatePolicy>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, updatePolicy, registry: ctx.registry, notifyDetail: "update-policy",
read: { [w] in w.getUpdatePolicy() },
write: { [w] v in w.setUpdatePolicy(policy: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.SpinRow.setUpdatePolicy(policy:)
/// Sets the policy for updating the spin row.
///
/// The options are always, or only when the value is invalid.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.SpinRow.setUpdatePolicy(policy:)`.
///
/// - Parameter updatePolicy: The policy for updating the spin row.
/// - Returns: A copy of this view with the modifier applied.
public func updatePolicy(_ updatePolicy: @escaping () -> Adw.SpinButtonUpdatePolicy) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setUpdatePolicy(policy: updatePolicy()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.SpinRow.setValue(value:)
/// Sets the current value.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter value: The current value.
/// - Returns: A copy of this view with the modifier applied.
public func value(_ value: Double) -> Self {
appending { w, _ in
w.setValue(value: value)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.SpinRow.setValue(value:), GObject.Object.connectNotify(detail:_:), Adw.SpinRow.getValue()
/// Sets the current value.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Double` 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 value(_ value: Portico.Binding<Double>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, value, registry: ctx.registry, notifyDetail: "value",
read: { [w] in w.getValue() },
write: { [w] v in w.setValue(value: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.SpinRow.setValue(value:)
/// Sets the current value.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.SpinRow.setValue(value:)`.
///
/// - Parameter value: The current value.
/// - Returns: A copy of this view with the modifier applied.
public func value(_ value: @escaping () -> Double) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setValue(value: value()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.SpinRow.setWrap(wrap:)
/// Sets whether the spin row should wrap upon reaching its limits.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter wrap: Whether the spin row should wrap upon reaching its limits.
/// - Returns: A copy of this view with the modifier applied.
public func wrap(_ wrap: Bool) -> Self {
appending { w, _ in
w.setWrap(wrap: wrap)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.SpinRow.setWrap(wrap:), GObject.Object.connectNotify(detail:_:), Adw.SpinRow.getWrap()
/// Sets whether the spin row should wrap upon reaching its limits.
///
/// 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 wrap(_ wrap: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, wrap, registry: ctx.registry, notifyDetail: "wrap",
read: { [w] in w.getWrap() },
write: { [w] v in w.setWrap(wrap: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.SpinRow.setWrap(wrap:)
/// Sets whether the spin row should wrap upon reaching its limits.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.SpinRow.setWrap(wrap:)`.
///
/// - Parameter wrap: Whether the spin row should wrap upon reaching its limits.
/// - Returns: A copy of this view with the modifier applied.
public func wrap(_ wrap: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setWrap(wrap: wrap()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.SpinRow.connectInput(_:)
/// Emitted to convert the user's input into a double value.
///
/// The signal handler is expected to use [method`Gtk`.Editable.get_text] to
/// retrieve the text of the spinbutton and set new_value to the new value.
///
/// The default conversion uses [func`GLib`.strtod].
///
/// See [signal`Gtk`.SpinButton::input].
///
/// - Parameter handler: Invoked when the widget emits the `input` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
/// - Returns: A copy of this view with the modifier applied.
public func onInput(_ handler: @escaping (Double) -> Int32) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectInput { _, a0 in handler(a0) })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.SpinRow.connectOutput(_:)
/// Emitted to tweak the formatting of the value for display.
///
/// See [signal`Gtk`.SpinButton::output].
///
/// - Parameter handler: Invoked when the widget emits the `output` signal. Its return value is forwarded to GTK as the signal's result.
/// - Returns: A copy of this view with the modifier applied.
public func onOutput(_ handler: @escaping () -> Bool) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectOutput { _ in handler() })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.SpinRow.connectWrapped(_:)
/// Emitted right after the spinbutton wraps.
///
/// See [signal`Gtk`.SpinButton::wrapped].
///
/// - Parameter handler: Invoked when the widget emits the `wrapped` signal.
/// - Returns: A copy of this view with the modifier applied.
public func onWrapped(_ handler: @escaping () -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectWrapped { _ in handler() })
}
}
}