187 lines
10 KiB
Swift
187 lines
10 KiB
Swift
// 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.Window
|
|
/// A toplevel window which can contain other widgets.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="window-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img alt="An example GtkWindow" src="window.png">
|
|
/// </picture>
|
|
///
|
|
/// Windows normally have decorations that are under the control
|
|
/// of the windowing system and allow the user to manipulate the window
|
|
/// (resize it, move it, close it,...).
|
|
///
|
|
/// # GtkWindow as GtkBuildable
|
|
///
|
|
/// The `GtkWindow` implementation of the [iface`Gtk`.Buildable] interface supports
|
|
/// setting a child as the titlebar by specifying “titlebar” as the “type”
|
|
/// attribute of a `<child>` element.
|
|
///
|
|
/// # Shortcuts and Gestures
|
|
///
|
|
/// `GtkWindow` supports the following keyboard shortcuts:
|
|
///
|
|
/// - <kbd>F10</kbd> activates the menubar, if present.
|
|
/// - <kbd>Alt</kbd> makes the mnemonics visible while pressed.
|
|
///
|
|
/// The following signals have default keybindings:
|
|
///
|
|
/// - [signal`Gtk`.Window::activate-default]
|
|
/// - [signal`Gtk`.Window::activate-focus]
|
|
/// - [signal`Gtk`.Window::enable-debugging]
|
|
///
|
|
/// # Actions
|
|
///
|
|
/// `GtkWindow` defines a set of built-in actions:
|
|
///
|
|
/// - `default.activate` activates the default widget.
|
|
/// - `window.minimize` minimizes the window.
|
|
/// - `window.toggle-maximized` maximizes or restores the window.
|
|
/// - `window.close` closes the window.
|
|
///
|
|
/// # CSS nodes
|
|
///
|
|
/// ```
|
|
/// window.background [.csd / .solid-csd / .ssd] [.maximized / .fullscreen / .tiled]
|
|
/// ├── <child>
|
|
/// ╰── <titlebar child>.titlebar [.default-decoration]
|
|
/// ```
|
|
///
|
|
/// `GtkWindow` has a main CSS node with name window and style class .background.
|
|
///
|
|
/// Style classes that are typically used with the main CSS node are .csd (when
|
|
/// client-side decorations are in use), .solid-csd (for client-side decorations
|
|
/// without invisible borders), .ssd (used by mutter when rendering server-side
|
|
/// decorations). GtkWindow also represents window states with the following
|
|
/// style classes on the main node: .maximized, .fullscreen, .tiled (when supported,
|
|
/// also .tiled-top, .tiled-left, .tiled-right, .tiled-bottom).
|
|
///
|
|
/// `GtkWindow` subclasses often add their own discriminating style classes,
|
|
/// such as .dialog, .popup or .tooltip.
|
|
///
|
|
/// Generally, some CSS properties don't make sense on the toplevel window node,
|
|
/// such as margins or padding. When client-side decorations without invisible
|
|
/// borders are in use (i.e. the .solid-csd style class is added to the
|
|
/// main window node), the CSS border of the toplevel window is used for
|
|
/// resize drags. In the .csd case, the shadow area outside of the window
|
|
/// can be used to resize it.
|
|
///
|
|
/// `GtkWindow` adds the .titlebar and .default-decoration style classes to the
|
|
/// widget that is added as a titlebar child.
|
|
///
|
|
/// # Accessibility
|
|
///
|
|
/// `GtkWindow` uses the [enum`Gtk`.AccessibleRole.window] role.
|
|
///
|
|
/// From GTK 4.12 to 4.18, it used the [enum`Gtk`.AccessibleRole.application] role.
|
|
///
|
|
/// A Portico view that mounts a `Gtk.Window`.
|
|
@MainActor public struct Window: View {
|
|
private let make: (MountContext) -> Gtk.Window
|
|
private var configure: [(Gtk.Window, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Gtk.Window.init()
|
|
/// Creates a new `GtkWindow`.
|
|
///
|
|
/// To get an undecorated window (without window borders),
|
|
/// use [method`Gtk`.Window.set_decorated].
|
|
///
|
|
/// All top-level windows created by this function are stored
|
|
/// in an internal top-level window list. This list can be obtained
|
|
/// from [func`Gtk`.Window.list_toplevels]. Due to GTK keeping a
|
|
/// reference to the window internally, this function does not
|
|
/// return a reference to the caller.
|
|
///
|
|
/// To delete a `GtkWindow`, call [method`Gtk`.Window.destroy].
|
|
///
|
|
/// 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 <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 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? = 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.Window() }
|
|
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 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 Window: WidgetView {
|
|
public typealias Target = Gtk.Window
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Gtk.Window, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension Window: Mountable {
|
|
@_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget {
|
|
let w = make(ctx)
|
|
for step in configure { step(w, ctx) }
|
|
return w
|
|
}
|
|
}
|