portico/Sources/Portico/Generated/Entry.swift

1420 lines
85 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
import Adw
import Gtk
import Gio
import Gdk
// PorticoGen: generateStruct | source: Gtk.Entry
/// A single-line text entry widget.
///
/// <picture>
/// <source srcset="entry-dark.png" media="(prefers-color-scheme: dark)">
/// <img alt="An example GtkEntry" src="entry.png">
/// </picture>
///
/// A fairly large set of key bindings are supported by default. If the
/// entered text is longer than the allocation of the widget, the widget
/// will scroll so that the cursor position is visible.
///
/// When using an entry for passwords and other sensitive information, it
/// can be put into password mode using [method`Gtk`.Entry.set_visibility].
/// In this mode, entered text is displayed using a invisible character.
/// By default, GTK picks the best invisible character that is available
/// in the current font, but it can be changed with
/// [method`Gtk`.Entry.set_invisible_char].
///
/// `GtkEntry` has the ability to display progress or activity
/// information behind the text. To make an entry display such information,
/// use [method`Gtk`.Entry.set_progress_fraction] or
/// [method`Gtk`.Entry.set_progress_pulse_step].
///
/// Additionally, `GtkEntry` can show icons at either side of the entry.
/// These icons can be activatable by clicking, can be set up as drag source
/// and can have tooltips. To add an icon, use
/// [method`Gtk`.Entry.set_icon_from_gicon] or one of the various other functions
/// that set an icon from an icon name or a paintable. To trigger an action when
/// the user clicks an icon, connect to the [signal`Gtk`.Entry::icon-press] signal.
/// To allow DND operations from an icon, use
/// [method`Gtk`.Entry.set_icon_drag_source]. To set a tooltip on an icon, use
/// [method`Gtk`.Entry.set_icon_tooltip_text] or the corresponding function
/// for markup.
///
/// Note that functionality or information that is only available by clicking
/// on an icon in an entry may not be accessible at all to users which are not
/// able to use a mouse or other pointing device. It is therefore recommended
/// that any such functionality should also be available by other means, e.g.
/// via the context menu of the entry.
///
/// # CSS nodes
///
/// ```
/// entry[.flat][.warning][.error]
/// text[.readonly]
/// image.left
/// image.right
/// [progress[.pulse]]
/// ```
///
/// `GtkEntry` has a main node with the name entry. Depending on the properties
/// of the entry, the style classes .read-only and .flat may appear. The style
/// classes .warning and .error may also be used with entries.
///
/// When the entry shows icons, it adds subnodes with the name image and the
/// style class .left or .right, depending on where the icon appears.
///
/// When the entry shows progress, it adds a subnode with the name progress.
/// The node has the style class .pulse when the shown progress is pulsing.
///
/// For all the subnodes added to the text node in various situations,
/// see [class`Gtk`.Text].
///
/// # GtkEntry as GtkBuildable
///
/// The `GtkEntry` implementation of the `GtkBuildable` interface supports a
/// custom `<attributes>` element, which supports any number of `<attribute>`
/// elements. The `<attribute>` element has attributes named name, value,
/// start and end and allows you to specify `PangoAttribute` values for
/// this label.
///
/// An example of a UI definition fragment specifying Pango attributes:
/// ```xml
/// <object class="GtkEntry">
/// <attributes>
/// <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
/// <attribute name="background" value="red" start="5" end="10"/>
/// </attributes>
/// </object>
/// ```
///
/// The start and end attributes specify the range of characters to which the
/// Pango attribute applies. If start and end are not specified, the attribute
/// is applied to the whole text. Note that specifying ranges does not make much
/// sense with translatable attributes. Use markup embedded in the translatable
/// content instead.
///
/// # Accessibility
///
/// `GtkEntry` uses the [enum`Gtk`.AccessibleRole.text_box] role.
///
/// A Portico view that mounts a `Gtk.Entry`.
@MainActor public struct Entry: View {
private let make: (MountContext) -> Gtk.Entry
private var configure: [(Gtk.Entry, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.Entry.init()
/// Creates a new entry.
///
/// Applied once at mount; use the `Binding` or closure overload for values that change.
/// 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 to activate the default widget when Enter is pressed.
/// - Parameter attributes: A list of Pango attributes to apply to the text of the entry.
/// - Parameter completion: The auxiliary completion object to use with the entry.
/// - Parameter extraMenu: A menu model whose contents will be appended to the context menu.
/// - Parameter hasFrame: Whether the entry should draw a frame.
/// - Parameter inputHints: Additional hints that allow input methods to fine-tune their behavior.
/// - Parameter inputPurpose: The purpose of this text field.
/// - Parameter invisibleChar: The character to use when masking entry contents (password mode).
/// - Parameter maxLength: Maximum number of characters for this entry.
/// - Parameter overwriteMode: If text is overwritten when typing in the `GtkEntry`.
/// - Parameter placeholderText: The text that will be displayed in the `GtkEntry` when it is empty and unfocused.
/// - Parameter progressFraction: The current fraction of the task that's been completed.
/// - Parameter progressPulseStep: The fraction of total entry width to move the progress bouncing block for each pulse.
/// - Parameter tabs: A list of tabstops to apply to the text of the entry.
/// - Parameter visibility: Whether the entry should show the invisible char instead of the actual text (password mode).
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
/// - Parameter onIconPress: Invoked when the widget emits the `icon-press` signal. The closure receives the signal's arguments in order.
/// - Parameter onIconRelease: Invoked when the widget emits the `icon-release` signal. The closure receives the signal's arguments in order.
public init(activatesDefault: Bool? = nil, attributes: Gtk.AttrList? = nil, completion: Gtk.EntryCompletion? = nil, extraMenu: Gtk.MenuModel? = nil, hasFrame: Bool? = nil, inputHints: Gtk.InputHints? = nil, inputPurpose: Gtk.InputPurpose? = nil, invisibleChar: UInt32? = nil, maxLength: Int32? = nil, overwriteMode: Bool? = nil, placeholderText: String? = nil, progressFraction: Double? = nil, progressPulseStep: Double? = nil, tabs: Gtk.TabArray? = nil, visibility: Bool? = nil, onActivate: (() -> Void)? = nil, onIconPress: ((Gtk.EntryIconPosition) -> Void)? = nil, onIconRelease: ((Gtk.EntryIconPosition) -> Void)? = nil) {
make = { _ in Gtk.Entry() }
configure.append { w, ctx in
if let activatesDefault { w.setActivatesDefault(setting: activatesDefault) }
if let attributes { w.setAttributes(attrs: attributes) }
if let completion { w.setCompletion(completion: completion) }
if let extraMenu { w.setExtraMenu(model: extraMenu) }
if let hasFrame { w.setHasFrame(setting: hasFrame) }
if let inputHints { w.setInputHints(hints: inputHints) }
if let inputPurpose { w.setInputPurpose(purpose: inputPurpose) }
if let invisibleChar { w.setInvisibleChar(ch: invisibleChar) }
if let maxLength { w.setMaxLength(max: maxLength) }
if let overwriteMode { w.setOverwriteMode(overwrite: overwriteMode) }
if let placeholderText { w.setPlaceholderText(text: placeholderText) }
if let progressFraction { w.setProgressFraction(fraction: progressFraction) }
if let progressPulseStep { w.setProgressPulseStep(fraction: progressPulseStep) }
if let tabs { w.setTabs(tabs: tabs) }
if let visibility { w.setVisibility(visible: visibility) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
if let onIconPress { ctx.registry.add(w.connectIconPress { _, a0 in onIconPress(a0) }) }
if let onIconRelease { ctx.registry.add(w.connectIconRelease { _, a0 in onIconRelease(a0) }) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.Entry.init(buffer:)
/// Creates a new entry with the specified text buffer.
///
/// Applied once at mount; use the `Binding` or closure overload for values that change.
/// 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 buffer: The buffer object which actually stores the text.
/// - Parameter activatesDefault: Whether to activate the default widget when Enter is pressed.
/// - Parameter attributes: A list of Pango attributes to apply to the text of the entry.
/// - Parameter completion: The auxiliary completion object to use with the entry.
/// - Parameter extraMenu: A menu model whose contents will be appended to the context menu.
/// - Parameter hasFrame: Whether the entry should draw a frame.
/// - Parameter inputHints: Additional hints that allow input methods to fine-tune their behavior.
/// - Parameter inputPurpose: The purpose of this text field.
/// - Parameter invisibleChar: The character to use when masking entry contents (password mode).
/// - Parameter maxLength: Maximum number of characters for this entry.
/// - Parameter overwriteMode: If text is overwritten when typing in the `GtkEntry`.
/// - Parameter placeholderText: The text that will be displayed in the `GtkEntry` when it is empty and unfocused.
/// - Parameter progressFraction: The current fraction of the task that's been completed.
/// - Parameter progressPulseStep: The fraction of total entry width to move the progress bouncing block for each pulse.
/// - Parameter tabs: A list of tabstops to apply to the text of the entry.
/// - Parameter visibility: Whether the entry should show the invisible char instead of the actual text (password mode).
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
/// - Parameter onIconPress: Invoked when the widget emits the `icon-press` signal. The closure receives the signal's arguments in order.
/// - Parameter onIconRelease: Invoked when the widget emits the `icon-release` signal. The closure receives the signal's arguments in order.
public init(buffer: Gtk.EntryBuffer, activatesDefault: Bool? = nil, attributes: Gtk.AttrList? = nil, completion: Gtk.EntryCompletion? = nil, extraMenu: Gtk.MenuModel? = nil, hasFrame: Bool? = nil, inputHints: Gtk.InputHints? = nil, inputPurpose: Gtk.InputPurpose? = nil, invisibleChar: UInt32? = nil, maxLength: Int32? = nil, overwriteMode: Bool? = nil, placeholderText: String? = nil, progressFraction: Double? = nil, progressPulseStep: Double? = nil, tabs: Gtk.TabArray? = nil, visibility: Bool? = nil, onActivate: (() -> Void)? = nil, onIconPress: ((Gtk.EntryIconPosition) -> Void)? = nil, onIconRelease: ((Gtk.EntryIconPosition) -> Void)? = nil) {
make = { _ in Gtk.Entry(buffer: buffer) }
configure.append { w, ctx in
if let activatesDefault { w.setActivatesDefault(setting: activatesDefault) }
if let attributes { w.setAttributes(attrs: attributes) }
if let completion { w.setCompletion(completion: completion) }
if let extraMenu { w.setExtraMenu(model: extraMenu) }
if let hasFrame { w.setHasFrame(setting: hasFrame) }
if let inputHints { w.setInputHints(hints: inputHints) }
if let inputPurpose { w.setInputPurpose(purpose: inputPurpose) }
if let invisibleChar { w.setInvisibleChar(ch: invisibleChar) }
if let maxLength { w.setMaxLength(max: maxLength) }
if let overwriteMode { w.setOverwriteMode(overwrite: overwriteMode) }
if let placeholderText { w.setPlaceholderText(text: placeholderText) }
if let progressFraction { w.setProgressFraction(fraction: progressFraction) }
if let progressPulseStep { w.setProgressPulseStep(fraction: progressPulseStep) }
if let tabs { w.setTabs(tabs: tabs) }
if let visibility { w.setVisibility(visible: visibility) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
if let onIconPress { ctx.registry.add(w.connectIconPress { _, a0 in onIconPress(a0) }) }
if let onIconRelease { ctx.registry.add(w.connectIconRelease { _, a0 in onIconRelease(a0) }) }
}
}
// PorticoGen: generateInits(binding) | source: Gtk.Entry.init(buffer:), Gtk.Entry.setBuffer(buffer:)
/// Creates a new entry with the specified text buffer.
///
/// The initial value is the binding's current value; every later change is pushed into the widget through `Gtk.Entry.setBuffer(buffer:)` 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 buffer: The buffer object which actually stores the text.
/// - Parameter activatesDefault: Whether to activate the default widget when Enter is pressed.
/// - Parameter attributes: A list of Pango attributes to apply to the text of the entry.
/// - Parameter completion: The auxiliary completion object to use with the entry.
/// - Parameter extraMenu: A menu model whose contents will be appended to the context menu.
/// - Parameter hasFrame: Whether the entry should draw a frame.
/// - Parameter inputHints: Additional hints that allow input methods to fine-tune their behavior.
/// - Parameter inputPurpose: The purpose of this text field.
/// - Parameter invisibleChar: The character to use when masking entry contents (password mode).
/// - Parameter maxLength: Maximum number of characters for this entry.
/// - Parameter overwriteMode: If text is overwritten when typing in the `GtkEntry`.
/// - Parameter placeholderText: The text that will be displayed in the `GtkEntry` when it is empty and unfocused.
/// - Parameter progressFraction: The current fraction of the task that's been completed.
/// - Parameter progressPulseStep: The fraction of total entry width to move the progress bouncing block for each pulse.
/// - Parameter tabs: A list of tabstops to apply to the text of the entry.
/// - Parameter visibility: Whether the entry should show the invisible char instead of the actual text (password mode).
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
/// - Parameter onIconPress: Invoked when the widget emits the `icon-press` signal. The closure receives the signal's arguments in order.
/// - Parameter onIconRelease: Invoked when the widget emits the `icon-release` signal. The closure receives the signal's arguments in order.
public init(buffer: Portico.Binding<Gtk.EntryBuffer>, activatesDefault: Portico.Binding<Bool>? = nil, attributes: Portico.Binding<Gtk.AttrList>? = nil, completion: Portico.Binding<Gtk.EntryCompletion?>? = nil, extraMenu: Portico.Binding<Gtk.MenuModel?>? = nil, hasFrame: Portico.Binding<Bool>? = nil, inputHints: Portico.Binding<Gtk.InputHints>? = nil, inputPurpose: Portico.Binding<Gtk.InputPurpose>? = nil, invisibleChar: Portico.Binding<UInt32>? = nil, maxLength: Portico.Binding<Int32>? = nil, overwriteMode: Portico.Binding<Bool>? = nil, placeholderText: Portico.Binding<String?>? = nil, progressFraction: Portico.Binding<Double>? = nil, progressPulseStep: Portico.Binding<Double>? = nil, tabs: Portico.Binding<Gtk.TabArray?>? = nil, visibility: Portico.Binding<Bool>? = nil, onActivate: (() -> Void)? = nil, onIconPress: ((Gtk.EntryIconPosition) -> Void)? = nil, onIconRelease: ((Gtk.EntryIconPosition) -> Void)? = nil) {
make = { _ in Gtk.Entry(buffer: buffer.wrappedValue) }
configure.append { w, ctx in
ctx.registry.add(buffer.subscribe { [w] v in w.setBuffer(buffer: v) })
if let activatesDefault {
Portico.bindProperty(w, activatesDefault, registry: ctx.registry, notifyDetail: "activates-default", read: { [w] in w.getActivatesDefault() }, write: { [w] v in w.setActivatesDefault(setting: v) })
}
if let attributes {
Portico.bindProperty(w, attributes, registry: ctx.registry, notifyDetail: "attributes", read: { [w] in w.getAttributes() }, write: { [w] v in w.setAttributes(attrs: v) })
}
if let completion {
Portico.bindProperty(w, completion, registry: ctx.registry, notifyDetail: "completion", read: { [w] in w.getCompletion() }, write: { [w] v in w.setCompletion(completion: v) })
}
if let extraMenu {
Portico.bindProperty(w, extraMenu, registry: ctx.registry, notifyDetail: "extra-menu", read: { [w] in w.getExtraMenu() }, write: { [w] v in w.setExtraMenu(model: v) })
}
if let hasFrame {
Portico.bindProperty(w, hasFrame, registry: ctx.registry, notifyDetail: "has-frame", read: { [w] in w.getHasFrame() }, write: { [w] v in w.setHasFrame(setting: v) })
}
if let inputHints {
Portico.bindProperty(w, inputHints, registry: ctx.registry, notifyDetail: "input-hints", read: { [w] in w.getInputHints() }, write: { [w] v in w.setInputHints(hints: v) })
}
if let inputPurpose {
Portico.bindProperty(w, inputPurpose, registry: ctx.registry, notifyDetail: "input-purpose", read: { [w] in w.getInputPurpose() }, write: { [w] v in w.setInputPurpose(purpose: v) })
}
if let invisibleChar {
Portico.bindProperty(w, invisibleChar, registry: ctx.registry, notifyDetail: "invisible-char", read: { [w] in w.getInvisibleChar() }, write: { [w] v in w.setInvisibleChar(ch: v) })
}
if let maxLength {
Portico.bindProperty(w, maxLength, registry: ctx.registry, notifyDetail: "max-length", read: { [w] in w.getMaxLength() }, write: { [w] v in w.setMaxLength(max: v) })
}
if let overwriteMode {
Portico.bindProperty(w, overwriteMode, registry: ctx.registry, notifyDetail: "overwrite-mode", read: { [w] in w.getOverwriteMode() }, write: { [w] v in w.setOverwriteMode(overwrite: v) })
}
if let placeholderText {
Portico.bindProperty(w, placeholderText, registry: ctx.registry, notifyDetail: "placeholder-text", read: { [w] in w.getPlaceholderText() }, write: { [w] v in w.setPlaceholderText(text: v) })
}
if let progressFraction {
Portico.bindProperty(w, progressFraction, registry: ctx.registry, notifyDetail: "progress-fraction", read: { [w] in w.getProgressFraction() }, write: { [w] v in w.setProgressFraction(fraction: v) })
}
if let progressPulseStep {
Portico.bindProperty(w, progressPulseStep, registry: ctx.registry, notifyDetail: "progress-pulse-step", read: { [w] in w.getProgressPulseStep() }, write: { [w] v in w.setProgressPulseStep(fraction: v) })
}
if let tabs {
Portico.bindProperty(w, tabs, registry: ctx.registry, notifyDetail: "tabs", read: { [w] in w.getTabs() }, write: { [w] v in w.setTabs(tabs: v) })
}
if let visibility {
Portico.bindProperty(w, visibility, registry: ctx.registry, notifyDetail: "visibility", read: { [w] in w.getVisibility() }, write: { [w] v in w.setVisibility(visible: v) })
}
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
if let onIconPress { ctx.registry.add(w.connectIconPress { _, a0 in onIconPress(a0) }) }
if let onIconRelease { ctx.registry.add(w.connectIconRelease { _, a0 in onIconRelease(a0) }) }
}
}
// PorticoGen: generateInits(closure) | source: Gtk.Entry.init(buffer:), Gtk.Entry.setBuffer(buffer:)
/// Creates a new entry with the specified text buffer.
///
/// Each closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Entry.setBuffer(buffer:)`.
/// 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 buffer: The buffer object which actually stores the text.
/// - Parameter activatesDefault: Whether to activate the default widget when Enter is pressed.
/// - Parameter attributes: A list of Pango attributes to apply to the text of the entry.
/// - Parameter completion: The auxiliary completion object to use with the entry.
/// - Parameter extraMenu: A menu model whose contents will be appended to the context menu.
/// - Parameter hasFrame: Whether the entry should draw a frame.
/// - Parameter inputHints: Additional hints that allow input methods to fine-tune their behavior.
/// - Parameter inputPurpose: The purpose of this text field.
/// - Parameter invisibleChar: The character to use when masking entry contents (password mode).
/// - Parameter maxLength: Maximum number of characters for this entry.
/// - Parameter overwriteMode: If text is overwritten when typing in the `GtkEntry`.
/// - Parameter placeholderText: The text that will be displayed in the `GtkEntry` when it is empty and unfocused.
/// - Parameter progressFraction: The current fraction of the task that's been completed.
/// - Parameter progressPulseStep: The fraction of total entry width to move the progress bouncing block for each pulse.
/// - Parameter tabs: A list of tabstops to apply to the text of the entry.
/// - Parameter visibility: Whether the entry should show the invisible char instead of the actual text (password mode).
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
/// - Parameter onIconPress: Invoked when the widget emits the `icon-press` signal. The closure receives the signal's arguments in order.
/// - Parameter onIconRelease: Invoked when the widget emits the `icon-release` signal. The closure receives the signal's arguments in order.
public init(buffer: @escaping () -> Gtk.EntryBuffer, activatesDefault: Bool? = nil, attributes: Gtk.AttrList? = nil, completion: Gtk.EntryCompletion? = nil, extraMenu: Gtk.MenuModel? = nil, hasFrame: Bool? = nil, inputHints: Gtk.InputHints? = nil, inputPurpose: Gtk.InputPurpose? = nil, invisibleChar: UInt32? = nil, maxLength: Int32? = nil, overwriteMode: Bool? = nil, placeholderText: String? = nil, progressFraction: Double? = nil, progressPulseStep: Double? = nil, tabs: Gtk.TabArray? = nil, visibility: Bool? = nil, onActivate: (() -> Void)? = nil, onIconPress: ((Gtk.EntryIconPosition) -> Void)? = nil, onIconRelease: ((Gtk.EntryIconPosition) -> Void)? = nil) {
make = { _ in Gtk.Entry(buffer: buffer()) }
configure.append { w, ctx in
let t0 = DependencyTracker { [w] in w.setBuffer(buffer: buffer()) }
t0.run()
ctx.registry.add(t0)
if let activatesDefault { w.setActivatesDefault(setting: activatesDefault) }
if let attributes { w.setAttributes(attrs: attributes) }
if let completion { w.setCompletion(completion: completion) }
if let extraMenu { w.setExtraMenu(model: extraMenu) }
if let hasFrame { w.setHasFrame(setting: hasFrame) }
if let inputHints { w.setInputHints(hints: inputHints) }
if let inputPurpose { w.setInputPurpose(purpose: inputPurpose) }
if let invisibleChar { w.setInvisibleChar(ch: invisibleChar) }
if let maxLength { w.setMaxLength(max: maxLength) }
if let overwriteMode { w.setOverwriteMode(overwrite: overwriteMode) }
if let placeholderText { w.setPlaceholderText(text: placeholderText) }
if let progressFraction { w.setProgressFraction(fraction: progressFraction) }
if let progressPulseStep { w.setProgressPulseStep(fraction: progressPulseStep) }
if let tabs { w.setTabs(tabs: tabs) }
if let visibility { w.setVisibility(visible: visibility) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
if let onIconPress { ctx.registry.add(w.connectIconPress { _, a0 in onIconPress(a0) }) }
if let onIconRelease { ctx.registry.add(w.connectIconRelease { _, a0 in onIconRelease(a0) }) }
}
}
}
extension Entry: WidgetView {
public typealias Target = Gtk.Entry
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.Entry, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension Entry: 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.Entry
/// Modifiers for `Gtk.Entry`, available on every Portico view whose
/// backing widget is `Gtk.Entry` or one of its subclasses.
extension WidgetView where Target: Gtk.Entry {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Entry.setActivatesDefault(setting:)
/// Sets whether pressing Enter in the `entry` will activate the default
/// widget for the window containing the entry.
///
/// This usually means that the dialog containing the entry will be closed,
/// since the default widget is usually one of the dialog buttons.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter activatesDefault: Whether to activate the default widget when Enter is pressed.
/// - Returns: A copy of this view with the modifier applied.
public func activatesDefault(_ activatesDefault: Bool) -> Self {
appending { w, _ in
w.setActivatesDefault(setting: activatesDefault)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Entry.setActivatesDefault(setting:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getActivatesDefault()
/// Sets whether pressing Enter in the `entry` will activate the default
/// widget for the window containing the entry.
///
/// This usually means that the dialog containing the entry will be closed,
/// since the default widget is usually one of the dialog buttons.
///
/// 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(setting: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Entry.setActivatesDefault(setting:)
/// Sets whether pressing Enter in the `entry` will activate the default
/// widget for the window containing the entry.
///
/// This usually means that the dialog containing the entry will be closed,
/// since the default widget is usually one of the dialog buttons.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Entry.setActivatesDefault(setting:)`.
///
/// - Parameter activatesDefault: Whether to activate the default widget when Enter is pressed.
/// - 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(setting: activatesDefault()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Entry.setAttributes(attrs:)
/// Sets a `PangoAttrList`.
///
/// The attributes in the list are applied to the entry text.
///
/// Since the attributes will be applied to text that changes
/// as the user types, it makes most sense to use attributes
/// with unlimited extent.
///
/// 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 entry.
/// - Returns: A copy of this view with the modifier applied.
public func attributes(_ attributes: Gtk.AttrList) -> Self {
appending { w, _ in
w.setAttributes(attrs: attributes)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Entry.setAttributes(attrs:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getAttributes()
/// Sets a `PangoAttrList`.
///
/// The attributes in the list are applied to the entry text.
///
/// Since the attributes will be applied to text that changes
/// as the user types, it makes most sense to use attributes
/// with unlimited extent.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.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<Gtk.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(attrs: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lowered) | source: Gtk.Entry.setAttributes(attrs:)
/// Sets a `PangoAttrList`.
///
/// The attributes in the list are applied to the entry text.
///
/// Since the attributes will be applied to text that changes
/// as the user types, it makes most sense to use attributes
/// with unlimited extent.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant and this property has no unset state; this overload accepts a nullable binding and ignores `nil` values. Binds one way only.
///
/// - Returns: A copy of this view with the modifier applied.
public func attributes(_ attributes: Portico.Binding<Gtk.AttrList?>) -> Self {
appending { w, ctx in
if let v = attributes.untrackedValue { w.setAttributes(attrs: v) }
ctx.registry.add(attributes.subscribe { [w] v in if let v { w.setAttributes(attrs: v) } })
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Entry.setAttributes(attrs:)
/// Sets a `PangoAttrList`.
///
/// The attributes in the list are applied to the entry text.
///
/// Since the attributes will be applied to text that changes
/// as the user types, it makes most sense to use attributes
/// with unlimited extent.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Entry.setAttributes(attrs:)`.
///
/// - Parameter attributes: A list of Pango attributes to apply to the text of the entry.
/// - Returns: A copy of this view with the modifier applied.
public func attributes(_ attributes: @escaping () -> Gtk.AttrList) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setAttributes(attrs: attributes()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Entry.setBuffer(buffer:)
/// Set the `GtkEntryBuffer` object which holds the text for
/// this widget.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter buffer: The buffer object which actually stores the text.
/// - Returns: A copy of this view with the modifier applied.
public func buffer(_ buffer: Gtk.EntryBuffer) -> Self {
appending { w, _ in
w.setBuffer(buffer: buffer)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Entry.setBuffer(buffer:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getBuffer()
/// Set the `GtkEntryBuffer` object which holds the text for
/// this widget.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.EntryBuffer` 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 buffer(_ buffer: Portico.Binding<Gtk.EntryBuffer>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, buffer, registry: ctx.registry, notifyDetail: "buffer",
read: { [w] in w.getBuffer() },
write: { [w] v in w.setBuffer(buffer: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Entry.setBuffer(buffer:)
/// Set the `GtkEntryBuffer` object which holds the text for
/// this widget.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Entry.setBuffer(buffer:)`.
///
/// - Parameter buffer: The buffer object which actually stores the text.
/// - Returns: A copy of this view with the modifier applied.
public func buffer(_ buffer: @escaping () -> Gtk.EntryBuffer) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setBuffer(buffer: buffer()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Entry.setCompletion(completion:)
/// Sets `completion` to be the auxiliary completion object
/// to use with `entry`.
///
/// All further configuration of the completion mechanism is
/// done on `completion` using the `GtkEntryCompletion` API.
/// Completion is disabled if `completion` is set to `nil`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter completion: The auxiliary completion object to use with the entry.
/// - Returns: A copy of this view with the modifier applied.
public func completion(_ completion: Gtk.EntryCompletion?) -> Self {
appending { w, _ in
w.setCompletion(completion: completion)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Entry.setCompletion(completion:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getCompletion()
/// Sets `completion` to be the auxiliary completion object
/// to use with `entry`.
///
/// All further configuration of the completion mechanism is
/// done on `completion` using the `GtkEntryCompletion` API.
/// Completion is disabled if `completion` is set to `nil`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.EntryCompletion?` 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 completion(_ completion: Portico.Binding<Gtk.EntryCompletion?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, completion, registry: ctx.registry, notifyDetail: "completion",
read: { [w] in w.getCompletion() },
write: { [w] v in w.setCompletion(completion: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.Entry.setCompletion(completion:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getCompletion()
/// Sets `completion` to be the auxiliary completion object
/// to use with `entry`.
///
/// All further configuration of the completion mechanism is
/// done on `completion` using the `GtkEntryCompletion` API.
/// Completion is disabled if `completion` is set to `nil`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Gtk.EntryCompletion>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.EntryCompletion?>` to be able to clear the property.
/// When `Gtk.EntryCompletion` 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 completion(_ completion: Portico.Binding<Gtk.EntryCompletion>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, completion, registry: ctx.registry, notifyDetail: "completion",
read: { [w] in w.getCompletion() },
write: { [w] v in w.setCompletion(completion: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Entry.setCompletion(completion:)
/// Sets `completion` to be the auxiliary completion object
/// to use with `entry`.
///
/// All further configuration of the completion mechanism is
/// done on `completion` using the `GtkEntryCompletion` API.
/// Completion is disabled if `completion` is set to `nil`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Entry.setCompletion(completion:)`.
///
/// - Parameter completion: The auxiliary completion object to use with the entry.
/// - Returns: A copy of this view with the modifier applied.
public func completion(_ completion: @escaping () -> Gtk.EntryCompletion?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setCompletion(completion: completion()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Entry.setExtraMenu(model:)
/// Sets a menu model to add when constructing
/// the context menu for `entry`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter extraMenu: A menu model whose contents will be appended to the context menu.
/// - Returns: A copy of this view with the modifier applied.
public func extraMenu(_ extraMenu: Gtk.MenuModel?) -> Self {
appending { w, _ in
w.setExtraMenu(model: extraMenu)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Entry.setExtraMenu(model:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getExtraMenu()
/// Sets a menu model to add when constructing
/// the context menu for `entry`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.MenuModel?` 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 extraMenu(_ extraMenu: Portico.Binding<Gtk.MenuModel?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, extraMenu, registry: ctx.registry, notifyDetail: "extra-menu",
read: { [w] in w.getExtraMenu() },
write: { [w] v in w.setExtraMenu(model: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.Entry.setExtraMenu(model:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getExtraMenu()
/// Sets a menu model to add when constructing
/// the context menu for `entry`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Gtk.MenuModel>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.MenuModel?>` to be able to clear the property.
/// When `Gtk.MenuModel` 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 extraMenu(_ extraMenu: Portico.Binding<Gtk.MenuModel>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, extraMenu, registry: ctx.registry, notifyDetail: "extra-menu",
read: { [w] in w.getExtraMenu() },
write: { [w] v in w.setExtraMenu(model: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Entry.setExtraMenu(model:)
/// Sets a menu model to add when constructing
/// the context menu for `entry`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Entry.setExtraMenu(model:)`.
///
/// - Parameter extraMenu: A menu model whose contents will be appended to the context menu.
/// - Returns: A copy of this view with the modifier applied.
public func extraMenu(_ extraMenu: @escaping () -> Gtk.MenuModel?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setExtraMenu(model: extraMenu()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Entry.setHasFrame(setting:)
/// Sets whether the entry has a beveled frame around it.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter hasFrame: Whether the entry should draw a frame.
/// - Returns: A copy of this view with the modifier applied.
public func hasFrame(_ hasFrame: Bool) -> Self {
appending { w, _ in
w.setHasFrame(setting: hasFrame)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Entry.setHasFrame(setting:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getHasFrame()
/// Sets whether the entry has a beveled frame around it.
///
/// 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 hasFrame(_ hasFrame: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, hasFrame, registry: ctx.registry, notifyDetail: "has-frame",
read: { [w] in w.getHasFrame() },
write: { [w] v in w.setHasFrame(setting: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Entry.setHasFrame(setting:)
/// Sets whether the entry has a beveled frame around it.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Entry.setHasFrame(setting:)`.
///
/// - Parameter hasFrame: Whether the entry should draw a frame.
/// - Returns: A copy of this view with the modifier applied.
public func hasFrame(_ hasFrame: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setHasFrame(setting: hasFrame()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Entry.setInputHints(hints:)
/// Set additional hints which allow input methods to
/// fine-tune their behavior.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter inputHints: Additional hints that allow input methods to fine-tune their behavior.
/// - 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.Entry.setInputHints(hints:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getInputHints()
/// Set additional hints which allow input methods to
/// fine-tune their behavior.
///
/// 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.Entry.setInputHints(hints:)
/// Set additional hints which allow input methods to
/// fine-tune their behavior.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Entry.setInputHints(hints:)`.
///
/// - Parameter inputHints: Additional hints that allow input methods to fine-tune their behavior.
/// - 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.Entry.setInputPurpose(purpose:)
/// Sets the input purpose which 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 purpose of this text field.
/// - 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.Entry.setInputPurpose(purpose:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getInputPurpose()
/// Sets the input purpose which can be used by input methods
/// to adjust their behavior.
///
/// 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.Entry.setInputPurpose(purpose:)
/// Sets the input purpose which 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 `Gtk.Entry.setInputPurpose(purpose:)`.
///
/// - Parameter inputPurpose: The purpose of this text field.
/// - 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.Entry.setInvisibleChar(ch:)
/// Sets the character to use in place of the actual text
/// in password mode.
///
/// See [method`Gtk`.Entry.set_visibility] for how to enable
/// password mode.
///
/// By default, GTK picks the best invisible char available in
/// the current font. If you set the invisible char to 0, then
/// the user will get no feedback at all; there will be no text
/// on the screen as they type.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter invisibleChar: The character to use when masking entry contents (password mode).
/// - Returns: A copy of this view with the modifier applied.
public func invisibleChar(_ invisibleChar: UInt32) -> Self {
appending { w, _ in
w.setInvisibleChar(ch: invisibleChar)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Entry.setInvisibleChar(ch:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getInvisibleChar()
/// Sets the character to use in place of the actual text
/// in password mode.
///
/// See [method`Gtk`.Entry.set_visibility] for how to enable
/// password mode.
///
/// By default, GTK picks the best invisible char available in
/// the current font. If you set the invisible char to 0, then
/// the user will get no feedback at all; there will be no text
/// on the screen as they type.
///
/// 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 invisibleChar(_ invisibleChar: Portico.Binding<UInt32>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, invisibleChar, registry: ctx.registry, notifyDetail: "invisible-char",
read: { [w] in w.getInvisibleChar() },
write: { [w] v in w.setInvisibleChar(ch: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Entry.setInvisibleChar(ch:)
/// Sets the character to use in place of the actual text
/// in password mode.
///
/// See [method`Gtk`.Entry.set_visibility] for how to enable
/// password mode.
///
/// By default, GTK picks the best invisible char available in
/// the current font. If you set the invisible char to 0, then
/// the user will get no feedback at all; there will be no text
/// on the screen as they type.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Entry.setInvisibleChar(ch:)`.
///
/// - Parameter invisibleChar: The character to use when masking entry contents (password mode).
/// - Returns: A copy of this view with the modifier applied.
public func invisibleChar(_ invisibleChar: @escaping () -> UInt32) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setInvisibleChar(ch: invisibleChar()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Entry.setMaxLength(max:)
/// Sets the maximum allowed length of the contents of the widget.
///
/// If the current contents are longer than the given length, then
/// they will be truncated to fit. The length is in characters.
///
/// This is equivalent to getting `entry`'s `GtkEntryBuffer` and
/// calling [method`Gtk`.EntryBuffer.set_max_length] on it.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter maxLength: Maximum number of characters for this entry.
/// - Returns: A copy of this view with the modifier applied.
public func maxLength(_ maxLength: Int32) -> Self {
appending { w, _ in
w.setMaxLength(max: maxLength)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Entry.setMaxLength(max:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getMaxLength()
/// Sets the maximum allowed length of the contents of the widget.
///
/// If the current contents are longer than the given length, then
/// they will be truncated to fit. The length is in characters.
///
/// This is equivalent to getting `entry`'s `GtkEntryBuffer` and
/// calling [method`Gtk`.EntryBuffer.set_max_length] on it.
///
/// 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(max: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Entry.setMaxLength(max:)
/// Sets the maximum allowed length of the contents of the widget.
///
/// If the current contents are longer than the given length, then
/// they will be truncated to fit. The length is in characters.
///
/// This is equivalent to getting `entry`'s `GtkEntryBuffer` and
/// calling [method`Gtk`.EntryBuffer.set_max_length] on it.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Entry.setMaxLength(max:)`.
///
/// - Parameter maxLength: Maximum number of characters for this 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(max: maxLength()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Entry.setOverwriteMode(overwrite:)
/// Sets whether the text is overwritten when typing in the `GtkEntry`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter overwriteMode: If text is overwritten when typing in the `GtkEntry`.
/// - Returns: A copy of this view with the modifier applied.
public func overwriteMode(_ overwriteMode: Bool) -> Self {
appending { w, _ in
w.setOverwriteMode(overwrite: overwriteMode)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Entry.setOverwriteMode(overwrite:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getOverwriteMode()
/// Sets whether the text is overwritten when typing in the `GtkEntry`.
///
/// 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 overwriteMode(_ overwriteMode: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, overwriteMode, registry: ctx.registry, notifyDetail: "overwrite-mode",
read: { [w] in w.getOverwriteMode() },
write: { [w] v in w.setOverwriteMode(overwrite: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Entry.setOverwriteMode(overwrite:)
/// Sets whether the text is overwritten when typing in the `GtkEntry`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Entry.setOverwriteMode(overwrite:)`.
///
/// - Parameter overwriteMode: If text is overwritten when typing in the `GtkEntry`.
/// - Returns: A copy of this view with the modifier applied.
public func overwriteMode(_ overwriteMode: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setOverwriteMode(overwrite: overwriteMode()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Entry.setPlaceholderText(text:)
/// Sets text to be displayed in `entry` when it is empty.
///
/// This can be used to give a visual hint of the expected
/// contents of the `GtkEntry`.
///
/// 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 `GtkEntry` 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.Entry.setPlaceholderText(text:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getPlaceholderText()
/// Sets text to be displayed in `entry` when it is empty.
///
/// This can be used to give a visual hint of the expected
/// contents of the `GtkEntry`.
///
/// 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.Entry.setPlaceholderText(text:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getPlaceholderText()
/// Sets text to be displayed in `entry` when it is empty.
///
/// This can be used to give a visual hint of the expected
/// contents of the `GtkEntry`.
///
/// 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.Entry.setPlaceholderText(text:)
/// Sets text to be displayed in `entry` when it is empty.
///
/// This can be used to give a visual hint of the expected
/// contents of the `GtkEntry`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Entry.setPlaceholderText(text:)`.
///
/// - Parameter placeholderText: The text that will be displayed in the `GtkEntry` 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.Entry.setPlaceholderText(text:)
/// Sets text to be displayed in `entry` when it is empty.
///
/// This can be used to give a visual hint of the expected
/// contents of the `GtkEntry`.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.Entry.setPlaceholderText(text:)`. A literal with no interpolation is applied once, with no subscription.
///
/// - Parameter placeholderText: The text that will be displayed in the `GtkEntry` 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.Entry.setProgressFraction(fraction:)
/// Causes the entrys progress indicator to fill in the given
/// fraction of the bar.
///
/// The fraction should be between 0.0 and 1.0, inclusive.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter progressFraction: The current fraction of the task that's been completed.
/// - Returns: A copy of this view with the modifier applied.
public func progressFraction(_ progressFraction: Double) -> Self {
appending { w, _ in
w.setProgressFraction(fraction: progressFraction)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Entry.setProgressFraction(fraction:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getProgressFraction()
/// Causes the entrys progress indicator to fill in the given
/// fraction of the bar.
///
/// The fraction should be between 0.0 and 1.0, inclusive.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Double` 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 progressFraction(_ progressFraction: Portico.Binding<Double>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, progressFraction, registry: ctx.registry, notifyDetail: "progress-fraction",
read: { [w] in w.getProgressFraction() },
write: { [w] v in w.setProgressFraction(fraction: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Entry.setProgressFraction(fraction:)
/// Causes the entrys progress indicator to fill in the given
/// fraction of the bar.
///
/// The fraction should be between 0.0 and 1.0, inclusive.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Entry.setProgressFraction(fraction:)`.
///
/// - Parameter progressFraction: The current fraction of the task that's been completed.
/// - Returns: A copy of this view with the modifier applied.
public func progressFraction(_ progressFraction: @escaping () -> Double) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setProgressFraction(fraction: progressFraction()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Entry.setProgressPulseStep(fraction:)
/// Sets the fraction of total entry width to move the progress
/// bouncing block for each pulse.
///
/// Use [method`Gtk`.Entry.progress_pulse] to pulse
/// the progress.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter progressPulseStep: The fraction of total entry width to move the progress bouncing block for each pulse.
/// - Returns: A copy of this view with the modifier applied.
public func progressPulseStep(_ progressPulseStep: Double) -> Self {
appending { w, _ in
w.setProgressPulseStep(fraction: progressPulseStep)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Entry.setProgressPulseStep(fraction:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getProgressPulseStep()
/// Sets the fraction of total entry width to move the progress
/// bouncing block for each pulse.
///
/// Use [method`Gtk`.Entry.progress_pulse] to pulse
/// the progress.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Double` 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 progressPulseStep(_ progressPulseStep: Portico.Binding<Double>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, progressPulseStep, registry: ctx.registry, notifyDetail: "progress-pulse-step",
read: { [w] in w.getProgressPulseStep() },
write: { [w] v in w.setProgressPulseStep(fraction: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Entry.setProgressPulseStep(fraction:)
/// Sets the fraction of total entry width to move the progress
/// bouncing block for each pulse.
///
/// Use [method`Gtk`.Entry.progress_pulse] to pulse
/// the progress.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Entry.setProgressPulseStep(fraction:)`.
///
/// - Parameter progressPulseStep: The fraction of total entry width to move the progress bouncing block for each pulse.
/// - Returns: A copy of this view with the modifier applied.
public func progressPulseStep(_ progressPulseStep: @escaping () -> Double) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setProgressPulseStep(fraction: progressPulseStep()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Entry.setTabs(tabs:)
/// Sets a `PangoTabArray`.
///
/// The tabstops in the array are applied to the entry text.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter tabs: A list of tabstops to apply to the text of the entry.
/// - Returns: A copy of this view with the modifier applied.
public func tabs(_ tabs: Gtk.TabArray?) -> Self {
appending { w, _ in
w.setTabs(tabs: tabs)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Entry.setTabs(tabs:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getTabs()
/// Sets a `PangoTabArray`.
///
/// The tabstops in the array are applied to the entry text.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.TabArray?` 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 tabs(_ tabs: Portico.Binding<Gtk.TabArray?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, tabs, registry: ctx.registry, notifyDetail: "tabs",
read: { [w] in w.getTabs() },
write: { [w] v in w.setTabs(tabs: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.Entry.setTabs(tabs:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getTabs()
/// Sets a `PangoTabArray`.
///
/// The tabstops in the array are applied to the entry text.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Gtk.TabArray>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.TabArray?>` to be able to clear the property.
/// When `Gtk.TabArray` 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 tabs(_ tabs: Portico.Binding<Gtk.TabArray>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, tabs, registry: ctx.registry, notifyDetail: "tabs",
read: { [w] in w.getTabs() },
write: { [w] v in w.setTabs(tabs: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Entry.setTabs(tabs:)
/// Sets a `PangoTabArray`.
///
/// The tabstops in the array are applied to the entry text.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Entry.setTabs(tabs:)`.
///
/// - Parameter tabs: A list of tabstops to apply to the text of the entry.
/// - Returns: A copy of this view with the modifier applied.
public func tabs(_ tabs: @escaping () -> Gtk.TabArray?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setTabs(tabs: tabs()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Entry.setVisibility(visible:)
/// Sets whether the contents of the entry are visible or not.
///
/// When visibility is set to `false`, characters are displayed
/// as the invisible char, and will also appear that way when
/// the text in the entry widget is copied elsewhere.
///
/// By default, GTK picks the best invisible character available
/// in the current font, but it can be changed with
/// [method`Gtk`.Entry.set_invisible_char].
///
/// Note that you probably want to set [property`Gtk`.Entry:input-purpose]
/// to `GTK_INPUT_PURPOSE_PASSWORD` or `GTK_INPUT_PURPOSE_PIN` to
/// inform input methods about the purpose of this entry,
/// in addition to setting visibility to `false`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter visibility: Whether the entry should show the invisible char instead of the actual text (password mode).
/// - Returns: A copy of this view with the modifier applied.
public func visibility(_ visibility: Bool) -> Self {
appending { w, _ in
w.setVisibility(visible: visibility)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Entry.setVisibility(visible:), GObject.Object.connectNotify(detail:_:), Gtk.Entry.getVisibility()
/// Sets whether the contents of the entry are visible or not.
///
/// When visibility is set to `false`, characters are displayed
/// as the invisible char, and will also appear that way when
/// the text in the entry widget is copied elsewhere.
///
/// By default, GTK picks the best invisible character available
/// in the current font, but it can be changed with
/// [method`Gtk`.Entry.set_invisible_char].
///
/// Note that you probably want to set [property`Gtk`.Entry:input-purpose]
/// to `GTK_INPUT_PURPOSE_PASSWORD` or `GTK_INPUT_PURPOSE_PIN` to
/// inform input methods about the purpose of this entry,
/// in addition to setting visibility to `false`.
///
/// 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 visibility(_ visibility: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, visibility, registry: ctx.registry, notifyDetail: "visibility",
read: { [w] in w.getVisibility() },
write: { [w] v in w.setVisibility(visible: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Entry.setVisibility(visible:)
/// Sets whether the contents of the entry are visible or not.
///
/// When visibility is set to `false`, characters are displayed
/// as the invisible char, and will also appear that way when
/// the text in the entry widget is copied elsewhere.
///
/// By default, GTK picks the best invisible character available
/// in the current font, but it can be changed with
/// [method`Gtk`.Entry.set_invisible_char].
///
/// Note that you probably want to set [property`Gtk`.Entry:input-purpose]
/// to `GTK_INPUT_PURPOSE_PASSWORD` or `GTK_INPUT_PURPOSE_PIN` to
/// inform input methods about the purpose of this entry,
/// in addition to setting visibility to `false`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Entry.setVisibility(visible:)`.
///
/// - Parameter visibility: Whether the entry should show the invisible char instead of the actual text (password mode).
/// - Returns: A copy of this view with the modifier applied.
public func visibility(_ visibility: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setVisibility(visible: visibility()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Entry.connectActivate(_:)
/// Emitted when the entry is activated.
///
/// The keybindings for this signal are all forms of the Enter 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.Entry.connectIconPress(_:)
/// Emitted when an activatable icon is clicked.
///
/// - Parameter handler: Invoked when the widget emits the `icon-press` signal. The closure receives the signal's arguments in order.
/// - Returns: A copy of this view with the modifier applied.
public func onIconPress(_ handler: @escaping (Gtk.EntryIconPosition) -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectIconPress { _, a0 in handler(a0) })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Entry.connectIconRelease(_:)
/// Emitted on the button release from a mouse click
/// over an activatable icon.
///
/// - Parameter handler: Invoked when the widget emits the `icon-release` signal. The closure receives the signal's arguments in order.
/// - Returns: A copy of this view with the modifier applied.
public func onIconRelease(_ handler: @escaping (Gtk.EntryIconPosition) -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectIconRelease { _, a0 in handler(a0) })
}
}
}