portico/Sources/Portico/Generated/ListView.swift

700 lines
38 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.ListView
/// Presents a large dynamic list of items.
///
/// `GtkListView` uses its factory to generate one row widget for each visible
/// item and shows them in a linear display, either vertically or horizontally.
///
/// The [property`Gtk`.ListView:show-separators] property offers a simple way to
/// display separators between the rows.
///
/// `GtkListView` 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`.ListView:enable-rubberband].
///
/// If you need multiple columns with headers, see [class`Gtk`.ColumnView].
///
/// To learn more about the list widget framework, see the
/// [overview](section-list-widget.html).
///
/// An example of using `GtkListView`:
/// ```c
/// static void
/// setup_listitem_cb (GtkListItemFactory *factory,
/// GtkListItem *list_item)
/// {
/// GtkWidget *image;
///
/// image = gtk_image_new ();
/// gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
/// gtk_list_item_set_child (list_item, image);
/// }
///
/// static void
/// bind_listitem_cb (GtkListItemFactory *factory,
/// GtkListItem *list_item)
/// {
/// GtkWidget *image;
/// GAppInfo *app_info;
///
/// image = gtk_list_item_get_child (list_item);
/// app_info = gtk_list_item_get_item (list_item);
/// gtk_image_set_from_gicon (GTK_IMAGE (image), g_app_info_get_icon (app_info));
/// }
///
/// static void
/// activate_cb (GtkListView *list,
/// guint position,
/// gpointer unused)
/// {
/// GAppInfo *app_info;
///
/// app_info = g_list_model_get_item (G_LIST_MODEL (gtk_list_view_get_model (list)), position);
/// g_app_info_launch (app_info, NULL, NULL, NULL);
/// g_object_unref (app_info);
/// }
///
/// ...
///
/// model = create_application_list ();
///
/// factory = gtk_signal_list_item_factory_new ();
/// g_signal_connect (factory, "setup", G_CALLBACK (setup_listitem_cb), NULL);
/// g_signal_connect (factory, "bind", G_CALLBACK (bind_listitem_cb), NULL);
///
/// list = gtk_list_view_new (GTK_SELECTION_MODEL (gtk_single_selection_new (model)), factory);
///
/// g_signal_connect (list, "activate", G_CALLBACK (activate_cb), NULL);
///
/// gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
/// ```
///
/// # Actions
///
/// `GtkListView` defines a set of built-in actions:
///
/// - `list.activate-item` activates the item at given position by emitting
/// the [signal`Gtk`.ListView::activate] signal.
///
/// # CSS nodes
///
/// ```
/// listview[.separators][.rich-list][.navigation-sidebar][.data-table]
/// row[.activatable]
///
/// row[.activatable]
///
///
/// [rubberband]
/// ```
///
/// `GtkListView` uses a single CSS node named `listview`. It may carry the
/// `.separators` style class, when [property`Gtk`.ListView:show-separators]
/// property is set. Each child widget uses a single CSS node named `row`.
/// If the [property`Gtk`.ListItem:activatable] property is set, the
/// corresponding row will have the `.activatable` style class. For
/// rubberband selection, a node with name `rubberband` is used.
///
/// The main listview node may also carry style classes to select
/// the style of [list presentation](section-list-widget.html`list`-styles):
/// .rich-list, .navigation-sidebar or .data-table.
///
/// # Accessibility
///
/// `GtkListView` uses the [enum`Gtk`.AccessibleRole.list] role, and the list
/// items use the [enum`Gtk`.AccessibleRole.list_item] role.
///
/// A Portico view that mounts a `Gtk.ListView`.
@MainActor public struct ListView: View {
private let make: (MountContext) -> Gtk.ListView
private var configure: [(Gtk.ListView, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.ListView.init(model:factory:)
/// Creates a new `GtkListView` that uses the given `factory` for
/// mapping items to widgets.
///
/// The function takes ownership of the
/// arguments, so you can write code like
/// ```c
/// list_view = gtk_list_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 headerFactory: Factory for creating header widgets.
/// - Parameter showSeparators: Show separators between rows.
/// - 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, headerFactory: Gtk.ListItemFactory? = nil, showSeparators: Bool? = nil, singleClickActivate: Bool? = nil, tabBehavior: Gtk.ListTabBehavior? = nil, onActivate: ((UInt32) -> Void)? = nil) {
make = { _ in Gtk.ListView(model: model, factory: factory) }
configure.append { w, ctx in
if let enableRubberband { w.setEnableRubberband(enableRubberband: enableRubberband) }
if let headerFactory { w.setHeaderFactory(factory: headerFactory) }
if let showSeparators { w.setShowSeparators(showSeparators: showSeparators) }
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.ListView.init(model:factory:), Gtk.ListView.setModel(model:), Gtk.ListView.setFactory(factory:)
/// Creates a new `GtkListView` that uses the given `factory` for
/// mapping items to widgets.
///
/// The function takes ownership of the
/// arguments, so you can write code like
/// ```c
/// list_view = gtk_list_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.ListView.setModel(model:), Gtk.ListView.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 headerFactory: Factory for creating header widgets.
/// - Parameter showSeparators: Show separators between rows.
/// - 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, headerFactory: Portico.Binding<Gtk.ListItemFactory?>? = nil, showSeparators: Portico.Binding<Bool>? = nil, singleClickActivate: Portico.Binding<Bool>? = nil, tabBehavior: Portico.Binding<Gtk.ListTabBehavior>? = nil, onActivate: ((UInt32) -> Void)? = nil) {
make = { _ in Gtk.ListView(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 headerFactory {
Portico.bindProperty(w, headerFactory, registry: ctx.registry, notifyDetail: "header-factory", read: { [w] in w.getHeaderFactory() }, write: { [w] v in w.setHeaderFactory(factory: v) })
}
if let showSeparators {
Portico.bindProperty(w, showSeparators, registry: ctx.registry, notifyDetail: "show-separators", read: { [w] in w.getShowSeparators() }, write: { [w] v in w.setShowSeparators(showSeparators: 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.ListView.init(model:factory:), Gtk.ListView.setModel(model:), Gtk.ListView.setFactory(factory:)
/// Creates a new `GtkListView` that uses the given `factory` for
/// mapping items to widgets.
///
/// The function takes ownership of the
/// arguments, so you can write code like
/// ```c
/// list_view = gtk_list_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.ListView.setModel(model:), Gtk.ListView.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 headerFactory: Factory for creating header widgets.
/// - Parameter showSeparators: Show separators between rows.
/// - 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, headerFactory: Gtk.ListItemFactory? = nil, showSeparators: Bool? = nil, singleClickActivate: Bool? = nil, tabBehavior: Gtk.ListTabBehavior? = nil, onActivate: ((UInt32) -> Void)? = nil) {
make = { _ in Gtk.ListView(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 headerFactory { w.setHeaderFactory(factory: headerFactory) }
if let showSeparators { w.setShowSeparators(showSeparators: showSeparators) }
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 ListView: WidgetView {
public typealias Target = Gtk.ListView
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.ListView, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension ListView: 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.ListView
/// Modifiers for `Gtk.ListView`, available on every Portico view whose
/// backing widget is `Gtk.ListView` or one of its subclasses.
extension WidgetView where Target: Gtk.ListView {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.ListView.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.ListView.setEnableRubberband(enableRubberband:), GObject.Object.connectNotify(detail:_:), Gtk.ListView.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.ListView.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.ListView.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.ListView.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.ListView.setFactory(factory:), GObject.Object.connectNotify(detail:_:), Gtk.ListView.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.ListView.setFactory(factory:), GObject.Object.connectNotify(detail:_:), Gtk.ListView.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.ListView.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.ListView.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.ListView.setHeaderFactory(factory:)
/// Sets the `GtkListItemFactory` to use for populating the
/// [class`Gtk`.ListHeader] objects used in section headers.
///
/// If this factory is set to `NULL`, the list will not show
/// section headers.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter headerFactory: Factory for creating header widgets.
/// - 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.ListView.setHeaderFactory(factory:), GObject.Object.connectNotify(detail:_:), Gtk.ListView.getHeaderFactory()
/// Sets the `GtkListItemFactory` to use for populating the
/// [class`Gtk`.ListHeader] objects used in section headers.
///
/// If this factory is set to `NULL`, the list will not show
/// section headers.
///
/// 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 headerFactory(_ headerFactory: Portico.Binding<Gtk.ListItemFactory?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, headerFactory, registry: ctx.registry, notifyDetail: "header-factory",
read: { [w] in w.getHeaderFactory() },
write: { [w] v in w.setHeaderFactory(factory: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.ListView.setHeaderFactory(factory:), GObject.Object.connectNotify(detail:_:), Gtk.ListView.getHeaderFactory()
/// Sets the `GtkListItemFactory` to use for populating the
/// [class`Gtk`.ListHeader] objects used in section headers.
///
/// If this factory is set to `NULL`, the list will not show
/// section headers.
///
/// 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 headerFactory(_ headerFactory: Portico.Binding<Gtk.ListItemFactory>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, headerFactory, registry: ctx.registry, notifyDetail: "header-factory",
read: { [w] in w.getHeaderFactory() },
write: { [w] v in w.setHeaderFactory(factory: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.ListView.setHeaderFactory(factory:)
/// Sets the `GtkListItemFactory` to use for populating the
/// [class`Gtk`.ListHeader] objects used in section headers.
///
/// If this factory is set to `NULL`, the list will not show
/// section headers.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.ListView.setHeaderFactory(factory:)`.
///
/// - Parameter headerFactory: Factory for creating header widgets.
/// - 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.ListView.setModel(model:)
/// Sets the model to use.
///
/// This must be a [iface`Gtk`.SelectionModel] to use.
///
/// 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.ListView.setModel(model:), GObject.Object.connectNotify(detail:_:), Gtk.ListView.getModel()
/// Sets the model to use.
///
/// This must be a [iface`Gtk`.SelectionModel] to use.
///
/// 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.ListView.setModel(model:), GObject.Object.connectNotify(detail:_:), Gtk.ListView.getModel()
/// Sets the model to use.
///
/// This must be a [iface`Gtk`.SelectionModel] to use.
///
/// 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.ListView.setModel(model:)
/// Sets the model to use.
///
/// This must be a [iface`Gtk`.SelectionModel] to use.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.ListView.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.ListView.setShowSeparators(showSeparators:)
/// Sets whether the listview should show separators
/// between rows.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter showSeparators: Show separators between rows.
/// - Returns: A copy of this view with the modifier applied.
public func showSeparators(_ showSeparators: Bool) -> Self {
appending { w, _ in
w.setShowSeparators(showSeparators: showSeparators)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.ListView.setShowSeparators(showSeparators:), GObject.Object.connectNotify(detail:_:), Gtk.ListView.getShowSeparators()
/// Sets whether the listview should show separators
/// between rows.
///
/// 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 showSeparators(_ showSeparators: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, showSeparators, registry: ctx.registry, notifyDetail: "show-separators",
read: { [w] in w.getShowSeparators() },
write: { [w] v in w.setShowSeparators(showSeparators: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.ListView.setShowSeparators(showSeparators:)
/// Sets whether the listview should show separators
/// between rows.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.ListView.setShowSeparators(showSeparators:)`.
///
/// - Parameter showSeparators: Show separators between rows.
/// - Returns: A copy of this view with the modifier applied.
public func showSeparators(_ showSeparators: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setShowSeparators(showSeparators: showSeparators()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.ListView.setSingleClickActivate(singleClickActivate:)
/// Sets whether rows 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.ListView.setSingleClickActivate(singleClickActivate:), GObject.Object.connectNotify(detail:_:), Gtk.ListView.getSingleClickActivate()
/// Sets whether rows 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.ListView.setSingleClickActivate(singleClickActivate:)
/// Sets whether rows 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.ListView.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.ListView.setTabBehavior(tabBehavior:)
/// Sets the <kbd>Tab</kbd> key behavior.
///
/// This influences how the <kbd>Tab</kbd> and
/// <kbd>Shift</kbd>+<kbd>Tab</kbd> keys move the
/// focus in the listview.
///
/// 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.ListView.setTabBehavior(tabBehavior:), GObject.Object.connectNotify(detail:_:), Gtk.ListView.getTabBehavior()
/// Sets the <kbd>Tab</kbd> key behavior.
///
/// This influences how the <kbd>Tab</kbd> and
/// <kbd>Shift</kbd>+<kbd>Tab</kbd> keys move the
/// focus in the listview.
///
/// 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.ListView.setTabBehavior(tabBehavior:)
/// Sets the <kbd>Tab</kbd> key behavior.
///
/// This influences how the <kbd>Tab</kbd> and
/// <kbd>Shift</kbd>+<kbd>Tab</kbd> keys move the
/// focus in the listview.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.ListView.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.ListView.connectActivate(_:)
/// Emitted when a row has been activated by the user.
///
/// Activation usually happens via the list.activate-item action of
/// the `GtkListView`.
///
/// This allows for a convenient way to handle activation in a listview.
/// See [method`Gtk`.ListItem.set_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) })
}
}
}