:right-sidebar: True ColumnViewSorter =================================================================== .. currentmodule:: gi.repository.Gtk .. versionadded:: 4.10 .. class:: ColumnViewSorter(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Sorter`, :class:`~gi.repository.GObject.Object` ``GtkColumnViewSorter`` is a sorter implementation that is geared towards the needs of ``GtkColumnView``. The sorter returned by :obj:`~gi.repository.Gtk.ColumnView.get_sorter` is a ``GtkColumnViewSorter``. In column views, sorting can be configured by associating sorters with columns, and users can invert sort order by clicking on column headers. The API of ``GtkColumnViewSorter`` is designed to allow saving and restoring this configuration. If you are only interested in the primary sort column (i.e. the column where a sort indicator is shown in the header), then you can just look at :obj:`~gi.repository.Gtk.ColumnViewSorter.props.primary_sort_column` and :obj:`~gi.repository.Gtk.ColumnViewSorter.props.primary_sort_order`. If you want to store the full sort configuration, including secondary sort columns that are used for tie breaking, then you can use :obj:`~gi.repository.Gtk.ColumnViewSorter.get_nth_sort_column`. To get notified about changes, use :obj:`~gi.repository.Gtk.Sorter.signals.changed`. To restore a saved sort configuration on a ``GtkColumnView``, use code like: .. code-block:: :dedent: sorter = gtk_column_view_get_sorter (view); for (i = gtk_column_view_sorter_get_n_sort_columns (sorter) - 1; i >= 0; i--) { column = gtk_column_view_sorter_get_nth_sort_column (sorter, i, &order); gtk_column_view_sort_by_column (view, column, order); } Methods ------- .. rst-class:: interim-class .. class:: ColumnViewSorter :no-index: .. method:: get_n_sort_columns() -> int Returns the number of columns by which the sorter sorts. If the sorter of the primary sort column does not determine a total order, then the secondary sorters are consulted to break the ties. Use the :obj:`~gi.repository.Gtk.Sorter.signals.changed` signal to get notified when the number of sort columns changes. .. versionadded:: 4.10 .. method:: get_nth_sort_column(position: int) -> tuple[~gi.repository.Gtk.ColumnViewColumn | None, ~gi.repository.Gtk.SortType] Gets the ``position``'th sort column and its associated sort order. Use the :obj:`~gi.repository.Gtk.Sorter.signals.changed` signal to get notified when sort columns change. .. versionadded:: 4.10 :param position: the position of the sort column to retrieve (0 for the primary sort column) .. method:: get_primary_sort_column() -> ~gi.repository.Gtk.ColumnViewColumn | None Returns the primary sort column. The primary sort column is the one that displays the triangle in a column view header. .. versionadded:: 4.10 .. method:: get_primary_sort_order() -> ~gi.repository.Gtk.SortType Returns the primary sort order. The primary sort order determines whether the triangle displayed in the column view header of the primary sort column points upwards or downwards. If there is no primary sort column, then this function returns ``GTK_SORT_ASCENDING``. .. versionadded:: 4.10 Properties ---------- .. rst-class:: interim-class .. class:: ColumnViewSorter :no-index: .. attribute:: props.primary_sort_column :type: ~gi.repository.Gtk.ColumnViewColumn The primary sort column. The primary sort column is the one that displays the triangle in a column view header. .. versionadded:: 4.10 .. attribute:: props.primary_sort_order :type: ~gi.repository.Gtk.SortType The primary sort order. The primary sort order determines whether the triangle displayed in the column view header of the primary sort column points upwards or downwards. .. versionadded:: 4.10