portico/Sources/Portico/Generated/NavigationSplitView.swift

768 lines
40 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.NavigationSplitView
/// A widget presenting sidebar and content side by side or as a navigation view.
///
/// <picture>
/// <source srcset="navigation-split-view-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="navigation-split-view.png" alt="navigation-split-view">
/// </picture>
/// <picture>
/// <source srcset="navigation-split-view-collapsed-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="navigation-split-view-collapsed.png" alt="navigation-split-view-collapsed">
/// </picture>
///
/// `AdwNavigationSplitView` has two [class`NavigationPage`] children: sidebar and
/// content, and displays them side by side.
///
/// When [property`NavigationSplitView`:collapsed] is set to `TRUE`, it instead
/// puts both children inside an [class`NavigationView`]. The
/// [property`NavigationSplitView`:show-content] controls which child is visible
/// while collapsed.
///
/// See also [class`OverlaySplitView`].
///
/// `AdwNavigationSplitView` is typically used together with an [class`Breakpoint`]
/// setting the `collapsed` property to `TRUE` on small widths, as follows:
///
/// ```xml
/// <object class="AdwWindow">
/// <property name="default-width">800</property>
/// <property name="default-height">800</property>
/// <child>
/// <object class="AdwBreakpoint">
/// <condition>max-width: 400sp</condition>
/// <setter object="split_view" property="collapsed">True</setter>
/// </object>
/// </child>
/// <property name="content">
/// <object class="AdwNavigationSplitView" id="split_view">
/// <property name="sidebar">
/// <object class="AdwNavigationPage">
/// <property name="title" translatable="yes">Sidebar</property>
/// <property name="child">
/// <!-- ... -->
/// </property>
/// </object>
/// </property>
/// <property name="content">
/// <object class="AdwNavigationPage">
/// <property name="title" translatable="yes">Content</property>
/// <property name="child">
/// <!-- ... -->
/// </property>
/// </object>
/// </property>
/// </object>
/// </property>
/// </object>
/// ```
///
/// ## Sizing
///
/// When not collapsed, `AdwNavigationSplitView` changes the sidebar width
/// depending on its own width.
///
/// If possible, it tries to allocate a fraction of the total width, controlled
/// with the [property`NavigationSplitView`:sidebar-width-fraction] property.
///
/// The sidebar also has minimum and maximum sizes, controlled with the
/// [property`NavigationSplitView`:min-sidebar-width] and
/// [property`NavigationSplitView`:max-sidebar-width] properties.
///
/// The minimum and maximum sizes are using the length unit specified with the
/// [property`NavigationSplitView`:sidebar-width-unit].
///
/// By default, sidebar is using 25% of the total width, with 180sp as the
/// minimum size and 280sp as the maximum size.
///
/// ## Header Bar Integration
///
/// When used inside `AdwNavigationSplitView`, [class`HeaderBar`] will
/// automatically hide the window buttons in the middle.
///
/// When collapsed, it also displays a back button for the content widget, as
/// well as the page titles. See [class`NavigationView`] documentation for details.
///
/// ## Actions
///
/// `AdwNavigationSplitView` defines the same actions as `AdwNavigationView`, but
/// they can be used even when the split view is not collapsed:
///
/// - `navigation.push` takes a string parameter specifying the tag of the page
/// to push. If it matches the tag of the content widget, it sets
/// [property`NavigationSplitView`:show-content] to `TRUE`.
///
/// - `navigation.pop` doesn't take any parameters and sets
/// [property`NavigationSplitView`:show-content] to `FALSE`.
///
/// ## `AdwNavigationSplitView` as `GtkBuildable`
///
/// The `AdwNavigationSplitView` implementation of the [iface`Gtk`.Buildable]
/// interface supports setting the sidebar widget by specifying sidebar as the
/// type attribute of a `<child>` element, Specifying content child type or
/// omitting it results in setting the content widget.
///
/// ## CSS nodes
///
/// `AdwNavigationSplitView` has a single CSS node with the name
/// `navigation-split-view`.
///
/// When collapsed, it contains a child node with the name `navigation-view`
/// containing both children.
///
/// ```
/// navigation-split-view
/// navigation-view
/// [sidebar child]
/// [content child]
/// ```
///
/// When not collapsed, it contains two nodes with the name `widget`, one with
/// the `.sidebar-pane` style class, the other one with `.content-view` style
/// class, containing the sidebar and content children respectively.
///
/// ```
/// navigation-split-view
/// widget.sidebar-pane
/// [sidebar child]
/// widget.content-pane
/// [content child]
/// ```
///
/// ## Accessibility
///
/// `AdwNavigationSplitView` uses the [enum`Gtk`.AccessibleRole.group] role.
///
/// A Portico view that mounts a `Adw.NavigationSplitView`.
@MainActor public struct NavigationSplitView: View {
private let make: (MountContext) -> Adw.NavigationSplitView
private var configure: [(Adw.NavigationSplitView, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Adw.NavigationSplitView.init()
/// Creates a new `AdwNavigationSplitView`.
///
/// 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 collapsed: Whether the split view is collapsed.
/// - Parameter content: The content widget.
/// - Parameter maxSidebarWidth: The maximum sidebar width.
/// - Parameter minSidebarWidth: The minimum sidebar width.
/// - Parameter showContent: Determines the visible page when collapsed.
/// - Parameter sidebar: The sidebar widget.
/// - Parameter sidebarPosition: The sidebar position.
/// - Parameter sidebarWidthFraction: The preferred sidebar width as a fraction of the total width.
/// - Parameter sidebarWidthUnit: The length unit for minimum and maximum sidebar widths.
public init(collapsed: Bool? = nil, content: Adw.NavigationPage? = nil, maxSidebarWidth: Double? = nil, minSidebarWidth: Double? = nil, showContent: Bool? = nil, sidebar: Adw.NavigationPage? = nil, sidebarPosition: Adw.PackType? = nil, sidebarWidthFraction: Double? = nil, sidebarWidthUnit: Adw.LengthUnit? = nil) {
make = { _ in Adw.NavigationSplitView() }
configure.append { w, _ in
if let collapsed { w.setCollapsed(collapsed: collapsed) }
if let content { w.setContent(content: content) }
if let maxSidebarWidth { w.setMaxSidebarWidth(width: maxSidebarWidth) }
if let minSidebarWidth { w.setMinSidebarWidth(width: minSidebarWidth) }
if let showContent { w.setShowContent(showContent: showContent) }
if let sidebar { w.setSidebar(sidebar: sidebar) }
if let sidebarPosition { w.setSidebarPosition(position: sidebarPosition) }
if let sidebarWidthFraction { w.setSidebarWidthFraction(fraction: sidebarWidthFraction) }
if let sidebarWidthUnit { w.setSidebarWidthUnit(unit: sidebarWidthUnit) }
}
}
}
extension NavigationSplitView: WidgetView {
public typealias Target = Adw.NavigationSplitView
@_spi(Portico) public func appending(
_ step: @escaping (Adw.NavigationSplitView, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension NavigationSplitView: 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.NavigationSplitView
/// Modifiers for `Adw.NavigationSplitView`, available on every Portico view whose
/// backing widget is `Adw.NavigationSplitView` or one of its subclasses.
extension WidgetView where Target: Adw.NavigationSplitView {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.NavigationSplitView.setCollapsed(collapsed:)
/// Sets whether `self` is collapsed.
///
/// When collapsed, the children are put inside an [class`NavigationView`],
/// otherwise they are displayed side by side.
///
/// The [property`NavigationSplitView`:show-content] controls which child is
/// visible while collapsed.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter collapsed: Whether the split view is collapsed.
/// - Returns: A copy of this view with the modifier applied.
public func collapsed(_ collapsed: Bool) -> Self {
appending { w, _ in
w.setCollapsed(collapsed: collapsed)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.NavigationSplitView.setCollapsed(collapsed:), GObject.Object.connectNotify(detail:_:), Adw.NavigationSplitView.getCollapsed()
/// Sets whether `self` is collapsed.
///
/// When collapsed, the children are put inside an [class`NavigationView`],
/// otherwise they are displayed side by side.
///
/// The [property`NavigationSplitView`:show-content] controls which child is
/// visible while collapsed.
///
/// 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 collapsed(_ collapsed: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, collapsed, registry: ctx.registry, notifyDetail: "collapsed",
read: { [w] in w.getCollapsed() },
write: { [w] v in w.setCollapsed(collapsed: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.NavigationSplitView.setCollapsed(collapsed:)
/// Sets whether `self` is collapsed.
///
/// When collapsed, the children are put inside an [class`NavigationView`],
/// otherwise they are displayed side by side.
///
/// The [property`NavigationSplitView`:show-content] controls which child is
/// visible while collapsed.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.NavigationSplitView.setCollapsed(collapsed:)`.
///
/// - Parameter collapsed: Whether the split view is collapsed.
/// - Returns: A copy of this view with the modifier applied.
public func collapsed(_ collapsed: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setCollapsed(collapsed: collapsed()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.NavigationSplitView.setContent(content:)
/// Sets the content widget for `self`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter content: The content widget.
/// - Returns: A copy of this view with the modifier applied.
public func content(_ content: Adw.NavigationPage?) -> Self {
appending { w, _ in
w.setContent(content: content)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.NavigationSplitView.setContent(content:), GObject.Object.connectNotify(detail:_:), Adw.NavigationSplitView.getContent()
/// Sets the content widget for `self`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.NavigationPage?` 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 content<W: Adw.NavigationPage>(_ content: Portico.Binding<W?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, content, registry: ctx.registry, notifyDetail: "content",
read: { [w] in w.getContent() as? W },
write: { [w] v in w.setContent(content: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.NavigationSplitView.setContent(content:), GObject.Object.connectNotify(detail:_:), Adw.NavigationSplitView.getContent()
/// Sets the content widget for `self`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Adw.NavigationPage>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Adw.NavigationPage?>` to be able to clear the property.
/// When `Adw.NavigationPage` 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 content<W: Adw.NavigationPage>(_ content: Portico.Binding<W>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, content, registry: ctx.registry, notifyDetail: "content",
read: { [w] in w.getContent() as? W },
write: { [w] v in w.setContent(content: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.NavigationSplitView.setContent(content:)
/// Sets the content widget for `self`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.NavigationSplitView.setContent(content:)`.
///
/// - Parameter content: The content widget.
/// - Returns: A copy of this view with the modifier applied.
public func content(_ content: @escaping () -> Adw.NavigationPage?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setContent(content: content()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.NavigationSplitView.setMaxSidebarWidth(width:)
/// Sets the maximum sidebar width for `self`.
///
/// Maximum width is affected by
/// [property`NavigationSplitView`:sidebar-width-unit].
///
/// The sidebar widget can still be allocated with larger width if its own
/// minimum width exceeds it.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter maxSidebarWidth: The maximum sidebar width.
/// - Returns: A copy of this view with the modifier applied.
public func maxSidebarWidth(_ maxSidebarWidth: Double) -> Self {
appending { w, _ in
w.setMaxSidebarWidth(width: maxSidebarWidth)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.NavigationSplitView.setMaxSidebarWidth(width:), GObject.Object.connectNotify(detail:_:), Adw.NavigationSplitView.getMaxSidebarWidth()
/// Sets the maximum sidebar width for `self`.
///
/// Maximum width is affected by
/// [property`NavigationSplitView`:sidebar-width-unit].
///
/// The sidebar widget can still be allocated with larger width if its own
/// minimum width exceeds it.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Double` 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 maxSidebarWidth(_ maxSidebarWidth: Portico.Binding<Double>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, maxSidebarWidth, registry: ctx.registry, notifyDetail: "max-sidebar-width",
read: { [w] in w.getMaxSidebarWidth() },
write: { [w] v in w.setMaxSidebarWidth(width: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.NavigationSplitView.setMaxSidebarWidth(width:)
/// Sets the maximum sidebar width for `self`.
///
/// Maximum width is affected by
/// [property`NavigationSplitView`:sidebar-width-unit].
///
/// The sidebar widget can still be allocated with larger width if its own
/// minimum width exceeds it.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.NavigationSplitView.setMaxSidebarWidth(width:)`.
///
/// - Parameter maxSidebarWidth: The maximum sidebar width.
/// - Returns: A copy of this view with the modifier applied.
public func maxSidebarWidth(_ maxSidebarWidth: @escaping () -> Double) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setMaxSidebarWidth(width: maxSidebarWidth()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.NavigationSplitView.setMinSidebarWidth(width:)
/// Sets the minimum sidebar width for `self`.
///
/// Minimum width is affected by
/// [property`NavigationSplitView`:sidebar-width-unit].
///
/// The sidebar widget can still be allocated with larger width if its own
/// minimum width exceeds it.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter minSidebarWidth: The minimum sidebar width.
/// - Returns: A copy of this view with the modifier applied.
public func minSidebarWidth(_ minSidebarWidth: Double) -> Self {
appending { w, _ in
w.setMinSidebarWidth(width: minSidebarWidth)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.NavigationSplitView.setMinSidebarWidth(width:), GObject.Object.connectNotify(detail:_:), Adw.NavigationSplitView.getMinSidebarWidth()
/// Sets the minimum sidebar width for `self`.
///
/// Minimum width is affected by
/// [property`NavigationSplitView`:sidebar-width-unit].
///
/// The sidebar widget can still be allocated with larger width if its own
/// minimum width exceeds it.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Double` 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 minSidebarWidth(_ minSidebarWidth: Portico.Binding<Double>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, minSidebarWidth, registry: ctx.registry, notifyDetail: "min-sidebar-width",
read: { [w] in w.getMinSidebarWidth() },
write: { [w] v in w.setMinSidebarWidth(width: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.NavigationSplitView.setMinSidebarWidth(width:)
/// Sets the minimum sidebar width for `self`.
///
/// Minimum width is affected by
/// [property`NavigationSplitView`:sidebar-width-unit].
///
/// The sidebar widget can still be allocated with larger width if its own
/// minimum width exceeds it.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.NavigationSplitView.setMinSidebarWidth(width:)`.
///
/// - Parameter minSidebarWidth: The minimum sidebar width.
/// - Returns: A copy of this view with the modifier applied.
public func minSidebarWidth(_ minSidebarWidth: @escaping () -> Double) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setMinSidebarWidth(width: minSidebarWidth()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.NavigationSplitView.setShowContent(showContent:)
/// Sets which page is visible when `self` is collapsed.
///
/// If set to `TRUE`, the content widget will be the visible page when
/// [property`NavigationSplitView`:collapsed] is `TRUE`; otherwise the sidebar
/// widget will be visible.
///
/// If the split view is already collapsed, the visible page changes immediately.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter showContent: Determines the visible page when collapsed.
/// - Returns: A copy of this view with the modifier applied.
public func showContent(_ showContent: Bool) -> Self {
appending { w, _ in
w.setShowContent(showContent: showContent)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.NavigationSplitView.setShowContent(showContent:), GObject.Object.connectNotify(detail:_:), Adw.NavigationSplitView.getShowContent()
/// Sets which page is visible when `self` is collapsed.
///
/// If set to `TRUE`, the content widget will be the visible page when
/// [property`NavigationSplitView`:collapsed] is `TRUE`; otherwise the sidebar
/// widget will be visible.
///
/// If the split view is already collapsed, the visible page changes immediately.
///
/// 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 showContent(_ showContent: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, showContent, registry: ctx.registry, notifyDetail: "show-content",
read: { [w] in w.getShowContent() },
write: { [w] v in w.setShowContent(showContent: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.NavigationSplitView.setShowContent(showContent:)
/// Sets which page is visible when `self` is collapsed.
///
/// If set to `TRUE`, the content widget will be the visible page when
/// [property`NavigationSplitView`:collapsed] is `TRUE`; otherwise the sidebar
/// widget will be visible.
///
/// If the split view is already collapsed, the visible page changes immediately.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.NavigationSplitView.setShowContent(showContent:)`.
///
/// - Parameter showContent: Determines the visible page when collapsed.
/// - Returns: A copy of this view with the modifier applied.
public func showContent(_ showContent: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setShowContent(showContent: showContent()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.NavigationSplitView.setSidebar(sidebar:)
/// Sets the sidebar widget for `self`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter sidebar: The sidebar widget.
/// - Returns: A copy of this view with the modifier applied.
public func sidebar(_ sidebar: Adw.NavigationPage?) -> Self {
appending { w, _ in
w.setSidebar(sidebar: sidebar)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.NavigationSplitView.setSidebar(sidebar:), GObject.Object.connectNotify(detail:_:), Adw.NavigationSplitView.getSidebar()
/// Sets the sidebar widget for `self`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.NavigationPage?` 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 sidebar<W: Adw.NavigationPage>(_ sidebar: Portico.Binding<W?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, sidebar, registry: ctx.registry, notifyDetail: "sidebar",
read: { [w] in w.getSidebar() as? W },
write: { [w] v in w.setSidebar(sidebar: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.NavigationSplitView.setSidebar(sidebar:), GObject.Object.connectNotify(detail:_:), Adw.NavigationSplitView.getSidebar()
/// Sets the sidebar widget for `self`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Adw.NavigationPage>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Adw.NavigationPage?>` to be able to clear the property.
/// When `Adw.NavigationPage` 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 sidebar<W: Adw.NavigationPage>(_ sidebar: Portico.Binding<W>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, sidebar, registry: ctx.registry, notifyDetail: "sidebar",
read: { [w] in w.getSidebar() as? W },
write: { [w] v in w.setSidebar(sidebar: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.NavigationSplitView.setSidebar(sidebar:)
/// Sets the sidebar widget for `self`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.NavigationSplitView.setSidebar(sidebar:)`.
///
/// - Parameter sidebar: The sidebar widget.
/// - Returns: A copy of this view with the modifier applied.
public func sidebar(_ sidebar: @escaping () -> Adw.NavigationPage?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setSidebar(sidebar: sidebar()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.NavigationSplitView.setSidebarPosition(position:)
/// Sets the sidebar position for `self`.
///
/// If set to [enum`Gtk`.PackType.start], the sidebar is displayed before the
/// content, and the sidebar will be the root page when collapsed.
///
/// If set to [enum`Gtk`.PackType.end], the sidebar is displayed after the
/// content, and the content will be the root page.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter sidebarPosition: The sidebar position.
/// - Returns: A copy of this view with the modifier applied.
public func sidebarPosition(_ sidebarPosition: Adw.PackType) -> Self {
appending { w, _ in
w.setSidebarPosition(position: sidebarPosition)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.NavigationSplitView.setSidebarPosition(position:), GObject.Object.connectNotify(detail:_:), Adw.NavigationSplitView.getSidebarPosition()
/// Sets the sidebar position for `self`.
///
/// If set to [enum`Gtk`.PackType.start], the sidebar is displayed before the
/// content, and the sidebar will be the root page when collapsed.
///
/// If set to [enum`Gtk`.PackType.end], the sidebar is displayed after the
/// content, and the content will be the root page.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.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 sidebarPosition(_ sidebarPosition: Portico.Binding<Adw.PackType>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, sidebarPosition, registry: ctx.registry, notifyDetail: "sidebar-position",
read: { [w] in w.getSidebarPosition() },
write: { [w] v in w.setSidebarPosition(position: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.NavigationSplitView.setSidebarPosition(position:)
/// Sets the sidebar position for `self`.
///
/// If set to [enum`Gtk`.PackType.start], the sidebar is displayed before the
/// content, and the sidebar will be the root page when collapsed.
///
/// If set to [enum`Gtk`.PackType.end], the sidebar is displayed after the
/// content, and the content will be the root page.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.NavigationSplitView.setSidebarPosition(position:)`.
///
/// - Parameter sidebarPosition: The sidebar position.
/// - Returns: A copy of this view with the modifier applied.
public func sidebarPosition(_ sidebarPosition: @escaping () -> Adw.PackType) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setSidebarPosition(position: sidebarPosition()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.NavigationSplitView.setSidebarWidthFraction(fraction:)
/// Sets the preferred sidebar width as a fraction of the total width of `self`.
///
/// The preferred width is additionally limited by
/// [property`NavigationSplitView`:min-sidebar-width] and
/// [property`NavigationSplitView`:max-sidebar-width].
///
/// The sidebar widget can be allocated with larger width if its own minimum
/// width exceeds the preferred width.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter sidebarWidthFraction: The preferred sidebar width as a fraction of the total width.
/// - Returns: A copy of this view with the modifier applied.
public func sidebarWidthFraction(_ sidebarWidthFraction: Double) -> Self {
appending { w, _ in
w.setSidebarWidthFraction(fraction: sidebarWidthFraction)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.NavigationSplitView.setSidebarWidthFraction(fraction:), GObject.Object.connectNotify(detail:_:), Adw.NavigationSplitView.getSidebarWidthFraction()
/// Sets the preferred sidebar width as a fraction of the total width of `self`.
///
/// The preferred width is additionally limited by
/// [property`NavigationSplitView`:min-sidebar-width] and
/// [property`NavigationSplitView`:max-sidebar-width].
///
/// The sidebar widget can be allocated with larger width if its own minimum
/// width exceeds the preferred width.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Double` 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 sidebarWidthFraction(_ sidebarWidthFraction: Portico.Binding<Double>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, sidebarWidthFraction, registry: ctx.registry, notifyDetail: "sidebar-width-fraction",
read: { [w] in w.getSidebarWidthFraction() },
write: { [w] v in w.setSidebarWidthFraction(fraction: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.NavigationSplitView.setSidebarWidthFraction(fraction:)
/// Sets the preferred sidebar width as a fraction of the total width of `self`.
///
/// The preferred width is additionally limited by
/// [property`NavigationSplitView`:min-sidebar-width] and
/// [property`NavigationSplitView`:max-sidebar-width].
///
/// The sidebar widget can be allocated with larger width if its own minimum
/// width exceeds the preferred width.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.NavigationSplitView.setSidebarWidthFraction(fraction:)`.
///
/// - Parameter sidebarWidthFraction: The preferred sidebar width as a fraction of the total width.
/// - Returns: A copy of this view with the modifier applied.
public func sidebarWidthFraction(_ sidebarWidthFraction: @escaping () -> Double) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setSidebarWidthFraction(fraction: sidebarWidthFraction()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.NavigationSplitView.setSidebarWidthUnit(unit:)
/// Sets the length unit for minimum and maximum sidebar widths.
///
/// See [property`NavigationSplitView`:min-sidebar-width] and
/// [property`NavigationSplitView`:max-sidebar-width].
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter sidebarWidthUnit: The length unit for minimum and maximum sidebar widths.
/// - Returns: A copy of this view with the modifier applied.
public func sidebarWidthUnit(_ sidebarWidthUnit: Adw.LengthUnit) -> Self {
appending { w, _ in
w.setSidebarWidthUnit(unit: sidebarWidthUnit)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.NavigationSplitView.setSidebarWidthUnit(unit:), GObject.Object.connectNotify(detail:_:), Adw.NavigationSplitView.getSidebarWidthUnit()
/// Sets the length unit for minimum and maximum sidebar widths.
///
/// See [property`NavigationSplitView`:min-sidebar-width] and
/// [property`NavigationSplitView`:max-sidebar-width].
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.LengthUnit` 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 sidebarWidthUnit(_ sidebarWidthUnit: Portico.Binding<Adw.LengthUnit>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, sidebarWidthUnit, registry: ctx.registry, notifyDetail: "sidebar-width-unit",
read: { [w] in w.getSidebarWidthUnit() },
write: { [w] v in w.setSidebarWidthUnit(unit: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.NavigationSplitView.setSidebarWidthUnit(unit:)
/// Sets the length unit for minimum and maximum sidebar widths.
///
/// See [property`NavigationSplitView`:min-sidebar-width] and
/// [property`NavigationSplitView`:max-sidebar-width].
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.NavigationSplitView.setSidebarWidthUnit(unit:)`.
///
/// - Parameter sidebarWidthUnit: The length unit for minimum and maximum sidebar widths.
/// - Returns: A copy of this view with the modifier applied.
public func sidebarWidthUnit(_ sidebarWidthUnit: @escaping () -> Adw.LengthUnit) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setSidebarWidthUnit(unit: sidebarWidthUnit()) }
tracker.run()
ctx.registry.add(tracker)
}
}
}