40 GtkTreeModelSort

A GtkTreeModel which makes an underlying tree model sortable

40.1 Overview

The <gtk-tree-model-sort> is a model which implements the
<gtk-tree-sortable> interface. It does not hold any data itself, but
rather is created with a child model and proxies its data. It has identical
column types to this child model, and the changes in the child are propagated.
The primary purpose of this model is to provide a way to sort a different model
without modifying it. Note that the sort function used by
<gtk-tree-model-sort> is not guaranteed to be stable.

The use of this is best demonstrated through an example. In the following sample
code we create two <gtk-tree-view> widgets each with a view of the same
data. As the model is wrapped here by a <gtk-tree-model-sort>, the two
<gtk-tree-view>s can each sort their view of the data without affecting
the other. By contrast, if we simply put the same model in each widget, then
sorting the first would sort the second.

To demonstrate how to access the underlying child model from the sort model, the
next example will be a callback for the <gtk-tree-selection> "changed"
signal. In this callback, we get a string from COLUMN_1 of the model. We then
modify the string, find the same selected row on the child model, and change the
row there.

This function should almost never be called. It clears the tree-model-sort
of any cached iterators that haven't been reffed with
gtk-tree-model-ref-node. This might be useful if the child model being
sorted is static (and doesn't change often) and there has been a lot of unreffed
access to nodes. As a side effect of this function, all unreffed iters will be
invalid.