portico/Sources/Portico/Generated/GridView.swift

616 lines
34 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.GridView
/// Presents a large dynamic grid of items.
///
/// `GtkGridView` uses its factory to generate one child widget for each
/// visible item and shows them in a grid. The orientation of the grid view
/// determines if the grid reflows vertically or horizontally.
///
/// `GtkGridView` allows the user to select items according to the selection
/// characteristics of the model. For models that allow multiple selected items,
/// it is possible to turn on _rubberband selection_, using
/// [property`Gtk`.GridView:enable-rubberband].
///
/// To learn more about the list widget framework, see the
/// [overview](section-list-widget.html).
///
/// # Actions
///
/// `GtkGridView` defines a set of built-in actions:
///
/// - `list.activate-item` activates the item at given position by emitting the
/// the [signal`Gtk`.GridView::activate] signal.
///
/// # CSS nodes
///
/// ```
/// gridview
/// child[.activatable]
///
/// child[.activatable]
///
///
/// [rubberband]
/// ```
///
/// `GtkGridView` uses a single CSS node with name `gridview`. Each child uses
/// a single CSS node with name `child`. If the [property`Gtk`.ListItem:activatable]
/// property is set, the corresponding row will have the `.activatable` style
/// class. For rubberband selection, a subnode with name `rubberband` is used.
///
/// # Accessibility
///
/// `GtkGridView` uses the [enum`Gtk`.AccessibleRole.grid] role, and the items
/// use the [enum`Gtk`.AccessibleRole.grid_cell] role.
///
/// A Portico view that mounts a `Gtk.GridView`.
@MainActor public struct GridView: View {
private let make: (MountContext) -> Gtk.GridView
private var configure: [(Gtk.GridView, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.GridView.init(model:factory:)
/// Creates a new `GtkGridView` that uses the given `factory` for
/// mapping items to widgets.
///
/// The function takes ownership of the
/// arguments, so you can write code like
/// ```c
/// grid_view = gtk_grid_view_new (create_model (),
/// gtk_builder_list_item_factory_new_from_resource ("/resource.ui"));
/// ```
///
/// Applied once at mount; use the `Binding` or closure overload for values that change.
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
///
/// - Parameter model: Model for the items displayed.
/// - Parameter factory: Factory for populating list items.
/// - Parameter enableRubberband: Allow rubberband selection.
/// - Parameter maxColumns: Maximum number of columns per row.
/// - Parameter minColumns: Minimum number of columns per row.
/// - Parameter singleClickActivate: Activate rows on single click and select them on hover.
/// - Parameter tabBehavior: Behavior of the <kbd>Tab</kbd> key
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal. The closure receives the signal's arguments in order.
public init(model: Gtk.SelectionModel?, factory: Gtk.ListItemFactory?, enableRubberband: Bool? = nil, maxColumns: UInt32? = nil, minColumns: UInt32? = nil, singleClickActivate: Bool? = nil, tabBehavior: Gtk.ListTabBehavior? = nil, onActivate: ((UInt32) -> Void)? = nil) {
make = { _ in Gtk.GridView(model: model, factory: factory) }
configure.append { w, ctx in
if let enableRubberband { w.setEnableRubberband(enableRubberband: enableRubberband) }
if let maxColumns { w.setMaxColumns(maxColumns: maxColumns) }
if let minColumns { w.setMinColumns(minColumns: minColumns) }
if let singleClickActivate { w.setSingleClickActivate(singleClickActivate: singleClickActivate) }
if let tabBehavior { w.setTabBehavior(tabBehavior: tabBehavior) }
if let onActivate { ctx.registry.add(w.connectActivate { _, a0 in onActivate(a0) }) }
}
}
// PorticoGen: generateInits(binding) | source: Gtk.GridView.init(model:factory:), Gtk.GridView.setModel(model:), Gtk.GridView.setFactory(factory:)
/// Creates a new `GtkGridView` that uses the given `factory` for
/// mapping items to widgets.
///
/// The function takes ownership of the
/// arguments, so you can write code like
/// ```c
/// grid_view = gtk_grid_view_new (create_model (),
/// gtk_builder_list_item_factory_new_from_resource ("/resource.ui"));
/// ```
///
/// The initial value is the binding's current value; every later change is pushed into the widget through `Gtk.GridView.setModel(model:), Gtk.GridView.setFactory(factory:)` without rebuilding the view.
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
/// Optional `Binding` parameters bind through `Portico.bindProperty`, so they are two-way wherever the wrapper exposes a safe getter.
///
/// - Parameter model: Model for the items displayed.
/// - Parameter factory: Factory for populating list items.
/// - Parameter enableRubberband: Allow rubberband selection.
/// - Parameter maxColumns: Maximum number of columns per row.
/// - Parameter minColumns: Minimum number of columns per row.
/// - Parameter singleClickActivate: Activate rows on single click and select them on hover.
/// - Parameter tabBehavior: Behavior of the <kbd>Tab</kbd> key
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal. The closure receives the signal's arguments in order.
public init(model: Portico.Binding<Gtk.SelectionModel?>, factory: Portico.Binding<Gtk.ListItemFactory?>, enableRubberband: Portico.Binding<Bool>? = nil, maxColumns: Portico.Binding<UInt32>? = nil, minColumns: Portico.Binding<UInt32>? = nil, singleClickActivate: Portico.Binding<Bool>? = nil, tabBehavior: Portico.Binding<Gtk.ListTabBehavior>? = nil, onActivate: ((UInt32) -> Void)? = nil) {
make = { _ in Gtk.GridView(model: model.wrappedValue, factory: factory.wrappedValue) }
configure.append { w, ctx in
ctx.registry.add(model.subscribe { [w] v in w.setModel(model: v) })
ctx.registry.add(factory.subscribe { [w] v in w.setFactory(factory: v) })
if let enableRubberband {
Portico.bindProperty(w, enableRubberband, registry: ctx.registry, notifyDetail: "enable-rubberband", read: { [w] in w.getEnableRubberband() }, write: { [w] v in w.setEnableRubberband(enableRubberband: v) })
}
if let maxColumns {
Portico.bindProperty(w, maxColumns, registry: ctx.registry, notifyDetail: "max-columns", read: { [w] in w.getMaxColumns() }, write: { [w] v in w.setMaxColumns(maxColumns: v) })
}
if let minColumns {
Portico.bindProperty(w, minColumns, registry: ctx.registry, notifyDetail: "min-columns", read: { [w] in w.getMinColumns() }, write: { [w] v in w.setMinColumns(minColumns: v) })
}
if let singleClickActivate {
Portico.bindProperty(w, singleClickActivate, registry: ctx.registry, notifyDetail: "single-click-activate", read: { [w] in w.getSingleClickActivate() }, write: { [w] v in w.setSingleClickActivate(singleClickActivate: v) })
}
if let tabBehavior {
Portico.bindProperty(w, tabBehavior, registry: ctx.registry, notifyDetail: "tab-behavior", read: { [w] in w.getTabBehavior() }, write: { [w] v in w.setTabBehavior(tabBehavior: v) })
}
if let onActivate { ctx.registry.add(w.connectActivate { _, a0 in onActivate(a0) }) }
}
}
// PorticoGen: generateInits(closure) | source: Gtk.GridView.init(model:factory:), Gtk.GridView.setModel(model:), Gtk.GridView.setFactory(factory:)
/// Creates a new `GtkGridView` that uses the given `factory` for
/// mapping items to widgets.
///
/// The function takes ownership of the
/// arguments, so you can write code like
/// ```c
/// grid_view = gtk_grid_view_new (create_model (),
/// gtk_builder_list_item_factory_new_from_resource ("/resource.ui"));
/// ```
///
/// Each closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.GridView.setModel(model:), Gtk.GridView.setFactory(factory:)`.
/// 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: Model for the items displayed.
/// - Parameter factory: Factory for populating list items.
/// - Parameter enableRubberband: Allow rubberband selection.
/// - Parameter maxColumns: Maximum number of columns per row.
/// - Parameter minColumns: Minimum number of columns per row.
/// - Parameter singleClickActivate: Activate rows on single click and select them on hover.
/// - Parameter tabBehavior: Behavior of the <kbd>Tab</kbd> key
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal. The closure receives the signal's arguments in order.
public init(model: @escaping () -> Gtk.SelectionModel?, factory: @escaping () -> Gtk.ListItemFactory?, enableRubberband: Bool? = nil, maxColumns: UInt32? = nil, minColumns: UInt32? = nil, singleClickActivate: Bool? = nil, tabBehavior: Gtk.ListTabBehavior? = nil, onActivate: ((UInt32) -> Void)? = nil) {
make = { _ in Gtk.GridView(model: model(), factory: factory()) }
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.setFactory(factory: factory()) }
t1.run()
ctx.registry.add(t1)
if let enableRubberband { w.setEnableRubberband(enableRubberband: enableRubberband) }
if let maxColumns { w.setMaxColumns(maxColumns: maxColumns) }
if let minColumns { w.setMinColumns(minColumns: minColumns) }
if let singleClickActivate { w.setSingleClickActivate(singleClickActivate: singleClickActivate) }
if let tabBehavior { w.setTabBehavior(tabBehavior: tabBehavior) }
if let onActivate { ctx.registry.add(w.connectActivate { _, a0 in onActivate(a0) }) }
}
}
}
extension GridView: WidgetView {
public typealias Target = Gtk.GridView
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.GridView, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension GridView: 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.GridView
/// Modifiers for `Gtk.GridView`, available on every Portico view whose
/// backing widget is `Gtk.GridView` or one of its subclasses.
extension WidgetView where Target: Gtk.GridView {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.GridView.setEnableRubberband(enableRubberband:)
/// Sets whether selections can be changed by dragging with the mouse.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter enableRubberband: Allow rubberband selection.
/// - Returns: A copy of this view with the modifier applied.
public func enableRubberband(_ enableRubberband: Bool) -> Self {
appending { w, _ in
w.setEnableRubberband(enableRubberband: enableRubberband)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.GridView.setEnableRubberband(enableRubberband:), GObject.Object.connectNotify(detail:_:), Gtk.GridView.getEnableRubberband()
/// Sets whether selections can be changed by dragging with the mouse.
///
/// 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 enableRubberband(_ enableRubberband: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, enableRubberband, registry: ctx.registry, notifyDetail: "enable-rubberband",
read: { [w] in w.getEnableRubberband() },
write: { [w] v in w.setEnableRubberband(enableRubberband: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.GridView.setEnableRubberband(enableRubberband:)
/// Sets whether selections can be changed by dragging with the mouse.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.GridView.setEnableRubberband(enableRubberband:)`.
///
/// - Parameter enableRubberband: Allow rubberband selection.
/// - Returns: A copy of this view with the modifier applied.
public func enableRubberband(_ enableRubberband: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setEnableRubberband(enableRubberband: enableRubberband()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.GridView.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.GridView.setFactory(factory:), GObject.Object.connectNotify(detail:_:), Gtk.GridView.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.
///
/// - 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, notifyDetail: "factory",
read: { [w] in w.getFactory() },
write: { [w] v in w.setFactory(factory: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.GridView.setFactory(factory:), GObject.Object.connectNotify(detail:_:), Gtk.GridView.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.
///
/// - 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, notifyDetail: "factory",
read: { [w] in w.getFactory() },
write: { [w] v in w.setFactory(factory: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.GridView.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.GridView.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.GridView.setMaxColumns(maxColumns:)
/// Sets the maximum number of columns to use.
///
/// This number must be at least 1.
///
/// If `max_columns` is smaller than the minimum set via
/// [method`Gtk`.GridView.set_min_columns], that value is used instead.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter maxColumns: Maximum number of columns per row.
/// - Returns: A copy of this view with the modifier applied.
public func maxColumns(_ maxColumns: UInt32) -> Self {
appending { w, _ in
w.setMaxColumns(maxColumns: maxColumns)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.GridView.setMaxColumns(maxColumns:), GObject.Object.connectNotify(detail:_:), Gtk.GridView.getMaxColumns()
/// Sets the maximum number of columns to use.
///
/// This number must be at least 1.
///
/// If `max_columns` is smaller than the minimum set via
/// [method`Gtk`.GridView.set_min_columns], that value is used instead.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `UInt32` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func maxColumns(_ maxColumns: Portico.Binding<UInt32>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, maxColumns, registry: ctx.registry, notifyDetail: "max-columns",
read: { [w] in w.getMaxColumns() },
write: { [w] v in w.setMaxColumns(maxColumns: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.GridView.setMaxColumns(maxColumns:)
/// Sets the maximum number of columns to use.
///
/// This number must be at least 1.
///
/// If `max_columns` is smaller than the minimum set via
/// [method`Gtk`.GridView.set_min_columns], that value is used instead.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.GridView.setMaxColumns(maxColumns:)`.
///
/// - Parameter maxColumns: Maximum number of columns per row.
/// - Returns: A copy of this view with the modifier applied.
public func maxColumns(_ maxColumns: @escaping () -> UInt32) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setMaxColumns(maxColumns: maxColumns()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.GridView.setMinColumns(minColumns:)
/// Sets the minimum number of columns to use.
///
/// This number must be at least 1.
///
/// If `min_columns` is smaller than the minimum set via
/// [method`Gtk`.GridView.set_max_columns], that value is ignored.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter minColumns: Minimum number of columns per row.
/// - Returns: A copy of this view with the modifier applied.
public func minColumns(_ minColumns: UInt32) -> Self {
appending { w, _ in
w.setMinColumns(minColumns: minColumns)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.GridView.setMinColumns(minColumns:), GObject.Object.connectNotify(detail:_:), Gtk.GridView.getMinColumns()
/// Sets the minimum number of columns to use.
///
/// This number must be at least 1.
///
/// If `min_columns` is smaller than the minimum set via
/// [method`Gtk`.GridView.set_max_columns], that value is ignored.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `UInt32` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func minColumns(_ minColumns: Portico.Binding<UInt32>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, minColumns, registry: ctx.registry, notifyDetail: "min-columns",
read: { [w] in w.getMinColumns() },
write: { [w] v in w.setMinColumns(minColumns: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.GridView.setMinColumns(minColumns:)
/// Sets the minimum number of columns to use.
///
/// This number must be at least 1.
///
/// If `min_columns` is smaller than the minimum set via
/// [method`Gtk`.GridView.set_max_columns], that value is ignored.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.GridView.setMinColumns(minColumns:)`.
///
/// - Parameter minColumns: Minimum number of columns per row.
/// - Returns: A copy of this view with the modifier applied.
public func minColumns(_ minColumns: @escaping () -> UInt32) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setMinColumns(minColumns: minColumns()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.GridView.setModel(model:)
/// Sets the model to use.
///
/// This must be a [iface`Gtk`.SelectionModel].
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter model: Model for the items displayed.
/// - Returns: A copy of this view with the modifier applied.
public func model(_ model: Gtk.SelectionModel?) -> Self {
appending { w, _ in
w.setModel(model: model)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.GridView.setModel(model:), GObject.Object.connectNotify(detail:_:), Gtk.GridView.getModel()
/// Sets the model to use.
///
/// This must be a [iface`Gtk`.SelectionModel].
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.SelectionModel?` 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.SelectionModel?>) -> 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.GridView.setModel(model:), GObject.Object.connectNotify(detail:_:), Gtk.GridView.getModel()
/// Sets the model to use.
///
/// This must be a [iface`Gtk`.SelectionModel].
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Gtk.SelectionModel>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.SelectionModel?>` to be able to clear the property.
/// When `Gtk.SelectionModel` 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.SelectionModel>) -> 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.GridView.setModel(model:)
/// Sets the model to use.
///
/// This must be a [iface`Gtk`.SelectionModel].
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.GridView.setModel(model:)`.
///
/// - Parameter model: Model for the items displayed.
/// - Returns: A copy of this view with the modifier applied.
public func model(_ model: @escaping () -> Gtk.SelectionModel?) -> 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.GridView.setSingleClickActivate(singleClickActivate:)
/// Sets whether items should be activated on single click and
/// selected on hover.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter singleClickActivate: Activate rows on single click and select them on hover.
/// - Returns: A copy of this view with the modifier applied.
public func singleClickActivate(_ singleClickActivate: Bool) -> Self {
appending { w, _ in
w.setSingleClickActivate(singleClickActivate: singleClickActivate)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.GridView.setSingleClickActivate(singleClickActivate:), GObject.Object.connectNotify(detail:_:), Gtk.GridView.getSingleClickActivate()
/// Sets whether items should be activated on single click and
/// selected on hover.
///
/// 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 singleClickActivate(_ singleClickActivate: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, singleClickActivate, registry: ctx.registry, notifyDetail: "single-click-activate",
read: { [w] in w.getSingleClickActivate() },
write: { [w] v in w.setSingleClickActivate(singleClickActivate: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.GridView.setSingleClickActivate(singleClickActivate:)
/// Sets whether items should be activated on single click and
/// selected on hover.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.GridView.setSingleClickActivate(singleClickActivate:)`.
///
/// - Parameter singleClickActivate: Activate rows on single click and select them on hover.
/// - Returns: A copy of this view with the modifier applied.
public func singleClickActivate(_ singleClickActivate: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setSingleClickActivate(singleClickActivate: singleClickActivate()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.GridView.setTabBehavior(tabBehavior:)
/// Sets the behavior of the <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter tabBehavior: Behavior of the <kbd>Tab</kbd> key
/// - Returns: A copy of this view with the modifier applied.
public func tabBehavior(_ tabBehavior: Gtk.ListTabBehavior) -> Self {
appending { w, _ in
w.setTabBehavior(tabBehavior: tabBehavior)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.GridView.setTabBehavior(tabBehavior:), GObject.Object.connectNotify(detail:_:), Gtk.GridView.getTabBehavior()
/// Sets the behavior of the <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.ListTabBehavior` 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 tabBehavior(_ tabBehavior: Portico.Binding<Gtk.ListTabBehavior>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, tabBehavior, registry: ctx.registry, notifyDetail: "tab-behavior",
read: { [w] in w.getTabBehavior() },
write: { [w] v in w.setTabBehavior(tabBehavior: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.GridView.setTabBehavior(tabBehavior:)
/// Sets the behavior of the <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.GridView.setTabBehavior(tabBehavior:)`.
///
/// - Parameter tabBehavior: Behavior of the <kbd>Tab</kbd> key
/// - Returns: A copy of this view with the modifier applied.
public func tabBehavior(_ tabBehavior: @escaping () -> Gtk.ListTabBehavior) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setTabBehavior(tabBehavior: tabBehavior()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.GridView.connectActivate(_:)
/// Emitted when a cell has been activated by the user,
/// usually via activating the GtkGridView|list.activate-item action.
///
/// This allows for a convenient way to handle activation in a gridview.
/// See [property`Gtk`.ListItem:activatable] for details on how to use
/// this signal.
///
/// - Parameter handler: Invoked when the widget emits the `activate` signal. The closure receives the signal's arguments in order.
/// - Returns: A copy of this view with the modifier applied.
public func onActivate(_ handler: @escaping (UInt32) -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectActivate { _, a0 in handler(a0) })
}
}
}