:right-sidebar: True TreeSortable =================================================================== .. currentmodule:: gi.repository.Gtk .. deprecated:: 4.10 There is no replacement for this interface. You should use :obj:`~gi.repository.Gtk.SortListModel` to wrap your list model instead .. class:: TreeSortable(*args, **kwargs) :no-contents-entry: Implementations: :class:`~gi.repository.Gtk.ListStore`, :class:`~gi.repository.Gtk.TreeModelSort`, :class:`~gi.repository.Gtk.TreeStore` The interface for sortable models used by GtkTreeView ``GtkTreeSortable`` is an interface to be implemented by tree models which support sorting. The ``GtkTreeView`` uses the methods provided by this interface to sort the model. Methods ------- .. rst-class:: interim-class .. class:: TreeSortable :no-index: .. method:: get_sort_column_id() -> ~typing.Tuple[bool, int, ~gi.repository.Gtk.SortType] Fills in ``sort_column_id`` and ``order`` with the current sort column and the order. It returns :const:`True` unless the ``sort_column_id`` is :const:`~gi.repository.Gtk.TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID` or :const:`~gi.repository.Gtk.TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID`. .. deprecated:: 4.10 Please do not use it in newly written code .. method:: has_default_sort_func() -> bool Returns :const:`True` if the model has a default sort function. This is used primarily by GtkTreeViewColumns in order to determine if a model can go back to the default state, or not. .. deprecated:: 4.10 Please do not use it in newly written code .. method:: set_default_sort_func(sort_func, user_data=None) Sets the default comparison function used when sorting to be ``sort_func``\. If the current sort column id of ``sortable`` is :const:`~gi.repository.Gtk.TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID`, then the model will sort using this function. If ``sort_func`` is :const:`None`, then there will be no default comparison function. This means that once the model has been sorted, it can’t go back to the default state. In this case, when the current sort column id of ``sortable`` is :const:`~gi.repository.Gtk.TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID`, the model will be unsorted. .. deprecated:: 4.10 Please do not use it in newly written code :param sort_func: The comparison function :param user_data: User data to pass to ``sort_func`` .. method:: set_sort_column_id(sort_column_id: int, order: ~gi.repository.Gtk.SortType) -> None Sets the current sort column to be ``sort_column_id``\. The ``sortable`` will resort itself to reflect this change, after emitting a ``GtkTreeSortable::sort-column-changed`` signal. ``sort_column_id`` may either be a regular column id, or one of the following special values: - :const:`~gi.repository.Gtk.TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID`: the default sort function will be used, if it is set - :const:`~gi.repository.Gtk.TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID`: no sorting will occur .. deprecated:: 4.10 Please do not use it in newly written code :param sort_column_id: the sort column id to set :param order: The sort order of the column .. method:: set_sort_func(sort_column_id, sort_func, user_data=None) Sets the comparison function used when sorting to be ``sort_func``\. If the current sort column id of ``sortable`` is the same as ``sort_column_id``\, then the model will sort using this function. .. deprecated:: 4.10 Please do not use it in newly written code :param sort_column_id: the sort column id to set the function for :param sort_func: The comparison function :param user_data: User data to pass to ``sort_func`` .. method:: sort_column_changed() -> None Emits a ``GtkTreeSortable::sort-column-changed`` signal on ``sortable``\. .. deprecated:: 4.10 Please do not use it in newly written code Signals ------- .. rst-class:: interim-class .. class:: TreeSortable.signals :no-index: .. method:: sort_column_changed() -> None The type of the None singleton. Virtual Methods --------------- .. rst-class:: interim-class .. class:: TreeSortable :no-index: .. method:: do_get_sort_column_id() -> ~typing.Tuple[bool, int, ~gi.repository.Gtk.SortType] Fills in ``sort_column_id`` and ``order`` with the current sort column and the order. It returns :const:`True` unless the ``sort_column_id`` is :const:`~gi.repository.Gtk.TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID` or :const:`~gi.repository.Gtk.TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID`. .. deprecated:: 4.10 Please do not use it in newly written code .. method:: do_has_default_sort_func() -> bool Returns :const:`True` if the model has a default sort function. This is used primarily by GtkTreeViewColumns in order to determine if a model can go back to the default state, or not. .. deprecated:: 4.10 Please do not use it in newly written code .. method:: do_set_default_sort_func(sort_func: ~typing.Callable[[~gi.repository.Gtk.TreeModel, ~gi.repository.Gtk.TreeIter, ~gi.repository.Gtk.TreeIter, ~typing.Any], int], user_data: ~typing.Any = None) -> None Sets the default comparison function used when sorting to be ``sort_func``\. If the current sort column id of ``sortable`` is :const:`~gi.repository.Gtk.TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID`, then the model will sort using this function. If ``sort_func`` is :const:`None`, then there will be no default comparison function. This means that once the model has been sorted, it can’t go back to the default state. In this case, when the current sort column id of ``sortable`` is :const:`~gi.repository.Gtk.TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID`, the model will be unsorted. .. deprecated:: 4.10 Please do not use it in newly written code :param sort_func: The comparison function :param user_data: User data to pass to ``sort_func`` .. method:: do_set_sort_column_id(sort_column_id: int, order: ~gi.repository.Gtk.SortType) -> None Sets the current sort column to be ``sort_column_id``\. The ``sortable`` will resort itself to reflect this change, after emitting a ``GtkTreeSortable::sort-column-changed`` signal. ``sort_column_id`` may either be a regular column id, or one of the following special values: - :const:`~gi.repository.Gtk.TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID`: the default sort function will be used, if it is set - :const:`~gi.repository.Gtk.TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID`: no sorting will occur .. deprecated:: 4.10 Please do not use it in newly written code :param sort_column_id: the sort column id to set :param order: The sort order of the column .. method:: do_set_sort_func(sort_column_id: int, sort_func: ~typing.Callable[[~gi.repository.Gtk.TreeModel, ~gi.repository.Gtk.TreeIter, ~gi.repository.Gtk.TreeIter, ~typing.Any], int], user_data: ~typing.Any = None) -> None Sets the comparison function used when sorting to be ``sort_func``\. If the current sort column id of ``sortable`` is the same as ``sort_column_id``\, then the model will sort using this function. .. deprecated:: 4.10 Please do not use it in newly written code :param sort_column_id: the sort column id to set the function for :param sort_func: The comparison function :param user_data: User data to pass to ``sort_func`` .. method:: do_sort_column_changed() -> None Emits a ``GtkTreeSortable::sort-column-changed`` signal on ``sortable``\. .. deprecated:: 4.10 Please do not use it in newly written code