795 lines
45 KiB
Swift
795 lines
45 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.MessageDialog
|
|
/// A dialog presenting a message or a question.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="message-dialog-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img src="message-dialog.png" alt="message-dialog">
|
|
/// </picture>
|
|
///
|
|
/// Message 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`MessageDialog`::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`MessageDialog`: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, `AdwMessageDialog` is closed automatically.
|
|
///
|
|
/// An example of using a message dialog:
|
|
///
|
|
/// ```c
|
|
/// GtkWidget *dialog;
|
|
///
|
|
/// dialog = adw_message_dialog_new (parent, _("Replace File?"), NULL);
|
|
///
|
|
/// adw_message_dialog_format_body (ADW_MESSAGE_DIALOG (dialog),
|
|
/// _("A file named “`s`” already exists. Do you want to replace it?"),
|
|
/// filename);
|
|
///
|
|
/// adw_message_dialog_add_responses (ADW_MESSAGE_DIALOG (dialog),
|
|
/// "cancel", _("_Cancel"),
|
|
/// "replace", _("_Replace"),
|
|
/// NULL);
|
|
///
|
|
/// adw_message_dialog_set_response_appearance (ADW_MESSAGE_DIALOG (dialog), "replace", ADW_RESPONSE_DESTRUCTIVE);
|
|
///
|
|
/// adw_message_dialog_set_default_response (ADW_MESSAGE_DIALOG (dialog), "cancel");
|
|
/// adw_message_dialog_set_close_response (ADW_MESSAGE_DIALOG (dialog), "cancel");
|
|
///
|
|
/// g_signal_connect (dialog, "response", G_CALLBACK (response_cb), self);
|
|
///
|
|
/// gtk_window_present (GTK_WINDOW (dialog));
|
|
/// ```
|
|
///
|
|
/// ## Async API
|
|
///
|
|
/// `AdwMessageDialog` can also be used via the [method`MessageDialog`.choose]
|
|
/// method. This API follows the GIO async pattern, for example:
|
|
///
|
|
/// ```c
|
|
/// static void
|
|
/// dialog_cb (AdwMessageDialog *dialog,
|
|
/// GAsyncResult *result,
|
|
/// MyWindow *self)
|
|
/// {
|
|
/// const char *response = adw_message_dialog_choose_finish (dialog, result);
|
|
///
|
|
/// // ...
|
|
/// }
|
|
///
|
|
/// static void
|
|
/// show_dialog (MyWindow *self)
|
|
/// {
|
|
/// GtkWidget *dialog;
|
|
///
|
|
/// dialog = adw_message_dialog_new (GTK_WINDOW (self), _("Replace File?"), NULL);
|
|
///
|
|
/// adw_message_dialog_format_body (ADW_MESSAGE_DIALOG (dialog),
|
|
/// _("A file named “`s`” already exists. Do you want to replace it?"),
|
|
/// filename);
|
|
///
|
|
/// adw_message_dialog_add_responses (ADW_MESSAGE_DIALOG (dialog),
|
|
/// "cancel", _("_Cancel"),
|
|
/// "replace", _("_Replace"),
|
|
/// NULL);
|
|
///
|
|
/// adw_message_dialog_set_response_appearance (ADW_MESSAGE_DIALOG (dialog), "replace", ADW_RESPONSE_DESTRUCTIVE);
|
|
///
|
|
/// adw_message_dialog_set_default_response (ADW_MESSAGE_DIALOG (dialog), "cancel");
|
|
/// adw_message_dialog_set_close_response (ADW_MESSAGE_DIALOG (dialog), "cancel");
|
|
///
|
|
/// adw_message_dialog_choose (ADW_MESSAGE_DIALOG (dialog), NULL, (GAsyncReadyCallback) dialog_cb, self);
|
|
/// }
|
|
/// ```
|
|
///
|
|
/// ## AdwMessageDialog as GtkBuildable
|
|
///
|
|
/// `AdwMessageDialog` 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`MessageDialog`.set_response_enabled] and
|
|
/// [method`MessageDialog`.set_response_appearance] for details.
|
|
///
|
|
/// Example of an `AdwMessageDialog` UI definition:
|
|
///
|
|
/// ```xml
|
|
/// <object class="AdwMessageDialog" 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>
|
|
/// ```
|
|
///
|
|
/// ## Accessibility
|
|
///
|
|
/// `AdwMessageDialog` uses the [enum`Gtk`.AccessibleRole.dialog] role.
|
|
///
|
|
/// A Portico view that mounts a `Adw.MessageDialog`.
|
|
@MainActor public struct MessageDialog: View {
|
|
private let make: (MountContext) -> Adw.MessageDialog
|
|
private var configure: [(Adw.MessageDialog, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Adw.MessageDialog.init(parent:heading:body:)
|
|
/// Creates a new `AdwMessageDialog`.
|
|
///
|
|
/// `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`MessageDialog`.format_body] or similar methods afterwards:
|
|
///
|
|
/// ```c
|
|
/// GtkWidget *dialog;
|
|
///
|
|
/// dialog = adw_message_dialog_new (parent, _("Replace File?"), NULL);
|
|
/// adw_message_dialog_format_body (ADW_MESSAGE_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 parent: The `parent` value forwarded to `Adw.MessageDialog`.
|
|
/// - 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 application: The `GtkApplication` associated with the window.
|
|
/// - Parameter decorated: Whether the window should have a frame (also known as *decorations*).
|
|
/// - Parameter deletable: Whether the window frame should have a close button.
|
|
/// - Parameter destroyWithParent: If this window should be destroyed when the parent is destroyed.
|
|
/// - Parameter display: The display that will display this window.
|
|
/// - Parameter focusVisible: Whether 'focus rectangles' are currently visible in this window.
|
|
/// - Parameter gravity: The gravity to use when resizing the window programmatically.
|
|
/// - Parameter handleMenubarAccel: Whether the window frame should handle <kbd>F10</kbd> for activating menubars.
|
|
/// - Parameter hideOnClose: If this window should be hidden instead of destroyed when the user clicks the close button.
|
|
/// - Parameter iconName: Specifies the name of the themed icon to use as the window icon.
|
|
/// - Parameter mnemonicsVisible: Whether mnemonics are currently visible in this window.
|
|
/// - Parameter modal: If true, the window is modal.
|
|
/// - Parameter resizable: If true, users can resize the window.
|
|
/// - Parameter startupId: A write-only property for setting window's startup notification identifier.
|
|
/// - Parameter title: The title of the window.
|
|
/// - Parameter transientFor: The transient parent of the window.
|
|
/// - 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 titlebar: A `ViewBuilder` closure whose first view is mounted into the `titlebar` slot.
|
|
/// - Parameter onActivateDefault: Invoked when the widget emits the `activate-default` signal.
|
|
/// - Parameter onActivateFocus: Invoked when the widget emits the `activate-focus` signal.
|
|
/// - Parameter onCloseRequest: Invoked when the widget emits the `close-request` signal. Its return value is forwarded to GTK as the signal's result.
|
|
/// - Parameter onEnableDebugging: Invoked when the widget emits the `enable-debugging` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
|
|
/// - Parameter onKeysChanged: Invoked when the widget emits the `keys-changed` signal.
|
|
public init(parent: Gtk.Window?, heading: String?, body: String?, bodyUseMarkup: Bool? = nil, closeResponse: String? = nil, defaultResponse: String? = nil, headingUseMarkup: Bool? = nil, application: Gtk.Application? = nil, decorated: Bool? = nil, deletable: Bool? = nil, destroyWithParent: Bool? = nil, display: Gtk.Display? = nil, focusVisible: Bool? = nil, gravity: Gtk.WindowGravity? = nil, handleMenubarAccel: Bool? = nil, hideOnClose: Bool? = nil, iconName: String? = nil, mnemonicsVisible: Bool? = nil, modal: Bool? = nil, resizable: Bool? = nil, startupId: String? = nil, title: String? = nil, transientFor: Gtk.Window? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, @ViewBuilder extraChild: @escaping () -> [AnyView] = { [] }, @ViewBuilder defaultWidget: @escaping () -> [AnyView] = { [] }, @ViewBuilder focusWidget: @escaping () -> [AnyView] = { [] }, @ViewBuilder titlebar: @escaping () -> [AnyView] = { [] }, onActivateDefault: (() -> Void)? = nil, onActivateFocus: (() -> Void)? = nil, onCloseRequest: (() -> Bool)? = nil, onEnableDebugging: ((Bool) -> Bool)? = nil, onKeysChanged: (() -> Void)? = nil) {
|
|
make = { _ in Adw.MessageDialog(parent: parent, 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 application { w.setApplication(application: application) }
|
|
if let decorated { w.setDecorated(setting: decorated) }
|
|
if let deletable { w.setDeletable(setting: deletable) }
|
|
if let destroyWithParent { w.setDestroyWithParent(setting: destroyWithParent) }
|
|
if let display { w.setDisplay(display: display) }
|
|
if let focusVisible { w.setFocusVisible(setting: focusVisible) }
|
|
if let gravity { w.setGravity(gravity: gravity) }
|
|
if let handleMenubarAccel { w.setHandleMenubarAccel(handleMenubarAccel: handleMenubarAccel) }
|
|
if let hideOnClose { w.setHideOnClose(setting: hideOnClose) }
|
|
if let iconName { w.setIconName(name: iconName) }
|
|
if let mnemonicsVisible { w.setMnemonicsVisible(setting: mnemonicsVisible) }
|
|
if let modal { w.setModal(modal: modal) }
|
|
if let resizable { w.setResizable(resizable: resizable) }
|
|
if let startupId { w.setStartupId(startupId: startupId) }
|
|
if let title { w.setTitle(title: title) }
|
|
if let transientFor { w.setTransientFor(parent: transientFor) }
|
|
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 v = Portico.mountSlotChild(titlebar, ctx, onUpdate: { v in w.setTitlebar(titlebar: v) }) { w.setTitlebar(titlebar: v) }
|
|
if let onActivateDefault { ctx.registry.add(w.connectActivateDefault { _ in onActivateDefault() }) }
|
|
if let onActivateFocus { ctx.registry.add(w.connectActivateFocus { _ in onActivateFocus() }) }
|
|
if let onCloseRequest { ctx.registry.add(w.connectCloseRequest { _ in onCloseRequest() }) }
|
|
if let onEnableDebugging { ctx.registry.add(w.connectEnableDebugging { _, a0 in onEnableDebugging(a0) }) }
|
|
if let onKeysChanged { ctx.registry.add(w.connectKeysChanged { _ in onKeysChanged() }) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension MessageDialog: WidgetView {
|
|
public typealias Target = Adw.MessageDialog
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Adw.MessageDialog, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension MessageDialog: 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.MessageDialog
|
|
/// Modifiers for `Adw.MessageDialog`, available on every Portico view whose
|
|
/// backing widget is `Adw.MessageDialog` or one of its subclasses.
|
|
extension WidgetView where Target: Adw.MessageDialog {
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.MessageDialog.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.MessageDialog.setBody(body:), GObject.Object.connectNotify(detail:_:), Adw.MessageDialog.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.MessageDialog.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.MessageDialog.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.MessageDialog.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.MessageDialog.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.MessageDialog.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.MessageDialog.setBodyUseMarkup(useMarkup:), GObject.Object.connectNotify(detail:_:), Adw.MessageDialog.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.MessageDialog.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.MessageDialog.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.MessageDialog.setCloseResponse(response:)
|
|
/// Sets the ID of the close response of `self`.
|
|
///
|
|
/// It will be passed to [signal`MessageDialog`::response] if the window 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.MessageDialog.setCloseResponse(response:), GObject.Object.connectNotify(detail:_:), Adw.MessageDialog.getCloseResponse()
|
|
/// Sets the ID of the close response of `self`.
|
|
///
|
|
/// It will be passed to [signal`MessageDialog`::response] if the window 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.MessageDialog.setCloseResponse(response:)
|
|
/// Sets the ID of the close response of `self`.
|
|
///
|
|
/// It will be passed to [signal`MessageDialog`::response] if the window 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.MessageDialog.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.MessageDialog.setCloseResponse(response:)
|
|
/// Sets the ID of the close response of `self`.
|
|
///
|
|
/// It will be passed to [signal`MessageDialog`::response] if the window 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.MessageDialog.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.MessageDialog.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`Gtk`.Window: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.MessageDialog.setDefaultResponse(response:), GObject.Object.connectNotify(detail:_:), Adw.MessageDialog.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`Gtk`.Window: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.MessageDialog.setDefaultResponse(response:), GObject.Object.connectNotify(detail:_:), Adw.MessageDialog.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`Gtk`.Window: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.MessageDialog.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`Gtk`.Window:default-widget].
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.MessageDialog.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.MessageDialog.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`Gtk`.Window:default-widget].
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.MessageDialog.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.MessageDialog.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.MessageDialog.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.MessageDialog.setExtraChild(child:), GObject.Object.connectNotify(detail:_:), Adw.MessageDialog.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.MessageDialog.setExtraChild(child:), GObject.Object.connectNotify(detail:_:), Adw.MessageDialog.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.MessageDialog.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.MessageDialog.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.MessageDialog.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.MessageDialog.setHeading(heading:), GObject.Object.connectNotify(detail:_:), Adw.MessageDialog.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.MessageDialog.setHeading(heading:), GObject.Object.connectNotify(detail:_:), Adw.MessageDialog.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.MessageDialog.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.MessageDialog.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.MessageDialog.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.MessageDialog.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.MessageDialog.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.MessageDialog.setHeadingUseMarkup(useMarkup:), GObject.Object.connectNotify(detail:_:), Adw.MessageDialog.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.MessageDialog.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.MessageDialog.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)
|
|
}
|
|
}
|
|
|
|
}
|