718 lines
40 KiB
Swift
718 lines
40 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.DropDown
|
|
/// Allows the user to choose an item from a list of options.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="drop-down-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img alt="An example GtkDropDown" src="drop-down.png">
|
|
/// </picture>
|
|
///
|
|
/// The `GtkDropDown` displays the [selected][property`Gtk`.DropDown:selected]
|
|
/// choice.
|
|
///
|
|
/// The options are given to `GtkDropDown` in the form of `GListModel`
|
|
/// and how the individual options are represented is determined by
|
|
/// a [class`Gtk`.ListItemFactory]. The default factory displays simple strings,
|
|
/// and adds a checkmark to the selected item in the popup.
|
|
///
|
|
/// To set your own factory, use [method`Gtk`.DropDown.set_factory]. It is
|
|
/// possible to use a separate factory for the items in the popup, with
|
|
/// [method`Gtk`.DropDown.set_list_factory].
|
|
///
|
|
/// `GtkDropDown` knows how to obtain strings from the items in a
|
|
/// [class`Gtk`.StringList]; for other models, you have to provide an expression
|
|
/// to find the strings via [method`Gtk`.DropDown.set_expression].
|
|
///
|
|
/// `GtkDropDown` can optionally allow search in the popup, which is
|
|
/// useful if the list of options is long. To enable the search entry,
|
|
/// use [method`Gtk`.DropDown.set_enable_search].
|
|
///
|
|
/// Here is a UI definition example for `GtkDropDown` with a simple model:
|
|
///
|
|
/// ```xml
|
|
/// <object class="GtkDropDown">
|
|
/// <property name="model">
|
|
/// <object class="GtkStringList">
|
|
/// <items>
|
|
/// <item translatable="yes">Factory</item>
|
|
/// <item translatable="yes">Home</item>
|
|
/// <item translatable="yes">Subway</item>
|
|
/// </items>
|
|
/// </object>
|
|
/// </property>
|
|
/// </object>
|
|
/// ```
|
|
///
|
|
/// If a `GtkDropDown` is created in this manner, or with
|
|
/// [ctor`Gtk`.DropDown.new_from_strings], for instance, the object returned from
|
|
/// [method`Gtk`.DropDown.get_selected_item] will be a [class`Gtk`.StringObject].
|
|
///
|
|
/// To learn more about the list widget framework, see the
|
|
/// [overview](section-list-widget.html).
|
|
///
|
|
/// ## CSS nodes
|
|
///
|
|
/// `GtkDropDown` has a single CSS node with name dropdown,
|
|
/// with the button and popover nodes as children.
|
|
///
|
|
/// ## Accessibility
|
|
///
|
|
/// `GtkDropDown` uses the [enum`Gtk`.AccessibleRole.combo_box] role.
|
|
///
|
|
/// A Portico view that mounts a `Gtk.DropDown`.
|
|
@MainActor public struct DropDown: View {
|
|
private let make: (MountContext) -> Gtk.DropDown
|
|
private var configure: [(Gtk.DropDown, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Gtk.DropDown.init(model:expression:)
|
|
/// Creates a new `GtkDropDown`.
|
|
///
|
|
/// You may want to call [method`Gtk`.DropDown.set_factory]
|
|
/// to set up a way to map its items to widgets.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for values that change.
|
|
///
|
|
/// - Parameter model: Model for the displayed items.
|
|
/// - Parameter expression: An expression to evaluate to obtain strings to match against the search term.
|
|
public init(model: Gtk.ListModel?, expression: Gtk.Expression?) {
|
|
make = { _ in Gtk.DropDown(model: model, expression: expression) }
|
|
}
|
|
|
|
// PorticoGen: generateInits(binding) | source: Gtk.DropDown.init(model:expression:), Gtk.DropDown.setModel(model:), Gtk.DropDown.setExpression(expression:)
|
|
/// Creates a new `GtkDropDown`.
|
|
///
|
|
/// You may want to call [method`Gtk`.DropDown.set_factory]
|
|
/// to set up a way to map its items to widgets.
|
|
///
|
|
/// The initial value is the binding's current value; every later change is pushed into the widget through `Gtk.DropDown.setModel(model:), Gtk.DropDown.setExpression(expression:)` without rebuilding the view.
|
|
///
|
|
/// - Parameter model: Model for the displayed items.
|
|
/// - Parameter expression: An expression to evaluate to obtain strings to match against the search term.
|
|
public init(model: Portico.Binding<Gtk.ListModel?>, expression: Portico.Binding<Gtk.Expression?>) {
|
|
make = { _ in Gtk.DropDown(model: model.wrappedValue, expression: expression.wrappedValue) }
|
|
configure.append { w, ctx in
|
|
ctx.registry.add(model.subscribe { [w] v in w.setModel(model: v) })
|
|
ctx.registry.add(expression.subscribe { [w] v in w.setExpression(expression: v) })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateInits(closure) | source: Gtk.DropDown.init(model:expression:), Gtk.DropDown.setModel(model:), Gtk.DropDown.setExpression(expression:)
|
|
/// Creates a new `GtkDropDown`.
|
|
///
|
|
/// You may want to call [method`Gtk`.DropDown.set_factory]
|
|
/// to set up a way to map its items to widgets.
|
|
///
|
|
/// Each closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.DropDown.setModel(model:), Gtk.DropDown.setExpression(expression:)`.
|
|
///
|
|
/// - Parameter model: Model for the displayed items.
|
|
/// - Parameter expression: An expression to evaluate to obtain strings to match against the search term.
|
|
public init(model: @escaping () -> Gtk.ListModel?, expression: @escaping () -> Gtk.Expression?) {
|
|
make = { _ in Gtk.DropDown(model: model(), expression: expression()) }
|
|
configure.append { w, ctx in
|
|
let t0 = DependencyTracker { [w] in w.setModel(model: model()) }
|
|
t0.run()
|
|
ctx.registry.add(t0)
|
|
let t1 = DependencyTracker { [w] in w.setExpression(expression: expression()) }
|
|
t1.run()
|
|
ctx.registry.add(t1)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateInits(static) | source: Gtk.DropDown.init(strings:)
|
|
/// Creates a new `GtkDropDown` that is populated with
|
|
/// the strings.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for values that change.
|
|
///
|
|
/// - Parameter strings: The `strings` value forwarded to `Gtk.DropDown`.
|
|
public init(strings: [String]) {
|
|
make = { _ in Gtk.DropDown(strings: strings) }
|
|
}
|
|
|
|
}
|
|
|
|
extension DropDown: WidgetView {
|
|
public typealias Target = Gtk.DropDown
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Gtk.DropDown, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension DropDown: 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.DropDown
|
|
/// Modifiers for `Gtk.DropDown`, available on every Portico view whose
|
|
/// backing widget is `Gtk.DropDown` or one of its subclasses.
|
|
extension WidgetView where Target: Gtk.DropDown {
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.DropDown.setEnableSearch(enableSearch:)
|
|
/// Sets whether a search entry will be shown in the popup that
|
|
/// allows to search for items in the list.
|
|
///
|
|
/// Note that [property`Gtk`.DropDown:expression] must be set for
|
|
/// search to work.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter enableSearch: Whether to show a search entry in the popup.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func enableSearch(_ enableSearch: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setEnableSearch(enableSearch: enableSearch)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.DropDown.setEnableSearch(enableSearch:), GObject.Object.connectNotify(detail:_:), Gtk.DropDown.getEnableSearch()
|
|
/// Sets whether a search entry will be shown in the popup that
|
|
/// allows to search for items in the list.
|
|
///
|
|
/// Note that [property`Gtk`.DropDown:expression] must be set for
|
|
/// search to work.
|
|
///
|
|
/// 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.
|
|
///
|
|
/// - Parameter enableSearch: Whether to show a search entry in the popup.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func enableSearch(_ enableSearch: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, enableSearch, registry: ctx.registry,
|
|
read: { [w] in w.getEnableSearch() },
|
|
write: { [w] v in w.setEnableSearch(enableSearch: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.DropDown.setEnableSearch(enableSearch:)
|
|
/// Sets whether a search entry will be shown in the popup that
|
|
/// allows to search for items in the list.
|
|
///
|
|
/// Note that [property`Gtk`.DropDown:expression] must be set for
|
|
/// search to work.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.DropDown.setEnableSearch(enableSearch:)`.
|
|
///
|
|
/// - Parameter enableSearch: Whether to show a search entry in the popup.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func enableSearch(_ enableSearch: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setEnableSearch(enableSearch: enableSearch()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.DropDown.setExpression(expression:)
|
|
/// Sets the expression that gets evaluated to obtain strings from items.
|
|
///
|
|
/// This is used for search in the popup. The expression must have
|
|
/// a value type of `G_TYPE_STRING`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter expression: An expression to evaluate to obtain strings to match against the search term.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func expression(_ expression: Gtk.Expression?) -> Self {
|
|
appending { w, _ in
|
|
w.setExpression(expression: expression)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.DropDown.setExpression(expression:), GObject.Object.connectNotify(detail:_:), Gtk.DropDown.getExpression()
|
|
/// Sets the expression that gets evaluated to obtain strings from items.
|
|
///
|
|
/// This is used for search in the popup. The expression must have
|
|
/// a value type of `G_TYPE_STRING`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Gtk.Expression?` 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.
|
|
///
|
|
/// - Parameter expression: An expression to evaluate to obtain strings to match against the search term.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func expression(_ expression: Portico.Binding<Gtk.Expression?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, expression, registry: ctx.registry,
|
|
read: { [w] in w.getExpression() },
|
|
write: { [w] v in w.setExpression(expression: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.DropDown.setExpression(expression:), GObject.Object.connectNotify(detail:_:), Gtk.DropDown.getExpression()
|
|
/// Sets the expression that gets evaluated to obtain strings from items.
|
|
///
|
|
/// This is used for search in the popup. The expression must have
|
|
/// a value type of `G_TYPE_STRING`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant, so a `Binding<Gtk.Expression>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.Expression?>` to be able to clear the property.
|
|
/// When `Gtk.Expression` 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.
|
|
///
|
|
/// - Parameter expression: An expression to evaluate to obtain strings to match against the search term.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func expression(_ expression: Portico.Binding<Gtk.Expression>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, expression, registry: ctx.registry,
|
|
read: { [w] in w.getExpression() },
|
|
write: { [w] v in w.setExpression(expression: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.DropDown.setExpression(expression:)
|
|
/// Sets the expression that gets evaluated to obtain strings from items.
|
|
///
|
|
/// This is used for search in the popup. The expression must have
|
|
/// a value type of `G_TYPE_STRING`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.DropDown.setExpression(expression:)`.
|
|
///
|
|
/// - Parameter expression: An expression to evaluate to obtain strings to match against the search term.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func expression(_ expression: @escaping () -> Gtk.Expression?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setExpression(expression: expression()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.DropDown.setFactory(factory:)
|
|
/// Sets the `GtkListItemFactory` to use for populating list items.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter factory: Factory for populating list items.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func factory(_ factory: Gtk.ListItemFactory?) -> Self {
|
|
appending { w, _ in
|
|
w.setFactory(factory: factory)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.DropDown.setFactory(factory:), GObject.Object.connectNotify(detail:_:), Gtk.DropDown.getFactory()
|
|
/// Sets the `GtkListItemFactory` to use for populating list items.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Gtk.ListItemFactory?` 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.
|
|
///
|
|
/// - Parameter factory: Factory for populating list items.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func factory(_ factory: Portico.Binding<Gtk.ListItemFactory?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, factory, registry: ctx.registry,
|
|
read: { [w] in w.getFactory() },
|
|
write: { [w] v in w.setFactory(factory: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.DropDown.setFactory(factory:), GObject.Object.connectNotify(detail:_:), Gtk.DropDown.getFactory()
|
|
/// Sets the `GtkListItemFactory` to use for populating list items.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant, so a `Binding<Gtk.ListItemFactory>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.ListItemFactory?>` to be able to clear the property.
|
|
/// When `Gtk.ListItemFactory` 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.
|
|
///
|
|
/// - Parameter factory: Factory for populating list items.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func factory(_ factory: Portico.Binding<Gtk.ListItemFactory>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, factory, registry: ctx.registry,
|
|
read: { [w] in w.getFactory() },
|
|
write: { [w] v in w.setFactory(factory: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.DropDown.setFactory(factory:)
|
|
/// Sets the `GtkListItemFactory` to use for populating list items.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.DropDown.setFactory(factory:)`.
|
|
///
|
|
/// - Parameter factory: Factory for populating list items.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func factory(_ factory: @escaping () -> Gtk.ListItemFactory?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setFactory(factory: factory()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.DropDown.setHeaderFactory(factory:)
|
|
/// Sets the `GtkListItemFactory` to use for creating header widgets for the popup.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter headerFactory: The factory for creating header widgets for the popup.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func headerFactory(_ headerFactory: Gtk.ListItemFactory?) -> Self {
|
|
appending { w, _ in
|
|
w.setHeaderFactory(factory: headerFactory)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.DropDown.setHeaderFactory(factory:), GObject.Object.connectNotify(detail:_:), Gtk.DropDown.getHeaderFactory()
|
|
/// Sets the `GtkListItemFactory` to use for creating header widgets for the popup.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Gtk.ListItemFactory?` 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.
|
|
///
|
|
/// - Parameter headerFactory: The factory for creating header widgets for the popup.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func headerFactory(_ headerFactory: Portico.Binding<Gtk.ListItemFactory?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, headerFactory, registry: ctx.registry,
|
|
read: { [w] in w.getHeaderFactory() },
|
|
write: { [w] v in w.setHeaderFactory(factory: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.DropDown.setHeaderFactory(factory:), GObject.Object.connectNotify(detail:_:), Gtk.DropDown.getHeaderFactory()
|
|
/// Sets the `GtkListItemFactory` to use for creating header widgets for the popup.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant, so a `Binding<Gtk.ListItemFactory>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.ListItemFactory?>` to be able to clear the property.
|
|
/// When `Gtk.ListItemFactory` 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.
|
|
///
|
|
/// - Parameter headerFactory: The factory for creating header widgets for the popup.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func headerFactory(_ headerFactory: Portico.Binding<Gtk.ListItemFactory>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, headerFactory, registry: ctx.registry,
|
|
read: { [w] in w.getHeaderFactory() },
|
|
write: { [w] v in w.setHeaderFactory(factory: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.DropDown.setHeaderFactory(factory:)
|
|
/// Sets the `GtkListItemFactory` to use for creating header widgets for the popup.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.DropDown.setHeaderFactory(factory:)`.
|
|
///
|
|
/// - Parameter headerFactory: The factory for creating header widgets for the popup.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func headerFactory(_ headerFactory: @escaping () -> Gtk.ListItemFactory?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setHeaderFactory(factory: headerFactory()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.DropDown.setListFactory(factory:)
|
|
/// Sets the `GtkListItemFactory` to use for populating list items in the popup.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter listFactory: The factory for populating list items in the popup.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func listFactory(_ listFactory: Gtk.ListItemFactory?) -> Self {
|
|
appending { w, _ in
|
|
w.setListFactory(factory: listFactory)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.DropDown.setListFactory(factory:), GObject.Object.connectNotify(detail:_:), Gtk.DropDown.getListFactory()
|
|
/// Sets the `GtkListItemFactory` to use for populating list items in the popup.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Gtk.ListItemFactory?` 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.
|
|
///
|
|
/// - Parameter listFactory: The factory for populating list items in the popup.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func listFactory(_ listFactory: Portico.Binding<Gtk.ListItemFactory?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, listFactory, registry: ctx.registry,
|
|
read: { [w] in w.getListFactory() },
|
|
write: { [w] v in w.setListFactory(factory: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.DropDown.setListFactory(factory:), GObject.Object.connectNotify(detail:_:), Gtk.DropDown.getListFactory()
|
|
/// Sets the `GtkListItemFactory` to use for populating list items in the popup.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant, so a `Binding<Gtk.ListItemFactory>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.ListItemFactory?>` to be able to clear the property.
|
|
/// When `Gtk.ListItemFactory` 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.
|
|
///
|
|
/// - Parameter listFactory: The factory for populating list items in the popup.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func listFactory(_ listFactory: Portico.Binding<Gtk.ListItemFactory>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, listFactory, registry: ctx.registry,
|
|
read: { [w] in w.getListFactory() },
|
|
write: { [w] v in w.setListFactory(factory: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.DropDown.setListFactory(factory:)
|
|
/// Sets the `GtkListItemFactory` to use for populating list items in the popup.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.DropDown.setListFactory(factory:)`.
|
|
///
|
|
/// - Parameter listFactory: The factory for populating list items in the popup.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func listFactory(_ listFactory: @escaping () -> Gtk.ListItemFactory?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setListFactory(factory: listFactory()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.DropDown.setModel(model:)
|
|
/// Sets the `GListModel` to use.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter model: Model for the displayed items.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func model(_ model: Gtk.ListModel?) -> Self {
|
|
appending { w, _ in
|
|
w.setModel(model: model)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.DropDown.setModel(model:), GObject.Object.connectNotify(detail:_:), Gtk.DropDown.getModel()
|
|
/// Sets the `GListModel` to use.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Gtk.ListModel?` 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.
|
|
///
|
|
/// - Parameter model: Model for the displayed items.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func model(_ model: Portico.Binding<Gtk.ListModel?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, model, registry: ctx.registry,
|
|
read: { [w] in w.getModel() },
|
|
write: { [w] v in w.setModel(model: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.DropDown.setModel(model:), GObject.Object.connectNotify(detail:_:), Gtk.DropDown.getModel()
|
|
/// Sets the `GListModel` to use.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant, so a `Binding<Gtk.ListModel>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.ListModel?>` to be able to clear the property.
|
|
/// When `Gtk.ListModel` 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.
|
|
///
|
|
/// - Parameter model: Model for the displayed items.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func model(_ model: Portico.Binding<Gtk.ListModel>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, model, registry: ctx.registry,
|
|
read: { [w] in w.getModel() },
|
|
write: { [w] v in w.setModel(model: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.DropDown.setModel(model:)
|
|
/// Sets the `GListModel` to use.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.DropDown.setModel(model:)`.
|
|
///
|
|
/// - Parameter model: Model for the displayed items.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func model(_ model: @escaping () -> Gtk.ListModel?) -> 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.DropDown.setSearchMatchMode(searchMatchMode:)
|
|
/// Sets the match mode for the search filter.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter searchMatchMode: The match mode for the search filter.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func searchMatchMode(_ searchMatchMode: Gtk.StringFilterMatchMode) -> Self {
|
|
appending { w, _ in
|
|
w.setSearchMatchMode(searchMatchMode: searchMatchMode)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.DropDown.setSearchMatchMode(searchMatchMode:), GObject.Object.connectNotify(detail:_:), Gtk.DropDown.getSearchMatchMode()
|
|
/// Sets the match mode for the search filter.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Gtk.StringFilterMatchMode` 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.
|
|
///
|
|
/// - Parameter searchMatchMode: The match mode for the search filter.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func searchMatchMode(_ searchMatchMode: Portico.Binding<Gtk.StringFilterMatchMode>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, searchMatchMode, registry: ctx.registry,
|
|
read: { [w] in w.getSearchMatchMode() },
|
|
write: { [w] v in w.setSearchMatchMode(searchMatchMode: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.DropDown.setSearchMatchMode(searchMatchMode:)
|
|
/// Sets the match mode for the search filter.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.DropDown.setSearchMatchMode(searchMatchMode:)`.
|
|
///
|
|
/// - Parameter searchMatchMode: The match mode for the search filter.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func searchMatchMode(_ searchMatchMode: @escaping () -> Gtk.StringFilterMatchMode) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setSearchMatchMode(searchMatchMode: searchMatchMode()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.DropDown.setSelected(position:)
|
|
/// Selects the item at the given position.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter selected: The position of the selected item.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func selected(_ selected: UInt32) -> Self {
|
|
appending { w, _ in
|
|
w.setSelected(position: selected)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.DropDown.setSelected(position:), GObject.Object.connectNotify(detail:_:), Gtk.DropDown.getSelected()
|
|
/// Selects the item at the given position.
|
|
///
|
|
/// 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.
|
|
///
|
|
/// - Parameter selected: The position of the selected item.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func selected(_ selected: Portico.Binding<UInt32>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, selected, registry: ctx.registry,
|
|
read: { [w] in w.getSelected() },
|
|
write: { [w] v in w.setSelected(position: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.DropDown.setSelected(position:)
|
|
/// Selects the item at the given position.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.DropDown.setSelected(position:)`.
|
|
///
|
|
/// - Parameter selected: The position of the selected item.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func selected(_ selected: @escaping () -> UInt32) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setSelected(position: selected()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.DropDown.setShowArrow(showArrow:)
|
|
/// Sets whether an arrow will be displayed within the widget.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter showArrow: Whether to show an arrow within the GtkDropDown widget.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func showArrow(_ showArrow: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setShowArrow(showArrow: showArrow)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.DropDown.setShowArrow(showArrow:), GObject.Object.connectNotify(detail:_:), Gtk.DropDown.getShowArrow()
|
|
/// Sets whether an arrow will be displayed within the 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.
|
|
///
|
|
/// - Parameter showArrow: Whether to show an arrow within the GtkDropDown widget.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func showArrow(_ showArrow: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, showArrow, registry: ctx.registry,
|
|
read: { [w] in w.getShowArrow() },
|
|
write: { [w] v in w.setShowArrow(showArrow: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.DropDown.setShowArrow(showArrow:)
|
|
/// Sets whether an arrow will be displayed within the widget.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.DropDown.setShowArrow(showArrow:)`.
|
|
///
|
|
/// - Parameter showArrow: Whether to show an arrow within the GtkDropDown widget.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func showArrow(_ showArrow: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setShowArrow(showArrow: showArrow()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.DropDown.connectActivate(_:)
|
|
/// Emitted to when the drop down is activated.
|
|
///
|
|
/// The `::activate` signal on `GtkDropDown` is an action signal and
|
|
/// emitting it causes the drop down 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() })
|
|
}
|
|
}
|
|
|
|
}
|