### Class

# Gtk TreeSelection

deprecated: 4.10 since: 4.0

#### Description [src]

    final class Gtk.TreeSelection : GObject.Object
    {
      /* No available fields */
    }

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 `GtkTreeSelection`::changed 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 `GtkTreeSelection`::changed signal when nothing has happened (mostly as a result of programmers calling select_row on an already selected row).

Available since: 4.0

Deprecated since: 4.10

Use `GtkSelectionModel` instead.

#### Ancestors

- GObject

#### Instance methods

###### gtk_tree_selection_count_selected_rows

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

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_get_mode

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

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_get_select_function

Returns the current selection function.

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_get_selected

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`.

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_get_selected_rows

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 `GtkTreeRowReference`s. To do this, you can use gtk_tree_row_reference_new().

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_get_tree_view

Returns the tree view associated with `selection`.

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_get_user_data

Returns the user data for the selection function.

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_iter_is_selected

Returns `TRUE` if the row at `iter` is currently selected.

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_path_is_selected

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

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_select_all

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

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_select_iter

Selects the specified iterator.

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_select_path

Select the row at `path`.

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_select_range

Selects a range of nodes, determined by `start_path` and `end_path` inclusive. `selection` must be set to `GTK_SELECTION_MULTIPLE` mode.

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_selected_foreach

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.

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_set_mode

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.

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_set_select_function

Sets the selection function.

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_unselect_all

Unselects all the nodes.

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_unselect_iter

Unselects the specified iterator.

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_unselect_path

Unselects the row at `path`.

deprecated: 4.10 since: 4.0

###### gtk_tree_selection_unselect_range

Unselects a range of nodes, determined by `start_path` and `end_path` inclusive.

deprecated: 4.10 since: 4.0

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Properties

###### Gtk.TreeSelection:mode

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

since: 4.0

#### Signals

###### Gtk.TreeSelection::changed

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.

since: 4.0

##### Signals inherited from GObject (1)

###### GObject::notify

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.

since: 2.0