portico/Sources/Portico/Generated/PreferencesRow.swift

306 lines
17 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.PreferencesRow
/// A [class`Gtk`.ListBoxRow] used to present preferences.
///
/// The `AdwPreferencesRow` widget has a title that [class`PreferencesDialog`]
/// will use to let the user look for a preference. It doesn't present the title
/// in any way and lets you present the preference as you please.
///
/// [class`ActionRow`] and its derivatives are convenient to use as preference
/// rows as they take care of presenting the preference's title while letting you
/// compose the inputs of the preference around it.
///
/// A Portico view that mounts a `Adw.PreferencesRow`.
@MainActor public struct PreferencesRow: View {
private let make: (MountContext) -> Adw.PreferencesRow
private var configure: [(Adw.PreferencesRow, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Adw.PreferencesRow.init()
/// Creates a new `AdwPreferencesRow`.
///
/// 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 title: The title of the preference represented by this row.
/// - Parameter titleSelectable: Whether the user can copy the title from the label.
/// - Parameter useMarkup: Whether to use Pango markup for the title label.
/// - Parameter useUnderline: Whether an embedded underline in the title indicates a mnemonic.
/// - Parameter activatable: Determines whether the ::row-activated signal will be emitted for this row.
/// - Parameter selectable: Determines whether this row can be selected.
/// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot.
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
public init(title: String? = nil, titleSelectable: Bool? = nil, useMarkup: Bool? = nil, useUnderline: Bool? = nil, activatable: Bool? = nil, selectable: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil) {
make = { _ in Adw.PreferencesRow() }
configure.append { w, ctx in
if let title { w.setTitle(title: title) }
if let titleSelectable { w.setTitleSelectable(titleSelectable: titleSelectable) }
if let useMarkup { w.setUseMarkup(useMarkup: useMarkup) }
if let useUnderline { w.setUseUnderline(useUnderline: useUnderline) }
if let activatable { w.setActivatable(activatable: activatable) }
if let selectable { w.setSelectable(selectable: selectable) }
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
}
}
}
extension PreferencesRow: WidgetView {
public typealias Target = Adw.PreferencesRow
@_spi(Portico) public func appending(
_ step: @escaping (Adw.PreferencesRow, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension PreferencesRow: 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.PreferencesRow
/// Modifiers for `Adw.PreferencesRow`, available on every Portico view whose
/// backing widget is `Adw.PreferencesRow` or one of its subclasses.
extension WidgetView where Target: Adw.PreferencesRow {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.PreferencesRow.setTitle(title:)
/// Sets the title of the preference represented by `self`.
///
/// The title is interpreted as Pango markup unless
/// [property`PreferencesRow`:use-markup] is set to `FALSE`.
///
/// 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 title: The title of the preference represented by this row.
/// - Returns: A copy of this view with the modifier applied.
@_disfavoredOverload
public func title<S: StringProtocol>(_ title: S) -> Self {
appending { w, _ in
w.setTitle(title: String(title))
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.PreferencesRow.setTitle(title:), GObject.Object.connectNotify(detail:_:), Adw.PreferencesRow.getTitle()
/// Sets the title of the preference represented by `self`.
///
/// The title is interpreted as Pango markup unless
/// [property`PreferencesRow`:use-markup] is set to `FALSE`.
///
/// 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 title(_ title: Portico.Binding<String>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, title, registry: ctx.registry, notifyDetail: "title",
read: { [w] in w.getTitle() },
write: { [w] v in w.setTitle(title: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.PreferencesRow.setTitle(title:)
/// Sets the title of the preference represented by `self`.
///
/// The title is interpreted as Pango markup unless
/// [property`PreferencesRow`:use-markup] is set to `FALSE`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.PreferencesRow.setTitle(title:)`.
///
/// - Parameter title: The title of the preference represented by this row.
/// - Returns: A copy of this view with the modifier applied.
public func title(_ title: @escaping () -> String) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setTitle(title: title()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.PreferencesRow.setTitle(title:)
/// Sets the title of the preference represented by `self`.
///
/// The title is interpreted as Pango markup unless
/// [property`PreferencesRow`:use-markup] is set to `FALSE`.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.PreferencesRow.setTitle(title:)`. A literal with no interpolation is applied once, with no subscription.
///
/// - Parameter title: The title of the preference represented by this row.
/// - Returns: A copy of this view with the modifier applied.
public func title(_ title: Portico.InterpolatedText) -> Self {
appending { w, ctx in
Portico.bindInterpolation(title, registry: ctx.registry) { [w] v in w.setTitle(title: v) }
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.PreferencesRow.setTitleSelectable(titleSelectable:)
/// Sets whether the user can copy the title from the label
///
/// See also [property`Gtk`.Label:selectable].
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter titleSelectable: Whether the user can copy the title from the label.
/// - Returns: A copy of this view with the modifier applied.
public func titleSelectable(_ titleSelectable: Bool) -> Self {
appending { w, _ in
w.setTitleSelectable(titleSelectable: titleSelectable)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.PreferencesRow.setTitleSelectable(titleSelectable:), GObject.Object.connectNotify(detail:_:), Adw.PreferencesRow.getTitleSelectable()
/// Sets whether the user can copy the title from the label
///
/// See also [property`Gtk`.Label:selectable].
///
/// 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 titleSelectable(_ titleSelectable: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, titleSelectable, registry: ctx.registry, notifyDetail: "title-selectable",
read: { [w] in w.getTitleSelectable() },
write: { [w] v in w.setTitleSelectable(titleSelectable: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.PreferencesRow.setTitleSelectable(titleSelectable:)
/// Sets whether the user can copy the title from the label
///
/// See also [property`Gtk`.Label:selectable].
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.PreferencesRow.setTitleSelectable(titleSelectable:)`.
///
/// - Parameter titleSelectable: Whether the user can copy the title from the label.
/// - Returns: A copy of this view with the modifier applied.
public func titleSelectable(_ titleSelectable: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setTitleSelectable(titleSelectable: titleSelectable()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.PreferencesRow.setUseMarkup(useMarkup:)
/// Sets whether to use Pango markup for the title label.
///
/// Subclasses may also use it for other labels, such as subtitle.
///
/// See also [func`Pango`.parse_markup].
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter useMarkup: Whether to use Pango markup for the title label.
/// - Returns: A copy of this view with the modifier applied.
public func useMarkup(_ useMarkup: Bool) -> Self {
appending { w, _ in
w.setUseMarkup(useMarkup: useMarkup)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.PreferencesRow.setUseMarkup(useMarkup:), GObject.Object.connectNotify(detail:_:), Adw.PreferencesRow.getUseMarkup()
/// Sets whether to use Pango markup for the title label.
///
/// Subclasses may also use it for other labels, such as subtitle.
///
/// See also [func`Pango`.parse_markup].
///
/// 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 useMarkup(_ useMarkup: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, useMarkup, registry: ctx.registry, notifyDetail: "use-markup",
read: { [w] in w.getUseMarkup() },
write: { [w] v in w.setUseMarkup(useMarkup: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.PreferencesRow.setUseMarkup(useMarkup:)
/// Sets whether to use Pango markup for the title label.
///
/// Subclasses may also use it for other labels, such as subtitle.
///
/// See also [func`Pango`.parse_markup].
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.PreferencesRow.setUseMarkup(useMarkup:)`.
///
/// - Parameter useMarkup: Whether to use Pango markup for the title label.
/// - Returns: A copy of this view with the modifier applied.
public func useMarkup(_ useMarkup: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setUseMarkup(useMarkup: useMarkup()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.PreferencesRow.setUseUnderline(useUnderline:)
/// Sets whether an embedded underline in the title indicates a mnemonic.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter useUnderline: Whether an embedded underline in the title indicates a mnemonic.
/// - Returns: A copy of this view with the modifier applied.
public func useUnderline(_ useUnderline: Bool) -> Self {
appending { w, _ in
w.setUseUnderline(useUnderline: useUnderline)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.PreferencesRow.setUseUnderline(useUnderline:), GObject.Object.connectNotify(detail:_:), Adw.PreferencesRow.getUseUnderline()
/// Sets whether an embedded underline in the title indicates a mnemonic.
///
/// 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 useUnderline(_ useUnderline: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, useUnderline, registry: ctx.registry, notifyDetail: "use-underline",
read: { [w] in w.getUseUnderline() },
write: { [w] v in w.setUseUnderline(useUnderline: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.PreferencesRow.setUseUnderline(useUnderline:)
/// Sets whether an embedded underline in the title indicates a mnemonic.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.PreferencesRow.setUseUnderline(useUnderline:)`.
///
/// - Parameter useUnderline: Whether an embedded underline in the title indicates a mnemonic.
/// - Returns: A copy of this view with the modifier applied.
public func useUnderline(_ useUnderline: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setUseUnderline(useUnderline: useUnderline()) }
tracker.run()
ctx.registry.add(tracker)
}
}
}