Gtk.TreeSelection¶
class — extends GObject.Object
:::warning Deprecated since 4.10 This API is deprecated. :::
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
TreeView.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¶
count_selected_rows¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Returns the number of rows that have been selected in tree.
get_mode¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Gets the selection mode for selection. See
TreeSelection.set_mode.
get_selected¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Sets iter to the currently selected node if selection is set to
SelectionMode.SINGLE or SelectionMode.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 SelectionMode.MULTIPLE.
get_selected_rows¶
:::warning Deprecated since 4.10 This API is deprecated. :::
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 TreeRowReference.new.
To free the return value, use:
get_tree_view¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Returns the tree view associated with selection.
iter_is_selected¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Returns True if the row at iter is currently selected.
Parameters:
iter— A validGtkTreeIter
path_is_selected¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Returns True if the row pointed to by path is currently selected. If path
does not point to a valid location, False is returned
Parameters:
path— AGtkTreePathto check selection on.
select_all¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Selects all the nodes. selection must be set to SelectionMode.MULTIPLE
mode.
select_iter¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Selects the specified iterator.
Parameters:
iter— TheGtkTreeIterto be selected.
select_path¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Select the row at path.
Parameters:
path— TheGtkTreePathto be selected.
select_range¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Selects a range of nodes, determined by start_path and end_path inclusive.
selection must be set to SelectionMode.MULTIPLE mode.
Parameters:
start_path— The initial node of the range.end_path— The final node of the range.
selected_foreach¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Calls a function for each selected node. Note that you cannot modify
the tree or selection from within this function. As a result,
TreeSelection.get_selected_rows might be more useful.
Parameters:
func— The function to call for each selected node.
set_mode¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Sets the selection mode of the selection. If the previous type was
SelectionMode.MULTIPLE, then the anchor is kept selected, if it was
previously selected.
Parameters:
type— The selection mode
set_select_function¶
:::warning Deprecated since 4.10 This API is deprecated. :::
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.
Parameters:
func— The selection function. May beNone
unselect_all¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Unselects all the nodes.
unselect_iter¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Unselects the specified iterator.
Parameters:
iter— TheGtkTreeIterto be unselected.
unselect_path¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Unselects the row at path.
Parameters:
path— TheGtkTreePathto be unselected.
unselect_range¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Unselects a range of nodes, determined by start_path and end_path
inclusive.
Parameters:
start_path— The initial node of the range.end_path— The initial node of the range.
Properties¶
mode¶
Selection mode.
See TreeSelection.set_mode for more information on this property.
Signals¶
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.