TreeSelection#
Deprecated since version 4.10: Use SelectionModel instead
Superclasses: Object
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
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).
Methods#
- class TreeSelection
- count_selected_rows() int#
Returns the number of rows that have been selected in
tree.Deprecated since version 4.10: Use GtkListView or GtkColumnView
- get_mode() SelectionMode#
Gets the selection mode for
selection. Seeset_mode().Deprecated since version 4.10: Use GtkListView or GtkColumnView
- get_selected()#
Sets
iterto the currently selected node ifselectionis set toSINGLEorBROWSE.itermay be NULL if you just want to test ifselectionhas any selected nodes.modelis filled with the current model as a convenience. This function will not work if you useselectionisMULTIPLE.Deprecated since version 4.10: Use GtkListView or GtkColumnView
- 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
GtkTreeRowReferences. To do this, you can usenew().To free the return value, use:
g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free);
Deprecated since version 4.10: Use GtkListView or GtkColumnView
- get_tree_view() TreeView#
Returns the tree view associated with
selection.Deprecated since version 4.10: Use GtkListView or GtkColumnView
- iter_is_selected(iter: TreeIter) bool#
Returns
Trueif the row atiteris currently selected.Deprecated since version 4.10: Use GtkListView or GtkColumnView
- Parameters:
iter – A valid
GtkTreeIter
- path_is_selected(path: TreePath) bool#
Returns
Trueif the row pointed to bypathis currently selected. Ifpathdoes not point to a valid location,Falseis returnedDeprecated since version 4.10: Use GtkListView or GtkColumnView
- Parameters:
path – A
GtkTreePathto check selection on.
- select_all() None#
Selects all the nodes.
selectionmust be set toMULTIPLEmode.Deprecated since version 4.10: Use GtkListView or GtkColumnView
- select_iter(iter: TreeIter) None#
Selects the specified iterator.
Deprecated since version 4.10: Use GtkListView or GtkColumnView
- Parameters:
iter – The
GtkTreeIterto be selected.
- select_path(path)#
Select the row at
path.Deprecated since version 4.10: Use GtkListView or GtkColumnView
- Parameters:
path – The
GtkTreePathto be selected.
- select_range(start_path: TreePath, end_path: TreePath) None#
Selects a range of nodes, determined by
start_pathandend_pathinclusive.selectionmust be set toMULTIPLEmode.Deprecated since version 4.10: Use GtkListView or GtkColumnView
- Parameters:
start_path – The initial node of the range.
end_path – The final node of the range.
- selected_foreach(func: Callable[[TreeModel, TreePath, TreeIter, Any], None], data: Any = None) None#
Calls a function for each selected node. Note that you cannot modify the tree or selection from within this function. As a result,
get_selected_rows()might be more useful.Deprecated since version 4.10: Use GtkListView or GtkColumnView
- Parameters:
func – The function to call for each selected node.
data – user data to pass to the function.
- set_mode(type: SelectionMode) None#
Sets the selection mode of the
selection. If the previous type wasMULTIPLE, then the anchor is kept selected, if it was previously selected.Deprecated since version 4.10: Use GtkListView or GtkColumnView
- Parameters:
type – The selection mode
- set_select_function(func: Callable[[TreeSelection, TreeModel, TreePath, bool, Any], bool] | None = None, data: Any = None) None#
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
Trueif the state of the node may be toggled, andFalseif the state of the node should be left unchanged.Deprecated since version 4.10: Use GtkListView or GtkColumnView
- Parameters:
func – The selection function. May be
Nonedata – The selection function’s data. May be
None
- unselect_all() None#
Unselects all the nodes.
Deprecated since version 4.10: Use GtkListView or GtkColumnView
- unselect_iter(iter: TreeIter) None#
Unselects the specified iterator.
Deprecated since version 4.10: Use GtkListView or GtkColumnView
- Parameters:
iter – The
GtkTreeIterto be unselected.
- unselect_path(path: TreePath) None#
Unselects the row at
path.Deprecated since version 4.10: Use GtkListView or GtkColumnView
- Parameters:
path – The
GtkTreePathto be unselected.
- unselect_range(start_path: TreePath, end_path: TreePath) None#
Unselects a range of nodes, determined by
start_pathandend_pathinclusive.Deprecated since version 4.10: Use GtkListView or GtkColumnView
- Parameters:
start_path – The initial node of the range.
end_path – The initial node of the range.
Properties#
- class TreeSelection
- props.mode: SelectionMode#
The type of the None singleton.