Package: gtk

Callback gtk:tree-iter-compare-func

Syntax

lambda (model iter1 iter2) => result

Arguments

model -- a gtk:tree-model object the comparison is within
iter1 -- a gtk:tree-iter iterator in model
iter2 -- another gtk:tree-iter iterator in model
result -- a negative integer, zero or a positive integer depending on whether iter1 sorts before, with or after iter2

Details

A gtk:tree-iter-compare-func callback function should return a negative integer, zero, or a positive integer if iter1 sorts before iter2, iter1 sorts with iter2, or iter1 sorts after iter2 respectively. If two iterators compare as equal, their order in the sorted model is undefined. In order to ensure that the gtk:tree-sortable object behaves as expected, the gtk:tree-iter-compare-func callback function must define a partial order on the model, i.e. it must be reflexive, antisymmetric and transitive.

For example, if the model is a product catalogue, then a compare function for the "price" column could be one which returns price-of(a) - price-of(b).
 

See also

#2024-3-23