:right-sidebar: True TreeSelection =================================================================== .. currentmodule:: gi.repository.Gtk .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.SelectionModel` instead .. class:: TreeSelection(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` :Constructors: :: TreeSelection(**properties) Methods ------- .. rst-class:: interim-class .. class:: TreeSelection :no-index: .. method:: count_selected_rows() -> int Returns the number of rows that have been selected in ``tree``. .. deprecated:: 4.10 Use GtkListView or GtkColumnView .. method:: get_mode() -> ~gi.repository.Gtk.SelectionMode Gets the selection mode for ``selection``. See :func:`~gi.repository.Gtk.TreeSelection.set_mode`. .. deprecated:: 4.10 Use GtkListView or GtkColumnView .. method:: get_selected() Sets ``iter`` to the currently selected node if ``selection`` is set to :const:`~gi.repository.Gtk.SelectionMode.SINGLE` or :const:`~gi.repository.Gtk.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 :const:`~gi.repository.Gtk.SelectionMode.MULTIPLE`. .. deprecated:: 4.10 Use GtkListView or GtkColumnView .. method:: 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 :func:`~gi.repository.Gtk.TreeRowReference.new`. To free the return value, use: .. code-block:: C :dedent: g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free); .. deprecated:: 4.10 Use GtkListView or GtkColumnView .. method:: get_tree_view() -> ~gi.repository.Gtk.TreeView Returns the tree view associated with ``selection``. .. deprecated:: 4.10 Use GtkListView or GtkColumnView .. method:: iter_is_selected(iter: ~gi.repository.Gtk.TreeIter) -> bool Returns :const:`True` if the row at ``iter`` is currently selected. .. deprecated:: 4.10 Use GtkListView or GtkColumnView :param iter: A valid ``GtkTreeIter`` .. method:: path_is_selected(path: ~gi.repository.Gtk.TreePath) -> bool Returns :const:`True` if the row pointed to by ``path`` is currently selected. If ``path`` does not point to a valid location, :const:`False` is returned .. deprecated:: 4.10 Use GtkListView or GtkColumnView :param path: A ``GtkTreePath`` to check selection on. .. method:: select_all() -> None Selects all the nodes. ``selection`` must be set to :const:`~gi.repository.Gtk.SelectionMode.MULTIPLE` mode. .. deprecated:: 4.10 Use GtkListView or GtkColumnView .. method:: select_iter(iter: ~gi.repository.Gtk.TreeIter) -> None Selects the specified iterator. .. deprecated:: 4.10 Use GtkListView or GtkColumnView :param iter: The ``GtkTreeIter`` to be selected. .. method:: select_path(path) Select the row at ``path``. .. deprecated:: 4.10 Use GtkListView or GtkColumnView :param path: The ``GtkTreePath`` to be selected. .. method:: select_range(start_path: ~gi.repository.Gtk.TreePath, end_path: ~gi.repository.Gtk.TreePath) -> None Selects a range of nodes, determined by ``start_path`` and ``end_path`` inclusive. ``selection`` must be set to :const:`~gi.repository.Gtk.SelectionMode.MULTIPLE` mode. .. deprecated:: 4.10 Use GtkListView or GtkColumnView :param start_path: The initial node of the range. :param end_path: The final node of the range. .. method:: selected_foreach(func: ~typing.Callable[[...], None], *data: ~typing.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, :func:`~gi.repository.Gtk.TreeSelection.get_selected_rows` might be more useful. .. deprecated:: 4.10 Use GtkListView or GtkColumnView :param func: The function to call for each selected node. :param data: user data to pass to the function. .. method:: set_mode(type: ~gi.repository.Gtk.SelectionMode) -> None Sets the selection mode of the ``selection``. If the previous type was :const:`~gi.repository.Gtk.SelectionMode.MULTIPLE`, then the anchor is kept selected, if it was previously selected. .. deprecated:: 4.10 Use GtkListView or GtkColumnView :param type: The selection mode .. method:: set_select_function(func: ~typing.Callable[[...], bool] | None = None, *data: ~typing.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 :const:`True` if the state of the node may be toggled, and :const:`False` if the state of the node should be left unchanged. .. deprecated:: 4.10 Use GtkListView or GtkColumnView :param func: The selection function. May be :const:`None` :param data: The selection function’s data. May be :const:`None` .. method:: unselect_all() -> None Unselects all the nodes. .. deprecated:: 4.10 Use GtkListView or GtkColumnView .. method:: unselect_iter(iter: ~gi.repository.Gtk.TreeIter) -> None Unselects the specified iterator. .. deprecated:: 4.10 Use GtkListView or GtkColumnView :param iter: The ``GtkTreeIter`` to be unselected. .. method:: unselect_path(path: ~gi.repository.Gtk.TreePath) -> None Unselects the row at ``path``. .. deprecated:: 4.10 Use GtkListView or GtkColumnView :param path: The ``GtkTreePath`` to be unselected. .. method:: unselect_range(start_path: ~gi.repository.Gtk.TreePath, end_path: ~gi.repository.Gtk.TreePath) -> None Unselects a range of nodes, determined by ``start_path`` and ``end_path`` inclusive. .. deprecated:: 4.10 Use GtkListView or GtkColumnView :param start_path: The initial node of the range. :param end_path: The initial node of the range. Properties ---------- .. rst-class:: interim-class .. class:: TreeSelection :no-index: .. attribute:: props.mode :type: ~gi.repository.Gtk.SelectionMode Selection mode. See :func:`~gi.repository.Gtk.TreeSelection.set_mode` for more information on this property. Signals ------- .. rst-class:: interim-class .. class:: TreeSelection.signals :no-index: .. method:: changed() -> None 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.