// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes. import Adw import Gtk import Gio import Gdk // PorticoGen: generateStruct | source: Adw.ShortcutsDialog /// A dialog that displays application's keyboard shortcuts. /// /// /// /// shortcuts-dialog /// /// /// Shortcuts are grouped into sections, represented by [class`ShortcutsSection`] /// objects. Each section has one or more items, represented by /// [class`ShortcutsItem`] objects. /// /// To add a section to the dialog, use [method`ShortcutsDialog`.add], or add it /// as a child when using UI files. /// /// Sections without titles can be used to further subdivide each section into /// groups. /// /// Example of an `AdwShortcutsDialog` UI definition: /// /// ```xml /// /// /// /// General /// /// /// Open Menu /// F10 /// /// /// /// /// Quit /// app.quit /// /// /// /// /// /// /// /// /// Move Tab Left /// <Shift><Ctrl>Page_Up /// ltr /// /// /// /// /// Move Tab Right /// <Shift><Ctrl>Page_Down /// ltr /// /// /// /// /// Move Tab Right /// <Shift><Ctrl>Page_Up /// rtl /// /// /// /// /// Move Tab Left /// <Shift><Ctrl>Page_Down /// rtl /// /// /// /// /// /// ``` /// /// If the `app.quit` action has the CtrlQ accelerator /// associated with it, the result will look as follows: /// /// /// /// shortcuts-dialog-example /// /// /// The recommended way to use `AdwShortcutsDialog` is via [class`Application`]'s /// automatic resource loading. /// /// See also: [class`ShortcutLabel`]. /// /// A Portico view that mounts a `Adw.ShortcutsDialog`. @MainActor public struct ShortcutsDialog: View { private let make: (MountContext) -> Adw.ShortcutsDialog private var configure: [(Adw.ShortcutsDialog, MountContext) -> Void] = [] public var body: Never { fatalError() } // PorticoGen: generateInits(static) | source: Adw.ShortcutsDialog.init() /// Creates a new `AdwShortcutsDialog`. /// /// Applied once at mount; use the `Binding` or closure overload for values that change. /// Each closure is evaluated once; children are added in order and slot closures mount their first view. /// An empty closure adds no children and leaves slots unset. /// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that. /// /// - Parameter canClose: Whether the dialog can be closed. /// - Parameter contentHeight: The height of the dialog's contents. /// - Parameter contentWidth: The width of the dialog's contents. /// - Parameter followsContentSize: Whether to size content automatically. /// - Parameter presentationMode: The dialog's presentation mode. /// - Parameter title: The title of the dialog. /// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot. /// - Parameter defaultWidget: A `ViewBuilder` closure whose first view is mounted into the `defaultWidget` slot. /// - Parameter focusWidget: A `ViewBuilder` closure whose first view is mounted into the `focusWidget` slot. /// - Parameter onCloseAttempt: Invoked when the widget emits the `close-attempt` signal. /// - Parameter onClosed: Invoked when the widget emits the `closed` signal. public init(canClose: Bool? = nil, contentHeight: Int32? = nil, contentWidth: Int32? = nil, followsContentSize: Bool? = nil, presentationMode: Adw.DialogPresentationMode? = nil, title: String? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, @ViewBuilder defaultWidget: @escaping () -> [AnyView] = { [] }, @ViewBuilder focusWidget: @escaping () -> [AnyView] = { [] }, onCloseAttempt: (() -> Void)? = nil, onClosed: (() -> Void)? = nil) { make = { _ in Adw.ShortcutsDialog() } configure.append { w, ctx in if let canClose { w.setCanClose(canClose: canClose) } if let contentHeight { w.setContentHeight(contentHeight: contentHeight) } if let contentWidth { w.setContentWidth(contentWidth: contentWidth) } if let followsContentSize { w.setFollowsContentSize(followsContentSize: followsContentSize) } if let presentationMode { w.setPresentationMode(presentationMode: presentationMode) } if let title { w.setTitle(title: title) } if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) } if let v = Portico.mountSlotChild(defaultWidget, ctx, onUpdate: { v in w.setDefaultWidget(defaultWidget: v) }) { w.setDefaultWidget(defaultWidget: v) } if let v = Portico.mountSlotChild(focusWidget, ctx, onUpdate: { v in w.setFocus(focus: v) }) { w.setFocus(focus: v) } if let onCloseAttempt { ctx.registry.add(w.connectCloseAttempt { _ in onCloseAttempt() }) } if let onClosed { ctx.registry.add(w.connectClosed { _ in onClosed() }) } } } } extension ShortcutsDialog: WidgetView { public typealias Target = Adw.ShortcutsDialog @_spi(Portico) public func appending( _ step: @escaping (Adw.ShortcutsDialog, MountContext) -> Void ) -> Self { var c = self c.configure.append(step) return c } } @_spi(Portico) extension ShortcutsDialog: Mountable { @_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget { let w = make(ctx) for step in configure { step(w, ctx) } return w } }