// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
import Adw
import Gtk
import Gio
import Gdk
@_spi(Portico) import Portico
// PorticoGen: generateStruct | source: Gtk.Dialog
/// Dialogs are a convenient way to prompt the user for a small amount
/// of input.
///
///
///
///
///
///
/// Typical uses are to display a message, ask a question, or anything else
/// that does not require extensive effort on the user’s part.
///
/// The main area of a `GtkDialog` is called the "content area", and is yours
/// to populate with widgets such a `GtkLabel` or `GtkEntry`, to present
/// your information, questions, or tasks to the user.
///
/// In addition, dialogs allow you to add "action widgets". Most commonly,
/// action widgets are buttons. Depending on the platform, action widgets may
/// be presented in the header bar at the top of the window, or at the bottom
/// of the window. To add action widgets, create your `GtkDialog` using
/// [ctor`Gtk`.Dialog.new_with_buttons], or use
/// [method`Gtk`.Dialog.add_button], [method`Gtk`.Dialog.add_buttons],
/// or [method`Gtk`.Dialog.add_action_widget].
///
/// `GtkDialogs` uses some heuristics to decide whether to add a close
/// button to the window decorations. If any of the action buttons use
/// the response ID `GTK_RESPONSE_CLOSE` or `GTK_RESPONSE_CANCEL`, the
/// close button is omitted.
///
/// Clicking a button that was added as an action widget will emit the
/// [signal`Gtk`.Dialog::response] signal with a response ID that you specified.
/// GTK will never assign a meaning to positive response IDs; these are
/// entirely user-defined. But for convenience, you can use the response
/// IDs in the [enum`Gtk`.ResponseType] enumeration (these all have values
/// less than zero). If a dialog receives a delete event, the
/// [signal`Gtk`.Dialog::response] signal will be emitted with the
/// `GTK_RESPONSE_DELETE_EVENT` response ID.
///
/// Dialogs are created with a call to [ctor`Gtk`.Dialog.new] or
/// [ctor`Gtk`.Dialog.new_with_buttons]. The latter is recommended; it allows
/// you to set the dialog title, some convenient flags, and add buttons.
///
/// A “modal” dialog (that is, one which freezes the rest of the application
/// from user input), can be created by calling [method`Gtk`.Window.set_modal]
/// on the dialog. When using [ctor`Gtk`.Dialog.new_with_buttons], you can also
/// pass the `GTK_DIALOG_MODAL` flag to make a dialog modal.
///
/// For the simple dialog in the following example, a [class`Gtk`.MessageDialog]
/// would save some effort. But you’d need to create the dialog contents manually
/// if you had more than a simple message in the dialog.
///
/// An example for simple `GtkDialog` usage:
///
/// ```c
/// // Function to open a dialog box with a message
/// void
/// quick_message (GtkWindow *parent, char *message)
/// {
/// GtkWidget *dialog, *label, *content_area;
/// GtkDialogFlags flags;
///
/// // Create the widgets
/// flags = GTK_DIALOG_DESTROY_WITH_PARENT;
/// dialog = gtk_dialog_new_with_buttons ("Message",
/// parent,
/// flags,
/// _("_OK"),
/// GTK_RESPONSE_NONE,
/// NULL);
/// content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
/// label = gtk_label_new (message);
///
/// // Ensure that the dialog box is destroyed when the user responds
///
/// g_signal_connect_swapped (dialog,
/// "response",
/// G_CALLBACK (gtk_window_destroy),
/// dialog);
///
/// // Add the label, and show everything we’ve added
///
/// gtk_box_append (GTK_BOX (content_area), label);
/// gtk_widget_show (dialog);
/// }
/// ```
///
/// # GtkDialog as GtkBuildable
///
/// The `GtkDialog` implementation of the `GtkBuildable` interface exposes the
/// `content_area` as an internal child with the name “content_area”.
///
/// `GtkDialog` supports a custom `` element, which can contain
/// multiple `` elements. The “response” attribute specifies a
/// numeric response, and the content of the element is the id of widget
/// (which should be a child of the dialogs `action_area`). To mark a response
/// as default, set the “default” attribute of the `` element
/// to true.
///
/// `GtkDialog` supports adding action widgets by specifying “action” as
/// the “type” attribute of a `` element. The widget will be added
/// either to the action area or the headerbar of the dialog, depending
/// on the “use-header-bar” property. The response id has to be associated
/// with the action widget using the `` element.
///
/// An example of a `GtkDialog` UI definition fragment:
///
/// ```xml
///
/// ```
///
/// # Accessibility
///
/// `GtkDialog` uses the `GTK_ACCESSIBLE_ROLE_DIALOG` role.
///
/// A Portico view that mounts a `Gtk.Dialog`.
@MainActor public struct Dialog: View {
private let make: (MountContext) -> Gtk.Dialog
private var configure: [(Gtk.Dialog, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.Dialog.init()
/// Creates a new dialog box.
///
/// Widgets should not be packed into the `GtkWindow`
/// directly, but into the `content_area` and `action_area`,
/// as described above.
///
/// 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 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 F10 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 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 onClose: Invoked when the widget emits the `close` signal.
/// - Parameter onResponse: Invoked when the widget emits the `response` signal. The closure receives the signal's arguments in order.
/// - 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(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 defaultWidget: @escaping () -> [AnyView] = { [] }, @ViewBuilder focusWidget: @escaping () -> [AnyView] = { [] }, @ViewBuilder titlebar: @escaping () -> [AnyView] = { [] }, onClose: (() -> Void)? = nil, onResponse: ((Int32) -> Void)? = nil, onActivateDefault: (() -> Void)? = nil, onActivateFocus: (() -> Void)? = nil, onCloseRequest: (() -> Bool)? = nil, onEnableDebugging: ((Bool) -> Bool)? = nil, onKeysChanged: (() -> Void)? = nil) {
make = { _ in Gtk.Dialog() }
configure.append { w, ctx in
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(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 onClose { ctx.registry.add(w.connectClose { _ in onClose() }) }
if let onResponse { ctx.registry.add(w.connectResponse { _, a0 in onResponse(a0) }) }
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 Dialog: WidgetView {
public typealias Target = Gtk.Dialog
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.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
}
}