327 lines
20 KiB
Swift
327 lines
20 KiB
Swift
// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
|
|
|
|
import Adw
|
|
import Gtk
|
|
import Gio
|
|
import Gdk
|
|
|
|
// PorticoGen: generateStruct | source: Adw.PreferencesWindow
|
|
/// A window to present an application's preferences.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="preferences-window-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img src="preferences-window.png" alt="preferences-window">
|
|
/// </picture>
|
|
///
|
|
/// The `AdwPreferencesWindow` widget presents an application's preferences
|
|
/// gathered into pages and groups. The preferences are searchable by the user.
|
|
///
|
|
/// ## CSS nodes
|
|
///
|
|
/// `AdwPreferencesWindow` has a main CSS node with the name `window` and the
|
|
/// style class `.preferences`.
|
|
///
|
|
/// A Portico view that mounts a `Adw.PreferencesWindow`.
|
|
@MainActor public struct PreferencesWindow: View {
|
|
private let make: (MountContext) -> Adw.PreferencesWindow
|
|
private var configure: [(Adw.PreferencesWindow, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Adw.PreferencesWindow.init()
|
|
/// Creates a new `AdwPreferencesWindow`.
|
|
///
|
|
/// 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 canNavigateBack: Whether gestures and shortcuts for closing subpages are enabled.
|
|
/// - Parameter searchEnabled: Whether search is enabled.
|
|
/// - Parameter visiblePageName: The name of the currently visible page.
|
|
/// - Parameter adaptivePreview: Whether adaptive preview is currently open.
|
|
/// - 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 content: A `ViewBuilder` closure whose first view is mounted into the `content` slot.
|
|
/// - 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(canNavigateBack: Bool? = nil, searchEnabled: Bool? = nil, visiblePageName: String? = nil, adaptivePreview: Bool? = nil, 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 content: @escaping () -> [AnyView] = { [] }, @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 Adw.PreferencesWindow() }
|
|
configure.append { w, ctx in
|
|
if let canNavigateBack { w.setCanNavigateBack(canNavigateBack: canNavigateBack) }
|
|
if let searchEnabled { w.setSearchEnabled(searchEnabled: searchEnabled) }
|
|
if let visiblePageName { w.setVisiblePageName(name: visiblePageName) }
|
|
if let adaptivePreview { w.setAdaptivePreview(adaptivePreview: adaptivePreview) }
|
|
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(content, ctx, onUpdate: { v in w.setContent(content: v) }) { w.setContent(content: v) }
|
|
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 PreferencesWindow: WidgetView {
|
|
public typealias Target = Adw.PreferencesWindow
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Adw.PreferencesWindow, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension PreferencesWindow: 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: Adw.PreferencesWindow
|
|
/// Modifiers for `Adw.PreferencesWindow`, available on every Portico view whose
|
|
/// backing widget is `Adw.PreferencesWindow` or one of its subclasses.
|
|
extension WidgetView where Target: Adw.PreferencesWindow {
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.PreferencesWindow.setCanNavigateBack(canNavigateBack:)
|
|
/// Sets whether gestures and shortcuts for closing subpages are enabled.
|
|
///
|
|
/// The supported gestures are:
|
|
///
|
|
/// - One-finger swipe on touchscreens
|
|
/// - Horizontal scrolling on touchpads (usually two-finger swipe)
|
|
/// - Back mouse button
|
|
///
|
|
/// The keyboard back key is also supported, as well as the
|
|
/// <kbd>Alt</kbd>+<kbd>←</kbd> shortcut.
|
|
///
|
|
/// For right-to-left locales, gestures and shortcuts are reversed.
|
|
///
|
|
/// Has no effect for subpages added with [method`PreferencesWindow`.push_subpage].
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter canNavigateBack: Whether gestures and shortcuts for closing subpages are enabled.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func canNavigateBack(_ canNavigateBack: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setCanNavigateBack(canNavigateBack: canNavigateBack)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.PreferencesWindow.setCanNavigateBack(canNavigateBack:), GObject.Object.connectNotify(detail:_:), Adw.PreferencesWindow.getCanNavigateBack()
|
|
/// Sets whether gestures and shortcuts for closing subpages are enabled.
|
|
///
|
|
/// The supported gestures are:
|
|
///
|
|
/// - One-finger swipe on touchscreens
|
|
/// - Horizontal scrolling on touchpads (usually two-finger swipe)
|
|
/// - Back mouse button
|
|
///
|
|
/// The keyboard back key is also supported, as well as the
|
|
/// <kbd>Alt</kbd>+<kbd>←</kbd> shortcut.
|
|
///
|
|
/// For right-to-left locales, gestures and shortcuts are reversed.
|
|
///
|
|
/// Has no effect for subpages added with [method`PreferencesWindow`.push_subpage].
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func canNavigateBack(_ canNavigateBack: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, canNavigateBack, registry: ctx.registry, notifyDetail: "can-navigate-back",
|
|
read: { [w] in w.getCanNavigateBack() },
|
|
write: { [w] v in w.setCanNavigateBack(canNavigateBack: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.PreferencesWindow.setCanNavigateBack(canNavigateBack:)
|
|
/// Sets whether gestures and shortcuts for closing subpages are enabled.
|
|
///
|
|
/// The supported gestures are:
|
|
///
|
|
/// - One-finger swipe on touchscreens
|
|
/// - Horizontal scrolling on touchpads (usually two-finger swipe)
|
|
/// - Back mouse button
|
|
///
|
|
/// The keyboard back key is also supported, as well as the
|
|
/// <kbd>Alt</kbd>+<kbd>←</kbd> shortcut.
|
|
///
|
|
/// For right-to-left locales, gestures and shortcuts are reversed.
|
|
///
|
|
/// Has no effect for subpages added with [method`PreferencesWindow`.push_subpage].
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.PreferencesWindow.setCanNavigateBack(canNavigateBack:)`.
|
|
///
|
|
/// - Parameter canNavigateBack: Whether gestures and shortcuts for closing subpages are enabled.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func canNavigateBack(_ canNavigateBack: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setCanNavigateBack(canNavigateBack: canNavigateBack()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.PreferencesWindow.setSearchEnabled(searchEnabled:)
|
|
/// Sets whether search is enabled for `self`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter searchEnabled: Whether search is enabled.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func searchEnabled(_ searchEnabled: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setSearchEnabled(searchEnabled: searchEnabled)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.PreferencesWindow.setSearchEnabled(searchEnabled:), GObject.Object.connectNotify(detail:_:), Adw.PreferencesWindow.getSearchEnabled()
|
|
/// Sets whether search is enabled for `self`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func searchEnabled(_ searchEnabled: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, searchEnabled, registry: ctx.registry, notifyDetail: "search-enabled",
|
|
read: { [w] in w.getSearchEnabled() },
|
|
write: { [w] v in w.setSearchEnabled(searchEnabled: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.PreferencesWindow.setSearchEnabled(searchEnabled:)
|
|
/// Sets whether search is enabled for `self`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.PreferencesWindow.setSearchEnabled(searchEnabled:)`.
|
|
///
|
|
/// - Parameter searchEnabled: Whether search is enabled.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func searchEnabled(_ searchEnabled: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setSearchEnabled(searchEnabled: searchEnabled()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.PreferencesWindow.setVisiblePageName(name:)
|
|
/// Makes the page with the given name visible.
|
|
///
|
|
/// See [property`PreferencesWindow`:visible-page].
|
|
///
|
|
/// Applied once at mount; use the `Binding`, closure, or `InterpolatedText` overload for a value that changes.
|
|
/// A string literal containing interpolation selects the `InterpolatedText` overload instead, which updates live.
|
|
///
|
|
/// - Parameter visiblePageName: The name of the currently visible page.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func visiblePageName<S: StringProtocol>(_ visiblePageName: S) -> Self {
|
|
appending { w, _ in
|
|
w.setVisiblePageName(name: String(visiblePageName))
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.PreferencesWindow.setVisiblePageName(name:), GObject.Object.connectNotify(detail:_:), Adw.PreferencesWindow.getVisiblePageName()
|
|
/// Makes the page with the given name visible.
|
|
///
|
|
/// See [property`PreferencesWindow`:visible-page].
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `String` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visiblePageName(_ visiblePageName: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, visiblePageName, registry: ctx.registry, notifyDetail: "visible-page-name",
|
|
read: { [w] in w.getVisiblePageName() },
|
|
write: { [w] v in w.setVisiblePageName(name: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.PreferencesWindow.setVisiblePageName(name:)
|
|
/// Makes the page with the given name visible.
|
|
///
|
|
/// See [property`PreferencesWindow`:visible-page].
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.PreferencesWindow.setVisiblePageName(name:)`.
|
|
///
|
|
/// - Parameter visiblePageName: The name of the currently visible page.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visiblePageName(_ visiblePageName: @escaping () -> String) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setVisiblePageName(name: visiblePageName()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.PreferencesWindow.setVisiblePageName(name:)
|
|
/// Makes the page with the given name visible.
|
|
///
|
|
/// See [property`PreferencesWindow`:visible-page].
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.PreferencesWindow.setVisiblePageName(name:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter visiblePageName: The name of the currently visible page.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func visiblePageName(_ visiblePageName: Portico.InterpolatedText) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindInterpolation(visiblePageName, registry: ctx.registry) { [w] v in w.setVisiblePageName(name: v) }
|
|
}
|
|
}
|
|
|
|
}
|