TreeSelectionProtocol

public protocol TreeSelectionProtocol : ObjectProtocol

The selection object for GtkTreeView

The GtkTreeSelection object is a helper object to manage the selection for a GtkTreeView widget. The GtkTreeSelection object is automatically created when a new GtkTreeView widget is created, and cannot exist independently of this widget. The primary reason the GtkTreeSelection objects exists is for cleanliness of code and API. That is, there is no conceptual reason all these functions could not be methods on the GtkTreeView widget instead of a separate function.

The GtkTreeSelection object is gotten from a GtkTreeView by calling gtk_tree_view_get_selection(). It can be manipulated to check the selection status of the tree, as well as select and deselect individual rows. Selection is done completely view side. As a result, multiple views of the same model can have completely different selections. Additionally, you cannot change the selection of a row on the model that is not currently displayed by the view without expanding its parents first.

One of the important things to remember when monitoring the selection of a view is that the GtkTreeSelectionchanged signal is mostly a hint. That is, it may only emit one signal when a range of rows is selected. Additionally, it may on occasion emit a GtkTreeSelectionchanged signal when nothing has happened (mostly as a result of programmers calling select_row on an already selected row).

The TreeSelectionProtocol protocol exposes the methods and properties of an underlying GtkTreeSelection instance. The default implementation of these can be found in the protocol extension below. For a concrete class that implements these methods and properties, see TreeSelection. Alternatively, use TreeSelectionRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying GtkTreeSelection instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • tree_selection_ptr Default implementation

    Typed pointer to the underlying GtkTreeSelection instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GtkTreeSelection instance.

    Declaration

    Swift

    var tree_selection_ptr: UnsafeMutablePointer<GtkTreeSelection>! { get }
  • Required Initialiser for types conforming to TreeSelectionProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

TreeSelection Class

  • Bind a TreeSelectionPropertyName source property to a given target object.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: TreeSelectionPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol

    Parameters

    source_property

    the source property to bind

    target

    the target object to bind to

    target_property

    the target property to bind to

    flags

    the flags to pass to the Binding

    transform_from

    ValueTransformer to use for forward transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return Value

    binding reference or nil in case of an error

  • get(property:) Extension method

    Get the value of a TreeSelection property

    Declaration

    Swift

    @inlinable
    func get(property: TreeSelectionPropertyName) -> GLibObject.Value

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

  • set(property:value:) Extension method

    Set the value of a TreeSelection property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

    @inlinable
    func set(property: TreeSelectionPropertyName, value v: GLibObject.Value)

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

