Skip to content

Gtk.TreeSortable

interface

:::warning Deprecated since 4.10 This API is deprecated. :::

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

get_sort_column_id

def get_sort_column_id(self) -> tuple[bool, int, SortType | int]

:::warning Deprecated since 4.10 This API is deprecated. :::

Fills in sort_column_id and order with the current sort column and the order. It returns True unless the sort_column_id is TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID or TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID.

has_default_sort_func

def has_default_sort_func(self) -> bool

:::warning Deprecated since 4.10 This API is deprecated. :::

Returns 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.

set_default_sort_func

def set_default_sort_func(self, sort_func: TreeIterCompareFunc) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

Sets the default comparison function used when sorting to be sort_func. If the current sort column id of sortable is TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, then the model will sort using this function.

If sort_func is 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 TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model will be unsorted.

Parameters:

  • sort_func — The comparison function

set_sort_column_id

def set_sort_column_id(self, sort_column_id: int, order: SortType | int) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

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:

Parameters:

  • sort_column_id — the sort column id to set
  • order — The sort order of the column

set_sort_func

def set_sort_func(self, sort_column_id: int, sort_func: TreeIterCompareFunc) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

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.

Parameters:

  • sort_column_id — the sort column id to set the function for
  • sort_func — The comparison function

sort_column_changed

def sort_column_changed(self) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

Emits a GtkTreeSortable::sort-column-changed signal on sortable.

Virtual methods

do_get_sort_column_id

def do_get_sort_column_id(self) -> tuple[bool, int, SortType | int]

:::warning Deprecated since 4.10 This API is deprecated. :::

Fills in sort_column_id and order with the current sort column and the order. It returns True unless the sort_column_id is TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID or TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID.

do_has_default_sort_func

def do_has_default_sort_func(self) -> bool

:::warning Deprecated since 4.10 This API is deprecated. :::

Returns 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.

do_set_default_sort_func

def do_set_default_sort_func(self, sort_func: TreeIterCompareFunc) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

Sets the default comparison function used when sorting to be sort_func. If the current sort column id of sortable is TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, then the model will sort using this function.

If sort_func is 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 TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model will be unsorted.

Parameters:

  • sort_func — The comparison function

do_set_sort_column_id

def do_set_sort_column_id(self, sort_column_id: int, order: SortType | int) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

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:

Parameters:

  • sort_column_id — the sort column id to set
  • order — The sort order of the column

do_set_sort_func

def do_set_sort_func(self, sort_column_id: int, sort_func: TreeIterCompareFunc) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

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.

Parameters:

  • sort_column_id — the sort column id to set the function for
  • sort_func — The comparison function

do_sort_column_changed

def do_sort_column_changed(self) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

Emits a GtkTreeSortable::sort-column-changed signal on sortable.

Signals

sort-column-changed

def on_sort_column_changed(self) -> None: ...

The ::sort-column-changed signal is emitted when the sort column or sort order of sortable is changed. The signal is emitted before the contents of sortable are resorted.