portico/Sources/Portico/Generated/ListBoxRow.swift

253 lines
13 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
import Adw
import Gtk
import Gio
import Gdk
// PorticoGen: generateStruct | source: Gtk.ListBoxRow
/// The kind of widget that can be added to a `GtkListBox`.
///
/// [class`Gtk`.ListBox] will automatically wrap its children in a `GtkListboxRow`
/// when necessary.
///
/// A Portico view that mounts a `Gtk.ListBoxRow`.
@MainActor public struct ListBoxRow: View {
private let make: (MountContext) -> Gtk.ListBoxRow
private var configure: [(Gtk.ListBoxRow, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.ListBoxRow.init()
/// Creates a new `GtkListBoxRow`.
///
/// 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 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 onActivate: Invoked when the widget emits the `activate` signal.
public init(activatable: Bool? = nil, selectable: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil) {
make = { _ in Gtk.ListBoxRow() }
configure.append { w, ctx in
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 onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
}
}
}
extension ListBoxRow: WidgetView {
public typealias Target = Gtk.ListBoxRow
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.ListBoxRow, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension ListBoxRow: 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.ListBoxRow
/// Modifiers for `Gtk.ListBoxRow`, available on every Portico view whose
/// backing widget is `Gtk.ListBoxRow` or one of its subclasses.
extension WidgetView where Target: Gtk.ListBoxRow {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.ListBoxRow.setActivatable(activatable:)
/// Set whether the row is activatable.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter activatable: Determines whether the ::row-activated signal will be emitted for this row.
/// - Returns: A copy of this view with the modifier applied.
public func activatable(_ activatable: Bool) -> Self {
appending { w, _ in
w.setActivatable(activatable: activatable)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.ListBoxRow.setActivatable(activatable:), GObject.Object.connectNotify(detail:_:), Gtk.ListBoxRow.getActivatable()
/// Set whether the row is activatable.
///
/// 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 activatable(_ activatable: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, activatable, registry: ctx.registry, notifyDetail: "activatable",
read: { [w] in w.getActivatable() },
write: { [w] v in w.setActivatable(activatable: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.ListBoxRow.setActivatable(activatable:)
/// Set whether the row is activatable.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.ListBoxRow.setActivatable(activatable:)`.
///
/// - Parameter activatable: Determines whether the ::row-activated signal will be emitted for this row.
/// - Returns: A copy of this view with the modifier applied.
public func activatable(_ activatable: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setActivatable(activatable: activatable()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.ListBoxRow.setChild(child:)
/// Sets the child widget of `self`.
///
/// 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.ListBoxRow.setChild(child:)
/// Sets the child widget of `self`.
///
/// 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.ListBoxRow.setChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.ListBoxRow.getChild()
/// Sets the child widget of `self`.
///
/// 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.ListBoxRow.setChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.ListBoxRow.getChild()
/// Sets the child widget of `self`.
///
/// 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.ListBoxRow.setChild(child:)
/// Sets the child widget of `self`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.ListBoxRow.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.ListBoxRow.setSelectable(selectable:)
/// Set whether the row can be selected.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter selectable: Determines whether this row can be selected.
/// - Returns: A copy of this view with the modifier applied.
public func selectable(_ selectable: Bool) -> Self {
appending { w, _ in
w.setSelectable(selectable: selectable)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.ListBoxRow.setSelectable(selectable:), GObject.Object.connectNotify(detail:_:), Gtk.ListBoxRow.getSelectable()
/// Set whether the row can be selected.
///
/// 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 selectable(_ selectable: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, selectable, registry: ctx.registry, notifyDetail: "selectable",
read: { [w] in w.getSelectable() },
write: { [w] v in w.setSelectable(selectable: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.ListBoxRow.setSelectable(selectable:)
/// Set whether the row can be selected.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.ListBoxRow.setSelectable(selectable:)`.
///
/// - Parameter selectable: Determines whether this row can be selected.
/// - Returns: A copy of this view with the modifier applied.
public func selectable(_ selectable: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setSelectable(selectable: selectable()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.ListBoxRow.connectActivate(_:)
/// This is a keybinding signal, which will cause this row to be activated.
///
/// If you want to be notified when the user activates a row (by key or not),
/// use the [signal`Gtk`.ListBox::row-activated] signal on the rows parent
/// `GtkListBox`.
///
/// - 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() })
}
}
}