SelectionModelRef

public struct SelectionModelRef : SelectionModelProtocol

GtkSelectionModel is an interface that add support for selection to list models.

This support is then used by widgets using list models to add the ability to select and unselect various items.

GTK provides default implementations of the most common selection modes such as [classGtk.SingleSelection], so you will only need to implement this interface if you want detailed control about how selections should be handled.

A GtkSelectionModel supports a single boolean per item indicating if an item is selected or not. This can be queried via [methodGtk.SelectionModel.is_selected]. When the selected state of one or more items changes, the model will emit the [signalGtk.SelectionModel::selection-changed] signal by calling the [methodGtk.SelectionModel.selection_changed] function. The positions given in that signal may have their selection state changed, though that is not a requirement. If new items added to the model via the items-changed signal are selected or not is up to the implementation.

Note that items added via items-changed may already be selected and no [Gtk.SelectionModelselection-changed] will be emitted for them. So to track which items are selected, it is necessary to listen to both signals.

Additionally, the interface can expose functionality to select and unselect items. If these functions are implemented, GTK’s list widgets will allow users to select and unselect items. However, GtkSelectionModels are free to only implement them partially or not at all. In that case the widgets will not support the unimplemented operations.

When selecting or unselecting is supported by a model, the return values of the selection functions do not indicate if selection or unselection happened. They are only meant to indicate complete failure, like when this mode of selecting is not supported by the model.

Selections may happen asynchronously, so the only reliable way to find out when an item was selected is to listen to the signals that indicate selection.

The SelectionModelRef type acts as a lightweight Swift reference to an underlying GtkSelectionModel instance. It exposes methods that can operate on this data type through SelectionModelProtocol conformance. Use SelectionModelRef only as an unowned reference to an existing GtkSelectionModel instance.

  • ptr
    Untyped pointer to the underlying `GtkSelectionModel` instance.
    

    For type-safe access, use the generated, typed pointer selection_model_ptr property instead.

    Declaration

    Swift

    public let ptr: UnsafeMutableRawPointer!

SelectionModel Interface

  • Designated initialiser from the underlying C data type

    Declaration

    Swift

    @inlinable
    init(_ p: UnsafeMutablePointer<GtkSelectionModel>)
  • Designated initialiser from a constant pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init(_ p: UnsafePointer<GtkSelectionModel>)
  • Conditional initialiser from an optional pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init!(_ maybePointer: UnsafeMutablePointer<GtkSelectionModel>?)
  • Conditional initialiser from an optional, non-mutable pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init!(_ maybePointer: UnsafePointer<GtkSelectionModel>?)
  • Conditional initialiser from an optional gpointer

    Declaration

    Swift

    @inlinable
    init!(gpointer g: gpointer?)
  • Conditional initialiser from an optional, non-mutable gconstpointer

    Declaration

    Swift

    @inlinable
    init!(gconstpointer g: gconstpointer?)
  • Reference intialiser for a related type that implements SelectionModelProtocol

    Declaration

    Swift

    @inlinable
    init<T>(_ other: T) where T : SelectionModelProtocol
  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to SelectionModelProtocol.

    Declaration

    Swift

    @inlinable
    init<T>(cPointer: UnsafeMutablePointer<T>)
  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to SelectionModelProtocol.

    Declaration

    Swift

    @inlinable
    init<T>(constPointer: UnsafePointer<T>)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to SelectionModelProtocol.

    Declaration

    Swift

    @inlinable
    init(mutating raw: UnsafeRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to SelectionModelProtocol.

    Declaration

    Swift

    @inlinable
    init(raw: UnsafeMutableRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to SelectionModelProtocol.

    Declaration

    Swift

    @inlinable
    init(opaquePointer: OpaquePointer)