130 lines
6.5 KiB
Swift
130 lines
6.5 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: Gtk.MediaControls
|
|
/// Shows controls for video playback.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="media-controls-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img alt="An example GtkMediaControls" src="media-controls.png">
|
|
/// </picture>
|
|
///
|
|
/// Usually, `GtkMediaControls` is used as part of [class`Gtk`.Video].
|
|
///
|
|
/// A Portico view that mounts a `Gtk.MediaControls`.
|
|
@MainActor public struct MediaControls: View {
|
|
private let make: (MountContext) -> Gtk.MediaControls
|
|
private var configure: [(Gtk.MediaControls, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Gtk.MediaControls.init(stream:)
|
|
/// Creates a new `GtkMediaControls` managing the `stream` passed to it.
|
|
///
|
|
/// 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 stream: The `stream` value forwarded to `Gtk.MediaControls`.
|
|
/// - Parameter mediaStream: The media-stream managed by this object or `nil` if none.
|
|
public init(stream: Gtk.MediaStream?, mediaStream: Gtk.MediaStream? = nil) {
|
|
make = { _ in Gtk.MediaControls(stream: stream) }
|
|
configure.append { w, _ in
|
|
if let mediaStream { w.setMediaStream(stream: mediaStream) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension MediaControls: WidgetView {
|
|
public typealias Target = Gtk.MediaControls
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Gtk.MediaControls, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension MediaControls: 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.MediaControls
|
|
/// Modifiers for `Gtk.MediaControls`, available on every Portico view whose
|
|
/// backing widget is `Gtk.MediaControls` or one of its subclasses.
|
|
extension WidgetView where Target: Gtk.MediaControls {
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.MediaControls.setMediaStream(stream:)
|
|
/// Sets the stream that is controlled by `controls`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter mediaStream: The media-stream managed by this object or `nil` if none.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func mediaStream(_ mediaStream: Gtk.MediaStream?) -> Self {
|
|
appending { w, _ in
|
|
w.setMediaStream(stream: mediaStream)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.MediaControls.setMediaStream(stream:), GObject.Object.connectNotify(detail:_:), Gtk.MediaControls.getMediaStream()
|
|
/// Sets the stream that is controlled by `controls`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Gtk.MediaStream?` 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 mediaStream(_ mediaStream: Portico.Binding<Gtk.MediaStream?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, mediaStream, registry: ctx.registry, notifyDetail: "media-stream",
|
|
read: { [w] in w.getMediaStream() },
|
|
write: { [w] v in w.setMediaStream(stream: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.MediaControls.setMediaStream(stream:), GObject.Object.connectNotify(detail:_:), Gtk.MediaControls.getMediaStream()
|
|
/// Sets the stream that is controlled by `controls`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant, so a `Binding<Gtk.MediaStream>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.MediaStream?>` to be able to clear the property.
|
|
/// When `Gtk.MediaStream` 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 mediaStream(_ mediaStream: Portico.Binding<Gtk.MediaStream>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, mediaStream, registry: ctx.registry, notifyDetail: "media-stream",
|
|
read: { [w] in w.getMediaStream() },
|
|
write: { [w] v in w.setMediaStream(stream: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.MediaControls.setMediaStream(stream:)
|
|
/// Sets the stream that is controlled by `controls`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.MediaControls.setMediaStream(stream:)`.
|
|
///
|
|
/// - Parameter mediaStream: The media-stream managed by this object or `nil` if none.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func mediaStream(_ mediaStream: @escaping () -> Gtk.MediaStream?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setMediaStream(stream: mediaStream()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
}
|