portico/Sources/Portico/Generated/ButtonRow.swift

290 lines
16 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.ButtonRow
/// A [class`Gtk`.ListBoxRow] that looks like a button.
///
/// <picture>
/// <source srcset="button-rows-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="button-rows.png" alt="button-rows">
/// </picture>
///
/// The `AdwButtonRow` widget has a title and two icons: before and after the
/// title.
///
/// It is convenient for presenting actions like "Delete" at the end of a boxed
/// list.
///
/// `AdwButtonRow` is always activatable.
///
/// ## CSS nodes
///
/// `AdwButtonRow` has a main CSS node with name `row` and the style class
/// `.button`.
///
/// It contains the subnode `box` for its main horizontal box, which contains the
/// nodes: `image.icon.start` for the start icon, `label.title` for the title,
/// and `image.icon.end` for the end icon.
///
/// ## Style classes
///
/// The [`.suggested-action`](style-classes.html`suggested`-action) style class
/// makes `AdwButtonRow` use accent color for its background. It should be used
/// very sparingly to denote important buttons.
///
/// <picture>
/// <source srcset="button-row-suggested-action-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="button-row-suggested-action.png" alt="button-row-suggested-action">
/// </picture>
///
/// The [`.destructive-action`](style-classes.html`destructive`-action) style
/// makes the row use destructive colors. It can be used to draw attention to the
/// potentially damaging consequences of using it. This style acts as a warning
/// to the user.
///
/// <picture>
/// <source srcset="button-row-destructive-action-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="button-row-destructive-action.png" alt="button-row-destructive-action">
/// </picture>
///
/// A Portico view that mounts a `Adw.ButtonRow`.
@MainActor public struct ButtonRow: View {
private let make: (MountContext) -> Adw.ButtonRow
private var configure: [(Adw.ButtonRow, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Adw.ButtonRow.init()
/// Creates a new `AdwButtonRow`.
///
/// 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 endIconName: The icon name to show after the title.
/// - Parameter startIconName: The icon name to show before the title.
/// - 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 onActivated: Invoked when the widget emits the `activated` signal.
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
public init(endIconName: String? = nil, startIconName: String? = nil, title: String? = nil, titleSelectable: Bool? = nil, useMarkup: Bool? = nil, useUnderline: Bool? = nil, activatable: Bool? = nil, selectable: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, onActivated: (() -> Void)? = nil, onActivate: (() -> Void)? = nil) {
make = { _ in Adw.ButtonRow() }
configure.append { w, ctx in
if let endIconName { w.setEndIconName(iconName: endIconName) }
if let startIconName { w.setStartIconName(iconName: startIconName) }
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 onActivated { ctx.registry.add(w.connectActivated { _ in onActivated() }) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
}
}
}
extension ButtonRow: WidgetView {
public typealias Target = Adw.ButtonRow
@_spi(Portico) public func appending(
_ step: @escaping (Adw.ButtonRow, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension ButtonRow: 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.ButtonRow
/// Modifiers for `Adw.ButtonRow`, available on every Portico view whose
/// backing widget is `Adw.ButtonRow` or one of its subclasses.
extension WidgetView where Target: Adw.ButtonRow {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.ButtonRow.setEndIconName(iconName:)
/// Sets the end icon name for `self`.
///
/// 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 endIconName: The icon name to show after the title.
/// - Returns: A copy of this view with the modifier applied.
@_disfavoredOverload
public func endIconName<S: StringProtocol>(_ endIconName: S?) -> Self {
appending { w, _ in
w.setEndIconName(iconName: endIconName.map { String($0) })
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.ButtonRow.setEndIconName(iconName:), GObject.Object.connectNotify(detail:_:), Adw.ButtonRow.getEndIconName()
/// Sets the end icon name for `self`.
///
/// 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 endIconName(_ endIconName: Portico.Binding<String?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, endIconName, registry: ctx.registry, notifyDetail: "end-icon-name",
read: { [w] in w.getEndIconName() },
write: { [w] v in w.setEndIconName(iconName: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.ButtonRow.setEndIconName(iconName:), GObject.Object.connectNotify(detail:_:), Adw.ButtonRow.getEndIconName()
/// Sets the end icon name for `self`.
///
/// 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 endIconName(_ endIconName: Portico.Binding<String>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, endIconName, registry: ctx.registry, notifyDetail: "end-icon-name",
read: { [w] in w.getEndIconName() },
write: { [w] v in w.setEndIconName(iconName: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.ButtonRow.setEndIconName(iconName:)
/// Sets the end icon name for `self`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.ButtonRow.setEndIconName(iconName:)`.
///
/// - Parameter endIconName: The icon name to show after the title.
/// - Returns: A copy of this view with the modifier applied.
public func endIconName(_ endIconName: @escaping () -> String?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setEndIconName(iconName: endIconName()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.ButtonRow.setEndIconName(iconName:)
/// Sets the end icon name for `self`.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.ButtonRow.setEndIconName(iconName:)`. A literal with no interpolation is applied once, with no subscription.
///
/// - Parameter endIconName: The icon name to show after the title.
/// - Returns: A copy of this view with the modifier applied.
public func endIconName(_ endIconName: Portico.InterpolatedText?) -> Self {
appending { w, ctx in
Portico.bindOptionalInterpolation(endIconName, registry: ctx.registry) { [w] v in w.setEndIconName(iconName: v) }
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.ButtonRow.setStartIconName(iconName:)
/// Sets the start icon name for `self`.
///
/// 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 startIconName: The icon name to show before the title.
/// - Returns: A copy of this view with the modifier applied.
@_disfavoredOverload
public func startIconName<S: StringProtocol>(_ startIconName: S?) -> Self {
appending { w, _ in
w.setStartIconName(iconName: startIconName.map { String($0) })
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.ButtonRow.setStartIconName(iconName:), GObject.Object.connectNotify(detail:_:), Adw.ButtonRow.getStartIconName()
/// Sets the start icon name for `self`.
///
/// 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 startIconName(_ startIconName: Portico.Binding<String?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, startIconName, registry: ctx.registry, notifyDetail: "start-icon-name",
read: { [w] in w.getStartIconName() },
write: { [w] v in w.setStartIconName(iconName: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.ButtonRow.setStartIconName(iconName:), GObject.Object.connectNotify(detail:_:), Adw.ButtonRow.getStartIconName()
/// Sets the start icon name for `self`.
///
/// 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 startIconName(_ startIconName: Portico.Binding<String>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, startIconName, registry: ctx.registry, notifyDetail: "start-icon-name",
read: { [w] in w.getStartIconName() },
write: { [w] v in w.setStartIconName(iconName: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.ButtonRow.setStartIconName(iconName:)
/// Sets the start icon name for `self`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.ButtonRow.setStartIconName(iconName:)`.
///
/// - Parameter startIconName: The icon name to show before the title.
/// - Returns: A copy of this view with the modifier applied.
public func startIconName(_ startIconName: @escaping () -> String?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setStartIconName(iconName: startIconName()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.ButtonRow.setStartIconName(iconName:)
/// Sets the start icon name for `self`.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.ButtonRow.setStartIconName(iconName:)`. A literal with no interpolation is applied once, with no subscription.
///
/// - Parameter startIconName: The icon name to show before the title.
/// - Returns: A copy of this view with the modifier applied.
public func startIconName(_ startIconName: Portico.InterpolatedText?) -> Self {
appending { w, ctx in
Portico.bindOptionalInterpolation(startIconName, registry: ctx.registry) { [w] v in w.setStartIconName(iconName: v) }
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.ButtonRow.connectActivated(_:)
/// This signal is emitted after the row has been activated.
///
/// - Parameter handler: Invoked when the widget emits the `activated` signal.
/// - Returns: A copy of this view with the modifier applied.
public func onActivated(_ handler: @escaping () -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectActivated { _ in handler() })
}
}
}