portico/Sources/Portico/Generated/SearchEntry.swift

603 lines
33 KiB
Swift

// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
import Adw
import Gtk
import Gio
import Gdk
// PorticoGen: generateStruct | source: Gtk.SearchEntry
/// A single-line text entry widget for use as a search entry.
///
/// The main API for interacting with a `GtkSearchEntry` as entry
/// is the `GtkEditable` interface.
///
/// <picture>
/// <source srcset="search-entry-dark.png" media="(prefers-color-scheme: dark)">
/// <img alt="An example GtkSearchEntry" src="search-entry.png">
/// </picture>
///
/// It will show an inactive symbolic find icon when the search
/// entry is empty, and a symbolic clear icon when there is text.
/// Clicking on the clear icon will empty the search entry.
///
/// To make filtering appear more reactive, it is a good idea to
/// not react to every change in the entry text immediately, but
/// only after a short delay. To support this, `GtkSearchEntry`
/// emits the [signal`Gtk`.SearchEntry::search-changed] signal which
/// can be used instead of the [signal`Gtk`.Editable::changed] signal.
///
/// The [signal`Gtk`.SearchEntry::previous-match],
/// [signal`Gtk`.SearchEntry::next-match] and
/// [signal`Gtk`.SearchEntry::stop-search] signals can be used to
/// implement moving between search results and ending the search.
///
/// Often, `GtkSearchEntry` will be fed events by means of being
/// placed inside a [class`Gtk`.SearchBar]. If that is not the case,
/// you can use [method`Gtk`.SearchEntry.set_key_capture_widget] to
/// let it capture key input from another widget.
///
/// `GtkSearchEntry` provides only minimal API and should be used with
/// the [iface`Gtk`.Editable] API.
///
/// ## Shortcuts and Gestures
///
/// The following signals have default keybindings:
///
/// - [signal`Gtk`.SearchEntry::activate]
/// - [signal`Gtk`.SearchEntry::next-match]
/// - [signal`Gtk`.SearchEntry::previous-match]
/// - [signal`Gtk`.SearchEntry::stop-search]
///
/// ## CSS Nodes
///
/// ```
/// entry.search
/// text
/// ```
///
/// `GtkSearchEntry` has a single CSS node with name entry that carries
/// a `.search` style class, and the text node is a child of that.
///
/// ## Accessibility
///
/// `GtkSearchEntry` uses the [enum`Gtk`.AccessibleRole.search_box] role.
///
/// A Portico view that mounts a `Gtk.SearchEntry`.
@MainActor public struct SearchEntry: View {
private let make: (MountContext) -> Gtk.SearchEntry
private var configure: [(Gtk.SearchEntry, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.SearchEntry.init()
/// Creates a `GtkSearchEntry`.
///
/// 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 inputHints: The hints about input for the `GtkSearchEntry` used to alter the behaviour of input methods.
/// - Parameter inputPurpose: The purpose for the `GtkSearchEntry` input used to alter the behaviour of input methods.
/// - Parameter placeholderText: The text that will be displayed in the `GtkSearchEntry` when it is empty and unfocused.
/// - Parameter searchDelay: The delay in milliseconds from last keypress to the search changed signal.
/// - Parameter keyCaptureWidget: A `ViewBuilder` closure whose first view is mounted into the `keyCaptureWidget` slot.
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
/// - Parameter onNextMatch: Invoked when the widget emits the `next-match` signal.
/// - Parameter onPreviousMatch: Invoked when the widget emits the `previous-match` signal.
/// - Parameter onSearchChanged: Invoked when the widget emits the `search-changed` signal.
/// - Parameter onSearchStarted: Invoked when the widget emits the `search-started` signal.
/// - Parameter onStopSearch: Invoked when the widget emits the `stop-search` signal.
public init(inputHints: Gtk.InputHints? = nil, inputPurpose: Gtk.InputPurpose? = nil, placeholderText: String? = nil, searchDelay: UInt32? = nil, @ViewBuilder keyCaptureWidget: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil, onNextMatch: (() -> Void)? = nil, onPreviousMatch: (() -> Void)? = nil, onSearchChanged: (() -> Void)? = nil, onSearchStarted: (() -> Void)? = nil, onStopSearch: (() -> Void)? = nil) {
make = { _ in Gtk.SearchEntry() }
configure.append { w, ctx in
if let inputHints { w.setInputHints(hints: inputHints) }
if let inputPurpose { w.setInputPurpose(purpose: inputPurpose) }
if let placeholderText { w.setPlaceholderText(text: placeholderText) }
if let searchDelay { w.setSearchDelay(delay: searchDelay) }
if let v = Portico.mountSlotChild(keyCaptureWidget, ctx, onUpdate: { v in w.setKeyCaptureWidget(widget: v) }) { w.setKeyCaptureWidget(widget: v) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
if let onNextMatch { ctx.registry.add(w.connectNextMatch { _ in onNextMatch() }) }
if let onPreviousMatch { ctx.registry.add(w.connectPreviousMatch { _ in onPreviousMatch() }) }
if let onSearchChanged { ctx.registry.add(w.connectSearchChanged { _ in onSearchChanged() }) }
if let onSearchStarted { ctx.registry.add(w.connectSearchStarted { _ in onSearchStarted() }) }
if let onStopSearch { ctx.registry.add(w.connectStopSearch { _ in onStopSearch() }) }
}
}
}
extension SearchEntry: WidgetView {
public typealias Target = Gtk.SearchEntry
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.SearchEntry, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension SearchEntry: Mountable {
@_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget {
let w = make(ctx)
for step in configure { step(w, ctx) }
return w
}
}
// PorticoGen: generateModifierExtension | source: Gtk.SearchEntry
/// Modifiers for `Gtk.SearchEntry`, available on every Portico view whose
/// backing widget is `Gtk.SearchEntry` or one of its subclasses.
extension WidgetView where Target: Gtk.SearchEntry {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.SearchEntry.setInputHints(hints:)
/// Sets the input hints for `entry`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter inputHints: The hints about input for the `GtkSearchEntry` used to alter the behaviour of input methods.
/// - Returns: A copy of this view with the modifier applied.
public func inputHints(_ inputHints: Gtk.InputHints) -> Self {
appending { w, _ in
w.setInputHints(hints: inputHints)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.SearchEntry.setInputHints(hints:), GObject.Object.connectNotify(detail:_:), Gtk.SearchEntry.getInputHints()
/// Sets the input hints for `entry`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.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<Gtk.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: Gtk.SearchEntry.setInputHints(hints:)
/// Sets the input hints for `entry`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.SearchEntry.setInputHints(hints:)`.
///
/// - Parameter inputHints: The hints about input for the `GtkSearchEntry` used to alter the behaviour of input methods.
/// - Returns: A copy of this view with the modifier applied.
public func inputHints(_ inputHints: @escaping () -> Gtk.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: Gtk.SearchEntry.setInputPurpose(purpose:)
/// Sets the input purpose of `entry`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter inputPurpose: The purpose for the `GtkSearchEntry` input used to alter the behaviour of input methods.
/// - Returns: A copy of this view with the modifier applied.
public func inputPurpose(_ inputPurpose: Gtk.InputPurpose) -> Self {
appending { w, _ in
w.setInputPurpose(purpose: inputPurpose)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.SearchEntry.setInputPurpose(purpose:), GObject.Object.connectNotify(detail:_:), Gtk.SearchEntry.getInputPurpose()
/// Sets the input purpose of `entry`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.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<Gtk.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: Gtk.SearchEntry.setInputPurpose(purpose:)
/// Sets the input purpose of `entry`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.SearchEntry.setInputPurpose(purpose:)`.
///
/// - Parameter inputPurpose: The purpose for the `GtkSearchEntry` input used to alter the behaviour of input methods.
/// - Returns: A copy of this view with the modifier applied.
public func inputPurpose(_ inputPurpose: @escaping () -> Gtk.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: Gtk.SearchEntry.setKeyCaptureWidget(widget:)
/// Sets `widget` as the widget that `entry` will capture key
/// events from.
///
/// Key events are consumed by the search entry to start or
/// continue a search.
///
/// If the entry is part of a `GtkSearchBar`, it is preferable
/// to call [method`Gtk`.SearchBar.set_key_capture_widget] instead,
/// which will reveal the entry in addition to triggering the
/// search entry.
///
/// Note that despite the name of this function, the events
/// are only 'captured' in the bubble phase, which means that
/// editable child widgets of `widget` will receive text input
/// before it gets captured. If that is not desired, you can
/// capture and forward the events yourself with
/// [method`Gtk`.EventControllerKey.forward].
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter keyCaptureWidget: The widget that the entry will use to capture key events.
/// - Returns: A copy of this view with the modifier applied.
public func keyCaptureWidget(_ keyCaptureWidget: Gtk.Widget?) -> Self {
appending { w, _ in
w.setKeyCaptureWidget(widget: keyCaptureWidget)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Gtk.SearchEntry.setKeyCaptureWidget(widget:)
/// Sets `widget` as the widget that `entry` will capture key
/// events from.
///
/// Key events are consumed by the search entry to start or
/// continue a search.
///
/// If the entry is part of a `GtkSearchBar`, it is preferable
/// to call [method`Gtk`.SearchBar.set_key_capture_widget] instead,
/// which will reveal the entry in addition to triggering the
/// search entry.
///
/// Note that despite the name of this function, the events
/// are only 'captured' in the bubble phase, which means that
/// editable child widgets of `widget` will receive text input
/// before it gets captured. If that is not desired, you can
/// capture and forward the events yourself with
/// [method`Gtk`.EventControllerKey.forward].
///
/// The closure is evaluated once when the modifier is applied. Its first view is mounted into the slot.
/// Additional views are ignored; an empty closure leaves the slot unset.
///
/// - Parameter keyCaptureWidget: The widget that the entry will use to capture key events.
/// - Returns: A copy of this view with the modifier applied.
public func keyCaptureWidget(@ViewBuilder _ keyCaptureWidget: () -> [AnyView]) -> Self {
let keyCaptureWidgetViews = keyCaptureWidget()
return appending { w, ctx in
guard let v = keyCaptureWidgetViews.first else { return }
w.setKeyCaptureWidget(widget: v.makeWidget(ctx))
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.SearchEntry.setKeyCaptureWidget(widget:), GObject.Object.connectNotify(detail:_:), Gtk.SearchEntry.getKeyCaptureWidget()
/// Sets `widget` as the widget that `entry` will capture key
/// events from.
///
/// Key events are consumed by the search entry to start or
/// continue a search.
///
/// If the entry is part of a `GtkSearchBar`, it is preferable
/// to call [method`Gtk`.SearchBar.set_key_capture_widget] instead,
/// which will reveal the entry in addition to triggering the
/// search entry.
///
/// Note that despite the name of this function, the events
/// are only 'captured' in the bubble phase, which means that
/// editable child widgets of `widget` will receive text input
/// before it gets captured. If that is not desired, you can
/// capture and forward the events yourself with
/// [method`Gtk`.EventControllerKey.forward].
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.Widget?` 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 keyCaptureWidget<W: Gtk.Widget>(_ keyCaptureWidget: Portico.Binding<W?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, keyCaptureWidget, registry: ctx.registry, notifyDetail: "key-capture-widget",
read: { [w] in w.getKeyCaptureWidget() as? W },
write: { [w] v in w.setKeyCaptureWidget(widget: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.SearchEntry.setKeyCaptureWidget(widget:), GObject.Object.connectNotify(detail:_:), Gtk.SearchEntry.getKeyCaptureWidget()
/// Sets `widget` as the widget that `entry` will capture key
/// events from.
///
/// Key events are consumed by the search entry to start or
/// continue a search.
///
/// If the entry is part of a `GtkSearchBar`, it is preferable
/// to call [method`Gtk`.SearchBar.set_key_capture_widget] instead,
/// which will reveal the entry in addition to triggering the
/// search entry.
///
/// Note that despite the name of this function, the events
/// are only 'captured' in the bubble phase, which means that
/// editable child widgets of `widget` will receive text input
/// before it gets captured. If that is not desired, you can
/// capture and forward the events yourself with
/// [method`Gtk`.EventControllerKey.forward].
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Gtk.Widget>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.Widget?>` to be able to clear the property.
/// When `Gtk.Widget` 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 keyCaptureWidget<W: Gtk.Widget>(_ keyCaptureWidget: Portico.Binding<W>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, keyCaptureWidget, registry: ctx.registry, notifyDetail: "key-capture-widget",
read: { [w] in w.getKeyCaptureWidget() as? W },
write: { [w] v in w.setKeyCaptureWidget(widget: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.SearchEntry.setKeyCaptureWidget(widget:)
/// Sets `widget` as the widget that `entry` will capture key
/// events from.
///
/// Key events are consumed by the search entry to start or
/// continue a search.
///
/// If the entry is part of a `GtkSearchBar`, it is preferable
/// to call [method`Gtk`.SearchBar.set_key_capture_widget] instead,
/// which will reveal the entry in addition to triggering the
/// search entry.
///
/// Note that despite the name of this function, the events
/// are only 'captured' in the bubble phase, which means that
/// editable child widgets of `widget` will receive text input
/// before it gets captured. If that is not desired, you can
/// capture and forward the events yourself with
/// [method`Gtk`.EventControllerKey.forward].
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.SearchEntry.setKeyCaptureWidget(widget:)`.
///
/// - Parameter keyCaptureWidget: The widget that the entry will use to capture key events.
/// - Returns: A copy of this view with the modifier applied.
public func keyCaptureWidget(_ keyCaptureWidget: @escaping () -> Gtk.Widget?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setKeyCaptureWidget(widget: keyCaptureWidget()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.SearchEntry.setPlaceholderText(text:)
/// Sets the placeholder text associated with `entry`.
///
/// 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 placeholderText: The text that will be displayed in the `GtkSearchEntry` when it is empty and unfocused.
/// - Returns: A copy of this view with the modifier applied.
@_disfavoredOverload
public func placeholderText<S: StringProtocol>(_ placeholderText: S?) -> Self {
appending { w, _ in
w.setPlaceholderText(text: placeholderText.map { String($0) })
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.SearchEntry.setPlaceholderText(text:), GObject.Object.connectNotify(detail:_:), Gtk.SearchEntry.getPlaceholderText()
/// Sets the placeholder text associated with `entry`.
///
/// 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 placeholderText(_ placeholderText: Portico.Binding<String?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, placeholderText, registry: ctx.registry, notifyDetail: "placeholder-text",
read: { [w] in w.getPlaceholderText() },
write: { [w] v in w.setPlaceholderText(text: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.SearchEntry.setPlaceholderText(text:), GObject.Object.connectNotify(detail:_:), Gtk.SearchEntry.getPlaceholderText()
/// Sets the placeholder text associated with `entry`.
///
/// 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 placeholderText(_ placeholderText: Portico.Binding<String>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, placeholderText, registry: ctx.registry, notifyDetail: "placeholder-text",
read: { [w] in w.getPlaceholderText() },
write: { [w] v in w.setPlaceholderText(text: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.SearchEntry.setPlaceholderText(text:)
/// Sets the placeholder text associated with `entry`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.SearchEntry.setPlaceholderText(text:)`.
///
/// - Parameter placeholderText: The text that will be displayed in the `GtkSearchEntry` when it is empty and unfocused.
/// - Returns: A copy of this view with the modifier applied.
public func placeholderText(_ placeholderText: @escaping () -> String?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setPlaceholderText(text: placeholderText()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Gtk.SearchEntry.setPlaceholderText(text:)
/// Sets the placeholder text associated with `entry`.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.SearchEntry.setPlaceholderText(text:)`. A literal with no interpolation is applied once, with no subscription.
///
/// - Parameter placeholderText: The text that will be displayed in the `GtkSearchEntry` when it is empty and unfocused.
/// - Returns: A copy of this view with the modifier applied.
public func placeholderText(_ placeholderText: Portico.InterpolatedText?) -> Self {
appending { w, ctx in
Portico.bindOptionalInterpolation(placeholderText, registry: ctx.registry) { [w] v in w.setPlaceholderText(text: v) }
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.SearchEntry.setSearchDelay(delay:)
/// Set the delay to be used between the last keypress and the
/// [signal`Gtk`.SearchEntry::search-changed] signal being emitted.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter searchDelay: The delay in milliseconds from last keypress to the search changed signal.
/// - Returns: A copy of this view with the modifier applied.
public func searchDelay(_ searchDelay: UInt32) -> Self {
appending { w, _ in
w.setSearchDelay(delay: searchDelay)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.SearchEntry.setSearchDelay(delay:), GObject.Object.connectNotify(detail:_:), Gtk.SearchEntry.getSearchDelay()
/// Set the delay to be used between the last keypress and the
/// [signal`Gtk`.SearchEntry::search-changed] signal being emitted.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `UInt32` 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 searchDelay(_ searchDelay: Portico.Binding<UInt32>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, searchDelay, registry: ctx.registry, notifyDetail: "search-delay",
read: { [w] in w.getSearchDelay() },
write: { [w] v in w.setSearchDelay(delay: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.SearchEntry.setSearchDelay(delay:)
/// Set the delay to be used between the last keypress and the
/// [signal`Gtk`.SearchEntry::search-changed] signal being emitted.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.SearchEntry.setSearchDelay(delay:)`.
///
/// - Parameter searchDelay: The delay in milliseconds from last keypress to the search changed signal.
/// - Returns: A copy of this view with the modifier applied.
public func searchDelay(_ searchDelay: @escaping () -> UInt32) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setSearchDelay(delay: searchDelay()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.SearchEntry.connectActivate(_:)
/// Emitted when the entry is activated.
///
/// The keybindings for this signal are all forms of the <kbd>Enter</kbd> key.
///
/// - Parameter handler: Invoked when the widget emits the `activate` signal.
/// - Returns: A copy of this view with the modifier applied.
public func onActivate(_ handler: @escaping () -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectActivate { _ in handler() })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.SearchEntry.connectNextMatch(_:)
/// Emitted when the user initiates a move to the next match
/// for the current search string.
///
/// This is a [keybinding signal](class.SignalAction.html).
///
/// Applications should connect to it, to implement moving
/// between matches.
///
/// The default bindings for this signal is <kbd>Ctrl</kbd>+<kbd>g</kbd>.
///
/// - Parameter handler: Invoked when the widget emits the `next-match` signal.
/// - Returns: A copy of this view with the modifier applied.
public func onNextMatch(_ handler: @escaping () -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectNextMatch { _ in handler() })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.SearchEntry.connectPreviousMatch(_:)
/// Emitted when the user initiates a move to the previous match
/// for the current search string.
///
/// This is a [keybinding signal](class.SignalAction.html).
///
/// Applications should connect to it, to implement moving
/// between matches.
///
/// The default bindings for this signal is
/// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>g</kbd>.
///
/// - Parameter handler: Invoked when the widget emits the `previous-match` signal.
/// - Returns: A copy of this view with the modifier applied.
public func onPreviousMatch(_ handler: @escaping () -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectPreviousMatch { _ in handler() })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.SearchEntry.connectSearchChanged(_:)
/// Emitted with a delay. The length of the delay can be
/// changed with the [property`Gtk`.SearchEntry:search-delay]
/// property.
///
/// - Parameter handler: Invoked when the widget emits the `search-changed` signal.
/// - Returns: A copy of this view with the modifier applied.
public func onSearchChanged(_ handler: @escaping () -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectSearchChanged { _ in handler() })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.SearchEntry.connectSearchStarted(_:)
/// Emitted when the user initiated a search on the entry.
///
/// - Parameter handler: Invoked when the widget emits the `search-started` signal.
/// - Returns: A copy of this view with the modifier applied.
public func onSearchStarted(_ handler: @escaping () -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectSearchStarted { _ in handler() })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.SearchEntry.connectStopSearch(_:)
/// Emitted when the user stops a search via keyboard input.
///
/// This is a [keybinding signal](class.SignalAction.html).
///
/// Applications should connect to it, to implement hiding
/// the search entry in this case.
///
/// The default bindings for this signal is <kbd>Escape</kbd>.
///
/// - Parameter handler: Invoked when the widget emits the `stop-search` signal.
/// - Returns: A copy of this view with the modifier applied.
public func onStopSearch(_ handler: @escaping () -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectStopSearch { _ in handler() })
}
}
}