portico/Sources/Portico/Generated/Paned.swift

718 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: Gtk.Paned
/// Arranges its children in two panes, horizontally or vertically.
///
/// <picture>
/// <source srcset="panes-dark.png" media="(prefers-color-scheme: dark)">
/// <img alt="An example GtkPaned" src="panes.png">
/// </picture>
///
/// The division between the two panes is adjustable by the user
/// by dragging a handle.
///
/// Child widgets are added to the panes of the widget with
/// [method`Gtk`.Paned.set_start_child] and [method`Gtk`.Paned.set_end_child].
/// The division between the two children is set by default from the size
/// requests of the children, but it can be adjusted by the user.
///
/// A paned widget draws a separator between the two child widgets and a
/// small handle that the user can drag to adjust the division. It does not
/// draw any relief around the children or around the separator. (The space
/// in which the separator is called the gutter.) Often, it is useful to put
/// each child inside a [class`Gtk`.Frame] so that the gutter appears as a
/// ridge. No separator is drawn if one of the children is missing.
///
/// Each child has two options that can be set, "resize" and "shrink". If
/// "resize" is true then, when the `GtkPaned` is resized, that child will
/// expand or shrink along with the paned widget. If "shrink" is true, then
/// that child can be made smaller than its requisition by the user.
/// Setting "shrink" to false allows the application to set a minimum size.
/// If "resize" is false for both children, then this is treated as if
/// "resize" is true for both children.
///
/// The application can set the position of the slider as if it were set
/// by the user, by calling [method`Gtk`.Paned.set_position].
///
/// # Shortcuts and Gestures
///
/// The following signals have default keybindings:
///
/// - [signal`Gtk`.Paned::accept-position]
/// - [signal`Gtk`.Paned::cancel-position]
/// - [signal`Gtk`.Paned::cycle-child-focus]
/// - [signal`Gtk`.Paned::cycle-handle-focus]
/// - [signal`Gtk`.Paned::move-handle]
/// - [signal`Gtk`.Paned::toggle-handle-focus]
///
/// # CSS nodes
///
/// ```
/// paned
/// <child>
/// separator[.wide]
/// <child>
/// ```
///
/// `GtkPaned` has a main CSS node with name paned, and a subnode for
/// the separator with name separator. The subnode gets a .wide style
/// class when the paned is supposed to be wide.
///
/// In horizontal orientation, the nodes are arranged based on the text
/// direction, so in left-to-right mode, :first-child will select the
/// leftmost child, while it will select the rightmost child in
/// RTL layouts.
///
/// ## Creating a paned widget with minimum sizes.
///
/// ```c
/// GtkWidget *hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
/// GtkWidget *frame1 = gtk_frame_new (NULL);
/// GtkWidget *frame2 = gtk_frame_new (NULL);
///
/// gtk_widget_set_size_request (hpaned, 200, -1);
///
/// gtk_paned_set_start_child (GTK_PANED (hpaned), frame1);
/// gtk_paned_set_resize_start_child (GTK_PANED (hpaned), TRUE);
/// gtk_paned_set_shrink_start_child (GTK_PANED (hpaned), FALSE);
/// gtk_widget_set_size_request (frame1, 50, -1);
///
/// gtk_paned_set_end_child (GTK_PANED (hpaned), frame2);
/// gtk_paned_set_resize_end_child (GTK_PANED (hpaned), FALSE);
/// gtk_paned_set_shrink_end_child (GTK_PANED (hpaned), FALSE);
/// gtk_widget_set_size_request (frame2, 50, -1);
/// ```
///
/// A Portico view that mounts a `Gtk.Paned`.
@MainActor public struct Paned: View {
private let make: (MountContext) -> Gtk.Paned
private var configure: [(Gtk.Paned, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.Paned.init(orientation:)
/// Creates a new `GtkPaned` widget.
///
/// 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 orientation: The `orientation` value forwarded to `Gtk.Paned`.
/// - Parameter position: Position of the separator in pixels, from the left/top.
/// - Parameter resizeEndChild: Determines whether the second child expands and shrinks along with the paned widget.
/// - Parameter resizeStartChild: Determines whether the first child expands and shrinks along with the paned widget.
/// - Parameter shrinkEndChild: Determines whether the second child can be made smaller than its requisition.
/// - Parameter shrinkStartChild: Determines whether the first child can be made smaller than its requisition.
/// - Parameter wideHandle: Whether the `GtkPaned` should provide a stronger visual separation.
/// - Parameter endChild: A `ViewBuilder` closure whose first view is mounted into the `endChild` slot.
/// - Parameter startChild: A `ViewBuilder` closure whose first view is mounted into the `startChild` slot.
/// - Parameter onAcceptPosition: Invoked when the widget emits the `accept-position` signal. Its return value is forwarded to GTK as the signal's result.
/// - Parameter onCancelPosition: Invoked when the widget emits the `cancel-position` signal. Its return value is forwarded to GTK as the signal's result.
/// - Parameter onCycleChildFocus: Invoked when the widget emits the `cycle-child-focus` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
/// - Parameter onCycleHandleFocus: Invoked when the widget emits the `cycle-handle-focus` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
/// - Parameter onMoveHandle: Invoked when the widget emits the `move-handle` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
/// - Parameter onToggleHandleFocus: Invoked when the widget emits the `toggle-handle-focus` signal. Its return value is forwarded to GTK as the signal's result.
public init(orientation: Gtk.Orientation, position: Int32? = nil, resizeEndChild: Bool? = nil, resizeStartChild: Bool? = nil, shrinkEndChild: Bool? = nil, shrinkStartChild: Bool? = nil, wideHandle: Bool? = nil, @ViewBuilder endChild: @escaping () -> [AnyView] = { [] }, @ViewBuilder startChild: @escaping () -> [AnyView] = { [] }, onAcceptPosition: (() -> Bool)? = nil, onCancelPosition: (() -> Bool)? = nil, onCycleChildFocus: ((Bool) -> Bool)? = nil, onCycleHandleFocus: ((Bool) -> Bool)? = nil, onMoveHandle: ((Gtk.ScrollType) -> Bool)? = nil, onToggleHandleFocus: (() -> Bool)? = nil) {
make = { _ in Gtk.Paned(orientation: orientation) }
configure.append { w, ctx in
if let position { w.setPosition(position: position) }
if let resizeEndChild { w.setResizeEndChild(resize: resizeEndChild) }
if let resizeStartChild { w.setResizeStartChild(resize: resizeStartChild) }
if let shrinkEndChild { w.setShrinkEndChild(resize: shrinkEndChild) }
if let shrinkStartChild { w.setShrinkStartChild(resize: shrinkStartChild) }
if let wideHandle { w.setWideHandle(wide: wideHandle) }
if let v = Portico.mountSlotChild(endChild, ctx, onUpdate: { v in w.setEndChild(child: v) }) { w.setEndChild(child: v) }
if let v = Portico.mountSlotChild(startChild, ctx, onUpdate: { v in w.setStartChild(child: v) }) { w.setStartChild(child: v) }
if let onAcceptPosition { ctx.registry.add(w.connectAcceptPosition { _ in onAcceptPosition() }) }
if let onCancelPosition { ctx.registry.add(w.connectCancelPosition { _ in onCancelPosition() }) }
if let onCycleChildFocus { ctx.registry.add(w.connectCycleChildFocus { _, a0 in onCycleChildFocus(a0) }) }
if let onCycleHandleFocus { ctx.registry.add(w.connectCycleHandleFocus { _, a0 in onCycleHandleFocus(a0) }) }
if let onMoveHandle { ctx.registry.add(w.connectMoveHandle { _, a0 in onMoveHandle(a0) }) }
if let onToggleHandleFocus { ctx.registry.add(w.connectToggleHandleFocus { _ in onToggleHandleFocus() }) }
}
}
}
extension Paned: WidgetView {
public typealias Target = Gtk.Paned
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.Paned, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension Paned: Mountable {
@_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget {
let w = make(ctx)
for step in configure { step(w, ctx) }
return w
}
}
// PorticoGen: generateModifierExtension | source: Gtk.Paned
/// Modifiers for `Gtk.Paned`, available on every Portico view whose
/// backing widget is `Gtk.Paned` or one of its subclasses.
extension WidgetView where Target: Gtk.Paned {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Paned.setEndChild(child:)
/// Sets the end child of `paned` to `child`.
///
/// If `child` is `NULL`, the existing child will be removed.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter endChild: The second child.
/// - Returns: A copy of this view with the modifier applied.
public func endChild(_ endChild: Gtk.Widget?) -> Self {
appending { w, _ in
w.setEndChild(child: endChild)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Gtk.Paned.setEndChild(child:)
/// Sets the end child of `paned` to `child`.
///
/// If `child` is `NULL`, the existing child will be removed.
///
/// 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 endChild: The second child.
/// - Returns: A copy of this view with the modifier applied.
public func endChild(@ViewBuilder _ endChild: () -> [AnyView]) -> Self {
let endChildViews = endChild()
return appending { w, ctx in
guard let v = endChildViews.first else { return }
w.setEndChild(child: v.makeWidget(ctx))
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Paned.setEndChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.Paned.getEndChild()
/// Sets the end child of `paned` to `child`.
///
/// If `child` is `NULL`, the existing child will be removed.
///
/// 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 endChild<W: Gtk.Widget>(_ endChild: Portico.Binding<W?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, endChild, registry: ctx.registry, notifyDetail: "end-child",
read: { [w] in w.getEndChild() as? W },
write: { [w] v in w.setEndChild(child: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.Paned.setEndChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.Paned.getEndChild()
/// Sets the end child of `paned` to `child`.
///
/// If `child` is `NULL`, the existing child will be removed.
///
/// 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 endChild<W: Gtk.Widget>(_ endChild: Portico.Binding<W>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, endChild, registry: ctx.registry, notifyDetail: "end-child",
read: { [w] in w.getEndChild() as? W },
write: { [w] v in w.setEndChild(child: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Paned.setEndChild(child:)
/// Sets the end child of `paned` to `child`.
///
/// If `child` is `NULL`, the existing child will be removed.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Paned.setEndChild(child:)`.
///
/// - Parameter endChild: The second child.
/// - Returns: A copy of this view with the modifier applied.
public func endChild(_ endChild: @escaping () -> Gtk.Widget?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setEndChild(child: endChild()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Paned.setPosition(position:)
/// Sets the position of the divider between the two panes.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter position: Position of the separator in pixels, from the left/top.
/// - Returns: A copy of this view with the modifier applied.
public func position(_ position: Int32) -> Self {
appending { w, _ in
w.setPosition(position: position)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Paned.setPosition(position:), GObject.Object.connectNotify(detail:_:), Gtk.Paned.getPosition()
/// Sets the position of the divider between the two panes.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Int32` 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 position(_ position: Portico.Binding<Int32>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, position, registry: ctx.registry, notifyDetail: "position",
read: { [w] in w.getPosition() },
write: { [w] v in w.setPosition(position: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Paned.setPosition(position:)
/// Sets the position of the divider between the two panes.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Paned.setPosition(position:)`.
///
/// - Parameter position: Position of the separator in pixels, from the left/top.
/// - Returns: A copy of this view with the modifier applied.
public func position(_ position: @escaping () -> Int32) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setPosition(position: position()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Paned.setResizeEndChild(resize:)
/// Sets whether the [property`Gtk`.Paned:end-child] can be resized.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter resizeEndChild: Determines whether the second child expands and shrinks along with the paned widget.
/// - Returns: A copy of this view with the modifier applied.
public func resizeEndChild(_ resizeEndChild: Bool) -> Self {
appending { w, _ in
w.setResizeEndChild(resize: resizeEndChild)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Paned.setResizeEndChild(resize:), GObject.Object.connectNotify(detail:_:), Gtk.Paned.getResizeEndChild()
/// Sets whether the [property`Gtk`.Paned:end-child] can be resized.
///
/// 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 resizeEndChild(_ resizeEndChild: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, resizeEndChild, registry: ctx.registry, notifyDetail: "resize-end-child",
read: { [w] in w.getResizeEndChild() },
write: { [w] v in w.setResizeEndChild(resize: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Paned.setResizeEndChild(resize:)
/// Sets whether the [property`Gtk`.Paned:end-child] can be resized.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Paned.setResizeEndChild(resize:)`.
///
/// - Parameter resizeEndChild: Determines whether the second child expands and shrinks along with the paned widget.
/// - Returns: A copy of this view with the modifier applied.
public func resizeEndChild(_ resizeEndChild: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setResizeEndChild(resize: resizeEndChild()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Paned.setResizeStartChild(resize:)
/// Sets whether the [property`Gtk`.Paned:start-child] can be resized.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter resizeStartChild: Determines whether the first child expands and shrinks along with the paned widget.
/// - Returns: A copy of this view with the modifier applied.
public func resizeStartChild(_ resizeStartChild: Bool) -> Self {
appending { w, _ in
w.setResizeStartChild(resize: resizeStartChild)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Paned.setResizeStartChild(resize:), GObject.Object.connectNotify(detail:_:), Gtk.Paned.getResizeStartChild()
/// Sets whether the [property`Gtk`.Paned:start-child] can be resized.
///
/// 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 resizeStartChild(_ resizeStartChild: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, resizeStartChild, registry: ctx.registry, notifyDetail: "resize-start-child",
read: { [w] in w.getResizeStartChild() },
write: { [w] v in w.setResizeStartChild(resize: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Paned.setResizeStartChild(resize:)
/// Sets whether the [property`Gtk`.Paned:start-child] can be resized.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Paned.setResizeStartChild(resize:)`.
///
/// - Parameter resizeStartChild: Determines whether the first child expands and shrinks along with the paned widget.
/// - Returns: A copy of this view with the modifier applied.
public func resizeStartChild(_ resizeStartChild: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setResizeStartChild(resize: resizeStartChild()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Paned.setShrinkEndChild(resize:)
/// Sets whether the [property`Gtk`.Paned:end-child] can shrink.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter shrinkEndChild: Determines whether the second child can be made smaller than its requisition.
/// - Returns: A copy of this view with the modifier applied.
public func shrinkEndChild(_ shrinkEndChild: Bool) -> Self {
appending { w, _ in
w.setShrinkEndChild(resize: shrinkEndChild)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Paned.setShrinkEndChild(resize:), GObject.Object.connectNotify(detail:_:), Gtk.Paned.getShrinkEndChild()
/// Sets whether the [property`Gtk`.Paned:end-child] can shrink.
///
/// 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 shrinkEndChild(_ shrinkEndChild: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, shrinkEndChild, registry: ctx.registry, notifyDetail: "shrink-end-child",
read: { [w] in w.getShrinkEndChild() },
write: { [w] v in w.setShrinkEndChild(resize: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Paned.setShrinkEndChild(resize:)
/// Sets whether the [property`Gtk`.Paned:end-child] can shrink.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Paned.setShrinkEndChild(resize:)`.
///
/// - Parameter shrinkEndChild: Determines whether the second child can be made smaller than its requisition.
/// - Returns: A copy of this view with the modifier applied.
public func shrinkEndChild(_ shrinkEndChild: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setShrinkEndChild(resize: shrinkEndChild()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Paned.setShrinkStartChild(resize:)
/// Sets whether the [property`Gtk`.Paned:start-child] can shrink.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter shrinkStartChild: Determines whether the first child can be made smaller than its requisition.
/// - Returns: A copy of this view with the modifier applied.
public func shrinkStartChild(_ shrinkStartChild: Bool) -> Self {
appending { w, _ in
w.setShrinkStartChild(resize: shrinkStartChild)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Paned.setShrinkStartChild(resize:), GObject.Object.connectNotify(detail:_:), Gtk.Paned.getShrinkStartChild()
/// Sets whether the [property`Gtk`.Paned:start-child] can shrink.
///
/// 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 shrinkStartChild(_ shrinkStartChild: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, shrinkStartChild, registry: ctx.registry, notifyDetail: "shrink-start-child",
read: { [w] in w.getShrinkStartChild() },
write: { [w] v in w.setShrinkStartChild(resize: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Paned.setShrinkStartChild(resize:)
/// Sets whether the [property`Gtk`.Paned:start-child] can shrink.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Paned.setShrinkStartChild(resize:)`.
///
/// - Parameter shrinkStartChild: Determines whether the first child can be made smaller than its requisition.
/// - Returns: A copy of this view with the modifier applied.
public func shrinkStartChild(_ shrinkStartChild: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setShrinkStartChild(resize: shrinkStartChild()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Paned.setStartChild(child:)
/// Sets the start child of `paned` to `child`.
///
/// If `child` is `NULL`, the existing child will be removed.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter startChild: The first child.
/// - Returns: A copy of this view with the modifier applied.
public func startChild(_ startChild: Gtk.Widget?) -> Self {
appending { w, _ in
w.setStartChild(child: startChild)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Gtk.Paned.setStartChild(child:)
/// Sets the start child of `paned` to `child`.
///
/// If `child` is `NULL`, the existing child will be removed.
///
/// 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 startChild: The first child.
/// - Returns: A copy of this view with the modifier applied.
public func startChild(@ViewBuilder _ startChild: () -> [AnyView]) -> Self {
let startChildViews = startChild()
return appending { w, ctx in
guard let v = startChildViews.first else { return }
w.setStartChild(child: v.makeWidget(ctx))
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Paned.setStartChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.Paned.getStartChild()
/// Sets the start child of `paned` to `child`.
///
/// If `child` is `NULL`, the existing child will be removed.
///
/// 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 startChild<W: Gtk.Widget>(_ startChild: Portico.Binding<W?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, startChild, registry: ctx.registry, notifyDetail: "start-child",
read: { [w] in w.getStartChild() as? W },
write: { [w] v in w.setStartChild(child: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.Paned.setStartChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.Paned.getStartChild()
/// Sets the start child of `paned` to `child`.
///
/// If `child` is `NULL`, the existing child will be removed.
///
/// 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 startChild<W: Gtk.Widget>(_ startChild: Portico.Binding<W>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, startChild, registry: ctx.registry, notifyDetail: "start-child",
read: { [w] in w.getStartChild() as? W },
write: { [w] v in w.setStartChild(child: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Paned.setStartChild(child:)
/// Sets the start child of `paned` to `child`.
///
/// If `child` is `NULL`, the existing child will be removed.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Paned.setStartChild(child:)`.
///
/// - Parameter startChild: The first child.
/// - Returns: A copy of this view with the modifier applied.
public func startChild(_ startChild: @escaping () -> Gtk.Widget?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setStartChild(child: startChild()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Paned.setWideHandle(wide:)
/// Sets whether the separator should be wide.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter wideHandle: Whether the `GtkPaned` should provide a stronger visual separation.
/// - Returns: A copy of this view with the modifier applied.
public func wideHandle(_ wideHandle: Bool) -> Self {
appending { w, _ in
w.setWideHandle(wide: wideHandle)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Paned.setWideHandle(wide:), GObject.Object.connectNotify(detail:_:), Gtk.Paned.getWideHandle()
/// Sets whether the separator should be wide.
///
/// 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 wideHandle(_ wideHandle: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, wideHandle, registry: ctx.registry, notifyDetail: "wide-handle",
read: { [w] in w.getWideHandle() },
write: { [w] v in w.setWideHandle(wide: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Paned.setWideHandle(wide:)
/// Sets whether the separator should be wide.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Paned.setWideHandle(wide:)`.
///
/// - Parameter wideHandle: Whether the `GtkPaned` should provide a stronger visual separation.
/// - Returns: A copy of this view with the modifier applied.
public func wideHandle(_ wideHandle: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setWideHandle(wide: wideHandle()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Paned.connectAcceptPosition(_:)
/// Emitted to accept the current position of the handle when
/// moving it using key bindings.
///
/// This is a [keybinding signal](class.SignalAction.html).
///
/// The default binding for this signal is <kbd>Return</kbd> or
/// <kbd>Space</kbd>.
///
/// - Parameter handler: Invoked when the widget emits the `accept-position` signal. Its return value is forwarded to GTK as the signal's result.
/// - Returns: A copy of this view with the modifier applied.
public func onAcceptPosition(_ handler: @escaping () -> Bool) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectAcceptPosition { _ in handler() })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Paned.connectCancelPosition(_:)
/// Emitted to cancel moving the position of the handle using key
/// bindings.
///
/// The position of the handle will be reset to the value prior to
/// moving it.
///
/// This is a [keybinding signal](class.SignalAction.html).
///
/// The default binding for this signal is <kbd>Escape</kbd>.
///
/// - Parameter handler: Invoked when the widget emits the `cancel-position` signal. Its return value is forwarded to GTK as the signal's result.
/// - Returns: A copy of this view with the modifier applied.
public func onCancelPosition(_ handler: @escaping () -> Bool) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectCancelPosition { _ in handler() })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Paned.connectCycleChildFocus(_:)
/// Emitted to cycle the focus between the children of the paned.
///
/// This is a [keybinding signal](class.SignalAction.html).
///
/// The default binding is <kbd>F6</kbd>.
///
/// - Parameter handler: Invoked when the widget emits the `cycle-child-focus` 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 onCycleChildFocus(_ handler: @escaping (Bool) -> Bool) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectCycleChildFocus { _, a0 in handler(a0) })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Paned.connectCycleHandleFocus(_:)
/// Emitted to cycle whether the paned should grab focus to allow
/// the user to change position of the handle by using key bindings.
///
/// This is a [keybinding signal](class.SignalAction.html).
///
/// The default binding for this signal is <kbd>F8</kbd>.
///
/// - Parameter handler: Invoked when the widget emits the `cycle-handle-focus` 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 onCycleHandleFocus(_ handler: @escaping (Bool) -> Bool) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectCycleHandleFocus { _, a0 in handler(a0) })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Paned.connectMoveHandle(_:)
/// Emitted to move the handle with key bindings.
///
/// This is a [keybinding signal](class.SignalAction.html).
///
/// The default bindings for this signal are
/// <kbd>Ctrl</kbd>+<kbd></kbd>, <kbd></kbd>,
/// <kbd>Ctrl</kbd>+<kbd></kbd>, <kbd></kbd>,
/// <kbd>Ctrl</kbd>+<kbd></kbd>, <kbd></kbd>,
/// <kbd>Ctrl</kbd>+<kbd></kbd>, <kbd></kbd>,
/// <kbd>PgUp</kbd>, <kbd>PgDn</kbd>, <kbd>Home</kbd>, <kbd>End</kbd>.
///
/// - Parameter handler: Invoked when the widget emits the `move-handle` 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 onMoveHandle(_ handler: @escaping (Gtk.ScrollType) -> Bool) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectMoveHandle { _, a0 in handler(a0) })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Paned.connectToggleHandleFocus(_:)
/// Emitted to accept the current position of the handle and then
/// move focus to the next widget in the focus chain.
///
/// This is a [keybinding signal](class.SignalAction.html).
///
/// The default binding is <kbd>Tab</kbd>.
///
/// - Parameter handler: Invoked when the widget emits the `toggle-handle-focus` signal. Its return value is forwarded to GTK as the signal's result.
/// - Returns: A copy of this view with the modifier applied.
public func onToggleHandleFocus(_ handler: @escaping () -> Bool) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectToggleHandleFocus { _ in handler() })
}
}
}