portico/Sources/Portico/Generated/PreferencesDialog.swift

215 lines
12 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.PreferencesDialog
/// A dialog showing application's preferences.
///
/// <picture>
/// <source srcset="preferences-dialog-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="preferences-dialog.png" alt="preferences-dialog">
/// </picture>
///
/// The `AdwPreferencesDialog` widget presents an application's preferences
/// gathered into pages and groups. The preferences are searchable by the user.
///
/// ## Actions
///
/// `AdwPrefencesDialog` defines the `navigation.pop` action, it doesn't take any
/// parameters and pops the current subpage from the navigation stack, equivalent
/// to calling [method`PreferencesDialog`.pop_subpage].
///
/// ## CSS nodes
///
/// `AdwPreferencesDialog` has a main CSS node with the name `dialog` and the
/// style class `.preferences`.
///
/// A Portico view that mounts a `Adw.PreferencesDialog`.
@MainActor public struct PreferencesDialog: View {
private let make: (MountContext) -> Adw.PreferencesDialog
private var configure: [(Adw.PreferencesDialog, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Adw.PreferencesDialog.init()
/// Creates a new `AdwPreferencesDialog`.
///
/// 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 searchEnabled: Whether search is enabled.
/// - Parameter visiblePageName: The name of the currently visible page.
/// - 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(searchEnabled: Bool? = nil, visiblePageName: String? = nil, 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.PreferencesDialog() }
configure.append { w, ctx in
if let searchEnabled { w.setSearchEnabled(searchEnabled: searchEnabled) }
if let visiblePageName { w.setVisiblePageName(name: visiblePageName) }
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 PreferencesDialog: WidgetView {
public typealias Target = Adw.PreferencesDialog
@_spi(Portico) public func appending(
_ step: @escaping (Adw.PreferencesDialog, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension PreferencesDialog: 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.PreferencesDialog
/// Modifiers for `Adw.PreferencesDialog`, available on every Portico view whose
/// backing widget is `Adw.PreferencesDialog` or one of its subclasses.
extension WidgetView where Target: Adw.PreferencesDialog {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.PreferencesDialog.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.PreferencesDialog.setSearchEnabled(searchEnabled:), GObject.Object.connectNotify(detail:_:), Adw.PreferencesDialog.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.PreferencesDialog.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.PreferencesDialog.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.PreferencesDialog.setVisiblePageName(name:)
/// Makes the page with the given name visible.
///
/// See [property`PreferencesDialog`: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.PreferencesDialog.setVisiblePageName(name:), GObject.Object.connectNotify(detail:_:), Adw.PreferencesDialog.getVisiblePageName()
/// Makes the page with the given name visible.
///
/// See [property`PreferencesDialog`: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.PreferencesDialog.setVisiblePageName(name:)
/// Makes the page with the given name visible.
///
/// See [property`PreferencesDialog`:visible-page].
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.PreferencesDialog.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.PreferencesDialog.setVisiblePageName(name:)
/// Makes the page with the given name visible.
///
/// See [property`PreferencesDialog`:visible-page].
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.PreferencesDialog.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) }
}
}
}