portico/Sources/Portico/Generated/HeaderBar.swift

1123 lines
60 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: Adw.HeaderBar
/// A title bar widget.
///
/// <picture>
/// <source srcset="header-bar-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="header-bar.png" alt="header-bar">
/// </picture>
///
/// `AdwHeaderBar` is similar to [class`Gtk`.HeaderBar], but provides additional
/// features compared to it. Refer to `GtkHeaderBar` for details. It is typically
/// used as a top bar within [class`ToolbarView`].
///
/// ## Dialog Integration
///
/// When placed inside an [class`Dialog`], `AdwHeaderBar` will display the dialog
/// title instead of window title. It will also adjust the decoration layout to
/// ensure it always has a close button and nothing else. Set
/// [property`HeaderBar`:show-start-title-buttons] and
/// [property`HeaderBar`:show-end-title-buttons] to `FALSE` to remove it if it's
/// unwanted.
///
/// ## Navigation View Integration
///
/// When placed inside an [class`NavigationPage`], `AdwHeaderBar` will display the
/// page title instead of window title.
///
/// When used together with [class`NavigationView`] or [class`NavigationSplitView`],
/// it will also display a back button that can be used to go back to the previous
/// page. The button also has a context menu, allowing to pop multiple pages at
/// once, potentially across multiple navigation views.
///
/// Set [property`HeaderBar`:show-back-button] to `FALSE` to disable this behavior
/// in rare scenarios where it's unwanted.
///
/// ## Split View Integration
///
/// When placed inside [class`NavigationSplitView`] or [class`OverlaySplitView`],
/// `AdwHeaderBar` will automatically hide the title buttons other than at the
/// edges of the window.
///
/// ## Bottom Sheet Integration
///
/// When played inside [class`BottomSheet`], `AdwHeaderBar` will not show the title
/// unless [property`BottomSheet`:show-drag-handle] is set to `FALSE`, regardless
/// of [property`HeaderBar`:show-title]. This only applies to the default title,
/// titles set with [property`HeaderBar`:title-widget] will still be shown.
///
/// ## Centering Policy
///
/// [property`HeaderBar`:centering-policy] allows to enforce strict centering of
/// the title widget. This can be useful for entries inside [class`Clamp`].
///
/// ## Title Buttons
///
/// Unlike `GtkHeaderBar`, `AdwHeaderBar` allows to toggle title button
/// visibility for each side individually, using the
/// [property`HeaderBar`:show-start-title-buttons] and
/// [property`HeaderBar`:show-end-title-buttons] properties.
///
/// ## CSS nodes
///
/// ```
/// headerbar
/// windowhandle
/// box
/// widget
/// box.start
/// windowcontrols.start
/// widget
/// [button.back]
/// [other children]
/// widget
/// [Title Widget]
/// widget
/// box.end
/// [other children]
/// windowcontrols.end
/// ```
///
/// `AdwHeaderBar`'s CSS node is called `headerbar`. It contains a `windowhandle`
/// subnode, which contains a `box` subnode, which contains three `widget`
/// subnodes at the start, center and end of the header bar. The start and end
/// subnodes contain a `box` subnode with the `.start` and `.end` style classes
/// respectively, and the center node contains a node that represents the title.
///
/// Each of the boxes contains a `windowcontrols` subnode, see
/// [class`Gtk`.WindowControls] for details, as well as other children.
///
/// When [property`HeaderBar`:show-back-button] is `TRUE`, the start box also
/// contains a node with the name `widget` that contains a node with the name
/// `button` and `.back` style class.
///
/// ## Accessibility
///
/// `AdwHeaderBar` uses the [enum`Gtk`.AccessibleRole.group] role.
///
/// A Portico view that mounts a `Adw.HeaderBar`.
@MainActor public struct HeaderBar: View {
private let make: (MountContext) -> Adw.HeaderBar
private var configure: [(Adw.HeaderBar, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Adw.HeaderBar.init()
/// Creates a new `AdwHeaderBar`.
///
/// Applied once at mount; use the `Binding` or closure overload for values that change.
/// Each closure is evaluated once; children are added in order and slot closures mount their first view.
/// An empty closure adds no children and leaves slots unset.
/// 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 centeringPolicy: The policy for aligning the center widget.
/// - Parameter decorationLayout: The decoration layout for buttons.
/// - Parameter showBackButton: Whether the header bar can show the back button.
/// - Parameter showEndTitleButtons: Whether to show title buttons at the end of the header bar.
/// - Parameter showStartTitleButtons: Whether to show title buttons at the start of the header bar.
/// - Parameter showTitle: Whether the title widget should be shown.
/// - Parameter titleWidget: A `ViewBuilder` closure whose first view is mounted into the `titleWidget` slot.
public init(centeringPolicy: Adw.CenteringPolicy? = nil, decorationLayout: String? = nil, showBackButton: Bool? = nil, showEndTitleButtons: Bool? = nil, showStartTitleButtons: Bool? = nil, showTitle: Bool? = nil, @ViewBuilder titleWidget: @escaping () -> [AnyView] = { [] }) {
make = { _ in Adw.HeaderBar() }
configure.append { w, ctx in
if let centeringPolicy { w.setCenteringPolicy(centeringPolicy: centeringPolicy) }
if let decorationLayout { w.setDecorationLayout(layout: decorationLayout) }
if let showBackButton { w.setShowBackButton(showBackButton: showBackButton) }
if let showEndTitleButtons { w.setShowEndTitleButtons(setting: showEndTitleButtons) }
if let showStartTitleButtons { w.setShowStartTitleButtons(setting: showStartTitleButtons) }
if let showTitle { w.setShowTitle(showTitle: showTitle) }
if let v = Portico.mountSlotChild(titleWidget, ctx, onUpdate: { v in w.setTitleWidget(titleWidget: v) }) { w.setTitleWidget(titleWidget: v) }
}
}
}
extension HeaderBar: WidgetView {
public typealias Target = Adw.HeaderBar
@_spi(Portico) public func appending(
_ step: @escaping (Adw.HeaderBar, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension HeaderBar: 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.HeaderBar
/// Modifiers for `Adw.HeaderBar`, available on every Portico view whose
/// backing widget is `Adw.HeaderBar` or one of its subclasses.
extension WidgetView where Target: Adw.HeaderBar {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.HeaderBar.setCenteringPolicy(centeringPolicy:)
/// Sets the policy for aligning the center widget.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter centeringPolicy: The policy for aligning the center widget.
/// - Returns: A copy of this view with the modifier applied.
public func centeringPolicy(_ centeringPolicy: Adw.CenteringPolicy) -> Self {
appending { w, _ in
w.setCenteringPolicy(centeringPolicy: centeringPolicy)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.HeaderBar.setCenteringPolicy(centeringPolicy:), GObject.Object.connectNotify(detail:_:), Adw.HeaderBar.getCenteringPolicy()
/// Sets the policy for aligning the center widget.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.CenteringPolicy` 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 centeringPolicy(_ centeringPolicy: Portico.Binding<Adw.CenteringPolicy>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, centeringPolicy, registry: ctx.registry, notifyDetail: "centering-policy",
read: { [w] in w.getCenteringPolicy() },
write: { [w] v in w.setCenteringPolicy(centeringPolicy: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.HeaderBar.setCenteringPolicy(centeringPolicy:)
/// Sets the policy for aligning the center widget.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.HeaderBar.setCenteringPolicy(centeringPolicy:)`.
///
/// - Parameter centeringPolicy: The policy for aligning the center widget.
/// - Returns: A copy of this view with the modifier applied.
public func centeringPolicy(_ centeringPolicy: @escaping () -> Adw.CenteringPolicy) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setCenteringPolicy(centeringPolicy: centeringPolicy()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.HeaderBar.setDecorationLayout(layout:)
/// Sets the decoration layout for `self`.
///
/// If this property is not set, the
/// [property`Gtk`.Settings:gtk-decoration-layout] setting is used.
///
/// The format of the string is button names, separated by commas. A colon
/// separates the buttons that should appear at the start from those at the end.
/// Recognized button names are minimize, maximize, close and icon (the window
/// icon).
///
/// For example, icon:minimize,maximize,close specifies an icon at the start,
/// and minimize, maximize and close buttons at the end.
///
/// 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 buttons.
/// - Returns: A copy of this view with the modifier applied.
@_disfavoredOverload
public func decorationLayout<S: StringProtocol>(_ decorationLayout: S?) -> Self {
appending { w, _ in
w.setDecorationLayout(layout: decorationLayout.map { String($0) })
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.HeaderBar.setDecorationLayout(layout:), GObject.Object.connectNotify(detail:_:), Adw.HeaderBar.getDecorationLayout()
/// Sets the decoration layout for `self`.
///
/// If this property is not set, the
/// [property`Gtk`.Settings:gtk-decoration-layout] setting is used.
///
/// The format of the string is button names, separated by commas. A colon
/// separates the buttons that should appear at the start from those at the end.
/// Recognized button names are minimize, maximize, close and icon (the window
/// icon).
///
/// For example, icon:minimize,maximize,close specifies an icon at the start,
/// and minimize, maximize and close buttons at the end.
///
/// 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<String?>) -> 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: Adw.HeaderBar.setDecorationLayout(layout:), GObject.Object.connectNotify(detail:_:), Adw.HeaderBar.getDecorationLayout()
/// Sets the decoration layout for `self`.
///
/// If this property is not set, the
/// [property`Gtk`.Settings:gtk-decoration-layout] setting is used.
///
/// The format of the string is button names, separated by commas. A colon
/// separates the buttons that should appear at the start from those at the end.
/// Recognized button names are minimize, maximize, close and icon (the window
/// icon).
///
/// For example, icon:minimize,maximize,close specifies an icon at the start,
/// and minimize, maximize and close buttons at the end.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<String>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<String?>` 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<String>) -> 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: Adw.HeaderBar.setDecorationLayout(layout:)
/// Sets the decoration layout for `self`.
///
/// If this property is not set, the
/// [property`Gtk`.Settings:gtk-decoration-layout] setting is used.
///
/// The format of the string is button names, separated by commas. A colon
/// separates the buttons that should appear at the start from those at the end.
/// Recognized button names are minimize, maximize, close and icon (the window
/// icon).
///
/// For example, icon:minimize,maximize,close specifies an icon at the start,
/// and minimize, maximize and close buttons at the end.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.HeaderBar.setDecorationLayout(layout:)`.
///
/// - Parameter decorationLayout: The decoration layout for 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: Adw.HeaderBar.setDecorationLayout(layout:)
/// Sets the decoration layout for `self`.
///
/// If this property is not set, the
/// [property`Gtk`.Settings:gtk-decoration-layout] setting is used.
///
/// The format of the string is button names, separated by commas. A colon
/// separates the buttons that should appear at the start from those at the end.
/// Recognized button names are minimize, maximize, close and icon (the window
/// icon).
///
/// For example, icon:minimize,maximize,close specifies an icon at the start,
/// and minimize, maximize and close buttons at the end.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.HeaderBar.setDecorationLayout(layout:)`. A literal with no interpolation is applied once, with no subscription.
///
/// - Parameter decorationLayout: The decoration layout for 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: Adw.HeaderBar.setShowBackButton(showBackButton:)
/// Sets whether `self` can show the back button.
///
/// The back button will never be shown unless the header bar is placed inside an
/// [class`NavigationView`]. Usually, there is no reason to set it to `FALSE`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter showBackButton: Whether the header bar can show the back button.
/// - Returns: A copy of this view with the modifier applied.
public func showBackButton(_ showBackButton: Bool) -> Self {
appending { w, _ in
w.setShowBackButton(showBackButton: showBackButton)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.HeaderBar.setShowBackButton(showBackButton:), GObject.Object.connectNotify(detail:_:), Adw.HeaderBar.getShowBackButton()
/// Sets whether `self` can show the back button.
///
/// The back button will never be shown unless the header bar is placed inside an
/// [class`NavigationView`]. Usually, there is no reason to set it to `FALSE`.
///
/// 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 showBackButton(_ showBackButton: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, showBackButton, registry: ctx.registry, notifyDetail: "show-back-button",
read: { [w] in w.getShowBackButton() },
write: { [w] v in w.setShowBackButton(showBackButton: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.HeaderBar.setShowBackButton(showBackButton:)
/// Sets whether `self` can show the back button.
///
/// The back button will never be shown unless the header bar is placed inside an
/// [class`NavigationView`]. Usually, there is no reason to set it to `FALSE`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.HeaderBar.setShowBackButton(showBackButton:)`.
///
/// - Parameter showBackButton: Whether the header bar can show the back button.
/// - Returns: A copy of this view with the modifier applied.
public func showBackButton(_ showBackButton: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setShowBackButton(showBackButton: showBackButton()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.HeaderBar.setShowEndTitleButtons(setting:)
/// Sets whether to show title buttons at the end of `self`.
///
/// See [property`HeaderBar`:show-start-title-buttons] for the other side.
///
/// Which buttons are actually shown and where is determined by the
/// [property`HeaderBar`:decoration-layout] property, and by the state of the
/// window (e.g. a close button will not be shown if the window can't be closed).
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter showEndTitleButtons: Whether to show title buttons at the end of the header bar.
/// - Returns: A copy of this view with the modifier applied.
public func showEndTitleButtons(_ showEndTitleButtons: Bool) -> Self {
appending { w, _ in
w.setShowEndTitleButtons(setting: showEndTitleButtons)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.HeaderBar.setShowEndTitleButtons(setting:), GObject.Object.connectNotify(detail:_:), Adw.HeaderBar.getShowEndTitleButtons()
/// Sets whether to show title buttons at the end of `self`.
///
/// See [property`HeaderBar`:show-start-title-buttons] for the other side.
///
/// Which buttons are actually shown and where is determined by the
/// [property`HeaderBar`:decoration-layout] property, and by the state of the
/// window (e.g. a close button will not be shown if the window can't be closed).
///
/// 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 showEndTitleButtons(_ showEndTitleButtons: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, showEndTitleButtons, registry: ctx.registry, notifyDetail: "show-end-title-buttons",
read: { [w] in w.getShowEndTitleButtons() },
write: { [w] v in w.setShowEndTitleButtons(setting: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.HeaderBar.setShowEndTitleButtons(setting:)
/// Sets whether to show title buttons at the end of `self`.
///
/// See [property`HeaderBar`:show-start-title-buttons] for the other side.
///
/// Which buttons are actually shown and where is determined by the
/// [property`HeaderBar`:decoration-layout] property, and by the state of the
/// window (e.g. a close button will not be shown if the window can't be closed).
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.HeaderBar.setShowEndTitleButtons(setting:)`.
///
/// - Parameter showEndTitleButtons: Whether to show title buttons at the end of the header bar.
/// - Returns: A copy of this view with the modifier applied.
public func showEndTitleButtons(_ showEndTitleButtons: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setShowEndTitleButtons(setting: showEndTitleButtons()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.HeaderBar.setShowStartTitleButtons(setting:)
/// Sets whether to show title buttons at the start of `self`.
///
/// See [property`HeaderBar`:show-end-title-buttons] for the other side.
///
/// Which buttons are actually shown and where is determined by the
/// [property`HeaderBar`:decoration-layout] property, and by the state of the
/// window (e.g. a close button will not be shown if the window can't be closed).
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter showStartTitleButtons: Whether to show title buttons at the start of the header bar.
/// - Returns: A copy of this view with the modifier applied.
public func showStartTitleButtons(_ showStartTitleButtons: Bool) -> Self {
appending { w, _ in
w.setShowStartTitleButtons(setting: showStartTitleButtons)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.HeaderBar.setShowStartTitleButtons(setting:), GObject.Object.connectNotify(detail:_:), Adw.HeaderBar.getShowStartTitleButtons()
/// Sets whether to show title buttons at the start of `self`.
///
/// See [property`HeaderBar`:show-end-title-buttons] for the other side.
///
/// Which buttons are actually shown and where is determined by the
/// [property`HeaderBar`:decoration-layout] property, and by the state of the
/// window (e.g. a close button will not be shown if the window can't be closed).
///
/// 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 showStartTitleButtons(_ showStartTitleButtons: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, showStartTitleButtons, registry: ctx.registry, notifyDetail: "show-start-title-buttons",
read: { [w] in w.getShowStartTitleButtons() },
write: { [w] v in w.setShowStartTitleButtons(setting: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.HeaderBar.setShowStartTitleButtons(setting:)
/// Sets whether to show title buttons at the start of `self`.
///
/// See [property`HeaderBar`:show-end-title-buttons] for the other side.
///
/// Which buttons are actually shown and where is determined by the
/// [property`HeaderBar`:decoration-layout] property, and by the state of the
/// window (e.g. a close button will not be shown if the window can't be closed).
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.HeaderBar.setShowStartTitleButtons(setting:)`.
///
/// - Parameter showStartTitleButtons: Whether to show title buttons at the start of the header bar.
/// - Returns: A copy of this view with the modifier applied.
public func showStartTitleButtons(_ showStartTitleButtons: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setShowStartTitleButtons(setting: showStartTitleButtons()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.HeaderBar.setShowTitle(showTitle:)
/// Sets whether the title widget should be shown.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter showTitle: Whether the title widget should be shown.
/// - Returns: A copy of this view with the modifier applied.
public func showTitle(_ showTitle: Bool) -> Self {
appending { w, _ in
w.setShowTitle(showTitle: showTitle)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.HeaderBar.setShowTitle(showTitle:), GObject.Object.connectNotify(detail:_:), Adw.HeaderBar.getShowTitle()
/// Sets whether the title widget should be shown.
///
/// 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 showTitle(_ showTitle: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, showTitle, registry: ctx.registry, notifyDetail: "show-title",
read: { [w] in w.getShowTitle() },
write: { [w] v in w.setShowTitle(showTitle: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.HeaderBar.setShowTitle(showTitle:)
/// Sets whether the title widget should be shown.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.HeaderBar.setShowTitle(showTitle:)`.
///
/// - Parameter showTitle: Whether the title widget should be shown.
/// - Returns: A copy of this view with the modifier applied.
public func showTitle(_ showTitle: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setShowTitle(showTitle: showTitle()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.HeaderBar.setTitleWidget(titleWidget:)
/// Sets the title widget for `self`.
///
/// When set to `NULL`, the header bar will display the title of the window it
/// is contained in.
///
/// To use a different title, use [class`WindowTitle`]:
///
/// ```xml
/// <object class="AdwHeaderBar">
/// <property name="title-widget">
/// <object class="AdwWindowTitle">
/// <property name="title" translatable="yes">Title</property>
/// </object>
/// </property>
/// </object>
/// ```
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter titleWidget: The title widget to display.
/// - Returns: A copy of this view with the modifier applied.
public func titleWidget(_ titleWidget: Adw.Widget?) -> Self {
appending { w, _ in
w.setTitleWidget(titleWidget: titleWidget)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Adw.HeaderBar.setTitleWidget(titleWidget:)
/// Sets the title widget for `self`.
///
/// When set to `NULL`, the header bar will display the title of the window it
/// is contained in.
///
/// To use a different title, use [class`WindowTitle`]:
///
/// ```xml
/// <object class="AdwHeaderBar">
/// <property name="title-widget">
/// <object class="AdwWindowTitle">
/// <property name="title" translatable="yes">Title</property>
/// </object>
/// </property>
/// </object>
/// ```
///
/// The closure is evaluated once when the modifier is applied. Its first view is mounted into the slot.
/// Additional views are ignored; an empty closure leaves the slot unset.
///
/// - Parameter titleWidget: The title widget to display.
/// - Returns: A copy of this view with the modifier applied.
public func titleWidget(@ViewBuilder _ titleWidget: () -> [AnyView]) -> Self {
let titleWidgetViews = titleWidget()
return appending { w, ctx in
guard let v = titleWidgetViews.first else { return }
w.setTitleWidget(titleWidget: v.makeWidget(ctx))
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.HeaderBar.setTitleWidget(titleWidget:), GObject.Object.connectNotify(detail:_:), Adw.HeaderBar.getTitleWidget()
/// Sets the title widget for `self`.
///
/// When set to `NULL`, the header bar will display the title of the window it
/// is contained in.
///
/// To use a different title, use [class`WindowTitle`]:
///
/// ```xml
/// <object class="AdwHeaderBar">
/// <property name="title-widget">
/// <object class="AdwWindowTitle">
/// <property name="title" translatable="yes">Title</property>
/// </object>
/// </property>
/// </object>
/// ```
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.Widget?` 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 titleWidget<W: Gtk.Widget>(_ titleWidget: Portico.Binding<W?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, titleWidget, registry: ctx.registry, notifyDetail: "title-widget",
read: { [w] in w.getTitleWidget() as? W },
write: { [w] v in w.setTitleWidget(titleWidget: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.HeaderBar.setTitleWidget(titleWidget:), GObject.Object.connectNotify(detail:_:), Adw.HeaderBar.getTitleWidget()
/// Sets the title widget for `self`.
///
/// When set to `NULL`, the header bar will display the title of the window it
/// is contained in.
///
/// To use a different title, use [class`WindowTitle`]:
///
/// ```xml
/// <object class="AdwHeaderBar">
/// <property name="title-widget">
/// <object class="AdwWindowTitle">
/// <property name="title" translatable="yes">Title</property>
/// </object>
/// </property>
/// </object>
/// ```
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Adw.Widget>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Adw.Widget?>` to be able to clear the property.
/// When `Adw.Widget` 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 titleWidget<W: Gtk.Widget>(_ titleWidget: Portico.Binding<W>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, titleWidget, registry: ctx.registry, notifyDetail: "title-widget",
read: { [w] in w.getTitleWidget() as? W },
write: { [w] v in w.setTitleWidget(titleWidget: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.HeaderBar.setTitleWidget(titleWidget:)
/// Sets the title widget for `self`.
///
/// When set to `NULL`, the header bar will display the title of the window it
/// is contained in.
///
/// To use a different title, use [class`WindowTitle`]:
///
/// ```xml
/// <object class="AdwHeaderBar">
/// <property name="title-widget">
/// <object class="AdwWindowTitle">
/// <property name="title" translatable="yes">Title</property>
/// </object>
/// </property>
/// </object>
/// ```
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.HeaderBar.setTitleWidget(titleWidget:)`.
///
/// - Parameter titleWidget: The title widget to display.
/// - Returns: A copy of this view with the modifier applied.
public func titleWidget(_ titleWidget: @escaping () -> Adw.Widget?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setTitleWidget(titleWidget: titleWidget()) }
tracker.run()
ctx.registry.add(tracker)
}
}
}
// PorticoGen: generateModifierExtension | source: Gtk.HeaderBar
/// Modifiers for `Gtk.HeaderBar`, available on every Portico view whose
/// backing widget is `Gtk.HeaderBar` or one of its subclasses.
extension WidgetView where Target: Gtk.HeaderBar {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.HeaderBar.setDecorationLayout(layout:)
/// Sets the decoration layout for this header bar.
///
/// This property overrides the
/// [property`Gtk`.Settings:gtk-decoration-layout] setting.
///
/// There can be valid reasons for overriding the setting, such
/// as a header bar design that does not allow for buttons to take
/// room on the right, or only offers room for a single close button.
/// Split header bars are another example for overriding the 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 an icon
/// on the left, and minimize, maximize and close buttons on the right.
///
/// 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 buttons.
/// - Returns: A copy of this view with the modifier applied.
@_disfavoredOverload
public func decorationLayout<S: StringProtocol>(_ decorationLayout: S?) -> Self {
appending { w, _ in
w.setDecorationLayout(layout: decorationLayout.map { String($0) })
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.HeaderBar.setDecorationLayout(layout:), GObject.Object.connectNotify(detail:_:), Gtk.HeaderBar.getDecorationLayout()
/// Sets the decoration layout for this header bar.
///
/// This property overrides the
/// [property`Gtk`.Settings:gtk-decoration-layout] setting.
///
/// There can be valid reasons for overriding the setting, such
/// as a header bar design that does not allow for buttons to take
/// room on the right, or only offers room for a single close button.
/// Split header bars are another example for overriding the 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 an icon
/// on the left, and minimize, maximize and close buttons on the right.
///
/// 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<String?>) -> 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.HeaderBar.setDecorationLayout(layout:), GObject.Object.connectNotify(detail:_:), Gtk.HeaderBar.getDecorationLayout()
/// Sets the decoration layout for this header bar.
///
/// This property overrides the
/// [property`Gtk`.Settings:gtk-decoration-layout] setting.
///
/// There can be valid reasons for overriding the setting, such
/// as a header bar design that does not allow for buttons to take
/// room on the right, or only offers room for a single close button.
/// Split header bars are another example for overriding the 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 an icon
/// on the left, and minimize, maximize and close buttons on the right.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<String>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<String?>` 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<String>) -> 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.HeaderBar.setDecorationLayout(layout:)
/// Sets the decoration layout for this header bar.
///
/// This property overrides the
/// [property`Gtk`.Settings:gtk-decoration-layout] setting.
///
/// There can be valid reasons for overriding the setting, such
/// as a header bar design that does not allow for buttons to take
/// room on the right, or only offers room for a single close button.
/// Split header bars are another example for overriding the 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 an icon
/// on the left, and minimize, maximize and close buttons on the right.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.HeaderBar.setDecorationLayout(layout:)`.
///
/// - Parameter decorationLayout: The decoration layout for 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.HeaderBar.setDecorationLayout(layout:)
/// Sets the decoration layout for this header bar.
///
/// This property overrides the
/// [property`Gtk`.Settings:gtk-decoration-layout] setting.
///
/// There can be valid reasons for overriding the setting, such
/// as a header bar design that does not allow for buttons to take
/// room on the right, or only offers room for a single close button.
/// Split header bars are another example for overriding the 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 an icon
/// on the left, and minimize, maximize and close buttons on the right.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.HeaderBar.setDecorationLayout(layout:)`. A literal with no interpolation is applied once, with no subscription.
///
/// - Parameter decorationLayout: The decoration layout for 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.HeaderBar.setShowTitleButtons(setting:)
/// Sets whether this header bar shows the standard window
/// title buttons.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter showTitleButtons: Whether to show title buttons like close, minimize, maximize.
/// - Returns: A copy of this view with the modifier applied.
public func showTitleButtons(_ showTitleButtons: Bool) -> Self {
appending { w, _ in
w.setShowTitleButtons(setting: showTitleButtons)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.HeaderBar.setShowTitleButtons(setting:), GObject.Object.connectNotify(detail:_:), Gtk.HeaderBar.getShowTitleButtons()
/// Sets whether this header bar shows the standard window
/// title buttons.
///
/// 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 showTitleButtons(_ showTitleButtons: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, showTitleButtons, registry: ctx.registry, notifyDetail: "show-title-buttons",
read: { [w] in w.getShowTitleButtons() },
write: { [w] v in w.setShowTitleButtons(setting: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.HeaderBar.setShowTitleButtons(setting:)
/// Sets whether this header bar shows the standard window
/// title buttons.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.HeaderBar.setShowTitleButtons(setting:)`.
///
/// - Parameter showTitleButtons: Whether to show title buttons like close, minimize, maximize.
/// - Returns: A copy of this view with the modifier applied.
public func showTitleButtons(_ showTitleButtons: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setShowTitleButtons(setting: showTitleButtons()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.HeaderBar.setTitleWidget(titleWidget:)
/// Sets the title for the header bar.
///
/// When set to `NULL`, the headerbar will display the title of
/// the window it is contained in.
///
/// The title should help a user identify the current view.
/// To achieve the same style as the builtin title, use the
/// title style class.
///
/// You should set the title widget to `NULL`, for the window
/// title label to be visible again.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter titleWidget: The title widget to display.
/// - Returns: A copy of this view with the modifier applied.
public func titleWidget(_ titleWidget: Gtk.Widget?) -> Self {
appending { w, _ in
w.setTitleWidget(titleWidget: titleWidget)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Gtk.HeaderBar.setTitleWidget(titleWidget:)
/// Sets the title for the header bar.
///
/// When set to `NULL`, the headerbar will display the title of
/// the window it is contained in.
///
/// The title should help a user identify the current view.
/// To achieve the same style as the builtin title, use the
/// title style class.
///
/// You should set the title widget to `NULL`, for the window
/// title label to be visible again.
///
/// The closure is evaluated once when the modifier is applied. Its first view is mounted into the slot.
/// Additional views are ignored; an empty closure leaves the slot unset.
///
/// - Parameter titleWidget: The title widget to display.
/// - Returns: A copy of this view with the modifier applied.
public func titleWidget(@ViewBuilder _ titleWidget: () -> [AnyView]) -> Self {
let titleWidgetViews = titleWidget()
return appending { w, ctx in
guard let v = titleWidgetViews.first else { return }
w.setTitleWidget(titleWidget: v.makeWidget(ctx))
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.HeaderBar.setTitleWidget(titleWidget:), GObject.Object.connectNotify(detail:_:), Gtk.HeaderBar.getTitleWidget()
/// Sets the title for the header bar.
///
/// When set to `NULL`, the headerbar will display the title of
/// the window it is contained in.
///
/// The title should help a user identify the current view.
/// To achieve the same style as the builtin title, use the
/// title style class.
///
/// You should set the title widget to `NULL`, for the window
/// title label to be visible again.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.Widget?` 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 titleWidget<W: Gtk.Widget>(_ titleWidget: Portico.Binding<W?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, titleWidget, registry: ctx.registry, notifyDetail: "title-widget",
read: { [w] in w.getTitleWidget() as? W },
write: { [w] v in w.setTitleWidget(titleWidget: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.HeaderBar.setTitleWidget(titleWidget:), GObject.Object.connectNotify(detail:_:), Gtk.HeaderBar.getTitleWidget()
/// Sets the title for the header bar.
///
/// When set to `NULL`, the headerbar will display the title of
/// the window it is contained in.
///
/// The title should help a user identify the current view.
/// To achieve the same style as the builtin title, use the
/// title style class.
///
/// You should set the title widget to `NULL`, for the window
/// title label to be visible again.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Gtk.Widget>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.Widget?>` to be able to clear the property.
/// When `Gtk.Widget` 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 titleWidget<W: Gtk.Widget>(_ titleWidget: Portico.Binding<W>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, titleWidget, registry: ctx.registry, notifyDetail: "title-widget",
read: { [w] in w.getTitleWidget() as? W },
write: { [w] v in w.setTitleWidget(titleWidget: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.HeaderBar.setTitleWidget(titleWidget:)
/// Sets the title for the header bar.
///
/// When set to `NULL`, the headerbar will display the title of
/// the window it is contained in.
///
/// The title should help a user identify the current view.
/// To achieve the same style as the builtin title, use the
/// title style class.
///
/// You should set the title widget to `NULL`, for the window
/// title label to be visible again.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.HeaderBar.setTitleWidget(titleWidget:)`.
///
/// - Parameter titleWidget: The title widget to display.
/// - Returns: A copy of this view with the modifier applied.
public func titleWidget(_ titleWidget: @escaping () -> Gtk.Widget?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setTitleWidget(titleWidget: titleWidget()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.HeaderBar.setUseNativeControls(setting:)
/// Sets whether this header bar shows native window controls.
///
/// 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.HeaderBar.setUseNativeControls(setting:), GObject.Object.connectNotify(detail:_:), Gtk.HeaderBar.getUseNativeControls()
/// Sets whether this header bar shows native window controls.
///
/// 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<Bool>) -> 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.HeaderBar.setUseNativeControls(setting:)
/// Sets whether this header bar shows native window controls.
///
/// 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.HeaderBar.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)
}
}
}