419 lines
24 KiB
Swift
419 lines
24 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.ShortcutLabel
|
|
/// A widget that displays a keyboard shortcut.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="shortcut-label-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img src="shortcut-label.png" alt="shortcut-label">
|
|
/// </picture>
|
|
///
|
|
/// The shown shortcut can be set using the [property`ShortcutLabel`:accelerator]
|
|
/// property.
|
|
///
|
|
/// Optionally, if no shortcut is set, `AdwShortcutLabel` will display a
|
|
/// placeholder set with the [property`ShortcutLabel`:disabled-text] property.
|
|
///
|
|
/// The following types of shortcuts can be displayed:
|
|
///
|
|
/// - A single shortcut in [func`Gtk`.accelerator_parse] format, e.g. `<Control>C`:
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="shortcut-label-single-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img src="shortcut-label-single.png" alt="shortcut-label-single">
|
|
/// </picture>
|
|
///
|
|
/// - Multiple alternative shortcuts, separated with spaces, e.g. `<Shift>A Home`:
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="shortcut-label-alternative-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img src="shortcut-label-alternative.png" alt="shortcut-label-alternative">
|
|
/// </picture>
|
|
///
|
|
/// - A range of shortcuts, separated with `...`, e.g. `<Alt>1...9`:
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="shortcut-label-range-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img src="shortcut-label-range.png" alt="shortcut-label-range">
|
|
/// </picture>
|
|
///
|
|
/// - Multiple keys pressed at once, separated with `&`, e.g. `Control_L&Control_R`:
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="shortcut-label-multiple-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img src="shortcut-label-multiple.png" alt="shortcut-label-multiple">
|
|
/// </picture>
|
|
///
|
|
/// - Multiple shortcuts or keys, pressed sequentially, separated with `+`, e.g. `<Control>C+<Control>X`:
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="shortcut-label-sequence-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img src="shortcut-label-sequence.png" alt="shortcut-label-sequence">
|
|
/// </picture>
|
|
///
|
|
/// ::: note
|
|
/// `<`, `>` and `&` need to be escaped as `<`, `>` and `&` when used in UI files.
|
|
///
|
|
/// ## CSS nodes
|
|
///
|
|
/// `AdwShortcutLabel` has a single CSS node with name `shortcut-label`. The
|
|
/// individual keycap labels each have the `.keycap` style class, while the
|
|
/// labels separating them have the `.dimmed` style class.
|
|
///
|
|
/// ## Accessibility
|
|
///
|
|
/// `AdwShortcutLabel` uses the [enum`Gtk`.AccessibleRole.label] role.
|
|
///
|
|
/// See also: [class`ShortcutsDialog`].
|
|
///
|
|
/// A Portico view that mounts a `Adw.ShortcutLabel`.
|
|
@MainActor public struct ShortcutLabel: View {
|
|
private let make: (MountContext) -> Adw.ShortcutLabel
|
|
private var configure: [(Adw.ShortcutLabel, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Adw.ShortcutLabel.init(accelerator:)
|
|
/// Creates a new `AdwShortcutLabel` showing `accelerator`.
|
|
///
|
|
/// Applied once at mount; use the `Binding`, closure, or `InterpolatedText` overload for values that change.
|
|
/// A string literal containing interpolation selects the `InterpolatedText` overload instead, which updates live.
|
|
/// 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 accelerator: The displayed accelerator.
|
|
/// - Parameter disabledText: The text displayed when no accelerator is set.
|
|
@_disfavoredOverload
|
|
public init<S: StringProtocol>(accelerator: S, disabledText: String? = nil) {
|
|
make = { _ in Adw.ShortcutLabel(accelerator: String(accelerator)) }
|
|
configure.append { w, _ in
|
|
if let disabledText { w.setDisabledText(disabledText: disabledText) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateInits(binding) | source: Adw.ShortcutLabel.init(accelerator:), Adw.ShortcutLabel.setAccelerator(accelerator:)
|
|
/// Creates a new `AdwShortcutLabel` showing `accelerator`.
|
|
///
|
|
/// The initial value is the binding's current value; every later change is pushed into the widget through `Adw.ShortcutLabel.setAccelerator(accelerator:)` without rebuilding the view.
|
|
/// 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.
|
|
/// Optional `Binding` parameters bind through `Portico.bindProperty`, so they are two-way wherever the wrapper exposes a safe getter.
|
|
///
|
|
/// - Parameter accelerator: The displayed accelerator.
|
|
/// - Parameter disabledText: The text displayed when no accelerator is set.
|
|
public init(accelerator: Portico.Binding<String>, disabledText: Portico.Binding<String>? = nil) {
|
|
make = { _ in Adw.ShortcutLabel(accelerator: accelerator.wrappedValue) }
|
|
configure.append { w, ctx in
|
|
ctx.registry.add(accelerator.subscribe { [w] v in w.setAccelerator(accelerator: v) })
|
|
if let disabledText {
|
|
Portico.bindProperty(w, disabledText, registry: ctx.registry, notifyDetail: "disabled-text", read: { [w] in w.getDisabledText() }, write: { [w] v in w.setDisabledText(disabledText: v) })
|
|
}
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateInits(closure) | source: Adw.ShortcutLabel.init(accelerator:), Adw.ShortcutLabel.setAccelerator(accelerator:)
|
|
/// Creates a new `AdwShortcutLabel` showing `accelerator`.
|
|
///
|
|
/// Each closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.ShortcutLabel.setAccelerator(accelerator:)`.
|
|
/// 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 accelerator: The displayed accelerator.
|
|
/// - Parameter disabledText: The text displayed when no accelerator is set.
|
|
public init(accelerator: @escaping () -> String, disabledText: String? = nil) {
|
|
make = { _ in Adw.ShortcutLabel(accelerator: accelerator()) }
|
|
configure.append { w, ctx in
|
|
let t0 = DependencyTracker { [w] in w.setAccelerator(accelerator: accelerator()) }
|
|
t0.run()
|
|
ctx.registry.add(t0)
|
|
if let disabledText { w.setDisabledText(disabledText: disabledText) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateInits(interpolation) | source: Adw.ShortcutLabel.init(accelerator:), Adw.ShortcutLabel.setAccelerator(accelerator:)
|
|
/// Creates a new `AdwShortcutLabel` showing `accelerator`.
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.ShortcutLabel.setAccelerator(accelerator:)`. A literal with no interpolation is applied once, with no subscription.
|
|
/// 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 accelerator: The displayed accelerator.
|
|
/// - Parameter disabledText: The text displayed when no accelerator is set.
|
|
public init(accelerator: Portico.InterpolatedText, disabledText: String? = nil) {
|
|
make = { _ in Adw.ShortcutLabel(accelerator: accelerator.untrackedText) }
|
|
configure.append { w, ctx in
|
|
Portico.bindInterpolation(accelerator, registry: ctx.registry) { [w] v in w.setAccelerator(accelerator: v) }
|
|
if let disabledText { w.setDisabledText(disabledText: disabledText) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension ShortcutLabel: WidgetView {
|
|
public typealias Target = Adw.ShortcutLabel
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Adw.ShortcutLabel, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension ShortcutLabel: 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.ShortcutLabel
|
|
/// Modifiers for `Adw.ShortcutLabel`, available on every Portico view whose
|
|
/// backing widget is `Adw.ShortcutLabel` or one of its subclasses.
|
|
extension WidgetView where Target: Adw.ShortcutLabel {
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.ShortcutLabel.setAccelerator(accelerator:)
|
|
/// Sets the accelerator to be displayed by `self`.
|
|
///
|
|
/// 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 accelerator: The displayed accelerator.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func accelerator<S: StringProtocol>(_ accelerator: S) -> Self {
|
|
appending { w, _ in
|
|
w.setAccelerator(accelerator: String(accelerator))
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.ShortcutLabel.setAccelerator(accelerator:), GObject.Object.connectNotify(detail:_:), Adw.ShortcutLabel.getAccelerator()
|
|
/// Sets the accelerator to be displayed by `self`.
|
|
///
|
|
/// 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 accelerator(_ accelerator: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, accelerator, registry: ctx.registry, notifyDetail: "accelerator",
|
|
read: { [w] in w.getAccelerator() },
|
|
write: { [w] v in w.setAccelerator(accelerator: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.ShortcutLabel.setAccelerator(accelerator:)
|
|
/// Sets the accelerator to be displayed by `self`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.ShortcutLabel.setAccelerator(accelerator:)`.
|
|
///
|
|
/// - Parameter accelerator: The displayed accelerator.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func accelerator(_ accelerator: @escaping () -> String) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setAccelerator(accelerator: accelerator()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.ShortcutLabel.setAccelerator(accelerator:)
|
|
/// Sets the accelerator to be displayed by `self`.
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.ShortcutLabel.setAccelerator(accelerator:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter accelerator: The displayed accelerator.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func accelerator(_ accelerator: Portico.InterpolatedText) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindInterpolation(accelerator, registry: ctx.registry) { [w] v in w.setAccelerator(accelerator: v) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.ShortcutLabel.setDisabledText(disabledText:)
|
|
/// Sets the text to be displayed by `self` when no accelerator is set.
|
|
///
|
|
/// 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 disabledText: The text displayed when no accelerator is set.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func disabledText<S: StringProtocol>(_ disabledText: S) -> Self {
|
|
appending { w, _ in
|
|
w.setDisabledText(disabledText: String(disabledText))
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.ShortcutLabel.setDisabledText(disabledText:), GObject.Object.connectNotify(detail:_:), Adw.ShortcutLabel.getDisabledText()
|
|
/// Sets the text to be displayed by `self` when no accelerator is set.
|
|
///
|
|
/// 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 disabledText(_ disabledText: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, disabledText, registry: ctx.registry, notifyDetail: "disabled-text",
|
|
read: { [w] in w.getDisabledText() },
|
|
write: { [w] v in w.setDisabledText(disabledText: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.ShortcutLabel.setDisabledText(disabledText:)
|
|
/// Sets the text to be displayed by `self` when no accelerator is set.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.ShortcutLabel.setDisabledText(disabledText:)`.
|
|
///
|
|
/// - Parameter disabledText: The text displayed when no accelerator is set.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func disabledText(_ disabledText: @escaping () -> String) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setDisabledText(disabledText: disabledText()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.ShortcutLabel.setDisabledText(disabledText:)
|
|
/// Sets the text to be displayed by `self` when no accelerator is set.
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.ShortcutLabel.setDisabledText(disabledText:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter disabledText: The text displayed when no accelerator is set.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func disabledText(_ disabledText: Portico.InterpolatedText) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindInterpolation(disabledText, registry: ctx.registry) { [w] v in w.setDisabledText(disabledText: v) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension | source: Gtk.ShortcutLabel
|
|
/// Modifiers for `Gtk.ShortcutLabel`, available on every Portico view whose
|
|
/// backing widget is `Gtk.ShortcutLabel` or one of its subclasses.
|
|
extension WidgetView where Target: Gtk.ShortcutLabel {
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.ShortcutLabel.setAccelerator(accelerator:)
|
|
/// Sets the accelerator to be displayed by `self`.
|
|
///
|
|
/// 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 accelerator: The accelerator that `self` displays.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func accelerator<S: StringProtocol>(_ accelerator: S) -> Self {
|
|
appending { w, _ in
|
|
w.setAccelerator(accelerator: String(accelerator))
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.ShortcutLabel.setAccelerator(accelerator:), GObject.Object.connectNotify(detail:_:), Gtk.ShortcutLabel.getAccelerator()
|
|
/// Sets the accelerator to be displayed by `self`.
|
|
///
|
|
/// 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 accelerator(_ accelerator: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, accelerator, registry: ctx.registry, notifyDetail: "accelerator",
|
|
read: { [w] in w.getAccelerator() },
|
|
write: { [w] v in w.setAccelerator(accelerator: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.ShortcutLabel.setAccelerator(accelerator:)
|
|
/// Sets the accelerator to be displayed by `self`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.ShortcutLabel.setAccelerator(accelerator:)`.
|
|
///
|
|
/// - Parameter accelerator: The accelerator that `self` displays.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func accelerator(_ accelerator: @escaping () -> String) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setAccelerator(accelerator: accelerator()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Gtk.ShortcutLabel.setAccelerator(accelerator:)
|
|
/// Sets the accelerator to be displayed by `self`.
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.ShortcutLabel.setAccelerator(accelerator:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter accelerator: The accelerator that `self` displays.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func accelerator(_ accelerator: Portico.InterpolatedText) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindInterpolation(accelerator, registry: ctx.registry) { [w] v in w.setAccelerator(accelerator: v) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.ShortcutLabel.setDisabledText(disabledText:)
|
|
/// Sets the text to be displayed by `self` when no accelerator is set.
|
|
///
|
|
/// 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 disabledText: The text that is displayed when no accelerator is set.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func disabledText<S: StringProtocol>(_ disabledText: S) -> Self {
|
|
appending { w, _ in
|
|
w.setDisabledText(disabledText: String(disabledText))
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.ShortcutLabel.setDisabledText(disabledText:), GObject.Object.connectNotify(detail:_:), Gtk.ShortcutLabel.getDisabledText()
|
|
/// Sets the text to be displayed by `self` when no accelerator is set.
|
|
///
|
|
/// 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 disabledText(_ disabledText: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, disabledText, registry: ctx.registry, notifyDetail: "disabled-text",
|
|
read: { [w] in w.getDisabledText() },
|
|
write: { [w] v in w.setDisabledText(disabledText: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.ShortcutLabel.setDisabledText(disabledText:)
|
|
/// Sets the text to be displayed by `self` when no accelerator is set.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.ShortcutLabel.setDisabledText(disabledText:)`.
|
|
///
|
|
/// - Parameter disabledText: The text that is displayed when no accelerator is set.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func disabledText(_ disabledText: @escaping () -> String) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setDisabledText(disabledText: disabledText()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Gtk.ShortcutLabel.setDisabledText(disabledText:)
|
|
/// Sets the text to be displayed by `self` when no accelerator is set.
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.ShortcutLabel.setDisabledText(disabledText:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter disabledText: The text that is displayed when no accelerator is set.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func disabledText(_ disabledText: Portico.InterpolatedText) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindInterpolation(disabledText, registry: ctx.registry) { [w] v in w.setDisabledText(disabledText: v) }
|
|
}
|
|
}
|
|
|
|
}
|