portico/Sources/Portico/Generated/Video.swift

525 lines
29 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.Video
/// Shows a `GtkMediaStream` with media controls.
///
/// <picture>
/// <source srcset="video-dark.png" media="(prefers-color-scheme: dark)">
/// <img alt="An example GtkVideo" src="video.png">
/// </picture>
///
/// The controls are available separately as [class`Gtk`.MediaControls].
/// If you just want to display a video without controls, you can treat it
/// like any other paintable and for example put it into a [class`Gtk`.Picture].
///
/// `GtkVideo` aims to cover use cases such as previews, embedded animations,
/// etc. It supports autoplay, looping, and simple media controls. It does
/// not have support for video overlays, multichannel audio, device
/// selection, or input. If you are writing a full-fledged video player,
/// you may want to use the [iface`Gdk`.Paintable] API and a media framework
/// such as Gstreamer directly.
///
/// A Portico view that mounts a `Gtk.Video`.
@MainActor public struct Video: View {
private let make: (MountContext) -> Gtk.Video
private var configure: [(Gtk.Video, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.Video.init()
/// Creates a new empty `GtkVideo`.
///
/// 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 autoplay: If the video should automatically begin playing.
/// - Parameter graphicsOffload: Whether to enable graphics offload.
/// - Parameter loop: If new media files should be set to loop.
/// - Parameter mediaStream: The media-stream played
public init(autoplay: Bool? = nil, graphicsOffload: Gtk.GraphicsOffloadEnabled? = nil, loop: Bool? = nil, mediaStream: Gtk.MediaStream? = nil) {
make = { _ in Gtk.Video() }
configure.append { w, _ in
if let autoplay { w.setAutoplay(autoplay: autoplay) }
if let graphicsOffload { w.setGraphicsOffload(enabled: graphicsOffload) }
if let loop { w.setLoop(loop: loop) }
if let mediaStream { w.setMediaStream(stream: mediaStream) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.Video.init(file:)
/// Creates a `GtkVideo` to play back the given `file`.
///
/// 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 file: The file played by this video if the video is playing a file.
/// - Parameter autoplay: If the video should automatically begin playing.
/// - Parameter graphicsOffload: Whether to enable graphics offload.
/// - Parameter loop: If new media files should be set to loop.
/// - Parameter mediaStream: The media-stream played
public init(file: Gtk.File?, autoplay: Bool? = nil, graphicsOffload: Gtk.GraphicsOffloadEnabled? = nil, loop: Bool? = nil, mediaStream: Gtk.MediaStream? = nil) {
make = { _ in Gtk.Video(file: file) }
configure.append { w, _ in
if let autoplay { w.setAutoplay(autoplay: autoplay) }
if let graphicsOffload { w.setGraphicsOffload(enabled: graphicsOffload) }
if let loop { w.setLoop(loop: loop) }
if let mediaStream { w.setMediaStream(stream: mediaStream) }
}
}
// PorticoGen: generateInits(binding) | source: Gtk.Video.init(file:), Gtk.Video.setFile(file:)
/// Creates a `GtkVideo` to play back the given `file`.
///
/// The initial value is the binding's current value; every later change is pushed into the widget through `Gtk.Video.setFile(file:)` without rebuilding the view.
/// 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.
/// Optional `Binding` parameters bind through `Portico.bindProperty`, so they are two-way wherever the wrapper exposes a safe getter.
///
/// - Parameter file: The file played by this video if the video is playing a file.
/// - Parameter autoplay: If the video should automatically begin playing.
/// - Parameter graphicsOffload: Whether to enable graphics offload.
/// - Parameter loop: If new media files should be set to loop.
/// - Parameter mediaStream: The media-stream played
public init(file: Portico.Binding<Gtk.File?>, autoplay: Portico.Binding<Bool>? = nil, graphicsOffload: Portico.Binding<Gtk.GraphicsOffloadEnabled>? = nil, loop: Portico.Binding<Bool>? = nil, mediaStream: Portico.Binding<Gtk.MediaStream?>? = nil) {
make = { _ in Gtk.Video(file: file.wrappedValue) }
configure.append { w, ctx in
ctx.registry.add(file.subscribe { [w] v in w.setFile(file: v) })
if let autoplay {
Portico.bindProperty(w, autoplay, registry: ctx.registry, notifyDetail: "autoplay", read: { [w] in w.getAutoplay() }, write: { [w] v in w.setAutoplay(autoplay: v) })
}
if let graphicsOffload {
Portico.bindProperty(w, graphicsOffload, registry: ctx.registry, notifyDetail: "graphics-offload", read: { [w] in w.getGraphicsOffload() }, write: { [w] v in w.setGraphicsOffload(enabled: v) })
}
if let loop {
Portico.bindProperty(w, loop, registry: ctx.registry, notifyDetail: "loop", read: { [w] in w.getLoop() }, write: { [w] v in w.setLoop(loop: v) })
}
if let mediaStream {
Portico.bindProperty(w, mediaStream, registry: ctx.registry, notifyDetail: "media-stream", read: { [w] in w.getMediaStream() }, write: { [w] v in w.setMediaStream(stream: v) })
}
}
}
// PorticoGen: generateInits(closure) | source: Gtk.Video.init(file:), Gtk.Video.setFile(file:)
/// Creates a `GtkVideo` to play back the given `file`.
///
/// Each closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Video.setFile(file:)`.
/// 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 file: The file played by this video if the video is playing a file.
/// - Parameter autoplay: If the video should automatically begin playing.
/// - Parameter graphicsOffload: Whether to enable graphics offload.
/// - Parameter loop: If new media files should be set to loop.
/// - Parameter mediaStream: The media-stream played
public init(file: @escaping () -> Gtk.File?, autoplay: Bool? = nil, graphicsOffload: Gtk.GraphicsOffloadEnabled? = nil, loop: Bool? = nil, mediaStream: Gtk.MediaStream? = nil) {
make = { _ in Gtk.Video(file: file()) }
configure.append { w, ctx in
let t0 = DependencyTracker { [w] in w.setFile(file: file()) }
t0.run()
ctx.registry.add(t0)
if let autoplay { w.setAutoplay(autoplay: autoplay) }
if let graphicsOffload { w.setGraphicsOffload(enabled: graphicsOffload) }
if let loop { w.setLoop(loop: loop) }
if let mediaStream { w.setMediaStream(stream: mediaStream) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.Video.init(filename:)
/// Creates a `GtkVideo` to play back the given `filename`.
///
/// This is a utility function that calls [ctor`Gtk`.Video.new_for_file],
/// See that function for details.
///
/// 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 filename: Makes `self` play the given `filename`.
/// - Parameter autoplay: If the video should automatically begin playing.
/// - Parameter graphicsOffload: Whether to enable graphics offload.
/// - Parameter loop: If new media files should be set to loop.
/// - Parameter mediaStream: The media-stream played
public init(filename: String?, autoplay: Bool? = nil, graphicsOffload: Gtk.GraphicsOffloadEnabled? = nil, loop: Bool? = nil, mediaStream: Gtk.MediaStream? = nil) {
make = { _ in Gtk.Video(filename: filename) }
configure.append { w, _ in
if let autoplay { w.setAutoplay(autoplay: autoplay) }
if let graphicsOffload { w.setGraphicsOffload(enabled: graphicsOffload) }
if let loop { w.setLoop(loop: loop) }
if let mediaStream { w.setMediaStream(stream: mediaStream) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.Video.init(stream:)
/// Creates a `GtkVideo` to play back the given `stream`.
///
/// 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.Video`.
/// - Parameter autoplay: If the video should automatically begin playing.
/// - Parameter graphicsOffload: Whether to enable graphics offload.
/// - Parameter loop: If new media files should be set to loop.
/// - Parameter mediaStream: The media-stream played
public init(stream: Gtk.MediaStream?, autoplay: Bool? = nil, graphicsOffload: Gtk.GraphicsOffloadEnabled? = nil, loop: Bool? = nil, mediaStream: Gtk.MediaStream? = nil) {
make = { _ in Gtk.Video(stream: stream) }
configure.append { w, _ in
if let autoplay { w.setAutoplay(autoplay: autoplay) }
if let graphicsOffload { w.setGraphicsOffload(enabled: graphicsOffload) }
if let loop { w.setLoop(loop: loop) }
if let mediaStream { w.setMediaStream(stream: mediaStream) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.Video.init(resourcePath:)
/// Creates a `GtkVideo` to play back the resource at the
/// given `resource_path`.
///
/// This is a utility function that calls [ctor`Gtk`.Video.new_for_file].
///
/// 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 resourcePath: The `resourcePath` value forwarded to `Gtk.Video`.
/// - Parameter autoplay: If the video should automatically begin playing.
/// - Parameter graphicsOffload: Whether to enable graphics offload.
/// - Parameter loop: If new media files should be set to loop.
/// - Parameter mediaStream: The media-stream played
public init(resourcePath: String?, autoplay: Bool? = nil, graphicsOffload: Gtk.GraphicsOffloadEnabled? = nil, loop: Bool? = nil, mediaStream: Gtk.MediaStream? = nil) {
make = { _ in Gtk.Video(resourcePath: resourcePath) }
configure.append { w, _ in
if let autoplay { w.setAutoplay(autoplay: autoplay) }
if let graphicsOffload { w.setGraphicsOffload(enabled: graphicsOffload) }
if let loop { w.setLoop(loop: loop) }
if let mediaStream { w.setMediaStream(stream: mediaStream) }
}
}
}
extension Video: WidgetView {
public typealias Target = Gtk.Video
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.Video, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension Video: 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.Video
/// Modifiers for `Gtk.Video`, available on every Portico view whose
/// backing widget is `Gtk.Video` or one of its subclasses.
extension WidgetView where Target: Gtk.Video {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Video.setAutoplay(autoplay:)
/// Sets whether `self` automatically starts playback when it
/// becomes visible or when a new file gets loaded.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter autoplay: If the video should automatically begin playing.
/// - Returns: A copy of this view with the modifier applied.
public func autoplay(_ autoplay: Bool) -> Self {
appending { w, _ in
w.setAutoplay(autoplay: autoplay)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Video.setAutoplay(autoplay:), GObject.Object.connectNotify(detail:_:), Gtk.Video.getAutoplay()
/// Sets whether `self` automatically starts playback when it
/// becomes visible or when a new file gets loaded.
///
/// 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 autoplay(_ autoplay: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, autoplay, registry: ctx.registry, notifyDetail: "autoplay",
read: { [w] in w.getAutoplay() },
write: { [w] v in w.setAutoplay(autoplay: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Video.setAutoplay(autoplay:)
/// Sets whether `self` automatically starts playback when it
/// becomes visible or when a new file gets loaded.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Video.setAutoplay(autoplay:)`.
///
/// - Parameter autoplay: If the video should automatically begin playing.
/// - Returns: A copy of this view with the modifier applied.
public func autoplay(_ autoplay: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setAutoplay(autoplay: autoplay()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Video.setFile(file:)
/// Makes `self` play the given `file`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter file: The file played by this video if the video is playing a file.
/// - Returns: A copy of this view with the modifier applied.
public func file(_ file: Gtk.File?) -> Self {
appending { w, _ in
w.setFile(file: file)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Video.setFile(file:), GObject.Object.connectNotify(detail:_:), Gtk.Video.getFile()
/// Makes `self` play the given `file`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.File?` 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 file(_ file: Portico.Binding<Gtk.File?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, file, registry: ctx.registry, notifyDetail: "file",
read: { [w] in w.getFile() },
write: { [w] v in w.setFile(file: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.Video.setFile(file:), GObject.Object.connectNotify(detail:_:), Gtk.Video.getFile()
/// Makes `self` play the given `file`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Gtk.File>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.File?>` to be able to clear the property.
/// When `Gtk.File` 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 file(_ file: Portico.Binding<Gtk.File>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, file, registry: ctx.registry, notifyDetail: "file",
read: { [w] in w.getFile() },
write: { [w] v in w.setFile(file: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Video.setFile(file:)
/// Makes `self` play the given `file`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Video.setFile(file:)`.
///
/// - Parameter file: The file played by this video if the video is playing a file.
/// - Returns: A copy of this view with the modifier applied.
public func file(_ file: @escaping () -> Gtk.File?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setFile(file: file()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Video.setGraphicsOffload(enabled:)
/// Sets whether to enable graphics offload.
///
/// See [class`Gtk`.GraphicsOffload] for more information on graphics offload.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter graphicsOffload: Whether to enable graphics offload.
/// - Returns: A copy of this view with the modifier applied.
public func graphicsOffload(_ graphicsOffload: Gtk.GraphicsOffloadEnabled) -> Self {
appending { w, _ in
w.setGraphicsOffload(enabled: graphicsOffload)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Video.setGraphicsOffload(enabled:), GObject.Object.connectNotify(detail:_:), Gtk.Video.getGraphicsOffload()
/// Sets whether to enable graphics offload.
///
/// See [class`Gtk`.GraphicsOffload] for more information on graphics offload.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.GraphicsOffloadEnabled` 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 graphicsOffload(_ graphicsOffload: Portico.Binding<Gtk.GraphicsOffloadEnabled>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, graphicsOffload, registry: ctx.registry, notifyDetail: "graphics-offload",
read: { [w] in w.getGraphicsOffload() },
write: { [w] v in w.setGraphicsOffload(enabled: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Video.setGraphicsOffload(enabled:)
/// Sets whether to enable graphics offload.
///
/// See [class`Gtk`.GraphicsOffload] for more information on graphics offload.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Video.setGraphicsOffload(enabled:)`.
///
/// - Parameter graphicsOffload: Whether to enable graphics offload.
/// - Returns: A copy of this view with the modifier applied.
public func graphicsOffload(_ graphicsOffload: @escaping () -> Gtk.GraphicsOffloadEnabled) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setGraphicsOffload(enabled: graphicsOffload()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Video.setLoop(loop:)
/// Sets whether new files loaded by `self` should be set to loop.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter loop: If new media files should be set to loop.
/// - Returns: A copy of this view with the modifier applied.
public func loop(_ loop: Bool) -> Self {
appending { w, _ in
w.setLoop(loop: loop)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Video.setLoop(loop:), GObject.Object.connectNotify(detail:_:), Gtk.Video.getLoop()
/// Sets whether new files loaded by `self` should be set to loop.
///
/// 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 loop(_ loop: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, loop, registry: ctx.registry, notifyDetail: "loop",
read: { [w] in w.getLoop() },
write: { [w] v in w.setLoop(loop: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Video.setLoop(loop:)
/// Sets whether new files loaded by `self` should be set to loop.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Video.setLoop(loop:)`.
///
/// - Parameter loop: If new media files should be set to loop.
/// - Returns: A copy of this view with the modifier applied.
public func loop(_ loop: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setLoop(loop: loop()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Video.setMediaStream(stream:)
/// Sets the media stream to be played back.
///
/// `self` will take full control of managing the media stream. If you
/// want to manage a media stream yourself, consider using a
/// [class`Gtk`.Picture] for display.
///
/// If you want to display a file, consider using [method`Gtk`.Video.set_file]
/// instead.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter mediaStream: The media-stream played
/// - 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.Video.setMediaStream(stream:), GObject.Object.connectNotify(detail:_:), Gtk.Video.getMediaStream()
/// Sets the media stream to be played back.
///
/// `self` will take full control of managing the media stream. If you
/// want to manage a media stream yourself, consider using a
/// [class`Gtk`.Picture] for display.
///
/// If you want to display a file, consider using [method`Gtk`.Video.set_file]
/// instead.
///
/// 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.Video.setMediaStream(stream:), GObject.Object.connectNotify(detail:_:), Gtk.Video.getMediaStream()
/// Sets the media stream to be played back.
///
/// `self` will take full control of managing the media stream. If you
/// want to manage a media stream yourself, consider using a
/// [class`Gtk`.Picture] for display.
///
/// If you want to display a file, consider using [method`Gtk`.Video.set_file]
/// instead.
///
/// 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.Video.setMediaStream(stream:)
/// Sets the media stream to be played back.
///
/// `self` will take full control of managing the media stream. If you
/// want to manage a media stream yourself, consider using a
/// [class`Gtk`.Picture] for display.
///
/// If you want to display a file, consider using [method`Gtk`.Video.set_file]
/// instead.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Video.setMediaStream(stream:)`.
///
/// - Parameter mediaStream: The media-stream played
/// - 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)
}
}
}