portico/Sources/Portico/Generated/StatusPage.swift

490 lines
27 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.StatusPage
/// A page used for empty/error states and similar use-cases.
///
/// <picture>
/// <source srcset="status-page-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="status-page.png" alt="status-page">
/// </picture>
///
/// The `AdwStatusPage` widget can have an icon, a title, a description and a
/// custom widget which is displayed below them.
///
/// ## CSS nodes
///
/// `AdwStatusPage` has a main CSS node with name `statuspage`.
///
/// When setting an [class`SpinnerPaintable`] as [property`StatusPage`:paintable],
/// the main nodes gains the `.spinner` style class for a more compact
/// appearance.
///
/// ## Style classes
///
/// `AdwStatusPage` can use the
/// [`.compact`](style-classes.html`compact`-status-page) style class for when it
/// needs to fit into a small space such a sidebar or a popover, similar to when
/// using a spinner as the paintable.
///
/// <picture>
/// <source srcset="status-page-compact-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="status-page-compact.png" alt="status-page-compact">
/// </picture>
///
/// A Portico view that mounts a `Adw.StatusPage`.
@MainActor public struct StatusPage: View {
private let make: (MountContext) -> Adw.StatusPage
private var configure: [(Adw.StatusPage, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Adw.StatusPage.init()
/// Creates a new `AdwStatusPage`.
///
/// 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 description: The description markup to be displayed below the title.
/// - Parameter iconName: The name of the icon to be used.
/// - Parameter paintable: The paintable to be used.
/// - Parameter title: The title to be displayed below the icon.
/// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot.
public init(description: String? = nil, iconName: String? = nil, paintable: Adw.Paintable? = nil, title: String? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }) {
make = { _ in Adw.StatusPage() }
configure.append { w, ctx in
if let description { w.setDescription(description: description) }
if let iconName { w.setIconName(iconName: iconName) }
if let paintable { w.setPaintable(paintable: paintable) }
if let title { w.setTitle(title: title) }
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
}
}
}
extension StatusPage: WidgetView {
public typealias Target = Adw.StatusPage
@_spi(Portico) public func appending(
_ step: @escaping (Adw.StatusPage, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension StatusPage: 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.StatusPage
/// Modifiers for `Adw.StatusPage`, available on every Portico view whose
/// backing widget is `Adw.StatusPage` or one of its subclasses.
extension WidgetView where Target: Adw.StatusPage {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.StatusPage.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: Adw.Widget?) -> Self {
appending { w, _ in
w.setChild(child: child)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Adw.StatusPage.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: Adw.StatusPage.setChild(child:), GObject.Object.connectNotify(detail:_:), Adw.StatusPage.getChild()
/// Sets the child widget of `self`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.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: Adw.StatusPage.setChild(child:), GObject.Object.connectNotify(detail:_:), Adw.StatusPage.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<Adw.Widget>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Adw.Widget?>` to be able to clear the property.
/// When `Adw.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: Adw.StatusPage.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 `Adw.StatusPage.setChild(child:)`.
///
/// - Parameter child: The child widget.
/// - Returns: A copy of this view with the modifier applied.
public func child(_ child: @escaping () -> Adw.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: Adw.StatusPage.setDescription(description:)
/// Sets the description markup for `self`.
///
/// The description is displayed below the title. It is parsed as Pango markup.
///
/// 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 description: The description markup to be displayed below the title.
/// - Returns: A copy of this view with the modifier applied.
@_disfavoredOverload
public func description<S: StringProtocol>(_ description: S?) -> Self {
appending { w, _ in
w.setDescription(description: description.map { String($0) })
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.StatusPage.setDescription(description:), GObject.Object.connectNotify(detail:_:), Adw.StatusPage.getDescription()
/// Sets the description markup for `self`.
///
/// The description is displayed below the title. It is parsed as Pango markup.
///
/// 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 description(_ description: Portico.Binding<String?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, description, registry: ctx.registry, notifyDetail: "description",
read: { [w] in w.getDescription() },
write: { [w] v in w.setDescription(description: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.StatusPage.setDescription(description:), GObject.Object.connectNotify(detail:_:), Adw.StatusPage.getDescription()
/// Sets the description markup for `self`.
///
/// The description is displayed below the title. It is parsed as Pango markup.
///
/// 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 description(_ description: Portico.Binding<String>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, description, registry: ctx.registry, notifyDetail: "description",
read: { [w] in w.getDescription() },
write: { [w] v in w.setDescription(description: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.StatusPage.setDescription(description:)
/// Sets the description markup for `self`.
///
/// The description is displayed below the title. It is parsed as Pango markup.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.StatusPage.setDescription(description:)`.
///
/// - Parameter description: The description markup to be displayed below the title.
/// - Returns: A copy of this view with the modifier applied.
public func description(_ description: @escaping () -> String?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setDescription(description: description()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.StatusPage.setDescription(description:)
/// Sets the description markup for `self`.
///
/// The description is displayed below the title. It is parsed as Pango markup.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.StatusPage.setDescription(description:)`. A literal with no interpolation is applied once, with no subscription.
///
/// - Parameter description: The description markup to be displayed below the title.
/// - Returns: A copy of this view with the modifier applied.
public func description(_ description: Portico.InterpolatedText?) -> Self {
appending { w, ctx in
Portico.bindOptionalInterpolation(description, registry: ctx.registry) { [w] v in w.setDescription(description: v) }
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.StatusPage.setIconName(iconName:)
/// Sets the icon name for `self`.
///
/// Changing this will set [property`StatusPage`:paintable] to `NULL`.
///
/// 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 iconName: The name of the icon to be used.
/// - Returns: A copy of this view with the modifier applied.
@_disfavoredOverload
public func iconName<S: StringProtocol>(_ iconName: S?) -> Self {
appending { w, _ in
w.setIconName(iconName: iconName.map { String($0) })
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.StatusPage.setIconName(iconName:), GObject.Object.connectNotify(detail:_:), Adw.StatusPage.getIconName()
/// Sets the icon name for `self`.
///
/// Changing this will set [property`StatusPage`:paintable] to `NULL`.
///
/// 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 iconName(_ iconName: Portico.Binding<String?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, iconName, registry: ctx.registry, notifyDetail: "icon-name",
read: { [w] in w.getIconName() },
write: { [w] v in w.setIconName(iconName: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.StatusPage.setIconName(iconName:), GObject.Object.connectNotify(detail:_:), Adw.StatusPage.getIconName()
/// Sets the icon name for `self`.
///
/// Changing this will set [property`StatusPage`:paintable] to `NULL`.
///
/// 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 iconName(_ iconName: Portico.Binding<String>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, iconName, registry: ctx.registry, notifyDetail: "icon-name",
read: { [w] in w.getIconName() },
write: { [w] v in w.setIconName(iconName: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.StatusPage.setIconName(iconName:)
/// Sets the icon name for `self`.
///
/// Changing this will set [property`StatusPage`:paintable] to `NULL`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.StatusPage.setIconName(iconName:)`.
///
/// - Parameter iconName: The name of the icon to be used.
/// - Returns: A copy of this view with the modifier applied.
public func iconName(_ iconName: @escaping () -> String?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setIconName(iconName: iconName()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.StatusPage.setIconName(iconName:)
/// Sets the icon name for `self`.
///
/// Changing this will set [property`StatusPage`:paintable] to `NULL`.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.StatusPage.setIconName(iconName:)`. A literal with no interpolation is applied once, with no subscription.
///
/// - Parameter iconName: The name of the icon to be used.
/// - Returns: A copy of this view with the modifier applied.
public func iconName(_ iconName: Portico.InterpolatedText?) -> Self {
appending { w, ctx in
Portico.bindOptionalInterpolation(iconName, registry: ctx.registry) { [w] v in w.setIconName(iconName: v) }
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.StatusPage.setPaintable(paintable:)
/// Sets the paintable for `self`.
///
/// Changing this will set [property`StatusPage`:icon-name] to `NULL`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter paintable: The paintable to be used.
/// - Returns: A copy of this view with the modifier applied.
public func paintable(_ paintable: Adw.Paintable?) -> Self {
appending { w, _ in
w.setPaintable(paintable: paintable)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.StatusPage.setPaintable(paintable:), GObject.Object.connectNotify(detail:_:), Adw.StatusPage.getPaintable()
/// Sets the paintable for `self`.
///
/// Changing this will set [property`StatusPage`:icon-name] to `NULL`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.Paintable?` 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 paintable(_ paintable: Portico.Binding<Adw.Paintable?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, paintable, registry: ctx.registry, notifyDetail: "paintable",
read: { [w] in w.getPaintable() },
write: { [w] v in w.setPaintable(paintable: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.StatusPage.setPaintable(paintable:), GObject.Object.connectNotify(detail:_:), Adw.StatusPage.getPaintable()
/// Sets the paintable for `self`.
///
/// Changing this will set [property`StatusPage`:icon-name] to `NULL`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Adw.Paintable>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Adw.Paintable?>` to be able to clear the property.
/// When `Adw.Paintable` 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 paintable(_ paintable: Portico.Binding<Adw.Paintable>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, paintable, registry: ctx.registry, notifyDetail: "paintable",
read: { [w] in w.getPaintable() },
write: { [w] v in w.setPaintable(paintable: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.StatusPage.setPaintable(paintable:)
/// Sets the paintable for `self`.
///
/// Changing this will set [property`StatusPage`:icon-name] to `NULL`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.StatusPage.setPaintable(paintable:)`.
///
/// - Parameter paintable: The paintable to be used.
/// - Returns: A copy of this view with the modifier applied.
public func paintable(_ paintable: @escaping () -> Adw.Paintable?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setPaintable(paintable: paintable()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.StatusPage.setTitle(title:)
/// Sets the title for `self`.
///
/// The title is displayed below the icon. It is not parsed as Pango markup.
///
/// 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 title: The title to be displayed below the icon.
/// - Returns: A copy of this view with the modifier applied.
@_disfavoredOverload
public func title<S: StringProtocol>(_ title: S) -> Self {
appending { w, _ in
w.setTitle(title: String(title))
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.StatusPage.setTitle(title:), GObject.Object.connectNotify(detail:_:), Adw.StatusPage.getTitle()
/// Sets the title for `self`.
///
/// The title is displayed below the icon. It is not parsed as Pango markup.
///
/// 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 title(_ title: Portico.Binding<String>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, title, registry: ctx.registry, notifyDetail: "title",
read: { [w] in w.getTitle() },
write: { [w] v in w.setTitle(title: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.StatusPage.setTitle(title:)
/// Sets the title for `self`.
///
/// The title is displayed below the icon. It is not parsed as Pango markup.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.StatusPage.setTitle(title:)`.
///
/// - Parameter title: The title to be displayed below the icon.
/// - Returns: A copy of this view with the modifier applied.
public func title(_ title: @escaping () -> String) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setTitle(title: title()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.StatusPage.setTitle(title:)
/// Sets the title for `self`.
///
/// The title is displayed below the icon. It is not parsed as Pango markup.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.StatusPage.setTitle(title:)`. A literal with no interpolation is applied once, with no subscription.
///
/// - Parameter title: The title to be displayed below the icon.
/// - Returns: A copy of this view with the modifier applied.
public func title(_ title: Portico.InterpolatedText) -> Self {
appending { w, ctx in
Portico.bindInterpolation(title, registry: ctx.registry) { [w] v in w.setTitle(title: v) }
}
}
}