// 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.ApplicationWindow /// A `GtkWindow` subclass that integrates with `GtkApplication`. /// /// Notably, `GtkApplicationWindow` can handle an application menubar. /// /// This class implements the [iface`Gio`.ActionGroup] and [iface`Gio`.ActionMap] /// interfaces, to let you add window-specific actions that will be exported /// by the associated [class`Gtk`.Application], together with its application-wide /// actions. Window-specific actions are prefixed with the “win.” /// prefix and application-wide actions are prefixed with the “app.” /// prefix. Actions must be addressed with the prefixed name when /// referring to them from a menu model. /// /// Note that widgets that are placed inside a `GtkApplicationWindow` /// can also activate these actions, if they implement the /// [iface`Gtk`.Actionable] interface. /// /// The settings [property`Gtk`.Settings:gtk-shell-shows-app-menu] and /// [property`Gtk`.Settings:gtk-shell-shows-menubar] tell GTK whether the /// desktop environment is showing the application menu and menubar /// models outside the application as part of the desktop shell. /// For instance, on OS X, both menus will be displayed remotely; /// on Windows neither will be. /// /// If the desktop environment does not display the menubar, it can be shown in /// the `GtkApplicationWindow` by setting the /// [property`Gtk`.ApplicationWindow:show-menubar] property to true. If the /// desktop environment does not display the application menu, then it will /// automatically be included in the menubar or in the window’s client-side /// decorations. /// /// See [class`Gtk`.PopoverMenu] for information about the XML language /// used by `GtkBuilder` for menu models. /// /// See also: [method`Gtk`.Application.set_menubar]. /// /// ## A GtkApplicationWindow with a menubar /// /// The code sample below shows how to set up a `GtkApplicationWindow` /// with a menu bar defined on the [class`Gtk`.Application]: /// /// ```c /// GtkApplication *app = gtk_application_new ("org.gtk.test", 0); /// /// GtkBuilder *builder = gtk_builder_new_from_string ( /// "" /// " " /// " " /// " _Edit" /// " " /// " _Copy" /// " win.copy" /// " " /// " " /// " _Paste" /// " win.paste" /// " " /// " " /// " " /// "", /// -1); /// /// GMenuModel *menubar = G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")); /// gtk_application_set_menubar (GTK_APPLICATION (app), menubar); /// g_object_unref (builder); /// /// // ... /// /// GtkWidget *window = gtk_application_window_new (app); /// ``` /// /// A Portico view that mounts a `Gtk.ApplicationWindow`. @MainActor public struct ApplicationWindow: View { private let make: (MountContext) -> Gtk.ApplicationWindow private var configure: [(Gtk.ApplicationWindow, MountContext) -> Void] = [] public var body: Never { fatalError() } // PorticoGen: generateInits(static) | source: Gtk.ApplicationWindow.init(application:) /// Creates a new `GtkApplicationWindow`. /// /// 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 `application` value forwarded to `Gtk.ApplicationWindow`. /// - Parameter showMenubar: If this property is true, the window will display a menubar unless it is shown by the desktop shell. /// - 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 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, showMenubar: Bool? = 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] = { [] }, onActivateDefault: (() -> Void)? = nil, onActivateFocus: (() -> Void)? = nil, onCloseRequest: (() -> Bool)? = nil, onEnableDebugging: ((Bool) -> Bool)? = nil, onKeysChanged: (() -> Void)? = nil) { make = { _ in Gtk.ApplicationWindow(application: application) } configure.append { w, ctx in if let showMenubar { w.setShowMenubar(showMenubar: showMenubar) } 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 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 ApplicationWindow: WidgetView { public typealias Target = Gtk.ApplicationWindow @_spi(Portico) public func appending( _ step: @escaping (Gtk.ApplicationWindow, MountContext) -> Void ) -> Self { var c = self c.configure.append(step) return c } } @_spi(Portico) extension ApplicationWindow: Mountable { @_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget { let w = make(ctx) for step in configure { step(w, ctx) } return w } }