portico/Sources/Portico/Generated/AppChooserDialog.swift

280 lines
21 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: Gtk.AppChooserDialog
/// `GtkAppChooserDialog` shows a `GtkAppChooserWidget` inside a `GtkDialog`.
///
/// <picture>
/// <source srcset="appchooserdialog-dark.png" media="(prefers-color-scheme: dark)">
/// <img alt="An example GtkAppChooserDialog" src="appchooserdialog.png">
/// </picture>
///
/// Note that `GtkAppChooserDialog` does not have any interesting methods
/// of its own. Instead, you should get the embedded `GtkAppChooserWidget`
/// using [method`Gtk`.AppChooserDialog.get_widget] and call its methods if
/// the generic [iface`Gtk`.AppChooser] interface is not sufficient for
/// your needs.
///
/// To set the heading that is shown above the `GtkAppChooserWidget`,
/// use [method`Gtk`.AppChooserDialog.set_heading].
///
/// ## CSS nodes
///
/// `GtkAppChooserDialog` has a single CSS node with the name `window` and style
/// class `.appchooser`.
///
/// A Portico view that mounts a `Gtk.AppChooserDialog`.
@MainActor public struct AppChooserDialog: View {
private let make: (MountContext) -> Gtk.AppChooserDialog
private var configure: [(Gtk.AppChooserDialog, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.AppChooserDialog.init(parent:flags:file:)
/// Creates a new `GtkAppChooserDialog` for the provided `GFile`.
///
/// The dialog will show applications that can open the file.
///
/// 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 parent: The `parent` value forwarded to `Gtk.AppChooserDialog`.
/// - Parameter flags: The `flags` value forwarded to `Gtk.AppChooserDialog`.
/// - Parameter file: The `file` value forwarded to `Gtk.AppChooserDialog`.
/// - Parameter heading: The text to show at the top of the dialog.
/// - 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 onClose: Invoked when the widget emits the `close` signal.
/// - Parameter onResponse: Invoked when the widget emits the `response` signal. The closure receives the signal's arguments in order.
/// - 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(parent: Gtk.Window?, flags: Gtk.DialogFlags, file: Gtk.File, heading: String? = 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 child: @escaping () -> [AnyView] = { [] }, @ViewBuilder defaultWidget: @escaping () -> [AnyView] = { [] }, @ViewBuilder focusWidget: @escaping () -> [AnyView] = { [] }, @ViewBuilder titlebar: @escaping () -> [AnyView] = { [] }, onClose: (() -> Void)? = nil, onResponse: ((Int32) -> Void)? = nil, onActivateDefault: (() -> Void)? = nil, onActivateFocus: (() -> Void)? = nil, onCloseRequest: (() -> Bool)? = nil, onEnableDebugging: ((Bool) -> Bool)? = nil, onKeysChanged: (() -> Void)? = nil) {
make = { _ in Gtk.AppChooserDialog(parent: parent, flags: flags, file: file) }
configure.append { w, ctx in
if let heading { w.setHeading(heading: heading) }
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 onClose { ctx.registry.add(w.connectClose { _ in onClose() }) }
if let onResponse { ctx.registry.add(w.connectResponse { _, a0 in onResponse(a0) }) }
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() }) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.AppChooserDialog.init(parent:flags:contentType:)
/// Creates a new `GtkAppChooserDialog` for the provided content type.
///
/// The dialog will show applications that can open the content type.
///
/// 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 parent: The `parent` value forwarded to `Gtk.AppChooserDialog`.
/// - Parameter flags: The `flags` value forwarded to `Gtk.AppChooserDialog`.
/// - Parameter contentType: The `contentType` value forwarded to `Gtk.AppChooserDialog`.
/// - Parameter heading: The text to show at the top of the dialog.
/// - 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 onClose: Invoked when the widget emits the `close` signal.
/// - Parameter onResponse: Invoked when the widget emits the `response` signal. The closure receives the signal's arguments in order.
/// - 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(parent: Gtk.Window?, flags: Gtk.DialogFlags, contentType: String, heading: String? = 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 child: @escaping () -> [AnyView] = { [] }, @ViewBuilder defaultWidget: @escaping () -> [AnyView] = { [] }, @ViewBuilder focusWidget: @escaping () -> [AnyView] = { [] }, @ViewBuilder titlebar: @escaping () -> [AnyView] = { [] }, onClose: (() -> Void)? = nil, onResponse: ((Int32) -> Void)? = nil, onActivateDefault: (() -> Void)? = nil, onActivateFocus: (() -> Void)? = nil, onCloseRequest: (() -> Bool)? = nil, onEnableDebugging: ((Bool) -> Bool)? = nil, onKeysChanged: (() -> Void)? = nil) {
make = { _ in Gtk.AppChooserDialog(parent: parent, flags: flags, contentType: contentType) }
configure.append { w, ctx in
if let heading { w.setHeading(heading: heading) }
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 onClose { ctx.registry.add(w.connectClose { _ in onClose() }) }
if let onResponse { ctx.registry.add(w.connectResponse { _, a0 in onResponse(a0) }) }
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 AppChooserDialog: WidgetView {
public typealias Target = Gtk.AppChooserDialog
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.AppChooserDialog, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension AppChooserDialog: 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: Gtk.AppChooserDialog
/// Modifiers for `Gtk.AppChooserDialog`, available on every Portico view whose
/// backing widget is `Gtk.AppChooserDialog` or one of its subclasses.
extension WidgetView where Target: Gtk.AppChooserDialog {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.AppChooserDialog.setHeading(heading:)
/// Sets the text to display at the top of the dialog.
///
/// If the heading is not set, the dialog displays a default text.
///
/// 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 heading: The text to show at the top of the dialog.
/// - Returns: A copy of this view with the modifier applied.
@_disfavoredOverload
public func heading<S: StringProtocol>(_ heading: S) -> Self {
appending { w, _ in
w.setHeading(heading: String(heading))
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.AppChooserDialog.setHeading(heading:), GObject.Object.connectNotify(detail:_:), Gtk.AppChooserDialog.getHeading()
/// Sets the text to display at the top of the dialog.
///
/// If the heading is not set, the dialog displays a default text.
///
/// 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 heading(_ heading: Portico.Binding<String>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, heading, registry: ctx.registry, notifyDetail: "heading",
read: { [w] in w.getHeading() },
write: { [w] v in w.setHeading(heading: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.AppChooserDialog.setHeading(heading:)
/// Sets the text to display at the top of the dialog.
///
/// If the heading is not set, the dialog displays a default text.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.AppChooserDialog.setHeading(heading:)`.
///
/// - Parameter heading: The text to show at the top of the dialog.
/// - Returns: A copy of this view with the modifier applied.
public func heading(_ heading: @escaping () -> String) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setHeading(heading: heading()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Gtk.AppChooserDialog.setHeading(heading:)
/// Sets the text to display at the top of the dialog.
///
/// If the heading is not set, the dialog displays a default text.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.AppChooserDialog.setHeading(heading:)`. A literal with no interpolation is applied once, with no subscription.
///
/// - Parameter heading: The text to show at the top of the dialog.
/// - Returns: A copy of this view with the modifier applied.
public func heading(_ heading: Portico.InterpolatedText) -> Self {
appending { w, ctx in
Portico.bindInterpolation(heading, registry: ctx.registry) { [w] v in w.setHeading(heading: v) }
}
}
}