portico/Sources/Portico/Generated/EditableLabel.swift

92 lines
2.9 KiB
Swift

// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
import Adw
import Gtk
import Gio
import Gdk
// PorticoGen: generateStruct | source: Gtk.EditableLabel
/// Allows users to edit the displayed text by switching to an edit mode.
///
/// <picture>
/// <source srcset="editable-label-dark.png" media="(prefers-color-scheme: dark)">
/// <img alt="An example GtkEditableLabel" src="editable-label.png">
/// </picture>
///
/// `GtkEditableLabel` does not have API of its own, but it
/// implements the [iface`Gtk`.Editable] interface.
///
/// The default bindings for activating the edit mode is
/// to click or press the Enter key. The default bindings
/// for leaving the edit mode are the Enter key (to save
/// the results) or the Escape key (to cancel the editing).
///
/// # Shortcuts and Gestures
///
/// `GtkEditableLabel` supports the following keyboard shortcuts:
///
/// - <kbd>Enter</kbd> starts editing.
/// - <kbd>Escape</kbd> stops editing.
///
/// # Actions
///
/// `GtkEditableLabel` defines a set of built-in actions:
///
/// - `editing.starts` switches the widget into editing mode.
/// - `editing.stop` switches the widget out of editing mode.
///
/// # CSS nodes
///
/// ```
/// editablelabel[.editing]
/// stack
/// label
/// text
/// ```
///
/// `GtkEditableLabel` has a main node with the name editablelabel.
/// When the entry is in editing mode, it gets the .editing style
/// class.
///
/// For all the subnodes added to the text node in various situations,
/// see [class`Gtk`.Text].
///
/// A Portico view that mounts a `Gtk.EditableLabel`.
@MainActor public struct EditableLabel: View {
private let make: (MountContext) -> Gtk.EditableLabel
private var configure: [(Gtk.EditableLabel, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.EditableLabel.init(str:)
/// Creates a new `GtkEditableLabel` widget.
///
/// 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 str: The `str` value forwarded to `Gtk.EditableLabel`.
public init(str: String) {
make = { _ in Gtk.EditableLabel(str: str) }
}
}
extension EditableLabel: WidgetView {
public typealias Target = Gtk.EditableLabel
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.EditableLabel, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension EditableLabel: Mountable {
@_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget {
let w = make(ctx)
for step in configure { step(w, ctx) }
return w
}
}