portico/Sources/Portico/Generated/Banner.swift

530 lines
29 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.Banner
/// A bar with contextual information.
///
/// <picture>
/// <source srcset="banner-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="banner.png" alt="banner">
/// </picture>
///
/// Banners are hidden by default, use [property`Banner`:revealed] to show them.
///
/// Banners have a title, set with [property`Banner`:title]. Titles can be marked
/// up with Pango markup, use [property`Banner`:use-markup] to enable it.
///
/// The title will be shown centered or left-aligned depending on available
/// space.
///
/// Banners can optionally have a button with text on it, set through
/// [property`Banner`:button-label]. The button can be used with a `GAction`,
/// or with the [signal`Banner`::button-clicked] signal. The button can have
/// different styles, a gray style and a suggested style.
///
/// <picture>
/// <source srcset="banner-suggested-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="banner-suggested.png" alt="banner with suggested button style">
/// </picture>
///
/// ## CSS nodes
///
/// `AdwBanner` has a main CSS node with the name `banner`.
///
/// A Portico view that mounts a `Adw.Banner`.
@MainActor public struct Banner: View {
private let make: (MountContext) -> Adw.Banner
private var configure: [(Adw.Banner, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Adw.Banner.init(title:)
/// Creates a new `AdwBanner`.
///
/// 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 title: The title for this banner.
/// - Parameter buttonLabel: The label to show on the button.
/// - Parameter buttonStyle: The style class to use for the banner button.
/// - Parameter revealed: Whether the banner is currently revealed.
/// - Parameter useMarkup: Whether to use Pango markup for the banner title.
/// - Parameter onButtonClicked: Invoked when the widget emits the `button-clicked` signal.
@_disfavoredOverload
public init<S: StringProtocol>(title: S, buttonLabel: String? = nil, buttonStyle: Adw.BannerButtonStyle? = nil, revealed: Bool? = nil, useMarkup: Bool? = nil, onButtonClicked: (() -> Void)? = nil) {
make = { _ in Adw.Banner(title: String(title)) }
configure.append { w, ctx in
if let buttonLabel { w.setButtonLabel(label: buttonLabel) }
if let buttonStyle { w.setButtonStyle(style: buttonStyle) }
if let revealed { w.setRevealed(revealed: revealed) }
if let useMarkup { w.setUseMarkup(useMarkup: useMarkup) }
if let onButtonClicked { ctx.registry.add(w.connectButtonClicked { _ in onButtonClicked() }) }
}
}
// PorticoGen: generateInits(binding) | source: Adw.Banner.init(title:), Adw.Banner.setTitle(title:)
/// Creates a new `AdwBanner`.
///
/// The initial value is the binding's current value; every later change is pushed into the widget through `Adw.Banner.setTitle(title:)` 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 title: The title for this banner.
/// - Parameter buttonLabel: The label to show on the button.
/// - Parameter buttonStyle: The style class to use for the banner button.
/// - Parameter revealed: Whether the banner is currently revealed.
/// - Parameter useMarkup: Whether to use Pango markup for the banner title.
/// - Parameter onButtonClicked: Invoked when the widget emits the `button-clicked` signal.
public init(title: Portico.Binding<String>, buttonLabel: Portico.Binding<String?>? = nil, buttonStyle: Portico.Binding<Adw.BannerButtonStyle>? = nil, revealed: Portico.Binding<Bool>? = nil, useMarkup: Portico.Binding<Bool>? = nil, onButtonClicked: (() -> Void)? = nil) {
make = { _ in Adw.Banner(title: title.wrappedValue) }
configure.append { w, ctx in
ctx.registry.add(title.subscribe { [w] v in w.setTitle(title: v) })
if let buttonLabel {
Portico.bindProperty(w, buttonLabel, registry: ctx.registry, notifyDetail: "button-label", read: { [w] in w.getButtonLabel() }, write: { [w] v in w.setButtonLabel(label: v) })
}
if let buttonStyle {
Portico.bindProperty(w, buttonStyle, registry: ctx.registry, notifyDetail: "button-style", read: { [w] in w.getButtonStyle() }, write: { [w] v in w.setButtonStyle(style: v) })
}
if let revealed {
Portico.bindProperty(w, revealed, registry: ctx.registry, notifyDetail: "revealed", read: { [w] in w.getRevealed() }, write: { [w] v in w.setRevealed(revealed: v) })
}
if let useMarkup {
Portico.bindProperty(w, useMarkup, registry: ctx.registry, notifyDetail: "use-markup", read: { [w] in w.getUseMarkup() }, write: { [w] v in w.setUseMarkup(useMarkup: v) })
}
if let onButtonClicked { ctx.registry.add(w.connectButtonClicked { _ in onButtonClicked() }) }
}
}
// PorticoGen: generateInits(closure) | source: Adw.Banner.init(title:), Adw.Banner.setTitle(title:)
/// Creates a new `AdwBanner`.
///
/// Each closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Banner.setTitle(title:)`.
/// 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 for this banner.
/// - Parameter buttonLabel: The label to show on the button.
/// - Parameter buttonStyle: The style class to use for the banner button.
/// - Parameter revealed: Whether the banner is currently revealed.
/// - Parameter useMarkup: Whether to use Pango markup for the banner title.
/// - Parameter onButtonClicked: Invoked when the widget emits the `button-clicked` signal.
public init(title: @escaping () -> String, buttonLabel: String? = nil, buttonStyle: Adw.BannerButtonStyle? = nil, revealed: Bool? = nil, useMarkup: Bool? = nil, onButtonClicked: (() -> Void)? = nil) {
make = { _ in Adw.Banner(title: title()) }
configure.append { w, ctx in
let t0 = DependencyTracker { [w] in w.setTitle(title: title()) }
t0.run()
ctx.registry.add(t0)
if let buttonLabel { w.setButtonLabel(label: buttonLabel) }
if let buttonStyle { w.setButtonStyle(style: buttonStyle) }
if let revealed { w.setRevealed(revealed: revealed) }
if let useMarkup { w.setUseMarkup(useMarkup: useMarkup) }
if let onButtonClicked { ctx.registry.add(w.connectButtonClicked { _ in onButtonClicked() }) }
}
}
// PorticoGen: generateInits(interpolation) | source: Adw.Banner.init(title:), Adw.Banner.setTitle(title:)
/// Creates a new `AdwBanner`.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.Banner.setTitle(title:)`. 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 title: The title for this banner.
/// - Parameter buttonLabel: The label to show on the button.
/// - Parameter buttonStyle: The style class to use for the banner button.
/// - Parameter revealed: Whether the banner is currently revealed.
/// - Parameter useMarkup: Whether to use Pango markup for the banner title.
/// - Parameter onButtonClicked: Invoked when the widget emits the `button-clicked` signal.
public init(title: Portico.InterpolatedText, buttonLabel: String? = nil, buttonStyle: Adw.BannerButtonStyle? = nil, revealed: Bool? = nil, useMarkup: Bool? = nil, onButtonClicked: (() -> Void)? = nil) {
make = { _ in Adw.Banner(title: title.untrackedText) }
configure.append { w, ctx in
Portico.bindInterpolation(title, registry: ctx.registry) { [w] v in w.setTitle(title: v) }
if let buttonLabel { w.setButtonLabel(label: buttonLabel) }
if let buttonStyle { w.setButtonStyle(style: buttonStyle) }
if let revealed { w.setRevealed(revealed: revealed) }
if let useMarkup { w.setUseMarkup(useMarkup: useMarkup) }
if let onButtonClicked { ctx.registry.add(w.connectButtonClicked { _ in onButtonClicked() }) }
}
}
}
extension Banner: WidgetView {
public typealias Target = Adw.Banner
@_spi(Portico) public func appending(
_ step: @escaping (Adw.Banner, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension Banner: 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.Banner
/// Modifiers for `Adw.Banner`, available on every Portico view whose
/// backing widget is `Adw.Banner` or one of its subclasses.
extension WidgetView where Target: Adw.Banner {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Banner.setButtonLabel(label:)
/// Sets the button label for `self`.
///
/// If set to `""` or `NULL`, the button won't be shown.
///
/// The button can be used with a `GAction`, or with the
/// [signal`Banner`::button-clicked] signal.
///
/// 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 buttonLabel: The label to show on the button.
/// - Returns: A copy of this view with the modifier applied.
@_disfavoredOverload
public func buttonLabel<S: StringProtocol>(_ buttonLabel: S?) -> Self {
appending { w, _ in
w.setButtonLabel(label: buttonLabel.map { String($0) })
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Banner.setButtonLabel(label:), GObject.Object.connectNotify(detail:_:), Adw.Banner.getButtonLabel()
/// Sets the button label for `self`.
///
/// If set to `""` or `NULL`, the button won't be shown.
///
/// The button can be used with a `GAction`, or with the
/// [signal`Banner`::button-clicked] signal.
///
/// 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 buttonLabel(_ buttonLabel: Portico.Binding<String?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, buttonLabel, registry: ctx.registry, notifyDetail: "button-label",
read: { [w] in w.getButtonLabel() },
write: { [w] v in w.setButtonLabel(label: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.Banner.setButtonLabel(label:), GObject.Object.connectNotify(detail:_:), Adw.Banner.getButtonLabel()
/// Sets the button label for `self`.
///
/// If set to `""` or `NULL`, the button won't be shown.
///
/// The button can be used with a `GAction`, or with the
/// [signal`Banner`::button-clicked] signal.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<String>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<String?>` to be able to clear the property.
/// 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.
/// A `nil` widget value is never written back into the binding.
///
/// - Returns: A copy of this view with the modifier applied.
public func buttonLabel(_ buttonLabel: Portico.Binding<String>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, buttonLabel, registry: ctx.registry, notifyDetail: "button-label",
read: { [w] in w.getButtonLabel() },
write: { [w] v in w.setButtonLabel(label: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Banner.setButtonLabel(label:)
/// Sets the button label for `self`.
///
/// If set to `""` or `NULL`, the button won't be shown.
///
/// The button can be used with a `GAction`, or with the
/// [signal`Banner`::button-clicked] signal.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Banner.setButtonLabel(label:)`.
///
/// - Parameter buttonLabel: The label to show on the button.
/// - Returns: A copy of this view with the modifier applied.
public func buttonLabel(_ buttonLabel: @escaping () -> String?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setButtonLabel(label: buttonLabel()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.Banner.setButtonLabel(label:)
/// Sets the button label for `self`.
///
/// If set to `""` or `NULL`, the button won't be shown.
///
/// The button can be used with a `GAction`, or with the
/// [signal`Banner`::button-clicked] signal.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.Banner.setButtonLabel(label:)`. A literal with no interpolation is applied once, with no subscription.
///
/// - Parameter buttonLabel: The label to show on the button.
/// - Returns: A copy of this view with the modifier applied.
public func buttonLabel(_ buttonLabel: Portico.InterpolatedText?) -> Self {
appending { w, ctx in
Portico.bindOptionalInterpolation(buttonLabel, registry: ctx.registry) { [w] v in w.setButtonLabel(label: v) }
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Banner.setButtonStyle(style:)
/// Sets the style class to use for the banner button.
///
/// When set to [enum`Adw`.BannerButtonStyle.default], the button is grey.
/// When set to [enum`Adw`.BannerButtonStyle.suggested], the button uses the
/// [`.suggested-action`](style-classes.html`suggested`-action) appearance.
///
/// <picture>
/// <source srcset="banner-suggested-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="banner-suggested.png" alt="banner with suggested button style">
/// </picture>
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter buttonStyle: The style class to use for the banner button.
/// - Returns: A copy of this view with the modifier applied.
public func buttonStyle(_ buttonStyle: Adw.BannerButtonStyle) -> Self {
appending { w, _ in
w.setButtonStyle(style: buttonStyle)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Banner.setButtonStyle(style:), GObject.Object.connectNotify(detail:_:), Adw.Banner.getButtonStyle()
/// Sets the style class to use for the banner button.
///
/// When set to [enum`Adw`.BannerButtonStyle.default], the button is grey.
/// When set to [enum`Adw`.BannerButtonStyle.suggested], the button uses the
/// [`.suggested-action`](style-classes.html`suggested`-action) appearance.
///
/// <picture>
/// <source srcset="banner-suggested-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="banner-suggested.png" alt="banner with suggested button style">
/// </picture>
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.BannerButtonStyle` 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 buttonStyle(_ buttonStyle: Portico.Binding<Adw.BannerButtonStyle>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, buttonStyle, registry: ctx.registry, notifyDetail: "button-style",
read: { [w] in w.getButtonStyle() },
write: { [w] v in w.setButtonStyle(style: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Banner.setButtonStyle(style:)
/// Sets the style class to use for the banner button.
///
/// When set to [enum`Adw`.BannerButtonStyle.default], the button is grey.
/// When set to [enum`Adw`.BannerButtonStyle.suggested], the button uses the
/// [`.suggested-action`](style-classes.html`suggested`-action) appearance.
///
/// <picture>
/// <source srcset="banner-suggested-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="banner-suggested.png" alt="banner with suggested button style">
/// </picture>
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Banner.setButtonStyle(style:)`.
///
/// - Parameter buttonStyle: The style class to use for the banner button.
/// - Returns: A copy of this view with the modifier applied.
public func buttonStyle(_ buttonStyle: @escaping () -> Adw.BannerButtonStyle) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setButtonStyle(style: buttonStyle()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Banner.setRevealed(revealed:)
/// Sets whether a banner should be revealed
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter revealed: Whether the banner is currently revealed.
/// - Returns: A copy of this view with the modifier applied.
public func revealed(_ revealed: Bool) -> Self {
appending { w, _ in
w.setRevealed(revealed: revealed)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.Banner.setRevealed(revealed:), GObject.Object.connectNotify(detail:_:), Adw.Banner.getRevealed()
/// Sets whether a banner should be revealed
///
/// 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 revealed(_ revealed: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, revealed, registry: ctx.registry, notifyDetail: "revealed",
read: { [w] in w.getRevealed() },
write: { [w] v in w.setRevealed(revealed: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.Banner.setRevealed(revealed:)
/// Sets whether a banner should be revealed
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Banner.setRevealed(revealed:)`.
///
/// - Parameter revealed: Whether the banner is currently revealed.
/// - Returns: A copy of this view with the modifier applied.
public func revealed(_ revealed: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setRevealed(revealed: revealed()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.Banner.setTitle(title:)
/// Sets the title for this banner.
///
/// See also: [property`Banner`:use-markup].
///
/// 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 for this banner.
/// - 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.Banner.setTitle(title:), GObject.Object.connectNotify(detail:_:), Adw.Banner.getTitle()
/// Sets the title for this banner.
///
/// See also: [property`Banner`:use-markup].
///
/// 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.Banner.setTitle(title:)
/// Sets the title for this banner.
///
/// See also: [property`Banner`:use-markup].
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.Banner.setTitle(title:)`.
///
/// - Parameter title: The title for this banner.
/// - 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.Banner.setTitle(title:)
/// Sets the title for this banner.
///
/// See also: [property`Banner`:use-markup].
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.Banner.setTitle(title:)`. A literal with no interpolation is applied once, with no subscription.
///
/// - Parameter title: The title for this banner.
/// - 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.Banner.setUseMarkup(useMarkup:)
/// Sets whether to use Pango markup for the banner title.
///
/// 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 banner title.
/// - 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.Banner.setUseMarkup(useMarkup:), GObject.Object.connectNotify(detail:_:), Adw.Banner.getUseMarkup()
/// Sets whether to use Pango markup for the banner title.
///
/// 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.Banner.setUseMarkup(useMarkup:)
/// Sets whether to use Pango markup for the banner title.
///
/// 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.Banner.setUseMarkup(useMarkup:)`.
///
/// - Parameter useMarkup: Whether to use Pango markup for the banner title.
/// - 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 -> generateSignalModifier | source: Adw.Banner.connectButtonClicked(_:)
/// This signal is emitted after the action button has been clicked.
///
/// It can be used as an alternative to setting an action.
///
/// - Parameter handler: Invoked when the widget emits the `button-clicked` signal.
/// - Returns: A copy of this view with the modifier applied.
public func onButtonClicked(_ handler: @escaping () -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectButtonClicked { _ in handler() })
}
}
}