850 lines
46 KiB
Swift
850 lines
46 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.Dialog
|
|
/// An adaptive dialog container.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="dialog-floating-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img src="dialog-floating.png" alt="dialog-floating">
|
|
/// </picture>
|
|
/// <picture>
|
|
/// <source srcset="dialog-bottom-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img src="dialog-bottom.png" alt="dialog-bottom">
|
|
/// </picture>
|
|
///
|
|
/// `AdwDialog` is similar to a window, but is shown within another window. It
|
|
/// can be used with [class`Window`] and [class`ApplicationWindow`], use
|
|
/// [method`Dialog`.present] to show it.
|
|
///
|
|
/// `AdwDialog` is not resizable. Use the [property`Dialog`:content-width] and
|
|
/// [property`Dialog`:content-height] properties to set its size, or set
|
|
/// [property`Dialog`:follows-content-size] to `TRUE` to make the dialog track the
|
|
/// content's size as it changes. `AdwDialog` can never be larger than its parent
|
|
/// window.
|
|
///
|
|
/// `AdwDialog` can be presented as a centered floating window or a bottom sheet.
|
|
/// By default it's automatic depending on the available size.
|
|
/// [property`Dialog`:presentation-mode] can be used to change that.
|
|
///
|
|
/// `AdwDialog` can be closed via [method`Dialog`.close].
|
|
///
|
|
/// When presented as a bottom sheet, `AdwDialog` can also be closed via swiping
|
|
/// it down.
|
|
///
|
|
/// The [property`Dialog`:can-close] can be used to prevent closing. In that case,
|
|
/// [signal`Dialog`::close-attempt] gets emitted instead.
|
|
///
|
|
/// Use [method`Dialog`.force_close] to close the dialog even when `can-close` is set to
|
|
/// `FALSE`.
|
|
///
|
|
/// `AdwDialog` is transient and doesn't integrate with the window below it, for
|
|
/// example it's not possible to collapse it into a bottom bar. See
|
|
/// [class`BottomSheet`] for persistent and more tightly integrated bottom sheets.
|
|
///
|
|
/// ## Header Bar Integration
|
|
///
|
|
/// When placed inside an `AdwDialog`, [class`HeaderBar`] will display the dialog
|
|
/// title instead of window title. It will also adjust the decoration layout to
|
|
/// ensure it always has a close button and nothing else. Set
|
|
/// [property`HeaderBar`:show-start-title-buttons] and
|
|
/// [property`HeaderBar`:show-end-title-buttons] to `FALSE` to remove it if it's
|
|
/// unwanted.
|
|
///
|
|
/// ## Breakpoints
|
|
///
|
|
/// `AdwDialog` can be used with [class`Breakpoint`] the same way as
|
|
/// [class`BreakpointBin`]. Refer to that widget's documentation for details.
|
|
///
|
|
/// Like `AdwBreakpointBin`, if breakpoints are used, `AdwDialog` doesn't have a
|
|
/// minimum size, and [property`Gtk`.Widget:width-request] and
|
|
/// [property`Gtk`.Widget:height-request] properties must be set manually.
|
|
///
|
|
/// A Portico view that mounts a `Adw.Dialog`.
|
|
@MainActor public struct Dialog: View {
|
|
private let make: (MountContext) -> Adw.Dialog
|
|
private var configure: [(Adw.Dialog, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Adw.Dialog.init()
|
|
/// Creates a new `AdwDialog`.
|
|
///
|
|
/// 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 canClose: Whether the dialog can be closed.
|
|
/// - Parameter contentHeight: The height of the dialog's contents.
|
|
/// - Parameter contentWidth: The width of the dialog's contents.
|
|
/// - Parameter followsContentSize: Whether to size content automatically.
|
|
/// - Parameter presentationMode: The dialog's presentation mode.
|
|
/// - Parameter title: The title of the dialog.
|
|
/// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot.
|
|
/// - Parameter defaultWidget: A `ViewBuilder` closure whose first view is mounted into the `defaultWidget` slot.
|
|
/// - Parameter focusWidget: A `ViewBuilder` closure whose first view is mounted into the `focusWidget` slot.
|
|
/// - Parameter onCloseAttempt: Invoked when the widget emits the `close-attempt` signal.
|
|
/// - Parameter onClosed: Invoked when the widget emits the `closed` signal.
|
|
public init(canClose: Bool? = nil, contentHeight: Int32? = nil, contentWidth: Int32? = nil, followsContentSize: Bool? = nil, presentationMode: Adw.DialogPresentationMode? = nil, title: String? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, @ViewBuilder defaultWidget: @escaping () -> [AnyView] = { [] }, @ViewBuilder focusWidget: @escaping () -> [AnyView] = { [] }, onCloseAttempt: (() -> Void)? = nil, onClosed: (() -> Void)? = nil) {
|
|
make = { _ in Adw.Dialog() }
|
|
configure.append { w, ctx in
|
|
if let canClose { w.setCanClose(canClose: canClose) }
|
|
if let contentHeight { w.setContentHeight(contentHeight: contentHeight) }
|
|
if let contentWidth { w.setContentWidth(contentWidth: contentWidth) }
|
|
if let followsContentSize { w.setFollowsContentSize(followsContentSize: followsContentSize) }
|
|
if let presentationMode { w.setPresentationMode(presentationMode: presentationMode) }
|
|
if let title { w.setTitle(title: title) }
|
|
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
|
|
if let v = Portico.mountSlotChild(defaultWidget, ctx, onUpdate: { v in w.setDefaultWidget(defaultWidget: v) }) { w.setDefaultWidget(defaultWidget: v) }
|
|
if let v = Portico.mountSlotChild(focusWidget, ctx, onUpdate: { v in w.setFocus(focus: v) }) { w.setFocus(focus: v) }
|
|
if let onCloseAttempt { ctx.registry.add(w.connectCloseAttempt { _ in onCloseAttempt() }) }
|
|
if let onClosed { ctx.registry.add(w.connectClosed { _ in onClosed() }) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension Dialog: WidgetView {
|
|
public typealias Target = Adw.Dialog
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Adw.Dialog, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension Dialog: 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.Dialog
|
|
/// Modifiers for `Adw.Dialog`, available on every Portico view whose
|
|
/// backing widget is `Adw.Dialog` or one of its subclasses.
|
|
extension WidgetView where Target: Adw.Dialog {
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Dialog.setCanClose(canClose:)
|
|
/// Sets whether `self` can be closed.
|
|
///
|
|
/// If set to `FALSE`, the close button, shortcuts and
|
|
/// [method`Dialog`.close] will result in [signal`Dialog`::close-attempt] being
|
|
/// emitted instead, and bottom sheet close swipe will be disabled.
|
|
/// [method`Dialog`.force_close] still works.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter canClose: Whether the dialog can be closed.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func canClose(_ canClose: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setCanClose(canClose: canClose)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Dialog.setCanClose(canClose:), GObject.Object.connectNotify(detail:_:), Adw.Dialog.getCanClose()
|
|
/// Sets whether `self` can be closed.
|
|
///
|
|
/// If set to `FALSE`, the close button, shortcuts and
|
|
/// [method`Dialog`.close] will result in [signal`Dialog`::close-attempt] being
|
|
/// emitted instead, and bottom sheet close swipe will be disabled.
|
|
/// [method`Dialog`.force_close] still works.
|
|
///
|
|
/// 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 canClose(_ canClose: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, canClose, registry: ctx.registry, notifyDetail: "can-close",
|
|
read: { [w] in w.getCanClose() },
|
|
write: { [w] v in w.setCanClose(canClose: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Dialog.setCanClose(canClose:)
|
|
/// Sets whether `self` can be closed.
|
|
///
|
|
/// If set to `FALSE`, the close button, shortcuts and
|
|
/// [method`Dialog`.close] will result in [signal`Dialog`::close-attempt] being
|
|
/// emitted instead, and bottom sheet close swipe will be disabled.
|
|
/// [method`Dialog`.force_close] still works.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Dialog.setCanClose(canClose:)`.
|
|
///
|
|
/// - Parameter canClose: Whether the dialog can be closed.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func canClose(_ canClose: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setCanClose(canClose: canClose()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Dialog.setChild(child:)
|
|
/// Sets the child widget of `self`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter child: The child widget of the `AdwDialog`.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func child(_ child: Adw.Widget?) -> Self {
|
|
appending { w, _ in
|
|
w.setChild(child: child)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Adw.Dialog.setChild(child:)
|
|
/// Sets the child widget of `self`.
|
|
///
|
|
/// 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 child: The child widget of the `AdwDialog`.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func child(@ViewBuilder _ child: () -> [AnyView]) -> Self {
|
|
let childViews = child()
|
|
return appending { w, ctx in
|
|
guard let v = childViews.first else { return }
|
|
w.setChild(child: v.makeWidget(ctx))
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Dialog.setChild(child:), GObject.Object.connectNotify(detail:_:), Adw.Dialog.getChild()
|
|
/// Sets the child widget of `self`.
|
|
///
|
|
/// 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 child<W: Gtk.Widget>(_ child: Portico.Binding<W?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, child, registry: ctx.registry, notifyDetail: "child",
|
|
read: { [w] in w.getChild() as? W },
|
|
write: { [w] v in w.setChild(child: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.Dialog.setChild(child:), GObject.Object.connectNotify(detail:_:), Adw.Dialog.getChild()
|
|
/// Sets the child widget of `self`.
|
|
///
|
|
/// 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 child<W: Gtk.Widget>(_ child: Portico.Binding<W>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, child, registry: ctx.registry, notifyDetail: "child",
|
|
read: { [w] in w.getChild() as? W },
|
|
write: { [w] v in w.setChild(child: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Dialog.setChild(child:)
|
|
/// Sets the child widget of `self`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Dialog.setChild(child:)`.
|
|
///
|
|
/// - Parameter child: The child widget of the `AdwDialog`.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func child(_ child: @escaping () -> Adw.Widget?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setChild(child: child()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Dialog.setContentHeight(contentHeight:)
|
|
/// Sets the height of the dialog's contents.
|
|
///
|
|
/// Set it to -1 to reset it to the content's natural height.
|
|
///
|
|
/// See also: [property`Gtk`.Window:default-height]
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter contentHeight: The height of the dialog's contents.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func contentHeight(_ contentHeight: Int32) -> Self {
|
|
appending { w, _ in
|
|
w.setContentHeight(contentHeight: contentHeight)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Dialog.setContentHeight(contentHeight:), GObject.Object.connectNotify(detail:_:), Adw.Dialog.getContentHeight()
|
|
/// Sets the height of the dialog's contents.
|
|
///
|
|
/// Set it to -1 to reset it to the content's natural height.
|
|
///
|
|
/// See also: [property`Gtk`.Window:default-height]
|
|
///
|
|
/// 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 contentHeight(_ contentHeight: Portico.Binding<Int32>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, contentHeight, registry: ctx.registry, notifyDetail: "content-height",
|
|
read: { [w] in w.getContentHeight() },
|
|
write: { [w] v in w.setContentHeight(contentHeight: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Dialog.setContentHeight(contentHeight:)
|
|
/// Sets the height of the dialog's contents.
|
|
///
|
|
/// Set it to -1 to reset it to the content's natural height.
|
|
///
|
|
/// See also: [property`Gtk`.Window:default-height]
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Dialog.setContentHeight(contentHeight:)`.
|
|
///
|
|
/// - Parameter contentHeight: The height of the dialog's contents.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func contentHeight(_ contentHeight: @escaping () -> Int32) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setContentHeight(contentHeight: contentHeight()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Dialog.setContentWidth(contentWidth:)
|
|
/// Sets the width of the dialog's contents.
|
|
///
|
|
/// Set it to -1 to reset it to the content's natural width.
|
|
///
|
|
/// See also: [property`Gtk`.Window:default-width]
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter contentWidth: The width of the dialog's contents.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func contentWidth(_ contentWidth: Int32) -> Self {
|
|
appending { w, _ in
|
|
w.setContentWidth(contentWidth: contentWidth)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Dialog.setContentWidth(contentWidth:), GObject.Object.connectNotify(detail:_:), Adw.Dialog.getContentWidth()
|
|
/// Sets the width of the dialog's contents.
|
|
///
|
|
/// Set it to -1 to reset it to the content's natural width.
|
|
///
|
|
/// See also: [property`Gtk`.Window:default-width]
|
|
///
|
|
/// 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 contentWidth(_ contentWidth: Portico.Binding<Int32>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, contentWidth, registry: ctx.registry, notifyDetail: "content-width",
|
|
read: { [w] in w.getContentWidth() },
|
|
write: { [w] v in w.setContentWidth(contentWidth: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Dialog.setContentWidth(contentWidth:)
|
|
/// Sets the width of the dialog's contents.
|
|
///
|
|
/// Set it to -1 to reset it to the content's natural width.
|
|
///
|
|
/// See also: [property`Gtk`.Window:default-width]
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Dialog.setContentWidth(contentWidth:)`.
|
|
///
|
|
/// - Parameter contentWidth: The width of the dialog's contents.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func contentWidth(_ contentWidth: @escaping () -> Int32) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setContentWidth(contentWidth: contentWidth()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Dialog.setDefaultWidget(defaultWidget:)
|
|
/// Sets the default widget for `self`.
|
|
///
|
|
/// It's activated when the user presses Enter.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter defaultWidget: The default widget.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func defaultWidget(_ defaultWidget: Adw.Widget?) -> Self {
|
|
appending { w, _ in
|
|
w.setDefaultWidget(defaultWidget: defaultWidget)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Adw.Dialog.setDefaultWidget(defaultWidget:)
|
|
/// Sets the default widget for `self`.
|
|
///
|
|
/// It's activated when the user presses Enter.
|
|
///
|
|
/// 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 defaultWidget: The default widget.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func defaultWidget(@ViewBuilder _ defaultWidget: () -> [AnyView]) -> Self {
|
|
let defaultWidgetViews = defaultWidget()
|
|
return appending { w, ctx in
|
|
guard let v = defaultWidgetViews.first else { return }
|
|
w.setDefaultWidget(defaultWidget: v.makeWidget(ctx))
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Dialog.setDefaultWidget(defaultWidget:), GObject.Object.connectNotify(detail:_:), Adw.Dialog.getDefaultWidget()
|
|
/// Sets the default widget for `self`.
|
|
///
|
|
/// It's activated when the user presses Enter.
|
|
///
|
|
/// 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 defaultWidget<W: Gtk.Widget>(_ defaultWidget: Portico.Binding<W?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, defaultWidget, registry: ctx.registry, notifyDetail: "default-widget",
|
|
read: { [w] in w.getDefaultWidget() as? W },
|
|
write: { [w] v in w.setDefaultWidget(defaultWidget: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.Dialog.setDefaultWidget(defaultWidget:), GObject.Object.connectNotify(detail:_:), Adw.Dialog.getDefaultWidget()
|
|
/// Sets the default widget for `self`.
|
|
///
|
|
/// It's activated when the user presses Enter.
|
|
///
|
|
/// 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 defaultWidget<W: Gtk.Widget>(_ defaultWidget: Portico.Binding<W>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, defaultWidget, registry: ctx.registry, notifyDetail: "default-widget",
|
|
read: { [w] in w.getDefaultWidget() as? W },
|
|
write: { [w] v in w.setDefaultWidget(defaultWidget: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Dialog.setDefaultWidget(defaultWidget:)
|
|
/// Sets the default widget for `self`.
|
|
///
|
|
/// It's activated when the user presses Enter.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Dialog.setDefaultWidget(defaultWidget:)`.
|
|
///
|
|
/// - Parameter defaultWidget: The default widget.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func defaultWidget(_ defaultWidget: @escaping () -> Adw.Widget?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setDefaultWidget(defaultWidget: defaultWidget()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Dialog.setFocus(focus:)
|
|
/// Sets the focus widget for `self`.
|
|
///
|
|
/// If `focus` is not the current focus widget, and is focusable, sets it as the
|
|
/// focus widget for the dialog.
|
|
///
|
|
/// If focus is `NULL`, unsets the focus widget for this dialog. To set the focus
|
|
/// to a particular widget in the dialog, it is usually more convenient to use
|
|
/// [method`Gtk`.Widget.grab_focus] instead of this function.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter focusWidget: The focus widget.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func focusWidget(_ focusWidget: Adw.Widget?) -> Self {
|
|
appending { w, _ in
|
|
w.setFocus(focus: focusWidget)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Adw.Dialog.setFocus(focus:)
|
|
/// Sets the focus widget for `self`.
|
|
///
|
|
/// If `focus` is not the current focus widget, and is focusable, sets it as the
|
|
/// focus widget for the dialog.
|
|
///
|
|
/// If focus is `NULL`, unsets the focus widget for this dialog. To set the focus
|
|
/// to a particular widget in the dialog, it is usually more convenient to use
|
|
/// [method`Gtk`.Widget.grab_focus] instead of this function.
|
|
///
|
|
/// 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 focusWidget: The focus widget.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func focusWidget(@ViewBuilder _ focusWidget: () -> [AnyView]) -> Self {
|
|
let focusWidgetViews = focusWidget()
|
|
return appending { w, ctx in
|
|
guard let v = focusWidgetViews.first else { return }
|
|
w.setFocus(focus: v.makeWidget(ctx))
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Dialog.setFocus(focus:), GObject.Object.connectNotify(detail:_:)
|
|
/// Sets the focus widget for `self`.
|
|
///
|
|
/// If `focus` is not the current focus widget, and is focusable, sets it as the
|
|
/// focus widget for the dialog.
|
|
///
|
|
/// If focus is `NULL`, unsets the focus widget for this dialog. To set the focus
|
|
/// to a particular widget in the dialog, it is usually more convenient to use
|
|
/// [method`Gtk`.Widget.grab_focus] instead of this function.
|
|
///
|
|
/// 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 focusWidget<W: Gtk.Widget>(_ focusWidget: Portico.Binding<W?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, focusWidget, registry: ctx.registry, notifyDetail: "focus-widget",
|
|
read: { [w] in w.focusWidget as? W },
|
|
write: { [w] v in w.setFocus(focus: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.Dialog.setFocus(focus:), GObject.Object.connectNotify(detail:_:)
|
|
/// Sets the focus widget for `self`.
|
|
///
|
|
/// If `focus` is not the current focus widget, and is focusable, sets it as the
|
|
/// focus widget for the dialog.
|
|
///
|
|
/// If focus is `NULL`, unsets the focus widget for this dialog. To set the focus
|
|
/// to a particular widget in the dialog, it is usually more convenient to use
|
|
/// [method`Gtk`.Widget.grab_focus] instead of this function.
|
|
///
|
|
/// 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 focusWidget<W: Gtk.Widget>(_ focusWidget: Portico.Binding<W>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, focusWidget, registry: ctx.registry, notifyDetail: "focus-widget",
|
|
read: { [w] in w.focusWidget as? W },
|
|
write: { [w] v in w.setFocus(focus: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Dialog.setFocus(focus:)
|
|
/// Sets the focus widget for `self`.
|
|
///
|
|
/// If `focus` is not the current focus widget, and is focusable, sets it as the
|
|
/// focus widget for the dialog.
|
|
///
|
|
/// If focus is `NULL`, unsets the focus widget for this dialog. To set the focus
|
|
/// to a particular widget in the dialog, it is usually more convenient to use
|
|
/// [method`Gtk`.Widget.grab_focus] instead of this function.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Dialog.setFocus(focus:)`.
|
|
///
|
|
/// - Parameter focusWidget: The focus widget.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func focusWidget(_ focusWidget: @escaping () -> Adw.Widget?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setFocus(focus: focusWidget()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Dialog.setFollowsContentSize(followsContentSize:)
|
|
/// Sets whether to size content of `self` automatically.
|
|
///
|
|
/// If set to `TRUE`, always use the content's natural size instead of
|
|
/// [property`Dialog`:content-width] and [property`Dialog`:content-height]. If
|
|
/// the content resizes, the dialog will immediately resize as well.
|
|
///
|
|
/// See also: [property`Gtk`.Window:resizable]
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter followsContentSize: Whether to size content automatically.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func followsContentSize(_ followsContentSize: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setFollowsContentSize(followsContentSize: followsContentSize)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Dialog.setFollowsContentSize(followsContentSize:), GObject.Object.connectNotify(detail:_:), Adw.Dialog.getFollowsContentSize()
|
|
/// Sets whether to size content of `self` automatically.
|
|
///
|
|
/// If set to `TRUE`, always use the content's natural size instead of
|
|
/// [property`Dialog`:content-width] and [property`Dialog`:content-height]. If
|
|
/// the content resizes, the dialog will immediately resize as well.
|
|
///
|
|
/// See also: [property`Gtk`.Window:resizable]
|
|
///
|
|
/// 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 followsContentSize(_ followsContentSize: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, followsContentSize, registry: ctx.registry, notifyDetail: "follows-content-size",
|
|
read: { [w] in w.getFollowsContentSize() },
|
|
write: { [w] v in w.setFollowsContentSize(followsContentSize: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Dialog.setFollowsContentSize(followsContentSize:)
|
|
/// Sets whether to size content of `self` automatically.
|
|
///
|
|
/// If set to `TRUE`, always use the content's natural size instead of
|
|
/// [property`Dialog`:content-width] and [property`Dialog`:content-height]. If
|
|
/// the content resizes, the dialog will immediately resize as well.
|
|
///
|
|
/// See also: [property`Gtk`.Window:resizable]
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Dialog.setFollowsContentSize(followsContentSize:)`.
|
|
///
|
|
/// - Parameter followsContentSize: Whether to size content automatically.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func followsContentSize(_ followsContentSize: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setFollowsContentSize(followsContentSize: followsContentSize()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Dialog.setPresentationMode(presentationMode:)
|
|
/// Sets presentation mode for `self`.
|
|
///
|
|
/// When set to [enum`Adw`.DialogPresentationMode.auto], the dialog appears as a
|
|
/// bottom sheet when the following condition is met:
|
|
/// `max-width: 450px or max-height: 360px`, and as a floating window otherwise.
|
|
///
|
|
/// Set it to [enum`Adw`.DialogPresentationMode.floating] or
|
|
/// [enum`Adw`.DialogPresentationMode.bottom-sheet] to always present it a
|
|
/// floating window or a bottom sheet respectively, regardless of available size.
|
|
///
|
|
/// Presentation mode does nothing for dialogs presented as a window.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter presentationMode: The dialog's presentation mode.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func presentationMode(_ presentationMode: Adw.DialogPresentationMode) -> Self {
|
|
appending { w, _ in
|
|
w.setPresentationMode(presentationMode: presentationMode)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Dialog.setPresentationMode(presentationMode:), GObject.Object.connectNotify(detail:_:), Adw.Dialog.getPresentationMode()
|
|
/// Sets presentation mode for `self`.
|
|
///
|
|
/// When set to [enum`Adw`.DialogPresentationMode.auto], the dialog appears as a
|
|
/// bottom sheet when the following condition is met:
|
|
/// `max-width: 450px or max-height: 360px`, and as a floating window otherwise.
|
|
///
|
|
/// Set it to [enum`Adw`.DialogPresentationMode.floating] or
|
|
/// [enum`Adw`.DialogPresentationMode.bottom-sheet] to always present it a
|
|
/// floating window or a bottom sheet respectively, regardless of available size.
|
|
///
|
|
/// Presentation mode does nothing for dialogs presented as a window.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Adw.DialogPresentationMode` 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 presentationMode(_ presentationMode: Portico.Binding<Adw.DialogPresentationMode>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, presentationMode, registry: ctx.registry, notifyDetail: "presentation-mode",
|
|
read: { [w] in w.getPresentationMode() },
|
|
write: { [w] v in w.setPresentationMode(presentationMode: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Dialog.setPresentationMode(presentationMode:)
|
|
/// Sets presentation mode for `self`.
|
|
///
|
|
/// When set to [enum`Adw`.DialogPresentationMode.auto], the dialog appears as a
|
|
/// bottom sheet when the following condition is met:
|
|
/// `max-width: 450px or max-height: 360px`, and as a floating window otherwise.
|
|
///
|
|
/// Set it to [enum`Adw`.DialogPresentationMode.floating] or
|
|
/// [enum`Adw`.DialogPresentationMode.bottom-sheet] to always present it a
|
|
/// floating window or a bottom sheet respectively, regardless of available size.
|
|
///
|
|
/// Presentation mode does nothing for dialogs presented as a window.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Dialog.setPresentationMode(presentationMode:)`.
|
|
///
|
|
/// - Parameter presentationMode: The dialog's presentation mode.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func presentationMode(_ presentationMode: @escaping () -> Adw.DialogPresentationMode) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setPresentationMode(presentationMode: presentationMode()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Dialog.setTitle(title:)
|
|
/// Sets the title of `self`.
|
|
///
|
|
/// Applied once at mount; use the `Binding`, closure, or `InterpolatedText` overload for a value that changes.
|
|
/// A string literal containing interpolation selects the `InterpolatedText` overload instead, which updates live.
|
|
///
|
|
/// - Parameter title: The title of the dialog.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func title<S: StringProtocol>(_ title: S) -> Self {
|
|
appending { w, _ in
|
|
w.setTitle(title: String(title))
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Dialog.setTitle(title:), GObject.Object.connectNotify(detail:_:), Adw.Dialog.getTitle()
|
|
/// Sets the title of `self`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `String` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func title(_ title: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, title, registry: ctx.registry, notifyDetail: "title",
|
|
read: { [w] in w.getTitle() },
|
|
write: { [w] v in w.setTitle(title: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Dialog.setTitle(title:)
|
|
/// Sets the title of `self`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Dialog.setTitle(title:)`.
|
|
///
|
|
/// - Parameter title: The title of the dialog.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func title(_ title: @escaping () -> String) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setTitle(title: title()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.Dialog.setTitle(title:)
|
|
/// Sets the title of `self`.
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.Dialog.setTitle(title:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter title: The title of the dialog.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func title(_ title: Portico.InterpolatedText) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindInterpolation(title, registry: ctx.registry) { [w] v in w.setTitle(title: v) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.Dialog.connectCloseAttempt(_:)
|
|
/// Emitted when the close button or shortcut is used, or
|
|
/// [method`Dialog`.close] is called while [property`Dialog`:can-close] is set to
|
|
/// `FALSE`.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `close-attempt` signal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onCloseAttempt(_ handler: @escaping () -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectCloseAttempt { _ in handler() })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.Dialog.connectClosed(_:)
|
|
/// Emitted when the dialog is successfully closed.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `closed` signal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onClosed(_ handler: @escaping () -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectClosed { _ in handler() })
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension | source: Gtk.Dialog
|
|
/// Modifiers for `Gtk.Dialog`, available on every Portico view whose
|
|
/// backing widget is `Gtk.Dialog` or one of its subclasses.
|
|
extension WidgetView where Target: Gtk.Dialog {
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Dialog.connectClose(_:)
|
|
/// Emitted when the user uses a keybinding to close the dialog.
|
|
///
|
|
/// This is a [keybinding signal](class.SignalAction.html).
|
|
///
|
|
/// The default binding for this signal is the Escape key.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `close` signal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onClose(_ handler: @escaping () -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectClose { _ in handler() })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Dialog.connectResponse(_:)
|
|
/// Emitted when an action widget is clicked.
|
|
///
|
|
/// The signal is also emitted when the dialog receives a
|
|
/// delete event, and when [method`Gtk`.Dialog.response] is called.
|
|
/// On a delete event, the response ID is `GTK_RESPONSE_DELETE_EVENT`.
|
|
/// Otherwise, it depends on which action widget was clicked.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `response` signal. The closure receives the signal's arguments in order.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onResponse(_ handler: @escaping (Int32) -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectResponse { _, a0 in handler(a0) })
|
|
}
|
|
}
|
|
|
|
}
|