342 lines
18 KiB
Swift
342 lines
18 KiB
Swift
// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
|
|
|
|
import Adw
|
|
import Gtk
|
|
import Gio
|
|
import Gdk
|
|
|
|
// PorticoGen: generateModifierExtension | source: Gtk.Editable
|
|
/// Modifiers for `Gtk.Editable`, available on every Portico view whose
|
|
/// backing widget is `Gtk.Editable` or one of its subclasses.
|
|
extension WidgetView where Target: Gtk.Editable {
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Editable.setEditable(isEditable:)
|
|
/// Determines if the user can edit the text in the editable widget.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter editable: Whether the entry contents can be edited.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func editable(_ editable: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setEditable(isEditable: editable)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Editable.setEditable(isEditable:), GObject.Object.connectNotify(detail:_:), Gtk.Editable.getEditable()
|
|
/// Determines if the user can edit the text in the editable widget.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func editable(_ editable: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, editable, registry: ctx.registry, notifyDetail: "editable",
|
|
read: { [w] in w.getEditable() },
|
|
write: { [w] v in w.setEditable(isEditable: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Editable.setEditable(isEditable:)
|
|
/// Determines if the user can edit the text in the editable widget.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Editable.setEditable(isEditable:)`.
|
|
///
|
|
/// - Parameter editable: Whether the entry contents can be edited.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func editable(_ editable: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setEditable(isEditable: editable()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Editable.setEnableUndo(enableUndo:)
|
|
/// If enabled, changes to `editable` will be saved for undo/redo
|
|
/// actions.
|
|
///
|
|
/// This results in an additional copy of text changes and are not
|
|
/// stored in secure memory. As such, undo is forcefully disabled
|
|
/// when [property`Gtk`.Text:visibility] is set to `false`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter enableUndo: If undo/redo should be enabled for the editable.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func enableUndo(_ enableUndo: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setEnableUndo(enableUndo: enableUndo)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Editable.setEnableUndo(enableUndo:), GObject.Object.connectNotify(detail:_:), Gtk.Editable.getEnableUndo()
|
|
/// If enabled, changes to `editable` will be saved for undo/redo
|
|
/// actions.
|
|
///
|
|
/// This results in an additional copy of text changes and are not
|
|
/// stored in secure memory. As such, undo is forcefully disabled
|
|
/// when [property`Gtk`.Text:visibility] is set 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 enableUndo(_ enableUndo: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, enableUndo, registry: ctx.registry, notifyDetail: "enable-undo",
|
|
read: { [w] in w.getEnableUndo() },
|
|
write: { [w] v in w.setEnableUndo(enableUndo: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Editable.setEnableUndo(enableUndo:)
|
|
/// If enabled, changes to `editable` will be saved for undo/redo
|
|
/// actions.
|
|
///
|
|
/// This results in an additional copy of text changes and are not
|
|
/// stored in secure memory. As such, undo is forcefully disabled
|
|
/// when [property`Gtk`.Text:visibility] is set to `false`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Editable.setEnableUndo(enableUndo:)`.
|
|
///
|
|
/// - Parameter enableUndo: If undo/redo should be enabled for the editable.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func enableUndo(_ enableUndo: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setEnableUndo(enableUndo: enableUndo()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Editable.setMaxWidthChars(nChars:)
|
|
/// Sets the desired maximum width in characters of `editable`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter maxWidthChars: The desired maximum width of the entry, in characters.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func maxWidthChars(_ maxWidthChars: Int32) -> Self {
|
|
appending { w, _ in
|
|
w.setMaxWidthChars(nChars: maxWidthChars)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Editable.setMaxWidthChars(nChars:), GObject.Object.connectNotify(detail:_:), Gtk.Editable.getMaxWidthChars()
|
|
/// Sets the desired maximum width in characters of `editable`.
|
|
///
|
|
/// 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 maxWidthChars(_ maxWidthChars: Portico.Binding<Int32>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, maxWidthChars, registry: ctx.registry, notifyDetail: "max-width-chars",
|
|
read: { [w] in w.getMaxWidthChars() },
|
|
write: { [w] v in w.setMaxWidthChars(nChars: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Editable.setMaxWidthChars(nChars:)
|
|
/// Sets the desired maximum width in characters of `editable`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Editable.setMaxWidthChars(nChars:)`.
|
|
///
|
|
/// - Parameter maxWidthChars: The desired maximum width of the entry, in characters.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func maxWidthChars(_ maxWidthChars: @escaping () -> Int32) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setMaxWidthChars(nChars: maxWidthChars()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Editable.setText(text:)
|
|
/// Sets the text in the editable to the given value.
|
|
///
|
|
/// This is replacing the current contents.
|
|
///
|
|
/// 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 text: The contents of the entry.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func text<S: StringProtocol>(_ text: S) -> Self {
|
|
appending { w, _ in
|
|
w.setText(text: String(text))
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Editable.setText(text:), GObject.Object.connectNotify(detail:_:), Gtk.Editable.getText()
|
|
/// Sets the text in the editable to the given value.
|
|
///
|
|
/// This is replacing the current contents.
|
|
///
|
|
/// 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 text(_ text: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, text, registry: ctx.registry, notifyDetail: "text",
|
|
read: { [w] in w.getText() },
|
|
write: { [w] v in w.setText(text: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Editable.setText(text:)
|
|
/// Sets the text in the editable to the given value.
|
|
///
|
|
/// This is replacing the current contents.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Editable.setText(text:)`.
|
|
///
|
|
/// - Parameter text: The contents of the entry.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func text(_ text: @escaping () -> String) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setText(text: text()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Gtk.Editable.setText(text:)
|
|
/// Sets the text in the editable to the given value.
|
|
///
|
|
/// This is replacing the current contents.
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.Editable.setText(text:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter text: The contents of the entry.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func text(_ text: Portico.InterpolatedText) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindInterpolation(text, registry: ctx.registry) { [w] v in w.setText(text: v) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Editable.setWidthChars(nChars:)
|
|
/// Changes the size request of the editable to be about the
|
|
/// right size for `n_chars` characters.
|
|
///
|
|
/// Note that it changes the size request, the size can still
|
|
/// be affected by how you pack the widget into containers.
|
|
/// If `n_chars` is -1, the size reverts to the default size.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter widthChars: Number of characters to leave space for in the entry.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func widthChars(_ widthChars: Int32) -> Self {
|
|
appending { w, _ in
|
|
w.setWidthChars(nChars: widthChars)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Editable.setWidthChars(nChars:), GObject.Object.connectNotify(detail:_:), Gtk.Editable.getWidthChars()
|
|
/// Changes the size request of the editable to be about the
|
|
/// right size for `n_chars` characters.
|
|
///
|
|
/// Note that it changes the size request, the size can still
|
|
/// be affected by how you pack the widget into containers.
|
|
/// If `n_chars` is -1, the size reverts to the default size.
|
|
///
|
|
/// 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 widthChars(_ widthChars: Portico.Binding<Int32>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, widthChars, registry: ctx.registry, notifyDetail: "width-chars",
|
|
read: { [w] in w.getWidthChars() },
|
|
write: { [w] v in w.setWidthChars(nChars: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Editable.setWidthChars(nChars:)
|
|
/// Changes the size request of the editable to be about the
|
|
/// right size for `n_chars` characters.
|
|
///
|
|
/// Note that it changes the size request, the size can still
|
|
/// be affected by how you pack the widget into containers.
|
|
/// If `n_chars` is -1, the size reverts to the default size.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Editable.setWidthChars(nChars:)`.
|
|
///
|
|
/// - Parameter widthChars: Number of characters to leave space for in the entry.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func widthChars(_ widthChars: @escaping () -> Int32) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setWidthChars(nChars: widthChars()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Editable.connectChanged(_:)
|
|
/// Emitted at the end of a single user-visible operation on the
|
|
/// contents.
|
|
///
|
|
/// E.g., a paste operation that replaces the contents of the
|
|
/// selection will cause only one signal emission (even though it
|
|
/// is implemented by first deleting the selection, then inserting
|
|
/// the new content, and may cause multiple ::notify::text signals
|
|
/// to be emitted).
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `changed` signal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onChanged(_ handler: @escaping () -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectChanged { _ in handler() })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Editable.connectDeleteText(_:)
|
|
/// Emitted when text is deleted from the widget by the user.
|
|
///
|
|
/// The default handler for this signal will normally be responsible for
|
|
/// deleting the text, so by connecting to this signal and then stopping
|
|
/// the signal with g_signal_stop_emission(), it is possible to modify the
|
|
/// range of deleted text, or prevent it from being deleted entirely.
|
|
///
|
|
/// The `start_pos` and `end_pos` parameters are interpreted as for
|
|
/// [method`Gtk`.Editable.delete_text].
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `delete-text` signal. The closure receives the signal's arguments in order.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onDeleteText(_ handler: @escaping (Int32, Int32) -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectDeleteText { _, a0, a1 in handler(a0, a1) })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Editable.connectInsertText(_:)
|
|
/// Emitted when text is inserted into the widget by the user.
|
|
///
|
|
/// The default handler for this signal will normally be responsible
|
|
/// for inserting the text, so by connecting to this signal and then
|
|
/// stopping the signal with g_signal_stop_emission(), it is possible
|
|
/// to modify the inserted text, or prevent it from being inserted entirely.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `insert-text` signal. The closure receives the signal's arguments in order.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onInsertText(_ handler: @escaping (String, Int32, Int32) -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectInsertText { _, a0, a1, a2 in handler(a0, a1, a2) })
|
|
}
|
|
}
|
|
|
|
}
|