// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes. import Adw import Gtk import Gio import Gdk // PorticoGen: generateStruct | source: Gtk.WindowControls /// Shows window frame controls. /// /// Typical window frame controls are minimize, maximize and close buttons, /// and the window icon. /// /// /// /// An example GtkWindowControls /// /// /// `GtkWindowControls` only displays start or end side of the controls (see /// [property`Gtk`.WindowControls:side]), so it's intended to be always used /// in pair with another `GtkWindowControls` for the opposite side, for example: /// /// ```xml /// /// /// /// start /// /// /// /// ... /// /// /// /// end /// /// /// /// ``` /// /// # CSS nodes /// /// ``` /// windowcontrols /// ├── [image.icon] /// ├── [button.minimize] /// ├── [button.maximize] /// ╰── [button.close] /// ``` /// /// A `GtkWindowControls`' CSS node is called windowcontrols. It contains /// subnodes corresponding to each title button. Which of the title buttons /// exist and where they are placed exactly depends on the desktop environment /// and [property`Gtk`.WindowControls:decoration-layout] value. /// /// When [property`Gtk`.WindowControls:empty] is true, it gets the .empty /// style class. /// /// # Accessibility /// /// `GtkWindowControls` uses the [enum`Gtk`.AccessibleRole.group] role. /// /// A Portico view that mounts a `Gtk.WindowControls`. @MainActor public struct WindowControls: View { private let make: (MountContext) -> Gtk.WindowControls private var configure: [(Gtk.WindowControls, MountContext) -> Void] = [] public var body: Never { fatalError() } // PorticoGen: generateInits(static) | source: Gtk.WindowControls.init(side:) /// Creates a new `GtkWindowControls`. /// /// 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 side: Whether the widget shows start or end side of the decoration layout. /// - Parameter decorationLayout: The decoration layout for window buttons. /// - Parameter useNativeControls: Whether to show platform native close/minimize/maximize buttons. public init(side: Gtk.PackType, decorationLayout: String? = nil, useNativeControls: Bool? = nil) { make = { _ in Gtk.WindowControls(side: side) } configure.append { w, _ in if let decorationLayout { w.setDecorationLayout(layout: decorationLayout) } if let useNativeControls { w.setUseNativeControls(setting: useNativeControls) } } } // PorticoGen: generateInits(binding) | source: Gtk.WindowControls.init(side:), Gtk.WindowControls.setSide(side:) /// Creates a new `GtkWindowControls`. /// /// The initial value is the binding's current value; every later change is pushed into the widget through `Gtk.WindowControls.setSide(side:)` 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 side: Whether the widget shows start or end side of the decoration layout. /// - Parameter decorationLayout: The decoration layout for window buttons. /// - Parameter useNativeControls: Whether to show platform native close/minimize/maximize buttons. public init(side: Portico.Binding, decorationLayout: Portico.Binding? = nil, useNativeControls: Portico.Binding? = nil) { make = { _ in Gtk.WindowControls(side: side.wrappedValue) } configure.append { w, ctx in ctx.registry.add(side.subscribe { [w] v in w.setSide(side: v) }) if let decorationLayout { Portico.bindProperty(w, decorationLayout, registry: ctx.registry, notifyDetail: "decoration-layout", read: { [w] in w.getDecorationLayout() }, write: { [w] v in w.setDecorationLayout(layout: v) }) } if let useNativeControls { Portico.bindProperty(w, useNativeControls, registry: ctx.registry, notifyDetail: "use-native-controls", read: { [w] in w.getUseNativeControls() }, write: { [w] v in w.setUseNativeControls(setting: v) }) } } } // PorticoGen: generateInits(closure) | source: Gtk.WindowControls.init(side:), Gtk.WindowControls.setSide(side:) /// Creates a new `GtkWindowControls`. /// /// Each closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.WindowControls.setSide(side:)`. /// 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 side: Whether the widget shows start or end side of the decoration layout. /// - Parameter decorationLayout: The decoration layout for window buttons. /// - Parameter useNativeControls: Whether to show platform native close/minimize/maximize buttons. public init(side: @escaping () -> Gtk.PackType, decorationLayout: String? = nil, useNativeControls: Bool? = nil) { make = { _ in Gtk.WindowControls(side: side()) } configure.append { w, ctx in let t0 = DependencyTracker { [w] in w.setSide(side: side()) } t0.run() ctx.registry.add(t0) if let decorationLayout { w.setDecorationLayout(layout: decorationLayout) } if let useNativeControls { w.setUseNativeControls(setting: useNativeControls) } } } } extension WindowControls: WidgetView { public typealias Target = Gtk.WindowControls @_spi(Portico) public func appending( _ step: @escaping (Gtk.WindowControls, MountContext) -> Void ) -> Self { var c = self c.configure.append(step) return c } } @_spi(Portico) extension WindowControls: 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.WindowControls /// Modifiers for `Gtk.WindowControls`, available on every Portico view whose /// backing widget is `Gtk.WindowControls` or one of its subclasses. extension WidgetView where Target: Gtk.WindowControls { // PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.WindowControls.setDecorationLayout(layout:) /// Sets the decoration layout for the title buttons. /// /// This overrides the [property`Gtk`.Settings:gtk-decoration-layout] /// setting. /// /// The format of the string is button names, separated by commas. /// A colon separates the buttons that should appear on the left /// from those on the right. Recognized button names are minimize, /// maximize, close and icon (the window icon). /// /// For example, “icon:minimize,maximize,close” specifies a icon /// on the left, and minimize, maximize and close buttons on the right. /// /// If [property`Gtk`.WindowControls:side] value is [enum`Gtk`.PackType.start], /// `self` will display the part before the colon, otherwise after that. /// /// 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 decorationLayout: The decoration layout for window buttons. /// - Returns: A copy of this view with the modifier applied. @_disfavoredOverload public func decorationLayout(_ decorationLayout: S?) -> Self { appending { w, _ in w.setDecorationLayout(layout: decorationLayout.map { String($0) }) } } // PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.WindowControls.setDecorationLayout(layout:), GObject.Object.connectNotify(detail:_:), Gtk.WindowControls.getDecorationLayout() /// Sets the decoration layout for the title buttons. /// /// This overrides the [property`Gtk`.Settings:gtk-decoration-layout] /// setting. /// /// The format of the string is button names, separated by commas. /// A colon separates the buttons that should appear on the left /// from those on the right. Recognized button names are minimize, /// maximize, close and icon (the window icon). /// /// For example, “icon:minimize,maximize,close” specifies a icon /// on the left, and minimize, maximize and close buttons on the right. /// /// If [property`Gtk`.WindowControls:side] value is [enum`Gtk`.PackType.start], /// `self` will display the part before the colon, otherwise after that. /// /// 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 decorationLayout(_ decorationLayout: Portico.Binding) -> Self { appending { w, ctx in Portico.bindProperty( w, decorationLayout, registry: ctx.registry, notifyDetail: "decoration-layout", read: { [w] in w.getDecorationLayout() }, write: { [w] v in w.setDecorationLayout(layout: v) } ) } } // PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.WindowControls.setDecorationLayout(layout:), GObject.Object.connectNotify(detail:_:), Gtk.WindowControls.getDecorationLayout() /// Sets the decoration layout for the title buttons. /// /// This overrides the [property`Gtk`.Settings:gtk-decoration-layout] /// setting. /// /// The format of the string is button names, separated by commas. /// A colon separates the buttons that should appear on the left /// from those on the right. Recognized button names are minimize, /// maximize, close and icon (the window icon). /// /// For example, “icon:minimize,maximize,close” specifies a icon /// on the left, and minimize, maximize and close buttons on the right. /// /// If [property`Gtk`.WindowControls:side] value is [enum`Gtk`.PackType.start], /// `self` will display the part before the colon, otherwise after that. /// /// Applied at mount and re-applied on every change the binding publishes. /// `Binding` is invariant, so a `Binding` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding` 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 decorationLayout(_ decorationLayout: Portico.Binding) -> Self { appending { w, ctx in Portico.bindProperty( w, decorationLayout, registry: ctx.registry, notifyDetail: "decoration-layout", read: { [w] in w.getDecorationLayout() }, write: { [w] v in w.setDecorationLayout(layout: v) } ) } } // PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.WindowControls.setDecorationLayout(layout:) /// Sets the decoration layout for the title buttons. /// /// This overrides the [property`Gtk`.Settings:gtk-decoration-layout] /// setting. /// /// The format of the string is button names, separated by commas. /// A colon separates the buttons that should appear on the left /// from those on the right. Recognized button names are minimize, /// maximize, close and icon (the window icon). /// /// For example, “icon:minimize,maximize,close” specifies a icon /// on the left, and minimize, maximize and close buttons on the right. /// /// If [property`Gtk`.WindowControls:side] value is [enum`Gtk`.PackType.start], /// `self` will display the part before the colon, otherwise after that. /// /// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.WindowControls.setDecorationLayout(layout:)`. /// /// - Parameter decorationLayout: The decoration layout for window buttons. /// - Returns: A copy of this view with the modifier applied. public func decorationLayout(_ decorationLayout: @escaping () -> String?) -> Self { appending { w, ctx in let tracker = DependencyTracker { [w] in w.setDecorationLayout(layout: decorationLayout()) } tracker.run() ctx.registry.add(tracker) } } // PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Gtk.WindowControls.setDecorationLayout(layout:) /// Sets the decoration layout for the title buttons. /// /// This overrides the [property`Gtk`.Settings:gtk-decoration-layout] /// setting. /// /// The format of the string is button names, separated by commas. /// A colon separates the buttons that should appear on the left /// from those on the right. Recognized button names are minimize, /// maximize, close and icon (the window icon). /// /// For example, “icon:minimize,maximize,close” specifies a icon /// on the left, and minimize, maximize and close buttons on the right. /// /// If [property`Gtk`.WindowControls:side] value is [enum`Gtk`.PackType.start], /// `self` will display the part before the colon, otherwise after that. /// /// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.WindowControls.setDecorationLayout(layout:)`. A literal with no interpolation is applied once, with no subscription. /// /// - Parameter decorationLayout: The decoration layout for window buttons. /// - Returns: A copy of this view with the modifier applied. public func decorationLayout(_ decorationLayout: Portico.InterpolatedText?) -> Self { appending { w, ctx in Portico.bindOptionalInterpolation(decorationLayout, registry: ctx.registry) { [w] v in w.setDecorationLayout(layout: v) } } } // PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.WindowControls.setSide(side:) /// Determines which part of decoration layout /// the window controls widget uses. /// /// See [property`Gtk`.WindowControls:decoration-layout]. /// /// Applied once at mount; use the `Binding` or closure overload for a value that changes. /// /// - Parameter side: Whether the widget shows start or end side of the decoration layout. /// - Returns: A copy of this view with the modifier applied. public func side(_ side: Gtk.PackType) -> Self { appending { w, _ in w.setSide(side: side) } } // PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.WindowControls.setSide(side:), GObject.Object.connectNotify(detail:_:), Gtk.WindowControls.getSide() /// Determines which part of decoration layout /// the window controls widget uses. /// /// See [property`Gtk`.WindowControls:decoration-layout]. /// /// Applied at mount and re-applied on every change the binding publishes. /// When `Gtk.PackType` 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 side(_ side: Portico.Binding) -> Self { appending { w, ctx in Portico.bindProperty( w, side, registry: ctx.registry, notifyDetail: "side", read: { [w] in w.getSide() }, write: { [w] v in w.setSide(side: v) } ) } } // PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.WindowControls.setSide(side:) /// Determines which part of decoration layout /// the window controls widget uses. /// /// See [property`Gtk`.WindowControls:decoration-layout]. /// /// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.WindowControls.setSide(side:)`. /// /// - Parameter side: Whether the widget shows start or end side of the decoration layout. /// - Returns: A copy of this view with the modifier applied. public func side(_ side: @escaping () -> Gtk.PackType) -> Self { appending { w, ctx in let tracker = DependencyTracker { [w] in w.setSide(side: side()) } tracker.run() ctx.registry.add(tracker) } } // PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.WindowControls.setUseNativeControls(setting:) /// Sets whether platform native window controls are used. /// /// This option shows the "stoplight" buttons on macOS. /// For Linux, this option has no effect. /// /// See also [Using GTK on Apple macOS](osx.html?native-window-controls). /// /// Applied once at mount; use the `Binding` or closure overload for a value that changes. /// /// - Parameter useNativeControls: Whether to show platform native close/minimize/maximize buttons. /// - Returns: A copy of this view with the modifier applied. public func useNativeControls(_ useNativeControls: Bool) -> Self { appending { w, _ in w.setUseNativeControls(setting: useNativeControls) } } // PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.WindowControls.setUseNativeControls(setting:), GObject.Object.connectNotify(detail:_:), Gtk.WindowControls.getUseNativeControls() /// Sets whether platform native window controls are used. /// /// This option shows the "stoplight" buttons on macOS. /// For Linux, this option has no effect. /// /// See also [Using GTK on Apple macOS](osx.html?native-window-controls). /// /// 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 useNativeControls(_ useNativeControls: Portico.Binding) -> Self { appending { w, ctx in Portico.bindProperty( w, useNativeControls, registry: ctx.registry, notifyDetail: "use-native-controls", read: { [w] in w.getUseNativeControls() }, write: { [w] v in w.setUseNativeControls(setting: v) } ) } } // PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.WindowControls.setUseNativeControls(setting:) /// Sets whether platform native window controls are used. /// /// This option shows the "stoplight" buttons on macOS. /// For Linux, this option has no effect. /// /// See also [Using GTK on Apple macOS](osx.html?native-window-controls). /// /// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.WindowControls.setUseNativeControls(setting:)`. /// /// - Parameter useNativeControls: Whether to show platform native close/minimize/maximize buttons. /// - Returns: A copy of this view with the modifier applied. public func useNativeControls(_ useNativeControls: @escaping () -> Bool) -> Self { appending { w, ctx in let tracker = DependencyTracker { [w] in w.setUseNativeControls(setting: useNativeControls()) } tracker.run() ctx.registry.add(tracker) } } }