TreeSelection signals

  • Connect a Swift signal handler to the given, typed TreeSelectionSignalName signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func connect(signal s: TreeSelectionSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int

    Parameters

    signal

    The signal to connect

    flags

    The connection flags to use

    data

    A pointer to user data to provide to the callback

    destroyData

    A GClosureNotify C function to destroy the data pointed to by userData

    handler

    The Swift signal handler (function or callback) to invoke on the given signal

    Return Value

    The signal handler ID (always greater than 0 for successful connections)

  • Connect a C signal handler to the given, typed TreeSelectionSignalName signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func connect(signal s: TreeSelectionSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int

    Parameters

    signal

    The signal to connect

    flags

    The connection flags to use

    data

    A pointer to user data to provide to the callback

    destroyData

    A GClosureNotify C function to destroy the data pointed to by userData

    signalHandler

    The C function to be called on the given signal

    Return Value

    The signal handler ID (always greater than 0 for successful connections)

  • onChanged(flags:handler:) Extension method

    Emitted whenever the selection has (possibly) changed. Please note that this signal is mostly a hint. It may only be emitted once when a range of rows are selected, and it may occasionally be emitted when nothing has happened.

    Note

    This represents the underlying changed signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: TreeSelectionRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    handler

    The signal handler to call Run the given callback whenever the changed signal is emitted

  • changedSignal Extension method

    Typed changed signal for using the connect(signal:) methods

    Declaration

    Swift

    static var changedSignal: TreeSelectionSignalName { get }
  • onNotifyMode(flags:handler:) Extension method

    The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

    (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::mode signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyMode(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: TreeSelectionRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifyMode signal is emitted

  • notifyModeSignal Extension method

    Typed notify::mode signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyModeSignal: TreeSelectionSignalName { get }

TreeSelection Class: TreeSelectionProtocol extension (methods and fields)

  • countSelectedRows() Extension method

    Returns the number of rows that have been selected in tree.

    Declaration

    Swift

    @inlinable
    func countSelectedRows() -> Int
  • getMode() Extension method

    Gets the selection mode for selection. See gtk_tree_selection_set_mode().

    Declaration

    Swift

    @inlinable
    func getMode() -> GtkSelectionMode
  • getSelectFunction() Extension method

    Returns the current selection function.

    Declaration

    Swift

    @inlinable
    func getSelectFunction() -> GtkTreeSelectionFunc!
  • getSelected(model:iter:) Extension method

    Sets iter to the currently selected node if selection is set to GTK_SELECTION_SINGLE or GTK_SELECTION_BROWSE. iter may be NULL if you just want to test if selection has any selected nodes. model is filled with the current model as a convenience. This function will not work if you use selection is GTK_SELECTION_MULTIPLE.

    Declaration

    Swift

    @inlinable
    func getSelected(model: UnsafeMutablePointer<UnsafeMutablePointer<GtkTreeModel>?>! = nil, iter: TreeIterRef? = nil) -> Bool
  • getSelected(model:iter:) Extension method

    Sets iter to the currently selected node if selection is set to GTK_SELECTION_SINGLE or GTK_SELECTION_BROWSE. iter may be NULL if you just want to test if selection has any selected nodes. model is filled with the current model as a convenience. This function will not work if you use selection is GTK_SELECTION_MULTIPLE.

    Declaration

    Swift

    @inlinable
    func getSelected<TreeIterT>(model: UnsafeMutablePointer<UnsafeMutablePointer<GtkTreeModel>?>! = nil, iter: TreeIterT?) -> Bool where TreeIterT : TreeIterProtocol
  • getSelectedRows(model:) Extension method

    Creates a list of path of all selected rows. Additionally, if you are planning on modifying the model after calling this function, you may want to convert the returned list into a list of GtkTreeRowReferences. To do this, you can use gtk_tree_row_reference_new().

    To free the return value, use: (C Language Example):

    g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free);
    

    Declaration

    Swift

    @inlinable
    func getSelectedRows(model: UnsafeMutablePointer<UnsafeMutablePointer<GtkTreeModel>?>! = nil) -> GLib.ListRef!
  • getTreeView() Extension method

    Returns the tree view associated with selection.

    Declaration

    Swift

    @inlinable
    func getTreeView() -> TreeViewRef!
  • getUserData() Extension method

    Returns the user data for the selection function.

    Declaration

    Swift

    @inlinable
    func getUserData() -> gpointer!
  • iterIsSelected(iter:) Extension method

    Returns true if the row at iter is currently selected.

    Declaration

    Swift

    @inlinable
    func iterIsSelected<TreeIterT>(iter: TreeIterT) -> Bool where TreeIterT : TreeIterProtocol
  • pathIsSelected(path:) Extension method

    Returns true if the row pointed to by path is currently selected. If path does not point to a valid location, false is returned

    Declaration

    Swift

    @inlinable
    func pathIsSelected<TreePathT>(path: TreePathT) -> Bool where TreePathT : TreePathProtocol
  • selectAll() Extension method

    Selects all the nodes. selection must be set to GTK_SELECTION_MULTIPLE mode.

    Declaration

    Swift

    @inlinable
    func selectAll()
  • select(iter:) Extension method

    Selects the specified iterator.

    Declaration

    Swift

    @inlinable
    func select<TreeIterT>(iter: TreeIterT) where TreeIterT : TreeIterProtocol
  • select(path:) Extension method

    Select the row at path.

    Declaration

    Swift

    @inlinable
    func select<TreePathT>(path: TreePathT) where TreePathT : TreePathProtocol
  • Selects a range of nodes, determined by start_path and end_path inclusive. selection must be set to GTK_SELECTION_MULTIPLE mode.

    Declaration

    Swift

    @inlinable
    func selectRange<TreePathT>(startPath: TreePathT, endPath: TreePathT) where TreePathT : TreePathProtocol
  • selectedForeach(func:data:) Extension method

    Calls a function for each selected node. Note that you cannot modify the tree or selection from within this function. As a result, gtk_tree_selection_get_selected_rows() might be more useful.

    Declaration

    Swift

    @inlinable
    func selectedForeach(func: GtkTreeSelectionForeachFunc?, data: gpointer! = nil)
  • setMode(type:) Extension method

    Sets the selection mode of the selection. If the previous type was GTK_SELECTION_MULTIPLE, then the anchor is kept selected, if it was previously selected.

    Declaration

    Swift

    @inlinable
    func setMode(type: GtkSelectionMode)
  • Sets the selection function.

    If set, this function is called before any node is selected or unselected, giving some control over which nodes are selected. The select function should return true if the state of the node may be toggled, and false if the state of the node should be left unchanged.

    Declaration

    Swift

    @inlinable
    func setSelectFunction(func: GtkTreeSelectionFunc? = nil, data: gpointer! = nil, destroy: GDestroyNotify?)
  • unselectAll() Extension method

    Unselects all the nodes.

    Declaration

    Swift

    @inlinable
    func unselectAll()
  • unselect(iter:) Extension method

    Unselects the specified iterator.

    Declaration

    Swift

    @inlinable
    func unselect<TreeIterT>(iter: TreeIterT) where TreeIterT : TreeIterProtocol
  • unselect(path:) Extension method

    Unselects the row at path.

    Declaration

    Swift

    @inlinable
    func unselect<TreePathT>(path: TreePathT) where TreePathT : TreePathProtocol
  • Unselects a range of nodes, determined by start_path and end_path inclusive.

    Declaration

    Swift

    @inlinable
    func unselectRange<TreePathT>(startPath: TreePathT, endPath: TreePathT) where TreePathT : TreePathProtocol
  • mode Extension method

    Selection mode. See gtk_tree_selection_set_mode() for more information on this property.

    Declaration

    Swift

    @inlinable
    var mode: GtkSelectionMode { get nonmutating set }
  • selectFunction Extension method

    Returns the current selection function.

    Declaration

    Swift

    @inlinable
    var selectFunction: GtkTreeSelectionFunc! { get }
  • treeView Extension method

    Returns the tree view associated with selection.

    Declaration

    Swift

    @inlinable
    var treeView: TreeViewRef! { get }
  • userData Extension method

    Returns the user data for the selection function.

    Declaration

    Swift

    @inlinable
    var userData: gpointer! { get }