911 lines
52 KiB
Swift
911 lines
52 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.ComboBox
|
||
/// A `GtkComboBox` is a widget that allows the user to choose from a list of
|
||
/// valid choices.
|
||
///
|
||
/// <picture>
|
||
/// <source srcset="combo-box-dark.png" media="(prefers-color-scheme: dark)">
|
||
/// <img alt="An example GtkComboBox" src="combo-box.png">
|
||
/// </picture>
|
||
///
|
||
/// The `GtkComboBox` displays the selected choice; when activated, the
|
||
/// `GtkComboBox` displays a popup which allows the user to make a new choice.
|
||
///
|
||
/// The `GtkComboBox` uses the model-view pattern; the list of valid choices
|
||
/// is specified in the form of a tree model, and the display of the choices
|
||
/// can be adapted to the data in the model by using cell renderers, as you
|
||
/// would in a tree view. This is possible since `GtkComboBox` implements the
|
||
/// [iface`Gtk`.CellLayout] interface. The tree model holding the valid
|
||
/// choices is not restricted to a flat list, it can be a real tree, and the
|
||
/// popup will reflect the tree structure.
|
||
///
|
||
/// To allow the user to enter values not in the model, the
|
||
/// [property`Gtk`.ComboBox:has-entry] property allows the `GtkComboBox` to
|
||
/// contain a [class`Gtk`.Entry]. This entry can be accessed by calling
|
||
/// [method`Gtk`.ComboBox.get_child] on the combo box.
|
||
///
|
||
/// For a simple list of textual choices, the model-view API of `GtkComboBox`
|
||
/// can be a bit overwhelming. In this case, [class`Gtk`.ComboBoxText] offers
|
||
/// a simple alternative. Both `GtkComboBox` and `GtkComboBoxText` can contain
|
||
/// an entry.
|
||
///
|
||
/// ## CSS nodes
|
||
///
|
||
/// ```
|
||
/// combobox
|
||
/// ├── box.linked
|
||
/// │ ╰── button.combo
|
||
/// │ ╰── box
|
||
/// │ ├── cellview
|
||
/// │ ╰── arrow
|
||
/// ╰── window.popup
|
||
/// ```
|
||
///
|
||
/// A normal combobox contains a box with the .linked class, a button
|
||
/// with the .combo class and inside those buttons, there are a cellview and
|
||
/// an arrow.
|
||
///
|
||
/// ```
|
||
/// combobox
|
||
/// ├── box.linked
|
||
/// │ ├── entry.combo
|
||
/// │ ╰── button.combo
|
||
/// │ ╰── box
|
||
/// │ ╰── arrow
|
||
/// ╰── window.popup
|
||
/// ```
|
||
///
|
||
/// A `GtkComboBox` with an entry has a single CSS node with name combobox.
|
||
/// It contains a box with the .linked class. That box contains an entry and
|
||
/// a button, both with the .combo class added. The button also contains another
|
||
/// node with name arrow.
|
||
///
|
||
/// ## Accessibility
|
||
///
|
||
/// `GtkComboBox` uses the [enum`Gtk`.AccessibleRole.combo_box] role.
|
||
///
|
||
/// A Portico view that mounts a `Gtk.ComboBox`.
|
||
@MainActor public struct ComboBox: View {
|
||
private let make: (MountContext) -> Gtk.ComboBox
|
||
private var configure: [(Gtk.ComboBox, MountContext) -> Void] = []
|
||
|
||
public var body: Never { fatalError() }
|
||
|
||
// PorticoGen: generateInits(static) | source: Gtk.ComboBox.init()
|
||
/// Creates a new empty `GtkComboBox`.
|
||
///
|
||
/// Applied once at mount; use the `Binding` or closure overload for values that change.
|
||
/// Each closure is evaluated once; children are added in order and slot closures mount their first view.
|
||
/// An empty closure adds no children and leaves slots unset.
|
||
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
|
||
///
|
||
/// - Parameter active: The item which is currently active.
|
||
/// - Parameter activeId: The value of the ID column of the active row.
|
||
/// - Parameter buttonSensitivity: Whether the dropdown button is sensitive when the model is empty.
|
||
/// - Parameter entryTextColumn: The model column to associate with strings from the entry.
|
||
/// - Parameter idColumn: The model column that provides string IDs for the values in the model, if != -1.
|
||
/// - Parameter popupFixedWidth: Whether the popup's width should be a fixed width matching the allocated width of the combo box.
|
||
/// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot.
|
||
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
|
||
/// - Parameter onChanged: Invoked when the widget emits the `changed` signal.
|
||
/// - Parameter onFormatEntryText: Invoked when the widget emits the `format-entry-text` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
|
||
/// - Parameter onMoveActive: Invoked when the widget emits the `move-active` signal. The closure receives the signal's arguments in order.
|
||
/// - Parameter onPopdown: Invoked when the widget emits the `popdown` signal. Its return value is forwarded to GTK as the signal's result.
|
||
/// - Parameter onPopup: Invoked when the widget emits the `popup` signal.
|
||
public init(active: Int32? = nil, activeId: String? = nil, buttonSensitivity: Gtk.SensitivityType? = nil, entryTextColumn: Int32? = nil, idColumn: Int32? = nil, popupFixedWidth: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil, onChanged: (() -> Void)? = nil, onFormatEntryText: ((String) -> String)? = nil, onMoveActive: ((Gtk.ScrollType) -> Void)? = nil, onPopdown: (() -> Bool)? = nil, onPopup: (() -> Void)? = nil) {
|
||
make = { _ in Gtk.ComboBox() }
|
||
configure.append { w, ctx in
|
||
if let active { w.setActive(index: active) }
|
||
if let activeId { w.setActiveId(activeId: activeId) }
|
||
if let buttonSensitivity { w.setButtonSensitivity(sensitivity: buttonSensitivity) }
|
||
if let entryTextColumn { w.setEntryTextColumn(textColumn: entryTextColumn) }
|
||
if let idColumn { w.setIdColumn(idColumn: idColumn) }
|
||
if let popupFixedWidth { w.setPopupFixedWidth(fixed: popupFixedWidth) }
|
||
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
|
||
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
|
||
if let onChanged { ctx.registry.add(w.connectChanged { _ in onChanged() }) }
|
||
if let onFormatEntryText { ctx.registry.add(w.connectFormatEntryText { _, a0 in onFormatEntryText(a0) }) }
|
||
if let onMoveActive { ctx.registry.add(w.connectMoveActive { _, a0 in onMoveActive(a0) }) }
|
||
if let onPopdown { ctx.registry.add(w.connectPopdown { _ in onPopdown() }) }
|
||
if let onPopup { ctx.registry.add(w.connectPopup { _ in onPopup() }) }
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateInits(static) | source: Gtk.ComboBox.init(model:)
|
||
/// Creates a new `GtkComboBox` with a model.
|
||
///
|
||
/// Applied once at mount; use the `Binding` or closure overload for values that change.
|
||
/// Each closure is evaluated once; children are added in order and slot closures mount their first view.
|
||
/// An empty closure adds no children and leaves slots unset.
|
||
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
|
||
///
|
||
/// - Parameter model: The model from which the combo box takes its values.
|
||
/// - Parameter active: The item which is currently active.
|
||
/// - Parameter activeId: The value of the ID column of the active row.
|
||
/// - Parameter buttonSensitivity: Whether the dropdown button is sensitive when the model is empty.
|
||
/// - Parameter entryTextColumn: The model column to associate with strings from the entry.
|
||
/// - Parameter idColumn: The model column that provides string IDs for the values in the model, if != -1.
|
||
/// - Parameter popupFixedWidth: Whether the popup's width should be a fixed width matching the allocated width of the combo box.
|
||
/// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot.
|
||
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
|
||
/// - Parameter onChanged: Invoked when the widget emits the `changed` signal.
|
||
/// - Parameter onFormatEntryText: Invoked when the widget emits the `format-entry-text` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
|
||
/// - Parameter onMoveActive: Invoked when the widget emits the `move-active` signal. The closure receives the signal's arguments in order.
|
||
/// - Parameter onPopdown: Invoked when the widget emits the `popdown` signal. Its return value is forwarded to GTK as the signal's result.
|
||
/// - Parameter onPopup: Invoked when the widget emits the `popup` signal.
|
||
public init(model: Gtk.TreeModel, active: Int32? = nil, activeId: String? = nil, buttonSensitivity: Gtk.SensitivityType? = nil, entryTextColumn: Int32? = nil, idColumn: Int32? = nil, popupFixedWidth: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil, onChanged: (() -> Void)? = nil, onFormatEntryText: ((String) -> String)? = nil, onMoveActive: ((Gtk.ScrollType) -> Void)? = nil, onPopdown: (() -> Bool)? = nil, onPopup: (() -> Void)? = nil) {
|
||
make = { _ in Gtk.ComboBox(model: model) }
|
||
configure.append { w, ctx in
|
||
if let active { w.setActive(index: active) }
|
||
if let activeId { w.setActiveId(activeId: activeId) }
|
||
if let buttonSensitivity { w.setButtonSensitivity(sensitivity: buttonSensitivity) }
|
||
if let entryTextColumn { w.setEntryTextColumn(textColumn: entryTextColumn) }
|
||
if let idColumn { w.setIdColumn(idColumn: idColumn) }
|
||
if let popupFixedWidth { w.setPopupFixedWidth(fixed: popupFixedWidth) }
|
||
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
|
||
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
|
||
if let onChanged { ctx.registry.add(w.connectChanged { _ in onChanged() }) }
|
||
if let onFormatEntryText { ctx.registry.add(w.connectFormatEntryText { _, a0 in onFormatEntryText(a0) }) }
|
||
if let onMoveActive { ctx.registry.add(w.connectMoveActive { _, a0 in onMoveActive(a0) }) }
|
||
if let onPopdown { ctx.registry.add(w.connectPopdown { _ in onPopdown() }) }
|
||
if let onPopup { ctx.registry.add(w.connectPopup { _ in onPopup() }) }
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateInits(static) | source: Gtk.ComboBox.init(withModelAndEntryModel:)
|
||
/// Creates a new empty `GtkComboBox` with an entry and a model.
|
||
///
|
||
/// See also [ctor`Gtk`.ComboBox.new_with_entry].
|
||
///
|
||
/// Applied once at mount; use the `Binding` or closure overload for values that change.
|
||
/// Each closure is evaluated once; children are added in order and slot closures mount their first view.
|
||
/// An empty closure adds no children and leaves slots unset.
|
||
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
|
||
///
|
||
/// - Parameter withModelAndEntryModel: The `withModelAndEntryModel` value forwarded to `Gtk.ComboBox`.
|
||
/// - Parameter active: The item which is currently active.
|
||
/// - Parameter activeId: The value of the ID column of the active row.
|
||
/// - Parameter buttonSensitivity: Whether the dropdown button is sensitive when the model is empty.
|
||
/// - Parameter entryTextColumn: The model column to associate with strings from the entry.
|
||
/// - Parameter idColumn: The model column that provides string IDs for the values in the model, if != -1.
|
||
/// - Parameter popupFixedWidth: Whether the popup's width should be a fixed width matching the allocated width of the combo box.
|
||
/// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot.
|
||
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
|
||
/// - Parameter onChanged: Invoked when the widget emits the `changed` signal.
|
||
/// - Parameter onFormatEntryText: Invoked when the widget emits the `format-entry-text` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
|
||
/// - Parameter onMoveActive: Invoked when the widget emits the `move-active` signal. The closure receives the signal's arguments in order.
|
||
/// - Parameter onPopdown: Invoked when the widget emits the `popdown` signal. Its return value is forwarded to GTK as the signal's result.
|
||
/// - Parameter onPopup: Invoked when the widget emits the `popup` signal.
|
||
public init(withModelAndEntryModel: Gtk.TreeModel, active: Int32? = nil, activeId: String? = nil, buttonSensitivity: Gtk.SensitivityType? = nil, entryTextColumn: Int32? = nil, idColumn: Int32? = nil, popupFixedWidth: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil, onChanged: (() -> Void)? = nil, onFormatEntryText: ((String) -> String)? = nil, onMoveActive: ((Gtk.ScrollType) -> Void)? = nil, onPopdown: (() -> Bool)? = nil, onPopup: (() -> Void)? = nil) {
|
||
make = { _ in Gtk.ComboBox(withModelAndEntryModel: withModelAndEntryModel) }
|
||
configure.append { w, ctx in
|
||
if let active { w.setActive(index: active) }
|
||
if let activeId { w.setActiveId(activeId: activeId) }
|
||
if let buttonSensitivity { w.setButtonSensitivity(sensitivity: buttonSensitivity) }
|
||
if let entryTextColumn { w.setEntryTextColumn(textColumn: entryTextColumn) }
|
||
if let idColumn { w.setIdColumn(idColumn: idColumn) }
|
||
if let popupFixedWidth { w.setPopupFixedWidth(fixed: popupFixedWidth) }
|
||
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
|
||
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
|
||
if let onChanged { ctx.registry.add(w.connectChanged { _ in onChanged() }) }
|
||
if let onFormatEntryText { ctx.registry.add(w.connectFormatEntryText { _, a0 in onFormatEntryText(a0) }) }
|
||
if let onMoveActive { ctx.registry.add(w.connectMoveActive { _, a0 in onMoveActive(a0) }) }
|
||
if let onPopdown { ctx.registry.add(w.connectPopdown { _ in onPopdown() }) }
|
||
if let onPopup { ctx.registry.add(w.connectPopup { _ in onPopup() }) }
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
extension ComboBox: WidgetView {
|
||
public typealias Target = Gtk.ComboBox
|
||
|
||
@_spi(Portico) public func appending(
|
||
_ step: @escaping (Gtk.ComboBox, MountContext) -> Void
|
||
) -> Self {
|
||
var c = self
|
||
c.configure.append(step)
|
||
return c
|
||
}
|
||
}
|
||
|
||
@_spi(Portico) extension ComboBox: 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.ComboBox
|
||
/// Modifiers for `Gtk.ComboBox`, available on every Portico view whose
|
||
/// backing widget is `Gtk.ComboBox` or one of its subclasses.
|
||
extension WidgetView where Target: Gtk.ComboBox {
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.ComboBox.setActive(index:)
|
||
/// Sets the active item of `combo_box` to be the item at `index`.
|
||
///
|
||
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
||
///
|
||
/// - Parameter active: The item which is currently active.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func active(_ active: Int32) -> Self {
|
||
appending { w, _ in
|
||
w.setActive(index: active)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.ComboBox.setActive(index:), GObject.Object.connectNotify(detail:_:), Gtk.ComboBox.getActive()
|
||
/// Sets the active item of `combo_box` to be the item at `index`.
|
||
///
|
||
/// 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 active(_ active: Portico.Binding<Int32>) -> Self {
|
||
appending { w, ctx in
|
||
Portico.bindProperty(
|
||
w, active, registry: ctx.registry, notifyDetail: "active",
|
||
read: { [w] in w.getActive() },
|
||
write: { [w] v in w.setActive(index: v) }
|
||
)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.ComboBox.setActive(index:)
|
||
/// Sets the active item of `combo_box` to be the item at `index`.
|
||
///
|
||
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.ComboBox.setActive(index:)`.
|
||
///
|
||
/// - Parameter active: The item which is currently active.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func active(_ active: @escaping () -> Int32) -> Self {
|
||
appending { w, ctx in
|
||
let tracker = DependencyTracker { [w] in w.setActive(index: active()) }
|
||
tracker.run()
|
||
ctx.registry.add(tracker)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.ComboBox.setActiveId(activeId:)
|
||
/// Changes the active row of `combo_box` to the one that has an ID equal to
|
||
/// `active_id`.
|
||
///
|
||
/// If `active_id` is `nil`, the active row is unset. Rows having
|
||
/// a `nil` ID string cannot be made active by this function.
|
||
///
|
||
/// If the [property`Gtk`.ComboBox:id-column] property of `combo_box` is
|
||
/// unset or if no row has the given ID then the function does nothing
|
||
/// and returns `false`.
|
||
///
|
||
/// 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 activeId: The value of the ID column of the active row.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
@_disfavoredOverload
|
||
public func activeId<S: StringProtocol>(_ activeId: S?) -> Self {
|
||
appending { w, _ in
|
||
w.setActiveId(activeId: activeId.map { String($0) })
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.ComboBox.setActiveId(activeId:), GObject.Object.connectNotify(detail:_:), Gtk.ComboBox.getActiveId()
|
||
/// Changes the active row of `combo_box` to the one that has an ID equal to
|
||
/// `active_id`.
|
||
///
|
||
/// If `active_id` is `nil`, the active row is unset. Rows having
|
||
/// a `nil` ID string cannot be made active by this function.
|
||
///
|
||
/// If the [property`Gtk`.ComboBox:id-column] property of `combo_box` is
|
||
/// unset or if no row has the given ID then the function does nothing
|
||
/// and returns `false`.
|
||
///
|
||
/// 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 activeId(_ activeId: Portico.Binding<String?>) -> Self {
|
||
appending { w, ctx in
|
||
Portico.bindProperty(
|
||
w, activeId, registry: ctx.registry, notifyDetail: "active-id",
|
||
read: { [w] in w.getActiveId() },
|
||
write: { [w] v in w.setActiveId(activeId: v) }
|
||
)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.ComboBox.setActiveId(activeId:), GObject.Object.connectNotify(detail:_:), Gtk.ComboBox.getActiveId()
|
||
/// Changes the active row of `combo_box` to the one that has an ID equal to
|
||
/// `active_id`.
|
||
///
|
||
/// If `active_id` is `nil`, the active row is unset. Rows having
|
||
/// a `nil` ID string cannot be made active by this function.
|
||
///
|
||
/// If the [property`Gtk`.ComboBox:id-column] property of `combo_box` is
|
||
/// unset or if no row has the given ID then the function does nothing
|
||
/// and returns `false`.
|
||
///
|
||
/// 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 activeId(_ activeId: Portico.Binding<String>) -> Self {
|
||
appending { w, ctx in
|
||
Portico.bindProperty(
|
||
w, activeId, registry: ctx.registry, notifyDetail: "active-id",
|
||
read: { [w] in w.getActiveId() },
|
||
write: { [w] v in w.setActiveId(activeId: v) }
|
||
)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.ComboBox.setActiveId(activeId:)
|
||
/// Changes the active row of `combo_box` to the one that has an ID equal to
|
||
/// `active_id`.
|
||
///
|
||
/// If `active_id` is `nil`, the active row is unset. Rows having
|
||
/// a `nil` ID string cannot be made active by this function.
|
||
///
|
||
/// If the [property`Gtk`.ComboBox:id-column] property of `combo_box` is
|
||
/// unset or if no row has the given ID then the function does nothing
|
||
/// and returns `false`.
|
||
///
|
||
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.ComboBox.setActiveId(activeId:)`.
|
||
///
|
||
/// - Parameter activeId: The value of the ID column of the active row.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func activeId(_ activeId: @escaping () -> String?) -> Self {
|
||
appending { w, ctx in
|
||
let tracker = DependencyTracker { [w] in w.setActiveId(activeId: activeId()) }
|
||
tracker.run()
|
||
ctx.registry.add(tracker)
|
||
}
|
||
}
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Gtk.ComboBox.setActiveId(activeId:)
|
||
/// Changes the active row of `combo_box` to the one that has an ID equal to
|
||
/// `active_id`.
|
||
///
|
||
/// If `active_id` is `nil`, the active row is unset. Rows having
|
||
/// a `nil` ID string cannot be made active by this function.
|
||
///
|
||
/// If the [property`Gtk`.ComboBox:id-column] property of `combo_box` is
|
||
/// unset or if no row has the given ID then the function does nothing
|
||
/// and returns `false`.
|
||
///
|
||
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.ComboBox.setActiveId(activeId:)`. A literal with no interpolation is applied once, with no subscription.
|
||
///
|
||
/// - Parameter activeId: The value of the ID column of the active row.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func activeId(_ activeId: Portico.InterpolatedText?) -> Self {
|
||
appending { w, ctx in
|
||
Portico.bindOptionalInterpolation(activeId, registry: ctx.registry) { [w] v in w.setActiveId(activeId: v) }
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.ComboBox.setButtonSensitivity(sensitivity:)
|
||
/// Sets whether the dropdown button of the combo box should update
|
||
/// its sensitivity depending on the model contents.
|
||
///
|
||
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
||
///
|
||
/// - Parameter buttonSensitivity: Whether the dropdown button is sensitive when the model is empty.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func buttonSensitivity(_ buttonSensitivity: Gtk.SensitivityType) -> Self {
|
||
appending { w, _ in
|
||
w.setButtonSensitivity(sensitivity: buttonSensitivity)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.ComboBox.setButtonSensitivity(sensitivity:), GObject.Object.connectNotify(detail:_:), Gtk.ComboBox.getButtonSensitivity()
|
||
/// Sets whether the dropdown button of the combo box should update
|
||
/// its sensitivity depending on the model contents.
|
||
///
|
||
/// Applied at mount and re-applied on every change the binding publishes.
|
||
/// When `Gtk.SensitivityType` 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 buttonSensitivity(_ buttonSensitivity: Portico.Binding<Gtk.SensitivityType>) -> Self {
|
||
appending { w, ctx in
|
||
Portico.bindProperty(
|
||
w, buttonSensitivity, registry: ctx.registry, notifyDetail: "button-sensitivity",
|
||
read: { [w] in w.getButtonSensitivity() },
|
||
write: { [w] v in w.setButtonSensitivity(sensitivity: v) }
|
||
)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.ComboBox.setButtonSensitivity(sensitivity:)
|
||
/// Sets whether the dropdown button of the combo box should update
|
||
/// its sensitivity depending on the model contents.
|
||
///
|
||
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.ComboBox.setButtonSensitivity(sensitivity:)`.
|
||
///
|
||
/// - Parameter buttonSensitivity: Whether the dropdown button is sensitive when the model is empty.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func buttonSensitivity(_ buttonSensitivity: @escaping () -> Gtk.SensitivityType) -> Self {
|
||
appending { w, ctx in
|
||
let tracker = DependencyTracker { [w] in w.setButtonSensitivity(sensitivity: buttonSensitivity()) }
|
||
tracker.run()
|
||
ctx.registry.add(tracker)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.ComboBox.setChild(child:)
|
||
/// Sets the child widget of `combo_box`.
|
||
///
|
||
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
||
///
|
||
/// - Parameter child: The child widget.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func child(_ child: Gtk.Widget?) -> Self {
|
||
appending { w, _ in
|
||
w.setChild(child: child)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Gtk.ComboBox.setChild(child:)
|
||
/// Sets the child widget of `combo_box`.
|
||
///
|
||
/// The closure is evaluated once when the modifier is applied. Its first view is mounted into the slot.
|
||
/// Additional views are ignored; an empty closure leaves the slot unset.
|
||
///
|
||
/// - Parameter child: The child widget.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func child(@ViewBuilder _ child: () -> [AnyView]) -> Self {
|
||
let childViews = child()
|
||
return appending { w, ctx in
|
||
guard let v = childViews.first else { return }
|
||
w.setChild(child: v.makeWidget(ctx))
|
||
}
|
||
}
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.ComboBox.setChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.ComboBox.getChild()
|
||
/// Sets the child widget of `combo_box`.
|
||
///
|
||
/// Applied at mount and re-applied on every change the binding publishes.
|
||
/// When `Gtk.Widget?` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
||
///
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func child<W: Gtk.Widget>(_ child: Portico.Binding<W?>) -> Self {
|
||
appending { w, ctx in
|
||
Portico.bindProperty(
|
||
w, child, registry: ctx.registry, notifyDetail: "child",
|
||
read: { [w] in w.getChild() as? W },
|
||
write: { [w] v in w.setChild(child: v) }
|
||
)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.ComboBox.setChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.ComboBox.getChild()
|
||
/// Sets the child widget of `combo_box`.
|
||
///
|
||
/// Applied at mount and re-applied on every change the binding publishes.
|
||
/// `Binding` is invariant, so a `Binding<Gtk.Widget>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.Widget?>` to be able to clear the property.
|
||
/// When `Gtk.Widget` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
||
/// A `nil` widget value is never written back into the binding.
|
||
///
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func child<W: Gtk.Widget>(_ child: Portico.Binding<W>) -> Self {
|
||
appending { w, ctx in
|
||
Portico.bindProperty(
|
||
w, child, registry: ctx.registry, notifyDetail: "child",
|
||
read: { [w] in w.getChild() as? W },
|
||
write: { [w] v in w.setChild(child: v) }
|
||
)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.ComboBox.setChild(child:)
|
||
/// Sets the child widget of `combo_box`.
|
||
///
|
||
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.ComboBox.setChild(child:)`.
|
||
///
|
||
/// - Parameter child: The child widget.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func child(_ child: @escaping () -> Gtk.Widget?) -> Self {
|
||
appending { w, ctx in
|
||
let tracker = DependencyTracker { [w] in w.setChild(child: child()) }
|
||
tracker.run()
|
||
ctx.registry.add(tracker)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.ComboBox.setEntryTextColumn(textColumn:)
|
||
/// Sets the model column which `combo_box` should use to get strings
|
||
/// from to be `text_column`.
|
||
///
|
||
/// For this column no separate
|
||
/// [class`Gtk`.CellRenderer] is needed.
|
||
///
|
||
/// The column `text_column` in the model of `combo_box` must be of
|
||
/// type `G_TYPE_STRING`.
|
||
///
|
||
/// This is only relevant if `combo_box` has been created with
|
||
/// [property`Gtk`.ComboBox:has-entry] as `true`.
|
||
///
|
||
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
||
///
|
||
/// - Parameter entryTextColumn: The model column to associate with strings from the entry.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func entryTextColumn(_ entryTextColumn: Int32) -> Self {
|
||
appending { w, _ in
|
||
w.setEntryTextColumn(textColumn: entryTextColumn)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.ComboBox.setEntryTextColumn(textColumn:), GObject.Object.connectNotify(detail:_:), Gtk.ComboBox.getEntryTextColumn()
|
||
/// Sets the model column which `combo_box` should use to get strings
|
||
/// from to be `text_column`.
|
||
///
|
||
/// For this column no separate
|
||
/// [class`Gtk`.CellRenderer] is needed.
|
||
///
|
||
/// The column `text_column` in the model of `combo_box` must be of
|
||
/// type `G_TYPE_STRING`.
|
||
///
|
||
/// This is only relevant if `combo_box` has been created with
|
||
/// [property`Gtk`.ComboBox:has-entry] as `true`.
|
||
///
|
||
/// 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 entryTextColumn(_ entryTextColumn: Portico.Binding<Int32>) -> Self {
|
||
appending { w, ctx in
|
||
Portico.bindProperty(
|
||
w, entryTextColumn, registry: ctx.registry, notifyDetail: "entry-text-column",
|
||
read: { [w] in w.getEntryTextColumn() },
|
||
write: { [w] v in w.setEntryTextColumn(textColumn: v) }
|
||
)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.ComboBox.setEntryTextColumn(textColumn:)
|
||
/// Sets the model column which `combo_box` should use to get strings
|
||
/// from to be `text_column`.
|
||
///
|
||
/// For this column no separate
|
||
/// [class`Gtk`.CellRenderer] is needed.
|
||
///
|
||
/// The column `text_column` in the model of `combo_box` must be of
|
||
/// type `G_TYPE_STRING`.
|
||
///
|
||
/// This is only relevant if `combo_box` has been created with
|
||
/// [property`Gtk`.ComboBox:has-entry] as `true`.
|
||
///
|
||
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.ComboBox.setEntryTextColumn(textColumn:)`.
|
||
///
|
||
/// - Parameter entryTextColumn: The model column to associate with strings from the entry.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func entryTextColumn(_ entryTextColumn: @escaping () -> Int32) -> Self {
|
||
appending { w, ctx in
|
||
let tracker = DependencyTracker { [w] in w.setEntryTextColumn(textColumn: entryTextColumn()) }
|
||
tracker.run()
|
||
ctx.registry.add(tracker)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.ComboBox.setIdColumn(idColumn:)
|
||
/// Sets the model column which `combo_box` should use to get string IDs
|
||
/// for values from.
|
||
///
|
||
/// The column `id_column` in the model of `combo_box` must be of type
|
||
/// `G_TYPE_STRING`.
|
||
///
|
||
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
||
///
|
||
/// - Parameter idColumn: The model column that provides string IDs for the values in the model, if != -1.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func idColumn(_ idColumn: Int32) -> Self {
|
||
appending { w, _ in
|
||
w.setIdColumn(idColumn: idColumn)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.ComboBox.setIdColumn(idColumn:), GObject.Object.connectNotify(detail:_:), Gtk.ComboBox.getIdColumn()
|
||
/// Sets the model column which `combo_box` should use to get string IDs
|
||
/// for values from.
|
||
///
|
||
/// The column `id_column` in the model of `combo_box` must be of type
|
||
/// `G_TYPE_STRING`.
|
||
///
|
||
/// 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 idColumn(_ idColumn: Portico.Binding<Int32>) -> Self {
|
||
appending { w, ctx in
|
||
Portico.bindProperty(
|
||
w, idColumn, registry: ctx.registry, notifyDetail: "id-column",
|
||
read: { [w] in w.getIdColumn() },
|
||
write: { [w] v in w.setIdColumn(idColumn: v) }
|
||
)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.ComboBox.setIdColumn(idColumn:)
|
||
/// Sets the model column which `combo_box` should use to get string IDs
|
||
/// for values from.
|
||
///
|
||
/// The column `id_column` in the model of `combo_box` must be of type
|
||
/// `G_TYPE_STRING`.
|
||
///
|
||
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.ComboBox.setIdColumn(idColumn:)`.
|
||
///
|
||
/// - Parameter idColumn: The model column that provides string IDs for the values in the model, if != -1.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func idColumn(_ idColumn: @escaping () -> Int32) -> Self {
|
||
appending { w, ctx in
|
||
let tracker = DependencyTracker { [w] in w.setIdColumn(idColumn: idColumn()) }
|
||
tracker.run()
|
||
ctx.registry.add(tracker)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.ComboBox.setModel(model:)
|
||
/// Sets the model used by `combo_box` to be `model`.
|
||
///
|
||
/// Will unset a previously set model (if applicable). If model is `nil`,
|
||
/// then it will unset the model.
|
||
///
|
||
/// Note that this function does not clear the cell renderers, you have to
|
||
/// call [method`Gtk`.CellLayout.clear] yourself if you need to set up different
|
||
/// cell renderers for the new model.
|
||
///
|
||
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
||
///
|
||
/// - Parameter model: The model from which the combo box takes its values.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func model(_ model: Gtk.TreeModel?) -> Self {
|
||
appending { w, _ in
|
||
w.setModel(model: model)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.ComboBox.setModel(model:), GObject.Object.connectNotify(detail:_:), Gtk.ComboBox.getModel()
|
||
/// Sets the model used by `combo_box` to be `model`.
|
||
///
|
||
/// Will unset a previously set model (if applicable). If model is `nil`,
|
||
/// then it will unset the model.
|
||
///
|
||
/// Note that this function does not clear the cell renderers, you have to
|
||
/// call [method`Gtk`.CellLayout.clear] yourself if you need to set up different
|
||
/// cell renderers for the new model.
|
||
///
|
||
/// Applied at mount and re-applied on every change the binding publishes.
|
||
/// When `Gtk.TreeModel?` 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 model(_ model: Portico.Binding<Gtk.TreeModel?>) -> Self {
|
||
appending { w, ctx in
|
||
Portico.bindProperty(
|
||
w, model, registry: ctx.registry, notifyDetail: "model",
|
||
read: { [w] in w.getModel() },
|
||
write: { [w] v in w.setModel(model: v) }
|
||
)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.ComboBox.setModel(model:), GObject.Object.connectNotify(detail:_:), Gtk.ComboBox.getModel()
|
||
/// Sets the model used by `combo_box` to be `model`.
|
||
///
|
||
/// Will unset a previously set model (if applicable). If model is `nil`,
|
||
/// then it will unset the model.
|
||
///
|
||
/// Note that this function does not clear the cell renderers, you have to
|
||
/// call [method`Gtk`.CellLayout.clear] yourself if you need to set up different
|
||
/// cell renderers for the new model.
|
||
///
|
||
/// Applied at mount and re-applied on every change the binding publishes.
|
||
/// `Binding` is invariant, so a `Binding<Gtk.TreeModel>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.TreeModel?>` to be able to clear the property.
|
||
/// When `Gtk.TreeModel` 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 model(_ model: Portico.Binding<Gtk.TreeModel>) -> Self {
|
||
appending { w, ctx in
|
||
Portico.bindProperty(
|
||
w, model, registry: ctx.registry, notifyDetail: "model",
|
||
read: { [w] in w.getModel() },
|
||
write: { [w] v in w.setModel(model: v) }
|
||
)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.ComboBox.setModel(model:)
|
||
/// Sets the model used by `combo_box` to be `model`.
|
||
///
|
||
/// Will unset a previously set model (if applicable). If model is `nil`,
|
||
/// then it will unset the model.
|
||
///
|
||
/// Note that this function does not clear the cell renderers, you have to
|
||
/// call [method`Gtk`.CellLayout.clear] yourself if you need to set up different
|
||
/// cell renderers for the new model.
|
||
///
|
||
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.ComboBox.setModel(model:)`.
|
||
///
|
||
/// - Parameter model: The model from which the combo box takes its values.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func model(_ model: @escaping () -> Gtk.TreeModel?) -> Self {
|
||
appending { w, ctx in
|
||
let tracker = DependencyTracker { [w] in w.setModel(model: model()) }
|
||
tracker.run()
|
||
ctx.registry.add(tracker)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.ComboBox.setPopupFixedWidth(fixed:)
|
||
/// Specifies whether the popup’s width should be a fixed width.
|
||
///
|
||
/// If `fixed` is `true`, the popup's width is set to match the
|
||
/// allocated width of the combo box.
|
||
///
|
||
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
||
///
|
||
/// - Parameter popupFixedWidth: Whether the popup's width should be a fixed width matching the allocated width of the combo box.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func popupFixedWidth(_ popupFixedWidth: Bool) -> Self {
|
||
appending { w, _ in
|
||
w.setPopupFixedWidth(fixed: popupFixedWidth)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.ComboBox.setPopupFixedWidth(fixed:), GObject.Object.connectNotify(detail:_:), Gtk.ComboBox.getPopupFixedWidth()
|
||
/// Specifies whether the popup’s width should be a fixed width.
|
||
///
|
||
/// If `fixed` is `true`, the popup's width is set to match the
|
||
/// allocated width of the combo box.
|
||
///
|
||
/// 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 popupFixedWidth(_ popupFixedWidth: Portico.Binding<Bool>) -> Self {
|
||
appending { w, ctx in
|
||
Portico.bindProperty(
|
||
w, popupFixedWidth, registry: ctx.registry, notifyDetail: "popup-fixed-width",
|
||
read: { [w] in w.getPopupFixedWidth() },
|
||
write: { [w] v in w.setPopupFixedWidth(fixed: v) }
|
||
)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.ComboBox.setPopupFixedWidth(fixed:)
|
||
/// Specifies whether the popup’s width should be a fixed width.
|
||
///
|
||
/// If `fixed` is `true`, the popup's width is set to match the
|
||
/// allocated width of the combo box.
|
||
///
|
||
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.ComboBox.setPopupFixedWidth(fixed:)`.
|
||
///
|
||
/// - Parameter popupFixedWidth: Whether the popup's width should be a fixed width matching the allocated width of the combo box.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func popupFixedWidth(_ popupFixedWidth: @escaping () -> Bool) -> Self {
|
||
appending { w, ctx in
|
||
let tracker = DependencyTracker { [w] in w.setPopupFixedWidth(fixed: popupFixedWidth()) }
|
||
tracker.run()
|
||
ctx.registry.add(tracker)
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.ComboBox.connectActivate(_:)
|
||
/// Emitted to when the combo box is activated.
|
||
///
|
||
/// The `::activate` signal on `GtkComboBox` is an action signal and
|
||
/// emitting it causes the combo box to pop up its dropdown.
|
||
///
|
||
/// - 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.ComboBox.connectChanged(_:)
|
||
/// Emitted when the active item is changed.
|
||
///
|
||
/// The can be due to the user selecting a different item from the list,
|
||
/// or due to a call to [method`Gtk`.ComboBox.set_active_iter]. It will
|
||
/// also be emitted while typing into the entry of a combo box with an entry.
|
||
///
|
||
/// - 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.ComboBox.connectFormatEntryText(_:)
|
||
/// Emitted to allow changing how the text in a combo box's entry is displayed.
|
||
///
|
||
/// See [property`Gtk`.ComboBox:has-entry].
|
||
///
|
||
/// Connect a signal handler which returns an allocated string representing
|
||
/// `path`. That string will then be used to set the text in the combo box's
|
||
/// entry. The default signal handler uses the text from the
|
||
/// [property`Gtk`.ComboBox:entry-text-column] model column.
|
||
///
|
||
/// Here's an example signal handler which fetches data from the model and
|
||
/// displays it in the entry.
|
||
/// ```c
|
||
/// static char *
|
||
/// format_entry_text_callback (GtkComboBox *combo,
|
||
/// const char *path,
|
||
/// gpointer user_data)
|
||
/// {
|
||
/// GtkTreeIter iter;
|
||
/// GtkTreeModel model;
|
||
/// double value;
|
||
///
|
||
/// model = gtk_combo_box_get_model (combo);
|
||
///
|
||
/// gtk_tree_model_get_iter_from_string (model, &iter, path);
|
||
/// gtk_tree_model_get (model, &iter,
|
||
/// THE_DOUBLE_VALUE_COLUMN, &value,
|
||
/// -1);
|
||
///
|
||
/// return g_strdup_printf ("`g`", value);
|
||
/// }
|
||
/// ```
|
||
///
|
||
/// - Parameter handler: Invoked when the widget emits the `format-entry-text` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func onFormatEntryText(_ handler: @escaping (String) -> String) -> Self {
|
||
appending { w, ctx in
|
||
ctx.registry.add(w.connectFormatEntryText { _, a0 in handler(a0) })
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.ComboBox.connectMoveActive(_:)
|
||
/// Emitted to move the active selection.
|
||
///
|
||
/// This is an [keybinding signal](class.SignalAction.html).
|
||
///
|
||
/// - Parameter handler: Invoked when the widget emits the `move-active` signal. The closure receives the signal's arguments in order.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func onMoveActive(_ handler: @escaping (Gtk.ScrollType) -> Void) -> Self {
|
||
appending { w, ctx in
|
||
ctx.registry.add(w.connectMoveActive { _, a0 in handler(a0) })
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.ComboBox.connectPopdown(_:)
|
||
/// Emitted to popdown the combo box list.
|
||
///
|
||
/// This is an [keybinding signal](class.SignalAction.html).
|
||
///
|
||
/// The default bindings for this signal are Alt+Up and Escape.
|
||
///
|
||
/// - Parameter handler: Invoked when the widget emits the `popdown` signal. Its return value is forwarded to GTK as the signal's result.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func onPopdown(_ handler: @escaping () -> Bool) -> Self {
|
||
appending { w, ctx in
|
||
ctx.registry.add(w.connectPopdown { _ in handler() })
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.ComboBox.connectPopup(_:)
|
||
/// Emitted to popup the combo box list.
|
||
///
|
||
/// This is an [keybinding signal](class.SignalAction.html).
|
||
///
|
||
/// The default binding for this signal is Alt+Down.
|
||
///
|
||
/// - Parameter handler: Invoked when the widget emits the `popup` signal.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func onPopup(_ handler: @escaping () -> Void) -> Self {
|
||
appending { w, ctx in
|
||
ctx.registry.add(w.connectPopup { _ in handler() })
|
||
}
|
||
}
|
||
|
||
}
|