portico/Sources/Portico/Generated/EntryRow.swift

597 lines
32 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.EntryRow
/// A [class`Gtk`.ListBoxRow] with an embedded text entry.
///
/// <picture>
/// <source srcset="entry-row-dark.png" media="(prefers-color-scheme: dark)">
/// <img src="entry-row.png" alt="entry-row">
/// </picture>
///
/// `AdwEntryRow` has a title that doubles as placeholder text. It shows an icon
/// indicating that it's editable and can receive additional widgets before or
/// after the editable part.
///
/// If [property`EntryRow`:show-apply-button] is set to `TRUE`, `AdwEntryRow` can
/// show an apply button when editing its contents. This can be useful if
/// changing its contents can result in an expensive operation, such as network
/// activity.
///
/// `AdwEntryRow` provides only minimal API and should be used with the
/// [iface`Gtk`.Editable] API.
///
/// See also [class`PasswordEntryRow`].
///
/// ## AdwEntryRow as GtkBuildable
///
/// The `AdwEntryRow` implementation of the [iface`Gtk`.Buildable] interface
/// supports adding a child at its end by specifying suffix or omitting the
/// type attribute of a <child> element.
///
/// It also supports adding a child as a prefix widget by specifying prefix as
/// the type attribute of a <child> element.
///
/// ## CSS nodes
///
/// `AdwEntryRow` has a single CSS node with name `row` and the `.entry` style
/// class.
///
/// A Portico view that mounts a `Adw.EntryRow`.
@MainActor public struct EntryRow: View {
private let make: (MountContext) -> Adw.EntryRow
private var configure: [(Adw.EntryRow, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Adw.EntryRow.init()
/// Creates a new `AdwEntryRow`.
///
/// 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 activatesDefault: Whether activating the embedded entry can activate the default widget.
/// - Parameter attributes: A list of Pango attributes to apply to the text of the embedded entry.
/// - Parameter enableEmojiCompletion: Whether to suggest emoji replacements on the entry row.
/// - Parameter inputHints: Additional input hints for the entry row.
/// - Parameter inputPurpose: The input purpose of the entry row.
/// - Parameter maxLength: Maximum number of characters for the entry.
/// - Parameter showApplyButton: Whether to show the apply button.
/// - 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 onApply: Invoked when the widget emits the `apply` signal.
/// - Parameter onEntryActivated: Invoked when the widget emits the `entry-activated` signal.
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
public init(activatesDefault: Bool? = nil, attributes: Adw.AttrList? = nil, enableEmojiCompletion: Bool? = nil, inputHints: Adw.InputHints? = nil, inputPurpose: Adw.InputPurpose? = nil, maxLength: Int32? = nil, showApplyButton: Bool? = nil, title: String? = nil, titleSelectable: Bool? = nil, useMarkup: Bool? = nil, useUnderline: Bool? = nil, activatable: Bool? = nil, selectable: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, onApply: (() -> Void)? = nil, onEntryActivated: (() -> Void)? = nil, onActivate: (() -> Void)? = nil) {
make = { _ in Adw.EntryRow() }
configure.append { w, ctx in
if let activatesDefault { w.setActivatesDefault(activates: activatesDefault) }
if let attributes { w.setAttributes(attributes: attributes) }
if let enableEmojiCompletion { w.setEnableEmojiCompletion(enableEmojiCompletion: enableEmojiCompletion) }
if let inputHints { w.setInputHints(hints: inputHints) }
if let inputPurpose { w.setInputPurpose(purpose: inputPurpose) }
if let maxLength { w.setMaxLength(maxLength: maxLength) }
if let showApplyButton { w.setShowApplyButton(showApplyButton: showApplyButton) }
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 onApply { ctx.registry.add(w.connectApply { _ in onApply() }) }
if let onEntryActivated { ctx.registry.add(w.connectEntryActivated { _ in onEntryActivated() }) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
}
}
}
extension EntryRow: WidgetView {
public typealias Target = Adw.EntryRow
@_spi(Portico) public func appending(
_ step: @escaping (Adw.EntryRow, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension EntryRow: 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.EntryRow
/// Modifiers for `Adw.EntryRow`, available on every Portico view whose
/// backing widget is `Adw.EntryRow` or one of its subclasses.
extension WidgetView where Target: Adw.EntryRow {
// PorticoGen: generateModifierExtension -> generateChildAdderModifiers(static) | source: Adw.EntryRow.addPrefix(widget:)
/// Adds a prefix widget to `self`.
///
/// Applied once at mount; use the `@ViewBuilder` overload for multiple children.
///
/// - Parameter child: A child widget to add.
/// - Returns: A copy of this view with the modifier applied.
public func addPrefix(_ child: Gtk.Widget) -> Self {
appending { w, _ in
w.addPrefix(widget: child)
}
}
// PorticoGen: generateModifierExtension -> generateChildAdderModifiers(viewBuilder) | source: Adw.EntryRow.addPrefix(widget:)
/// Adds a prefix widget to `self`.
///
/// Every view the closure produces is added at mount, in order.
///
/// - Parameter child: A closure producing child views.
/// - Returns: A copy of this view with the modifier applied.
public func addPrefix(@ViewBuilder _ child: () -> [AnyView]) -> Self {
let childViews = child()
return appending { w, ctx in
for v in childViews { w.addPrefix(widget: v.makeWidget(ctx)) }
}
}
// PorticoGen: generateModifierExtension -> generateChildAdderModifiers(static) | source: Adw.EntryRow.addSuffix(widget:)
/// Adds a suffix widget to `self`.
///
/// Applied once at mount; use the `@ViewBuilder` overload for multiple children.
///
/// - Parameter child: A child widget to add.
/// - Returns: A copy of this view with the modifier applied.
public func addSuffix(_ child: Gtk.Widget) -> Self {
appending { w, _ in
w.addSuffix(widget: child)
}
}
// PorticoGen: generateModifierExtension -> generateChildAdderModifiers(viewBuilder) | source: Adw.EntryRow.addSuffix(widget:)
/// Adds a suffix widget to `self`.
///
/// Every view the closure produces is added at mount, in order.
///
/// - Parameter child: A closure producing child views.
/// - Returns: A copy of this view with the modifier applied.
public func addSuffix(@ViewBuilder _ child: () -> [AnyView]) -> Self {
let childViews = child()
return appending { w, ctx in
for v in childViews { w.addSuffix(widget: v.makeWidget(ctx)) }
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.EntryRow.setActivatesDefault(activates:)
/// Sets whether activating the embedded entry can activate the default widget.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter activatesDefault: Whether activating the embedded entry can activate the default widget.
/// - Returns: A copy of this view with the modifier applied.
public func activatesDefault(_ activatesDefault: Bool) -> Self {
appending { w, _ in
w.setActivatesDefault(activates: activatesDefault)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.EntryRow.setActivatesDefault(activates:), GObject.Object.connectNotify(detail:_:), Adw.EntryRow.getActivatesDefault()
/// Sets whether activating the embedded entry can activate the default widget.
///
/// 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 activatesDefault(_ activatesDefault: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, activatesDefault, registry: ctx.registry, notifyDetail: "activates-default",
read: { [w] in w.getActivatesDefault() },
write: { [w] v in w.setActivatesDefault(activates: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.EntryRow.setActivatesDefault(activates:)
/// Sets whether activating the embedded entry can activate the default widget.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.EntryRow.setActivatesDefault(activates:)`.
///
/// - Parameter activatesDefault: Whether activating the embedded entry can activate the default widget.
/// - Returns: A copy of this view with the modifier applied.
public func activatesDefault(_ activatesDefault: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setActivatesDefault(activates: activatesDefault()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.EntryRow.setAttributes(attributes:)
/// Sets Pango attributes to apply to the text of the embedded entry.
///
/// The [struct`Pango`.Attribute]'s `start_index` and `end_index` must refer to
/// the [class`Gtk`.EntryBuffer] text, i.e. without the preedit string.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter attributes: A list of Pango attributes to apply to the text of the embedded entry.
/// - Returns: A copy of this view with the modifier applied.
public func attributes(_ attributes: Adw.AttrList?) -> Self {
appending { w, _ in
w.setAttributes(attributes: attributes)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.EntryRow.setAttributes(attributes:), GObject.Object.connectNotify(detail:_:), Adw.EntryRow.getAttributes()
/// Sets Pango attributes to apply to the text of the embedded entry.
///
/// The [struct`Pango`.Attribute]'s `start_index` and `end_index` must refer to
/// the [class`Gtk`.EntryBuffer] text, i.e. without the preedit string.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.AttrList?` 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 attributes(_ attributes: Portico.Binding<Adw.AttrList?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, attributes, registry: ctx.registry, notifyDetail: "attributes",
read: { [w] in w.getAttributes() },
write: { [w] v in w.setAttributes(attributes: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.EntryRow.setAttributes(attributes:), GObject.Object.connectNotify(detail:_:), Adw.EntryRow.getAttributes()
/// Sets Pango attributes to apply to the text of the embedded entry.
///
/// The [struct`Pango`.Attribute]'s `start_index` and `end_index` must refer to
/// the [class`Gtk`.EntryBuffer] text, i.e. without the preedit string.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Adw.AttrList>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Adw.AttrList?>` to be able to clear the property.
/// When `Adw.AttrList` 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 attributes(_ attributes: Portico.Binding<Adw.AttrList>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, attributes, registry: ctx.registry, notifyDetail: "attributes",
read: { [w] in w.getAttributes() },
write: { [w] v in w.setAttributes(attributes: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.EntryRow.setAttributes(attributes:)
/// Sets Pango attributes to apply to the text of the embedded entry.
///
/// The [struct`Pango`.Attribute]'s `start_index` and `end_index` must refer to
/// the [class`Gtk`.EntryBuffer] text, i.e. without the preedit string.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.EntryRow.setAttributes(attributes:)`.
///
/// - Parameter attributes: A list of Pango attributes to apply to the text of the embedded entry.
/// - Returns: A copy of this view with the modifier applied.
public func attributes(_ attributes: @escaping () -> Adw.AttrList?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setAttributes(attributes: attributes()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.EntryRow.setEnableEmojiCompletion(enableEmojiCompletion:)
/// Sets whether to suggest emoji replacements on `self`.
///
/// Emoji replacement is done with :-delimited names, like `:heart:`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter enableEmojiCompletion: Whether to suggest emoji replacements on the entry row.
/// - Returns: A copy of this view with the modifier applied.
public func enableEmojiCompletion(_ enableEmojiCompletion: Bool) -> Self {
appending { w, _ in
w.setEnableEmojiCompletion(enableEmojiCompletion: enableEmojiCompletion)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.EntryRow.setEnableEmojiCompletion(enableEmojiCompletion:), GObject.Object.connectNotify(detail:_:), Adw.EntryRow.getEnableEmojiCompletion()
/// Sets whether to suggest emoji replacements on `self`.
///
/// Emoji replacement is done with :-delimited names, like `:heart:`.
///
/// 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 enableEmojiCompletion(_ enableEmojiCompletion: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, enableEmojiCompletion, registry: ctx.registry, notifyDetail: "enable-emoji-completion",
read: { [w] in w.getEnableEmojiCompletion() },
write: { [w] v in w.setEnableEmojiCompletion(enableEmojiCompletion: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.EntryRow.setEnableEmojiCompletion(enableEmojiCompletion:)
/// Sets whether to suggest emoji replacements on `self`.
///
/// Emoji replacement is done with :-delimited names, like `:heart:`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.EntryRow.setEnableEmojiCompletion(enableEmojiCompletion:)`.
///
/// - Parameter enableEmojiCompletion: Whether to suggest emoji replacements on the entry row.
/// - Returns: A copy of this view with the modifier applied.
public func enableEmojiCompletion(_ enableEmojiCompletion: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setEnableEmojiCompletion(enableEmojiCompletion: enableEmojiCompletion()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.EntryRow.setInputHints(hints:)
/// Set additional input hints for `self`.
///
/// Input hints allow input methods to fine-tune their behavior.
///
/// See also: [property`AdwEntryRow`:input-purpose]
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter inputHints: Additional input hints for the entry row.
/// - Returns: A copy of this view with the modifier applied.
public func inputHints(_ inputHints: Adw.InputHints) -> Self {
appending { w, _ in
w.setInputHints(hints: inputHints)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.EntryRow.setInputHints(hints:), GObject.Object.connectNotify(detail:_:), Adw.EntryRow.getInputHints()
/// Set additional input hints for `self`.
///
/// Input hints allow input methods to fine-tune their behavior.
///
/// See also: [property`AdwEntryRow`:input-purpose]
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.InputHints` 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 inputHints(_ inputHints: Portico.Binding<Adw.InputHints>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, inputHints, registry: ctx.registry, notifyDetail: "input-hints",
read: { [w] in w.getInputHints() },
write: { [w] v in w.setInputHints(hints: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.EntryRow.setInputHints(hints:)
/// Set additional input hints for `self`.
///
/// Input hints allow input methods to fine-tune their behavior.
///
/// See also: [property`AdwEntryRow`:input-purpose]
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.EntryRow.setInputHints(hints:)`.
///
/// - Parameter inputHints: Additional input hints for the entry row.
/// - Returns: A copy of this view with the modifier applied.
public func inputHints(_ inputHints: @escaping () -> Adw.InputHints) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setInputHints(hints: inputHints()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.EntryRow.setInputPurpose(purpose:)
/// Sets the input purpose of `self`.
///
/// The input purpose can be used by input methods to adjust their behavior.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter inputPurpose: The input purpose of the entry row.
/// - Returns: A copy of this view with the modifier applied.
public func inputPurpose(_ inputPurpose: Adw.InputPurpose) -> Self {
appending { w, _ in
w.setInputPurpose(purpose: inputPurpose)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.EntryRow.setInputPurpose(purpose:), GObject.Object.connectNotify(detail:_:), Adw.EntryRow.getInputPurpose()
/// Sets the input purpose of `self`.
///
/// The input purpose can be used by input methods to adjust their behavior.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.InputPurpose` 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 inputPurpose(_ inputPurpose: Portico.Binding<Adw.InputPurpose>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, inputPurpose, registry: ctx.registry, notifyDetail: "input-purpose",
read: { [w] in w.getInputPurpose() },
write: { [w] v in w.setInputPurpose(purpose: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.EntryRow.setInputPurpose(purpose:)
/// Sets the input purpose of `self`.
///
/// The input purpose can be used by input methods to adjust their behavior.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.EntryRow.setInputPurpose(purpose:)`.
///
/// - Parameter inputPurpose: The input purpose of the entry row.
/// - Returns: A copy of this view with the modifier applied.
public func inputPurpose(_ inputPurpose: @escaping () -> Adw.InputPurpose) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setInputPurpose(purpose: inputPurpose()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.EntryRow.setMaxLength(maxLength:)
/// Sets the maximum length of the entry.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter maxLength: Maximum number of characters for the entry.
/// - Returns: A copy of this view with the modifier applied.
public func maxLength(_ maxLength: Int32) -> Self {
appending { w, _ in
w.setMaxLength(maxLength: maxLength)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.EntryRow.setMaxLength(maxLength:), GObject.Object.connectNotify(detail:_:), Adw.EntryRow.getMaxLength()
/// Sets the maximum length of the entry.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Int32` 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 maxLength(_ maxLength: Portico.Binding<Int32>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, maxLength, registry: ctx.registry, notifyDetail: "max-length",
read: { [w] in w.getMaxLength() },
write: { [w] v in w.setMaxLength(maxLength: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.EntryRow.setMaxLength(maxLength:)
/// Sets the maximum length of the entry.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.EntryRow.setMaxLength(maxLength:)`.
///
/// - Parameter maxLength: Maximum number of characters for the entry.
/// - Returns: A copy of this view with the modifier applied.
public func maxLength(_ maxLength: @escaping () -> Int32) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setMaxLength(maxLength: maxLength()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.EntryRow.setShowApplyButton(showApplyButton:)
/// Sets whether `self` can show the apply button.
///
/// When set to `TRUE`, typing text in the entry will reveal an apply button.
/// Clicking it or pressing the <kbd>Enter</kbd> key will hide the button and
/// emit the [signal`EntryRow`::apply] signal.
///
/// This is useful if changing the entry contents can trigger an expensive
/// operation, e.g. network activity, to avoid triggering it after typing every
/// character.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter showApplyButton: Whether to show the apply button.
/// - Returns: A copy of this view with the modifier applied.
public func showApplyButton(_ showApplyButton: Bool) -> Self {
appending { w, _ in
w.setShowApplyButton(showApplyButton: showApplyButton)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.EntryRow.setShowApplyButton(showApplyButton:), GObject.Object.connectNotify(detail:_:), Adw.EntryRow.getShowApplyButton()
/// Sets whether `self` can show the apply button.
///
/// When set to `TRUE`, typing text in the entry will reveal an apply button.
/// Clicking it or pressing the <kbd>Enter</kbd> key will hide the button and
/// emit the [signal`EntryRow`::apply] signal.
///
/// This is useful if changing the entry contents can trigger an expensive
/// operation, e.g. network activity, to avoid triggering it after typing every
/// character.
///
/// 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 showApplyButton(_ showApplyButton: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, showApplyButton, registry: ctx.registry, notifyDetail: "show-apply-button",
read: { [w] in w.getShowApplyButton() },
write: { [w] v in w.setShowApplyButton(showApplyButton: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.EntryRow.setShowApplyButton(showApplyButton:)
/// Sets whether `self` can show the apply button.
///
/// When set to `TRUE`, typing text in the entry will reveal an apply button.
/// Clicking it or pressing the <kbd>Enter</kbd> key will hide the button and
/// emit the [signal`EntryRow`::apply] signal.
///
/// This is useful if changing the entry contents can trigger an expensive
/// operation, e.g. network activity, to avoid triggering it after typing every
/// character.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.EntryRow.setShowApplyButton(showApplyButton:)`.
///
/// - Parameter showApplyButton: Whether to show the apply button.
/// - Returns: A copy of this view with the modifier applied.
public func showApplyButton(_ showApplyButton: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setShowApplyButton(showApplyButton: showApplyButton()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.EntryRow.connectApply(_:)
/// Emitted when the apply button is pressed.
///
/// See [property`EntryRow`:show-apply-button].
///
/// - Parameter handler: Invoked when the widget emits the `apply` signal.
/// - Returns: A copy of this view with the modifier applied.
public func onApply(_ handler: @escaping () -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectApply { _ in handler() })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.EntryRow.connectEntryActivated(_:)
/// Emitted when the embedded entry is activated.
///
/// - Parameter handler: Invoked when the widget emits the `entry-activated` signal.
/// - Returns: A copy of this view with the modifier applied.
public func onEntryActivated(_ handler: @escaping () -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectEntryActivated { _ in handler() })
}
}
}