// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes. import Adw import Gtk import Gio import Gdk // PorticoGen: generateStruct | source: Adw.WindowTitle /// A helper widget for setting a window's title and subtitle. /// /// /// /// window-title /// /// /// `AdwWindowTitle` shows a title and subtitle. It's intended to be used as the /// title child of [class`Gtk`.HeaderBar] or [class`HeaderBar`]. /// /// ## CSS nodes /// /// `AdwWindowTitle` has a single CSS node with name `windowtitle`. /// /// A Portico view that mounts a `Adw.WindowTitle`. @MainActor public struct WindowTitle: View { private let make: (MountContext) -> Adw.WindowTitle private var configure: [(Adw.WindowTitle, MountContext) -> Void] = [] public var body: Never { fatalError() } // PorticoGen: generateInits(static) | source: Adw.WindowTitle.init(title:subtitle:) /// Creates a new `AdwWindowTitle`. /// /// 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 title: The title to display. /// - Parameter subtitle: The subtitle to display. public init(title: String, subtitle: String) { make = { _ in Adw.WindowTitle(title: title, subtitle: subtitle) } } // PorticoGen: generateInits(binding) | source: Adw.WindowTitle.init(title:subtitle:), Adw.WindowTitle.setTitle(title:), Adw.WindowTitle.setSubtitle(subtitle:) /// Creates a new `AdwWindowTitle`. /// /// The initial value is the binding's current value; every later change is pushed into the widget through `Adw.WindowTitle.setTitle(title:), Adw.WindowTitle.setSubtitle(subtitle:)` 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 title: The title to display. /// - Parameter subtitle: The subtitle to display. public init(title: Portico.Binding, subtitle: Portico.Binding) { make = { _ in Adw.WindowTitle(title: title.wrappedValue, subtitle: subtitle.wrappedValue) } configure.append { w, ctx in ctx.registry.add(title.subscribe { [w] v in w.setTitle(title: v) }) ctx.registry.add(subtitle.subscribe { [w] v in w.setSubtitle(subtitle: v) }) } } // PorticoGen: generateInits(closure) | source: Adw.WindowTitle.init(title:subtitle:), Adw.WindowTitle.setTitle(title:), Adw.WindowTitle.setSubtitle(subtitle:) /// Creates a new `AdwWindowTitle`. /// /// Each closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.WindowTitle.setTitle(title:), Adw.WindowTitle.setSubtitle(subtitle:)`. /// 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 title: The title to display. /// - Parameter subtitle: The subtitle to display. public init(title: @escaping () -> String, subtitle: @escaping () -> String) { make = { _ in Adw.WindowTitle(title: title(), subtitle: subtitle()) } configure.append { w, ctx in let t0 = DependencyTracker { [w] in w.setTitle(title: title()) } t0.run() ctx.registry.add(t0) let t1 = DependencyTracker { [w] in w.setSubtitle(subtitle: subtitle()) } t1.run() ctx.registry.add(t1) } } } extension WindowTitle: WidgetView { public typealias Target = Adw.WindowTitle @_spi(Portico) public func appending( _ step: @escaping (Adw.WindowTitle, MountContext) -> Void ) -> Self { var c = self c.configure.append(step) return c } } @_spi(Portico) extension WindowTitle: 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.WindowTitle /// Modifiers for `Adw.WindowTitle`, available on every Portico view whose /// backing widget is `Adw.WindowTitle` or one of its subclasses. extension WidgetView where Target: Adw.WindowTitle { // PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.WindowTitle.setSubtitle(subtitle:) /// Sets the subtitle of `self`. /// /// The subtitle should give the user additional details. /// /// 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 subtitle: The subtitle to display. /// - Returns: A copy of this view with the modifier applied. @_disfavoredOverload public func subtitle(_ subtitle: S) -> Self { appending { w, _ in w.setSubtitle(subtitle: String(subtitle)) } } // PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.WindowTitle.setSubtitle(subtitle:), GObject.Object.connectNotify(detail:_:), Adw.WindowTitle.getSubtitle() /// Sets the subtitle of `self`. /// /// The subtitle should give the user additional details. /// /// 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 subtitle(_ subtitle: Portico.Binding) -> Self { appending { w, ctx in Portico.bindProperty( w, subtitle, registry: ctx.registry, notifyDetail: "subtitle", read: { [w] in w.getSubtitle() }, write: { [w] v in w.setSubtitle(subtitle: v) } ) } } // PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.WindowTitle.setSubtitle(subtitle:) /// Sets the subtitle of `self`. /// /// The subtitle should give the user additional details. /// /// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.WindowTitle.setSubtitle(subtitle:)`. /// /// - Parameter subtitle: The subtitle to display. /// - Returns: A copy of this view with the modifier applied. public func subtitle(_ subtitle: @escaping () -> String) -> Self { appending { w, ctx in let tracker = DependencyTracker { [w] in w.setSubtitle(subtitle: subtitle()) } tracker.run() ctx.registry.add(tracker) } } // PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.WindowTitle.setSubtitle(subtitle:) /// Sets the subtitle of `self`. /// /// The subtitle should give the user additional details. /// /// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.WindowTitle.setSubtitle(subtitle:)`. A literal with no interpolation is applied once, with no subscription. /// /// - Parameter subtitle: The subtitle to display. /// - Returns: A copy of this view with the modifier applied. public func subtitle(_ subtitle: Portico.InterpolatedText) -> Self { appending { w, ctx in Portico.bindInterpolation(subtitle, registry: ctx.registry) { [w] v in w.setSubtitle(subtitle: v) } } } // PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.WindowTitle.setTitle(title:) /// Sets the title of `self`. /// /// The title typically identifies the current view or content item, and /// generally does not use the application name. /// /// 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 display. /// - Returns: A copy of this view with the modifier applied. @_disfavoredOverload public func title(_ title: S) -> Self { appending { w, _ in w.setTitle(title: String(title)) } } // PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.WindowTitle.setTitle(title:), GObject.Object.connectNotify(detail:_:), Adw.WindowTitle.getTitle() /// Sets the title of `self`. /// /// The title typically identifies the current view or content item, and /// generally does not use the application name. /// /// 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) -> 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.WindowTitle.setTitle(title:) /// Sets the title of `self`. /// /// The title typically identifies the current view or content item, and /// generally does not use the application name. /// /// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.WindowTitle.setTitle(title:)`. /// /// - Parameter title: The title to display. /// - 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.WindowTitle.setTitle(title:) /// Sets the title of `self`. /// /// The title typically identifies the current view or content item, and /// generally does not use the application name. /// /// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.WindowTitle.setTitle(title:)`. A literal with no interpolation is applied once, with no subscription. /// /// - Parameter title: The title to display. /// - 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) } } } }