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
iter
to the currently selected node ifselection
is set toSINGLE
orBROWSE
.iter
may be NULL if you just want to test ifselection
has any selected nodes.model
is filled with the current model as a convenience. This function will not work if you useselection
isMULTIPLE
.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
GtkTreeRowReference
’s. 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
True
if the row atiter
is currently selected.Deprecated since version 4.10: Use GtkListView or GtkColumnView
- Parameters:
iter – A valid
GtkTreeIter
- path_is_selected(path: TreePath) bool #
Returns
True
if the row pointed to bypath
is currently selected. Ifpath
does not point to a valid location,False
is returnedDeprecated since version 4.10: Use GtkListView or GtkColumnView
- Parameters:
path – A
GtkTreePath
to check selection on.
- select_all() None #
Selects all the nodes.
selection
must be set toMULTIPLE
mode.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
GtkTreeIter
to be selected.
- select_path(path)#
Select the row at
path
.Deprecated since version 4.10: Use GtkListView or GtkColumnView
- Parameters:
path – The
GtkTreePath
to be selected.
- select_range(start_path: TreePath, end_path: TreePath) None #
Selects a range of nodes, determined by
start_path
andend_path
inclusive.selection
must be set toMULTIPLE
mode.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[[...], None], *data: Any) 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[[...], bool] | None = None, *data: Any) 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
True
if the state of the node may be toggled, andFalse
if 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
None
data – 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
GtkTreeIter
to be unselected.
- unselect_path(path: TreePath) None #
Unselects the row at
path
.Deprecated since version 4.10: Use GtkListView or GtkColumnView
- Parameters:
path – The
GtkTreePath
to be unselected.
- unselect_range(start_path: TreePath, end_path: TreePath) None #
Unselects a range of nodes, determined by
start_path
andend_path
inclusive.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.