74 lines
2.3 KiB
Swift
74 lines
2.3 KiB
Swift
// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
|
|
|
|
import Adw
|
|
import Gtk
|
|
import Gio
|
|
import Gdk
|
|
@_spi(Portico) import Portico
|
|
|
|
// PorticoGen: generateStruct | source: Gtk.Spinner
|
|
/// Displays an icon-size spinning animation.
|
|
///
|
|
/// It is often used as an alternative to a [class`Gtk`.ProgressBar]
|
|
/// for displaying indefinite activity, instead of actual progress.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="spinner-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img alt="An example GtkSpinner" src="spinner.png">
|
|
/// </picture>
|
|
///
|
|
/// To start the animation, use [method`Gtk`.Spinner.start], to stop it
|
|
/// use [method`Gtk`.Spinner.stop].
|
|
///
|
|
/// # CSS nodes
|
|
///
|
|
/// `GtkSpinner` has a single CSS node with the name spinner.
|
|
/// When the animation is active, the :checked pseudoclass is
|
|
/// added to this node.
|
|
///
|
|
/// # Accessibility
|
|
///
|
|
/// `GtkSpinner` uses the [enum`Gtk`.AccessibleRole.progress_bar] role.
|
|
///
|
|
/// A Portico view that mounts a `Gtk.Spinner`.
|
|
@MainActor public struct Spinner: View {
|
|
private let make: (MountContext) -> Gtk.Spinner
|
|
private var configure: [(Gtk.Spinner, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Gtk.Spinner.init()
|
|
/// Returns a new spinner widget. Not yet started.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for values that change.
|
|
/// 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 spinning: Whether the spinner is spinning
|
|
public init(spinning: Bool? = nil) {
|
|
make = { _ in Gtk.Spinner() }
|
|
configure.append { w, _ in
|
|
if let spinning { w.setSpinning(spinning: spinning) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension Spinner: WidgetView {
|
|
public typealias Target = Gtk.Spinner
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Gtk.Spinner, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension Spinner: Mountable {
|
|
@_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget {
|
|
let w = make(ctx)
|
|
for step in configure { step(w, ctx) }
|
|
return w
|
|
}
|
|
}
|