// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes. import Adw import Gtk import Gio import Gdk // PorticoGen: generateStruct | source: Gtk.Assistant /// `GtkAssistant` is used to represent a complex as a series of steps. /// /// /// /// An example GtkAssistant /// /// /// Each step consists of one or more pages. `GtkAssistant` guides the user /// through the pages, and controls the page flow to collect the data needed /// for the operation. /// /// `GtkAssistant` handles which buttons to show and to make sensitive based /// on page sequence knowledge and the [enum`Gtk`.AssistantPageType] of each /// page in addition to state information like the *completed* and *committed* /// page statuses. /// /// If you have a case that doesn’t quite fit in `GtkAssistant`s way of /// handling buttons, you can use the `GTK_ASSISTANT_PAGE_CUSTOM` page /// type and handle buttons yourself. /// /// `GtkAssistant` maintains a `GtkAssistantPage` object for each added /// child, which holds additional per-child properties. You /// obtain the `GtkAssistantPage` for a child with [method`Gtk`.Assistant.get_page]. /// /// # GtkAssistant as GtkBuildable /// /// The `GtkAssistant` implementation of the `GtkBuildable` interface /// exposes the `action_area` as internal children with the name /// “action_area”. /// /// To add pages to an assistant in `GtkBuilder`, simply add it as a /// child to the `GtkAssistant` object. If you need to set per-object /// properties, create a `GtkAssistantPage` object explicitly, and /// set the child widget as a property on it. /// /// # CSS nodes /// /// `GtkAssistant` has a single CSS node with the name window and style /// class .assistant. /// /// A Portico view that mounts a `Gtk.Assistant`. @MainActor public struct Assistant: View { private let make: (MountContext) -> Gtk.Assistant private var configure: [(Gtk.Assistant, MountContext) -> Void] = [] public var body: Never { fatalError() } // PorticoGen: generateInits(static) | source: Gtk.Assistant.init() /// Creates a new `GtkAssistant`. /// /// 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 onApply: Invoked when the widget emits the `apply` signal. /// - Parameter onCancel: Invoked when the widget emits the `cancel` signal. /// - Parameter onClose: Invoked when the widget emits the `close` signal. /// - Parameter onEscape: Invoked when the widget emits the `escape` signal. /// - Parameter onPrepare: Invoked when the widget emits the `prepare` 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] = { [] }, onApply: (() -> Void)? = nil, onCancel: (() -> Void)? = nil, onClose: (() -> Void)? = nil, onEscape: (() -> Void)? = nil, onPrepare: ((Gtk.Widget) -> Void)? = nil, onActivateDefault: (() -> Void)? = nil, onActivateFocus: (() -> Void)? = nil, onCloseRequest: (() -> Bool)? = nil, onEnableDebugging: ((Bool) -> Bool)? = nil, onKeysChanged: (() -> Void)? = nil) { make = { _ in Gtk.Assistant() } 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 onApply { ctx.registry.add(w.connectApply { _ in onApply() }) } if let onCancel { ctx.registry.add(w.connectCancel { _ in onCancel() }) } if let onClose { ctx.registry.add(w.connectClose { _ in onClose() }) } if let onEscape { ctx.registry.add(w.connectEscape { _ in onEscape() }) } if let onPrepare { ctx.registry.add(w.connectPrepare { _, a0 in onPrepare(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 Assistant: WidgetView { public typealias Target = Gtk.Assistant @_spi(Portico) public func appending( _ step: @escaping (Gtk.Assistant, MountContext) -> Void ) -> Self { var c = self c.configure.append(step) return c } } @_spi(Portico) extension Assistant: Mountable { @_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget { let w = make(ctx) for step in configure { step(w, ctx) } return w } } // PorticoGen: generateModifierExtension | source: Gtk.Assistant /// Modifiers for `Gtk.Assistant`, available on every Portico view whose /// backing widget is `Gtk.Assistant` or one of its subclasses. extension WidgetView where Target: Gtk.Assistant { // PorticoGen: generateModifierExtension -> generateChildAdderModifiers(static) | source: Gtk.Assistant.addActionWidget(child:) /// Adds a widget to the action area of a `GtkAssistant`. /// /// Applied once at mount; use the `@ViewBuilder` overload for multiple children. /// /// - Parameter child: A child widget to add. /// - Returns: A copy of this view with the modifier applied. public func addActionWidget(_ child: Gtk.Widget) -> Self { appending { w, _ in w.addActionWidget(child: child) } } // PorticoGen: generateModifierExtension -> generateChildAdderModifiers(viewBuilder) | source: Gtk.Assistant.addActionWidget(child:) /// Adds a widget to the action area of a `GtkAssistant`. /// /// Every view the closure produces is added at mount, in order. /// /// - Parameter child: A closure producing child views. /// - Returns: A copy of this view with the modifier applied. public func addActionWidget(@ViewBuilder _ child: () -> [AnyView]) -> Self { let childViews = child() return appending { w, ctx in for v in childViews { w.addActionWidget(child: v.makeWidget(ctx)) } } } // PorticoGen: generateModifierExtension -> generateChildAdderModifiers(static) | source: Gtk.Assistant.appendPage(page:) /// Appends a page to the `assistant`. /// /// Applied once at mount; use the `@ViewBuilder` overload for multiple children. /// /// - Parameter child: A child widget to add. /// - Returns: A copy of this view with the modifier applied. public func appendPage(_ child: Gtk.Widget) -> Self { appending { w, _ in _ = w.appendPage(page: child) } } // PorticoGen: generateModifierExtension -> generateChildAdderModifiers(viewBuilder) | source: Gtk.Assistant.appendPage(page:) /// Appends a page to the `assistant`. /// /// Every view the closure produces is added at mount, in order. /// /// - Parameter child: A closure producing child views. /// - Returns: A copy of this view with the modifier applied. public func appendPage(@ViewBuilder _ child: () -> [AnyView]) -> Self { let childViews = child() return appending { w, ctx in for v in childViews { _ = w.appendPage(page: v.makeWidget(ctx)) } } } // PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Assistant.connectApply(_:) /// Emitted when the apply button is clicked. /// /// The default behavior of the `GtkAssistant` is to switch to the page /// after the current page, unless the current page is the last one. /// /// A handler for the ::apply signal should carry out the actions for /// which the wizard has collected data. If the action takes a long time /// to complete, you might consider putting a page of type /// `GTK_ASSISTANT_PAGE_PROGRESS` after the confirmation page and handle /// this operation within the [signal`Gtk`.Assistant::prepare] signal of /// the progress page. /// /// - Parameter handler: Invoked when the widget emits the `apply` signal. /// - Returns: A copy of this view with the modifier applied. public func onApply(_ handler: @escaping () -> Void) -> Self { appending { w, ctx in ctx.registry.add(w.connectApply { _ in handler() }) } } // PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Assistant.connectCancel(_:) /// Emitted when then the cancel button is clicked. /// /// - Parameter handler: Invoked when the widget emits the `cancel` signal. /// - Returns: A copy of this view with the modifier applied. public func onCancel(_ handler: @escaping () -> Void) -> Self { appending { w, ctx in ctx.registry.add(w.connectCancel { _ in handler() }) } } // PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Assistant.connectClose(_:) /// Emitted either when the close button of a summary page is clicked, /// or when the apply button in the last page in the flow (of type /// `GTK_ASSISTANT_PAGE_CONFIRM`) is clicked. /// /// - Parameter handler: Invoked when the widget emits the `close` signal. /// - Returns: A copy of this view with the modifier applied. public func onClose(_ handler: @escaping () -> Void) -> Self { appending { w, ctx in ctx.registry.add(w.connectClose { _ in handler() }) } } // PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Assistant.connectEscape(_:) /// The action signal for the Escape binding. /// /// - Parameter handler: Invoked when the widget emits the `escape` signal. /// - Returns: A copy of this view with the modifier applied. public func onEscape(_ handler: @escaping () -> Void) -> Self { appending { w, ctx in ctx.registry.add(w.connectEscape { _ in handler() }) } } // PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Assistant.connectPrepare(_:) /// Emitted when a new page is set as the assistant's current page, /// before making the new page visible. /// /// A handler for this signal can do any preparations which are /// necessary before showing `page`. /// /// - Parameter handler: Invoked when the widget emits the `prepare` signal. The closure receives the signal's arguments in order. /// - Returns: A copy of this view with the modifier applied. public func onPrepare(_ handler: @escaping (Gtk.Widget) -> Void) -> Self { appending { w, ctx in ctx.registry.add(w.connectPrepare { _, a0 in handler(a0) }) } } }