portico/Sources/Portico/Generated/TabBar.swift

602 lines
33 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.TabBar
/// A tab bar for [class`TabView`].
///
/// <picture>
/// <source srcset="tab-bar-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="tab-bar.png" alt="tab-bar">
/// </picture>
///
/// The `AdwTabBar` widget is a tab bar that can be used with conjunction with
/// `AdwTabView`. It is typically used as a top bar within [class`ToolbarView`].
///
/// `AdwTabBar` can autohide and can optionally contain action widgets on both
/// sides of the tabs.
///
/// When there's not enough space to show all the tabs, `AdwTabBar` will scroll
/// them. Pinned tabs always stay visible and aren't a part of the scrollable
/// area.
///
/// ## Drag-and-Drop
///
/// `AdwTabBar` tabs can have an additional drop target for arbitrary content.
///
/// Use [method`TabBar`.setup_extra_drop_target] to set it up, specifying the
/// supported content types and drag actions, then connect to
/// [signal`TabBar`::extra-drag-drop] to handle a drop.
///
/// In some cases, it may be necessary to determine the used action based on the
/// content. In that case, set [property`TabBar`:extra-drag-preload] to `TRUE`
/// and connect to [signal`TabBar`::extra-drag-value] signal, then return the
/// action from its handler. To access this action from the
/// [signal`TabBar`::extra-drag-drop] handler, use the
/// [property`TabBar`:extra-drag-preferred-action] property.
///
/// [signal`TabBar`::extra-drag-value] is also always emitted when starting to
/// hover an item, with a `NULL` value. This happens even when
/// [property`TabBar`:extra-drag-preload] is `FALSE`.
///
/// ## CSS nodes
///
/// `AdwTabBar` has a single CSS node with name `tabbar`.
///
/// ## Style classes
///
/// By default `AdwTabBar` look like a part of an `AdwHeaderBar` and is intended
/// to be used directly attached to one or used as a [class`ToolbarView`] toolbar.
/// The [`.inline`](style-classes.html`inline`) style class removes its background,
/// so that it can be used in different contexts instead.
///
/// <picture>
/// <source srcset="tab-bar-inline-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="tab-bar-inline.png" alt="tab-bar-inline">
/// </picture>
///
/// A Portico view that mounts a `Adw.TabBar`.
@MainActor public struct TabBar: View {
private let make: (MountContext) -> Adw.TabBar
private var configure: [(Adw.TabBar, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Adw.TabBar.init()
/// Creates a new `AdwTabBar`.
///
/// 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 autohide: Whether the tabs automatically hide.
/// - Parameter expandTabs: Whether tabs expand to full width.
/// - Parameter extraDragPreload: Whether the drop data should be preloaded on hover.
/// - Parameter inverted: Whether tabs use inverted layout.
/// - Parameter view: The tab view the tab bar controls.
/// - Parameter endActionWidget: A `ViewBuilder` closure whose first view is mounted into the `endActionWidget` slot.
/// - Parameter startActionWidget: A `ViewBuilder` closure whose first view is mounted into the `startActionWidget` slot.
/// - Parameter onExtraDragDrop: Invoked when the widget emits the `extra-drag-drop` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
/// - Parameter onExtraDragValue: Invoked when the widget emits the `extra-drag-value` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
public init(autohide: Bool? = nil, expandTabs: Bool? = nil, extraDragPreload: Bool? = nil, inverted: Bool? = nil, view: Adw.TabView? = nil, @ViewBuilder endActionWidget: @escaping () -> [AnyView] = { [] }, @ViewBuilder startActionWidget: @escaping () -> [AnyView] = { [] }, onExtraDragDrop: ((Adw.TabPage, Adw.Value) -> Bool)? = nil, onExtraDragValue: ((Adw.TabPage, Adw.Value?) -> Adw.DragAction)? = nil) {
make = { _ in Adw.TabBar() }
configure.append { w, ctx in
if let autohide { w.setAutohide(autohide: autohide) }
if let expandTabs { w.setExpandTabs(expandTabs: expandTabs) }
if let extraDragPreload { w.setExtraDragPreload(preload: extraDragPreload) }
if let inverted { w.setInverted(inverted: inverted) }
if let view { w.setView(view: view) }
if let v = Portico.mountSlotChild(endActionWidget, ctx, onUpdate: { v in w.setEndActionWidget(widget: v) }) { w.setEndActionWidget(widget: v) }
if let v = Portico.mountSlotChild(startActionWidget, ctx, onUpdate: { v in w.setStartActionWidget(widget: v) }) { w.setStartActionWidget(widget: v) }
if let onExtraDragDrop { ctx.registry.add(w.connectExtraDragDrop { _, a0, a1 in onExtraDragDrop(a0, a1) }) }
if let onExtraDragValue { ctx.registry.add(w.connectExtraDragValue { _, a0, a1 in onExtraDragValue(a0, a1) }) }
}
}
}
extension TabBar: WidgetView {
public typealias Target = Adw.TabBar
@_spi(Portico) public func appending(
_ step: @escaping (Adw.TabBar, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension TabBar: 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.TabBar
/// Modifiers for `Adw.TabBar`, available on every Portico view whose
/// backing widget is `Adw.TabBar` or one of its subclasses.
extension WidgetView where Target: Adw.TabBar {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.TabBar.setAutohide(autohide:)
/// Sets whether the tabs automatically hide.
///
/// If set to `TRUE`, the tab bar disappears when [property`TabBar`:view] has 0
/// or 1 tab, no pinned tabs, and no tab is being transferred.
///
/// See [property`TabBar`:tabs-revealed].
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter autohide: Whether the tabs automatically hide.
/// - Returns: A copy of this view with the modifier applied.
public func autohide(_ autohide: Bool) -> Self {
appending { w, _ in
w.setAutohide(autohide: autohide)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.TabBar.setAutohide(autohide:), GObject.Object.connectNotify(detail:_:), Adw.TabBar.getAutohide()
/// Sets whether the tabs automatically hide.
///
/// If set to `TRUE`, the tab bar disappears when [property`TabBar`:view] has 0
/// or 1 tab, no pinned tabs, and no tab is being transferred.
///
/// See [property`TabBar`:tabs-revealed].
///
/// 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 autohide(_ autohide: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, autohide, registry: ctx.registry, notifyDetail: "autohide",
read: { [w] in w.getAutohide() },
write: { [w] v in w.setAutohide(autohide: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.TabBar.setAutohide(autohide:)
/// Sets whether the tabs automatically hide.
///
/// If set to `TRUE`, the tab bar disappears when [property`TabBar`:view] has 0
/// or 1 tab, no pinned tabs, and no tab is being transferred.
///
/// See [property`TabBar`:tabs-revealed].
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.TabBar.setAutohide(autohide:)`.
///
/// - Parameter autohide: Whether the tabs automatically hide.
/// - Returns: A copy of this view with the modifier applied.
public func autohide(_ autohide: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setAutohide(autohide: autohide()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.TabBar.setEndActionWidget(widget:)
/// Sets the widget to show after the tabs.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter endActionWidget: The widget shown after the tabs.
/// - Returns: A copy of this view with the modifier applied.
public func endActionWidget(_ endActionWidget: Adw.Widget?) -> Self {
appending { w, _ in
w.setEndActionWidget(widget: endActionWidget)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Adw.TabBar.setEndActionWidget(widget:)
/// Sets the widget to show after the tabs.
///
/// 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 endActionWidget: The widget shown after the tabs.
/// - Returns: A copy of this view with the modifier applied.
public func endActionWidget(@ViewBuilder _ endActionWidget: () -> [AnyView]) -> Self {
let endActionWidgetViews = endActionWidget()
return appending { w, ctx in
guard let v = endActionWidgetViews.first else { return }
w.setEndActionWidget(widget: v.makeWidget(ctx))
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.TabBar.setEndActionWidget(widget:), GObject.Object.connectNotify(detail:_:), Adw.TabBar.getEndActionWidget()
/// Sets the widget to show after the tabs.
///
/// 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 endActionWidget<W: Gtk.Widget>(_ endActionWidget: Portico.Binding<W?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, endActionWidget, registry: ctx.registry, notifyDetail: "end-action-widget",
read: { [w] in w.getEndActionWidget() as? W },
write: { [w] v in w.setEndActionWidget(widget: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.TabBar.setEndActionWidget(widget:), GObject.Object.connectNotify(detail:_:), Adw.TabBar.getEndActionWidget()
/// Sets the widget to show after the tabs.
///
/// 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 endActionWidget<W: Gtk.Widget>(_ endActionWidget: Portico.Binding<W>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, endActionWidget, registry: ctx.registry, notifyDetail: "end-action-widget",
read: { [w] in w.getEndActionWidget() as? W },
write: { [w] v in w.setEndActionWidget(widget: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.TabBar.setEndActionWidget(widget:)
/// Sets the widget to show after the tabs.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.TabBar.setEndActionWidget(widget:)`.
///
/// - Parameter endActionWidget: The widget shown after the tabs.
/// - Returns: A copy of this view with the modifier applied.
public func endActionWidget(_ endActionWidget: @escaping () -> Adw.Widget?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setEndActionWidget(widget: endActionWidget()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.TabBar.setExpandTabs(expandTabs:)
/// Sets whether tabs expand to full width.
///
/// If set to `TRUE`, the tabs will always vary width filling the whole width
/// when possible, otherwise tabs will always have the minimum possible size.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter expandTabs: Whether tabs expand to full width.
/// - Returns: A copy of this view with the modifier applied.
public func expandTabs(_ expandTabs: Bool) -> Self {
appending { w, _ in
w.setExpandTabs(expandTabs: expandTabs)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.TabBar.setExpandTabs(expandTabs:), GObject.Object.connectNotify(detail:_:), Adw.TabBar.getExpandTabs()
/// Sets whether tabs expand to full width.
///
/// If set to `TRUE`, the tabs will always vary width filling the whole width
/// when possible, otherwise tabs will always have the minimum possible size.
///
/// 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 expandTabs(_ expandTabs: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, expandTabs, registry: ctx.registry, notifyDetail: "expand-tabs",
read: { [w] in w.getExpandTabs() },
write: { [w] v in w.setExpandTabs(expandTabs: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.TabBar.setExpandTabs(expandTabs:)
/// Sets whether tabs expand to full width.
///
/// If set to `TRUE`, the tabs will always vary width filling the whole width
/// when possible, otherwise tabs will always have the minimum possible size.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.TabBar.setExpandTabs(expandTabs:)`.
///
/// - Parameter expandTabs: Whether tabs expand to full width.
/// - Returns: A copy of this view with the modifier applied.
public func expandTabs(_ expandTabs: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setExpandTabs(expandTabs: expandTabs()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.TabBar.setExtraDragPreload(preload:)
/// Sets whether drop data should be preloaded on hover.
///
/// See [property`Gtk`.DropTarget:preload].
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter extraDragPreload: Whether the drop data should be preloaded on hover.
/// - Returns: A copy of this view with the modifier applied.
public func extraDragPreload(_ extraDragPreload: Bool) -> Self {
appending { w, _ in
w.setExtraDragPreload(preload: extraDragPreload)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.TabBar.setExtraDragPreload(preload:), GObject.Object.connectNotify(detail:_:), Adw.TabBar.getExtraDragPreload()
/// Sets whether drop data should be preloaded on hover.
///
/// See [property`Gtk`.DropTarget:preload].
///
/// 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 extraDragPreload(_ extraDragPreload: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, extraDragPreload, registry: ctx.registry, notifyDetail: "extra-drag-preload",
read: { [w] in w.getExtraDragPreload() },
write: { [w] v in w.setExtraDragPreload(preload: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.TabBar.setExtraDragPreload(preload:)
/// Sets whether drop data should be preloaded on hover.
///
/// See [property`Gtk`.DropTarget:preload].
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.TabBar.setExtraDragPreload(preload:)`.
///
/// - Parameter extraDragPreload: Whether the drop data should be preloaded on hover.
/// - Returns: A copy of this view with the modifier applied.
public func extraDragPreload(_ extraDragPreload: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setExtraDragPreload(preload: extraDragPreload()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.TabBar.setInverted(inverted:)
/// Sets whether tabs tabs use inverted layout.
///
/// If set to `TRUE`, non-pinned tabs will have the close button at the beginning
/// and the indicator at the end rather than the opposite.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter inverted: Whether tabs use inverted layout.
/// - Returns: A copy of this view with the modifier applied.
public func inverted(_ inverted: Bool) -> Self {
appending { w, _ in
w.setInverted(inverted: inverted)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.TabBar.setInverted(inverted:), GObject.Object.connectNotify(detail:_:), Adw.TabBar.getInverted()
/// Sets whether tabs tabs use inverted layout.
///
/// If set to `TRUE`, non-pinned tabs will have the close button at the beginning
/// and the indicator at the end rather than the opposite.
///
/// 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 inverted(_ inverted: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, inverted, registry: ctx.registry, notifyDetail: "inverted",
read: { [w] in w.getInverted() },
write: { [w] v in w.setInverted(inverted: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.TabBar.setInverted(inverted:)
/// Sets whether tabs tabs use inverted layout.
///
/// If set to `TRUE`, non-pinned tabs will have the close button at the beginning
/// and the indicator at the end rather than the opposite.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.TabBar.setInverted(inverted:)`.
///
/// - Parameter inverted: Whether tabs use inverted layout.
/// - Returns: A copy of this view with the modifier applied.
public func inverted(_ inverted: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setInverted(inverted: inverted()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.TabBar.setStartActionWidget(widget:)
/// Sets the widget to show before the tabs.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter startActionWidget: The widget shown before the tabs.
/// - Returns: A copy of this view with the modifier applied.
public func startActionWidget(_ startActionWidget: Adw.Widget?) -> Self {
appending { w, _ in
w.setStartActionWidget(widget: startActionWidget)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Adw.TabBar.setStartActionWidget(widget:)
/// Sets the widget to show before the tabs.
///
/// 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 startActionWidget: The widget shown before the tabs.
/// - Returns: A copy of this view with the modifier applied.
public func startActionWidget(@ViewBuilder _ startActionWidget: () -> [AnyView]) -> Self {
let startActionWidgetViews = startActionWidget()
return appending { w, ctx in
guard let v = startActionWidgetViews.first else { return }
w.setStartActionWidget(widget: v.makeWidget(ctx))
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.TabBar.setStartActionWidget(widget:), GObject.Object.connectNotify(detail:_:), Adw.TabBar.getStartActionWidget()
/// Sets the widget to show before the tabs.
///
/// 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 startActionWidget<W: Gtk.Widget>(_ startActionWidget: Portico.Binding<W?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, startActionWidget, registry: ctx.registry, notifyDetail: "start-action-widget",
read: { [w] in w.getStartActionWidget() as? W },
write: { [w] v in w.setStartActionWidget(widget: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.TabBar.setStartActionWidget(widget:), GObject.Object.connectNotify(detail:_:), Adw.TabBar.getStartActionWidget()
/// Sets the widget to show before the tabs.
///
/// 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 startActionWidget<W: Gtk.Widget>(_ startActionWidget: Portico.Binding<W>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, startActionWidget, registry: ctx.registry, notifyDetail: "start-action-widget",
read: { [w] in w.getStartActionWidget() as? W },
write: { [w] v in w.setStartActionWidget(widget: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.TabBar.setStartActionWidget(widget:)
/// Sets the widget to show before the tabs.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.TabBar.setStartActionWidget(widget:)`.
///
/// - Parameter startActionWidget: The widget shown before the tabs.
/// - Returns: A copy of this view with the modifier applied.
public func startActionWidget(_ startActionWidget: @escaping () -> Adw.Widget?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setStartActionWidget(widget: startActionWidget()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.TabBar.setView(view:)
/// Sets the tab view `self` controls.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter view: The tab view the tab bar controls.
/// - Returns: A copy of this view with the modifier applied.
public func view(_ view: Adw.TabView?) -> Self {
appending { w, _ in
w.setView(view: view)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.TabBar.setView(view:), GObject.Object.connectNotify(detail:_:), Adw.TabBar.getView()
/// Sets the tab view `self` controls.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.TabView?` 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 view<W: Adw.TabView>(_ view: Portico.Binding<W?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, view, registry: ctx.registry, notifyDetail: "view",
read: { [w] in w.getView() as? W },
write: { [w] v in w.setView(view: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.TabBar.setView(view:), GObject.Object.connectNotify(detail:_:), Adw.TabBar.getView()
/// Sets the tab view `self` controls.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Adw.TabView>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Adw.TabView?>` to be able to clear the property.
/// When `Adw.TabView` 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 view<W: Adw.TabView>(_ view: Portico.Binding<W>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, view, registry: ctx.registry, notifyDetail: "view",
read: { [w] in w.getView() as? W },
write: { [w] v in w.setView(view: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.TabBar.setView(view:)
/// Sets the tab view `self` controls.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.TabBar.setView(view:)`.
///
/// - Parameter view: The tab view the tab bar controls.
/// - Returns: A copy of this view with the modifier applied.
public func view(_ view: @escaping () -> Adw.TabView?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setView(view: view()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.TabBar.connectExtraDragDrop(_:)
/// Emitted when content is dropped onto a tab.
///
/// The content must be of one of the types set up via
/// [method`TabBar`.setup_extra_drop_target].
///
/// See [signal`Gtk`.DropTarget::drop].
///
/// - Parameter handler: Invoked when the widget emits the `extra-drag-drop` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
/// - Returns: A copy of this view with the modifier applied.
public func onExtraDragDrop(_ handler: @escaping (Adw.TabPage, Adw.Value) -> Bool) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectExtraDragDrop { _, a0, a1 in handler(a0, a1) })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.TabBar.connectExtraDragValue(_:)
/// Emitted when the dropped content is preloaded.
///
/// In order for data to be preloaded, [property`TabBar`:extra-drag-preload]
/// must be set to `TRUE`.
///
/// The content must be of one of the types set up via
/// [method`TabBar`.setup_extra_drop_target].
///
/// See [property`Gtk`.DropTarget:value].
///
/// - Parameter handler: Invoked when the widget emits the `extra-drag-value` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
/// - Returns: A copy of this view with the modifier applied.
public func onExtraDragValue(_ handler: @escaping (Adw.TabPage, Adw.Value?) -> Adw.DragAction) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectExtraDragValue { _, a0, a1 in handler(a0, a1) })
}
}
}