856 lines
46 KiB
Swift
856 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.AlertDialog
|
|
/// A dialog presenting a message or a question.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="alert-dialog-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img src="alert-dialog.png" alt="alert-dialog">
|
|
/// </picture>
|
|
///
|
|
/// Alert dialogs have a heading, a body, an optional child widget, and one or
|
|
/// multiple responses, each presented as a button.
|
|
///
|
|
/// Each response has a unique string ID, and a button label. Additionally, each
|
|
/// response can be enabled or disabled, and can have a suggested or destructive
|
|
/// appearance.
|
|
///
|
|
/// When one of the responses is activated, or the dialog is closed, the
|
|
/// [signal`AlertDialog`::response] signal will be emitted. This signal is
|
|
/// detailed, and the detail, as well as the `response` parameter will be set to
|
|
/// the ID of the activated response, or to the value of the
|
|
/// [property`AlertDialog`:close-response] property if the dialog had been closed
|
|
/// without activating any of the responses.
|
|
///
|
|
/// Response buttons can be presented horizontally or vertically depending on
|
|
/// available space.
|
|
///
|
|
/// When a response is activated, `AdwAlertDialog` is closed automatically.
|
|
///
|
|
/// An example of using an alert dialog:
|
|
///
|
|
/// ```c
|
|
/// AdwDialog *dialog;
|
|
///
|
|
/// dialog = adw_alert_dialog_new (_("Replace File?"), NULL);
|
|
///
|
|
/// adw_alert_dialog_format_body (ADW_ALERT_DIALOG (dialog),
|
|
/// _("A file named “`s`” already exists. Do you want to replace it?"),
|
|
/// filename);
|
|
///
|
|
/// adw_alert_dialog_add_responses (ADW_ALERT_DIALOG (dialog),
|
|
/// "cancel", _("_Cancel"),
|
|
/// "replace", _("_Replace"),
|
|
/// NULL);
|
|
///
|
|
/// adw_alert_dialog_set_response_appearance (ADW_ALERT_DIALOG (dialog),
|
|
/// "replace",
|
|
/// ADW_RESPONSE_DESTRUCTIVE);
|
|
///
|
|
/// adw_alert_dialog_set_default_response (ADW_ALERT_DIALOG (dialog), "cancel");
|
|
/// adw_alert_dialog_set_close_response (ADW_ALERT_DIALOG (dialog), "cancel");
|
|
///
|
|
/// g_signal_connect (dialog, "response", G_CALLBACK (response_cb), self);
|
|
///
|
|
/// adw_dialog_present (dialog, parent);
|
|
/// ```
|
|
///
|
|
/// ## Async API
|
|
///
|
|
/// `AdwAlertDialog` can also be used via the [method`AlertDialog`.choose] method.
|
|
/// This API follows the GIO async pattern, for example:
|
|
///
|
|
/// ```c
|
|
/// static void
|
|
/// dialog_cb (AdwAlertDialog *dialog,
|
|
/// GAsyncResult *result,
|
|
/// MyWindow *self)
|
|
/// {
|
|
/// const char *response = adw_alert_dialog_choose_finish (dialog, result);
|
|
///
|
|
/// // ...
|
|
/// }
|
|
///
|
|
/// static void
|
|
/// show_dialog (MyWindow *self)
|
|
/// {
|
|
/// AdwDialog *dialog;
|
|
///
|
|
/// dialog = adw_alert_dialog_new (_("Replace File?"), NULL);
|
|
///
|
|
/// adw_alert_dialog_format_body (ADW_ALERT_DIALOG (dialog),
|
|
/// _("A file named “`s`” already exists. Do you want to replace it?"),
|
|
/// filename);
|
|
///
|
|
/// adw_alert_dialog_add_responses (ADW_ALERT_DIALOG (dialog),
|
|
/// "cancel", _("_Cancel"),
|
|
/// "replace", _("_Replace"),
|
|
/// NULL);
|
|
///
|
|
/// adw_alert_dialog_set_response_appearance (ADW_ALERT_DIALOG (dialog),
|
|
/// "replace",
|
|
/// ADW_RESPONSE_DESTRUCTIVE);
|
|
///
|
|
/// adw_alert_dialog_set_default_response (ADW_ALERT_DIALOG (dialog), "cancel");
|
|
/// adw_alert_dialog_set_close_response (ADW_ALERT_DIALOG (dialog), "cancel");
|
|
///
|
|
/// adw_alert_dialog_choose (ADW_ALERT_DIALOG (dialog), GTK_WIDGET (self),
|
|
/// NULL, (GAsyncReadyCallback) dialog_cb, self);
|
|
/// }
|
|
/// ```
|
|
///
|
|
/// ## AdwAlertDialog as GtkBuildable
|
|
///
|
|
/// `AdwAlertDialog` supports adding responses in UI definitions by via the
|
|
/// `<responses>` element that may contain multiple `<response>` elements, each
|
|
/// representing a response.
|
|
///
|
|
/// Each of the `<response>` elements must have the `id` attribute specifying the
|
|
/// response ID. The contents of the element are used as the response label.
|
|
///
|
|
/// Response labels can be translated with the usual `translatable`, `context`
|
|
/// and `comments` attributes.
|
|
///
|
|
/// The `<response>` elements can also have `enabled` and/or `appearance`
|
|
/// attributes. See [method`AlertDialog`.set_response_enabled] and
|
|
/// [method`AlertDialog`.set_response_appearance] for details.
|
|
///
|
|
/// Example of an `AdwAlertDialog` UI definition:
|
|
///
|
|
/// ```xml
|
|
/// <object class="AdwAlertDialog" id="dialog">
|
|
/// <property name="heading" translatable="yes">Save Changes?</property>
|
|
/// <property name="body" translatable="yes">Open documents contain unsaved changes. Changes which are not saved will be permanently lost.</property>
|
|
/// <property name="default-response">save</property>
|
|
/// <property name="close-response">cancel</property>
|
|
/// <signal name="response" handler="response_cb"/>
|
|
/// <responses>
|
|
/// <response id="cancel" translatable="yes">_Cancel</response>
|
|
/// <response id="discard" translatable="yes" appearance="destructive">_Discard</response>
|
|
/// <response id="save" translatable="yes" appearance="suggested" enabled="false">_Save</response>
|
|
/// </responses>
|
|
/// </object>
|
|
/// ```
|
|
///
|
|
/// A Portico view that mounts a `Adw.AlertDialog`.
|
|
@MainActor public struct AlertDialog: View {
|
|
private let make: (MountContext) -> Adw.AlertDialog
|
|
private var configure: [(Adw.AlertDialog, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Adw.AlertDialog.init(heading:body:)
|
|
/// Creates a new `AdwAlertDialog`.
|
|
///
|
|
/// `heading` and `body` can be set to `NULL`. This can be useful if they need to
|
|
/// be formatted or use markup. In that case, set them to `NULL` and call
|
|
/// [method`AlertDialog`.format_body] or similar methods afterwards:
|
|
///
|
|
/// ```c
|
|
/// AdwDialog *dialog;
|
|
///
|
|
/// dialog = adw_alert_dialog_new (_("Replace File?"), NULL);
|
|
/// adw_alert_dialog_format_body (ADW_ALERT_DIALOG (dialog),
|
|
/// _("A file named “`s`” already exists. Do you want to replace it?"),
|
|
/// filename);
|
|
/// ```
|
|
///
|
|
/// 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 heading: The heading of the dialog.
|
|
/// - Parameter body: The body text of the dialog.
|
|
/// - Parameter bodyUseMarkup: Whether the body text includes Pango markup.
|
|
/// - Parameter closeResponse: The ID of the close response.
|
|
/// - Parameter defaultResponse: The response ID of the default response.
|
|
/// - Parameter headingUseMarkup: Whether the heading includes Pango markup.
|
|
/// - Parameter preferWideLayout: Whether to prefer horizontal button layout.
|
|
/// - 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 extraChild: A `ViewBuilder` closure whose first view is mounted into the `extraChild` 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(heading: String?, body: String?, bodyUseMarkup: Bool? = nil, closeResponse: String? = nil, defaultResponse: String? = nil, headingUseMarkup: Bool? = nil, preferWideLayout: Bool? = nil, canClose: Bool? = nil, contentHeight: Int32? = nil, contentWidth: Int32? = nil, followsContentSize: Bool? = nil, presentationMode: Adw.DialogPresentationMode? = nil, title: String? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, @ViewBuilder extraChild: @escaping () -> [AnyView] = { [] }, @ViewBuilder defaultWidget: @escaping () -> [AnyView] = { [] }, @ViewBuilder focusWidget: @escaping () -> [AnyView] = { [] }, onCloseAttempt: (() -> Void)? = nil, onClosed: (() -> Void)? = nil) {
|
|
make = { _ in Adw.AlertDialog(heading: heading, body: body) }
|
|
configure.append { w, ctx in
|
|
if let bodyUseMarkup { w.setBodyUseMarkup(useMarkup: bodyUseMarkup) }
|
|
if let closeResponse { w.setCloseResponse(response: closeResponse) }
|
|
if let defaultResponse { w.setDefaultResponse(response: defaultResponse) }
|
|
if let headingUseMarkup { w.setHeadingUseMarkup(useMarkup: headingUseMarkup) }
|
|
if let preferWideLayout { w.setPreferWideLayout(preferWideLayout: preferWideLayout) }
|
|
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(extraChild, ctx, onUpdate: { v in w.setExtraChild(child: v) }) { w.setExtraChild(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 AlertDialog: WidgetView {
|
|
public typealias Target = Adw.AlertDialog
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Adw.AlertDialog, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension AlertDialog: 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.AlertDialog
|
|
/// Modifiers for `Adw.AlertDialog`, available on every Portico view whose
|
|
/// backing widget is `Adw.AlertDialog` or one of its subclasses.
|
|
extension WidgetView where Target: Adw.AlertDialog {
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.AlertDialog.setBody(body:)
|
|
/// Sets the body text 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 body: The body text of the dialog.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func body<S: StringProtocol>(_ body: S) -> Self {
|
|
appending { w, _ in
|
|
w.setBody(body: String(body))
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.AlertDialog.setBody(body:), GObject.Object.connectNotify(detail:_:), Adw.AlertDialog.getBody()
|
|
/// Sets the body text 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 body(_ body: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, body, registry: ctx.registry, notifyDetail: "body",
|
|
read: { [w] in w.getBody() },
|
|
write: { [w] v in w.setBody(body: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.AlertDialog.setBody(body:)
|
|
/// Sets the body text of `self`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.AlertDialog.setBody(body:)`.
|
|
///
|
|
/// - Parameter body: The body text of the dialog.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func body(_ body: @escaping () -> String) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setBody(body: body()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.AlertDialog.setBody(body:)
|
|
/// Sets the body text of `self`.
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.AlertDialog.setBody(body:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter body: The body text of the dialog.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func body(_ body: Portico.InterpolatedText) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindInterpolation(body, registry: ctx.registry) { [w] v in w.setBody(body: v) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.AlertDialog.setBodyUseMarkup(useMarkup:)
|
|
/// Sets whether the body text of `self` includes Pango markup.
|
|
///
|
|
/// See [func`Pango`.parse_markup].
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter bodyUseMarkup: Whether the body text includes Pango markup.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func bodyUseMarkup(_ bodyUseMarkup: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setBodyUseMarkup(useMarkup: bodyUseMarkup)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.AlertDialog.setBodyUseMarkup(useMarkup:), GObject.Object.connectNotify(detail:_:), Adw.AlertDialog.getBodyUseMarkup()
|
|
/// Sets whether the body text of `self` includes Pango markup.
|
|
///
|
|
/// See [func`Pango`.parse_markup].
|
|
///
|
|
/// 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 bodyUseMarkup(_ bodyUseMarkup: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, bodyUseMarkup, registry: ctx.registry, notifyDetail: "body-use-markup",
|
|
read: { [w] in w.getBodyUseMarkup() },
|
|
write: { [w] v in w.setBodyUseMarkup(useMarkup: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.AlertDialog.setBodyUseMarkup(useMarkup:)
|
|
/// Sets whether the body text of `self` includes Pango markup.
|
|
///
|
|
/// See [func`Pango`.parse_markup].
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.AlertDialog.setBodyUseMarkup(useMarkup:)`.
|
|
///
|
|
/// - Parameter bodyUseMarkup: Whether the body text includes Pango markup.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func bodyUseMarkup(_ bodyUseMarkup: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setBodyUseMarkup(useMarkup: bodyUseMarkup()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.AlertDialog.setCloseResponse(response:)
|
|
/// Sets the ID of the close response of `self`.
|
|
///
|
|
/// It will be passed to [signal`AlertDialog`::response] if the dialog is closed
|
|
/// by pressing <kbd>Escape</kbd> or with a system action.
|
|
///
|
|
/// It doesn't have to correspond to any of the responses in the dialog.
|
|
///
|
|
/// The default close response is `close`.
|
|
///
|
|
/// 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 closeResponse: The ID of the close response.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func closeResponse<S: StringProtocol>(_ closeResponse: S) -> Self {
|
|
appending { w, _ in
|
|
w.setCloseResponse(response: String(closeResponse))
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.AlertDialog.setCloseResponse(response:), GObject.Object.connectNotify(detail:_:), Adw.AlertDialog.getCloseResponse()
|
|
/// Sets the ID of the close response of `self`.
|
|
///
|
|
/// It will be passed to [signal`AlertDialog`::response] if the dialog is closed
|
|
/// by pressing <kbd>Escape</kbd> or with a system action.
|
|
///
|
|
/// It doesn't have to correspond to any of the responses in the dialog.
|
|
///
|
|
/// The default close response is `close`.
|
|
///
|
|
/// 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 closeResponse(_ closeResponse: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, closeResponse, registry: ctx.registry, notifyDetail: "close-response",
|
|
read: { [w] in w.getCloseResponse() },
|
|
write: { [w] v in w.setCloseResponse(response: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.AlertDialog.setCloseResponse(response:)
|
|
/// Sets the ID of the close response of `self`.
|
|
///
|
|
/// It will be passed to [signal`AlertDialog`::response] if the dialog is closed
|
|
/// by pressing <kbd>Escape</kbd> or with a system action.
|
|
///
|
|
/// It doesn't have to correspond to any of the responses in the dialog.
|
|
///
|
|
/// The default close response is `close`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.AlertDialog.setCloseResponse(response:)`.
|
|
///
|
|
/// - Parameter closeResponse: The ID of the close response.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func closeResponse(_ closeResponse: @escaping () -> String) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setCloseResponse(response: closeResponse()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.AlertDialog.setCloseResponse(response:)
|
|
/// Sets the ID of the close response of `self`.
|
|
///
|
|
/// It will be passed to [signal`AlertDialog`::response] if the dialog is closed
|
|
/// by pressing <kbd>Escape</kbd> or with a system action.
|
|
///
|
|
/// It doesn't have to correspond to any of the responses in the dialog.
|
|
///
|
|
/// The default close response is `close`.
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.AlertDialog.setCloseResponse(response:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter closeResponse: The ID of the close response.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func closeResponse(_ closeResponse: Portico.InterpolatedText) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindInterpolation(closeResponse, registry: ctx.registry) { [w] v in w.setCloseResponse(response: v) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.AlertDialog.setDefaultResponse(response:)
|
|
/// Sets the ID of the default response of `self`.
|
|
///
|
|
/// The button corresponding to this response will be set as the default widget
|
|
/// of `self`.
|
|
///
|
|
/// If not set, the default widget will not be set, and the last added response
|
|
/// will be focused by default.
|
|
///
|
|
/// See [property`Dialog`:default-widget].
|
|
///
|
|
/// 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 defaultResponse: The response ID of the default response.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func defaultResponse<S: StringProtocol>(_ defaultResponse: S?) -> Self {
|
|
appending { w, _ in
|
|
w.setDefaultResponse(response: defaultResponse.map { String($0) })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.AlertDialog.setDefaultResponse(response:), GObject.Object.connectNotify(detail:_:), Adw.AlertDialog.getDefaultResponse()
|
|
/// Sets the ID of the default response of `self`.
|
|
///
|
|
/// The button corresponding to this response will be set as the default widget
|
|
/// of `self`.
|
|
///
|
|
/// If not set, the default widget will not be set, and the last added response
|
|
/// will be focused by default.
|
|
///
|
|
/// See [property`Dialog`:default-widget].
|
|
///
|
|
/// 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 defaultResponse(_ defaultResponse: Portico.Binding<String?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, defaultResponse, registry: ctx.registry, notifyDetail: "default-response",
|
|
read: { [w] in w.getDefaultResponse() },
|
|
write: { [w] v in w.setDefaultResponse(response: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.AlertDialog.setDefaultResponse(response:), GObject.Object.connectNotify(detail:_:), Adw.AlertDialog.getDefaultResponse()
|
|
/// Sets the ID of the default response of `self`.
|
|
///
|
|
/// The button corresponding to this response will be set as the default widget
|
|
/// of `self`.
|
|
///
|
|
/// If not set, the default widget will not be set, and the last added response
|
|
/// will be focused by default.
|
|
///
|
|
/// See [property`Dialog`:default-widget].
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant, so a `Binding<String>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<String?>` to be able to clear the property.
|
|
/// When `String` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
|
/// A `nil` widget value is never written back into the binding.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func defaultResponse(_ defaultResponse: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, defaultResponse, registry: ctx.registry, notifyDetail: "default-response",
|
|
read: { [w] in w.getDefaultResponse() },
|
|
write: { [w] v in w.setDefaultResponse(response: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.AlertDialog.setDefaultResponse(response:)
|
|
/// Sets the ID of the default response of `self`.
|
|
///
|
|
/// The button corresponding to this response will be set as the default widget
|
|
/// of `self`.
|
|
///
|
|
/// If not set, the default widget will not be set, and the last added response
|
|
/// will be focused by default.
|
|
///
|
|
/// See [property`Dialog`:default-widget].
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.AlertDialog.setDefaultResponse(response:)`.
|
|
///
|
|
/// - Parameter defaultResponse: The response ID of the default response.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func defaultResponse(_ defaultResponse: @escaping () -> String?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setDefaultResponse(response: defaultResponse()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.AlertDialog.setDefaultResponse(response:)
|
|
/// Sets the ID of the default response of `self`.
|
|
///
|
|
/// The button corresponding to this response will be set as the default widget
|
|
/// of `self`.
|
|
///
|
|
/// If not set, the default widget will not be set, and the last added response
|
|
/// will be focused by default.
|
|
///
|
|
/// See [property`Dialog`:default-widget].
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.AlertDialog.setDefaultResponse(response:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter defaultResponse: The response ID of the default response.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func defaultResponse(_ defaultResponse: Portico.InterpolatedText?) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindOptionalInterpolation(defaultResponse, registry: ctx.registry) { [w] v in w.setDefaultResponse(response: v) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.AlertDialog.setExtraChild(child:)
|
|
/// Sets the child widget of `self`.
|
|
///
|
|
/// The child widget is displayed below the heading and body.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter extraChild: The child widget.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func extraChild(_ extraChild: Adw.Widget?) -> Self {
|
|
appending { w, _ in
|
|
w.setExtraChild(child: extraChild)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Adw.AlertDialog.setExtraChild(child:)
|
|
/// Sets the child widget of `self`.
|
|
///
|
|
/// The child widget is displayed below the heading and body.
|
|
///
|
|
/// 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 extraChild: The child widget.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func extraChild(@ViewBuilder _ extraChild: () -> [AnyView]) -> Self {
|
|
let extraChildViews = extraChild()
|
|
return appending { w, ctx in
|
|
guard let v = extraChildViews.first else { return }
|
|
w.setExtraChild(child: v.makeWidget(ctx))
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.AlertDialog.setExtraChild(child:), GObject.Object.connectNotify(detail:_:), Adw.AlertDialog.getExtraChild()
|
|
/// Sets the child widget of `self`.
|
|
///
|
|
/// The child widget is displayed below the heading and body.
|
|
///
|
|
/// 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 extraChild<W: Gtk.Widget>(_ extraChild: Portico.Binding<W?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, extraChild, registry: ctx.registry, notifyDetail: "extra-child",
|
|
read: { [w] in w.getExtraChild() as? W },
|
|
write: { [w] v in w.setExtraChild(child: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.AlertDialog.setExtraChild(child:), GObject.Object.connectNotify(detail:_:), Adw.AlertDialog.getExtraChild()
|
|
/// Sets the child widget of `self`.
|
|
///
|
|
/// The child widget is displayed below the heading and body.
|
|
///
|
|
/// 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 extraChild<W: Gtk.Widget>(_ extraChild: Portico.Binding<W>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, extraChild, registry: ctx.registry, notifyDetail: "extra-child",
|
|
read: { [w] in w.getExtraChild() as? W },
|
|
write: { [w] v in w.setExtraChild(child: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.AlertDialog.setExtraChild(child:)
|
|
/// Sets the child widget of `self`.
|
|
///
|
|
/// The child widget is displayed below the heading and body.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.AlertDialog.setExtraChild(child:)`.
|
|
///
|
|
/// - Parameter extraChild: The child widget.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func extraChild(_ extraChild: @escaping () -> Adw.Widget?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setExtraChild(child: extraChild()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.AlertDialog.setHeading(heading:)
|
|
/// Sets the heading 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 heading: The heading of the dialog.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func heading<S: StringProtocol>(_ heading: S?) -> Self {
|
|
appending { w, _ in
|
|
w.setHeading(heading: heading.map { String($0) })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.AlertDialog.setHeading(heading:), GObject.Object.connectNotify(detail:_:), Adw.AlertDialog.getHeading()
|
|
/// Sets the heading 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 heading(_ heading: Portico.Binding<String?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, heading, registry: ctx.registry, notifyDetail: "heading",
|
|
read: { [w] in w.getHeading() },
|
|
write: { [w] v in w.setHeading(heading: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.AlertDialog.setHeading(heading:), GObject.Object.connectNotify(detail:_:), Adw.AlertDialog.getHeading()
|
|
/// Sets the heading of `self`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant, so a `Binding<String>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<String?>` to be able to clear the property.
|
|
/// When `String` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
|
/// A `nil` widget value is never written back into the binding.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func heading(_ heading: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, heading, registry: ctx.registry, notifyDetail: "heading",
|
|
read: { [w] in w.getHeading() },
|
|
write: { [w] v in w.setHeading(heading: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.AlertDialog.setHeading(heading:)
|
|
/// Sets the heading of `self`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.AlertDialog.setHeading(heading:)`.
|
|
///
|
|
/// - Parameter heading: The heading of the dialog.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func heading(_ heading: @escaping () -> String?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setHeading(heading: heading()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.AlertDialog.setHeading(heading:)
|
|
/// Sets the heading of `self`.
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.AlertDialog.setHeading(heading:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter heading: The heading of the dialog.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func heading(_ heading: Portico.InterpolatedText?) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindOptionalInterpolation(heading, registry: ctx.registry) { [w] v in w.setHeading(heading: v) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.AlertDialog.setHeadingUseMarkup(useMarkup:)
|
|
/// Sets whether the heading of `self` includes Pango markup.
|
|
///
|
|
/// See [func`Pango`.parse_markup].
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter headingUseMarkup: Whether the heading includes Pango markup.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func headingUseMarkup(_ headingUseMarkup: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setHeadingUseMarkup(useMarkup: headingUseMarkup)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.AlertDialog.setHeadingUseMarkup(useMarkup:), GObject.Object.connectNotify(detail:_:), Adw.AlertDialog.getHeadingUseMarkup()
|
|
/// Sets whether the heading of `self` includes Pango markup.
|
|
///
|
|
/// See [func`Pango`.parse_markup].
|
|
///
|
|
/// 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 headingUseMarkup(_ headingUseMarkup: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, headingUseMarkup, registry: ctx.registry, notifyDetail: "heading-use-markup",
|
|
read: { [w] in w.getHeadingUseMarkup() },
|
|
write: { [w] v in w.setHeadingUseMarkup(useMarkup: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.AlertDialog.setHeadingUseMarkup(useMarkup:)
|
|
/// Sets whether the heading of `self` includes Pango markup.
|
|
///
|
|
/// See [func`Pango`.parse_markup].
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.AlertDialog.setHeadingUseMarkup(useMarkup:)`.
|
|
///
|
|
/// - Parameter headingUseMarkup: Whether the heading includes Pango markup.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func headingUseMarkup(_ headingUseMarkup: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setHeadingUseMarkup(useMarkup: headingUseMarkup()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.AlertDialog.setPreferWideLayout(preferWideLayout:)
|
|
/// Whether to prefer horizontal button layout.
|
|
///
|
|
/// `AdwAlertDialog` can present buttons horizontally or vertically depending
|
|
/// on available space, how many buttons there are and how wide they are.
|
|
///
|
|
/// By default it will prefer to stack buttons vertically at medium sizes.
|
|
///
|
|
/// Set to `TRUE` to prefer horizontal layout in these cases instead. This will
|
|
/// make the dialog slightly wider as well.
|
|
///
|
|
/// Vertical layout may still be used if the dialog would get too wide
|
|
/// otherwise.
|
|
///
|
|
/// Does nothing with just one button, or when the buttons are already
|
|
/// horizontal.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter preferWideLayout: Whether to prefer horizontal button layout.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func preferWideLayout(_ preferWideLayout: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setPreferWideLayout(preferWideLayout: preferWideLayout)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.AlertDialog.setPreferWideLayout(preferWideLayout:), GObject.Object.connectNotify(detail:_:), Adw.AlertDialog.getPreferWideLayout()
|
|
/// Whether to prefer horizontal button layout.
|
|
///
|
|
/// `AdwAlertDialog` can present buttons horizontally or vertically depending
|
|
/// on available space, how many buttons there are and how wide they are.
|
|
///
|
|
/// By default it will prefer to stack buttons vertically at medium sizes.
|
|
///
|
|
/// Set to `TRUE` to prefer horizontal layout in these cases instead. This will
|
|
/// make the dialog slightly wider as well.
|
|
///
|
|
/// Vertical layout may still be used if the dialog would get too wide
|
|
/// otherwise.
|
|
///
|
|
/// Does nothing with just one button, or when the buttons are already
|
|
/// horizontal.
|
|
///
|
|
/// 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 preferWideLayout(_ preferWideLayout: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, preferWideLayout, registry: ctx.registry, notifyDetail: "prefer-wide-layout",
|
|
read: { [w] in w.getPreferWideLayout() },
|
|
write: { [w] v in w.setPreferWideLayout(preferWideLayout: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.AlertDialog.setPreferWideLayout(preferWideLayout:)
|
|
/// Whether to prefer horizontal button layout.
|
|
///
|
|
/// `AdwAlertDialog` can present buttons horizontally or vertically depending
|
|
/// on available space, how many buttons there are and how wide they are.
|
|
///
|
|
/// By default it will prefer to stack buttons vertically at medium sizes.
|
|
///
|
|
/// Set to `TRUE` to prefer horizontal layout in these cases instead. This will
|
|
/// make the dialog slightly wider as well.
|
|
///
|
|
/// Vertical layout may still be used if the dialog would get too wide
|
|
/// otherwise.
|
|
///
|
|
/// Does nothing with just one button, or when the buttons are already
|
|
/// horizontal.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.AlertDialog.setPreferWideLayout(preferWideLayout:)`.
|
|
///
|
|
/// - Parameter preferWideLayout: Whether to prefer horizontal button layout.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func preferWideLayout(_ preferWideLayout: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setPreferWideLayout(preferWideLayout: preferWideLayout()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
}
|