Re: how to sort / swap rows

On Saturday, September 13, 2003, at 03:40 PM, Jens Luedicke wrote:

I added a sort function to one of the columns in a ListStore
and need to swap rows but gtk complains
that I can't to it. (sorted model)

how can I achive the desired effect? I don't
know if it is exactly what I want/need, but I would
try something like this.

my best guess is that the sort func is supposed to return 1, 0, or -1, and the model code will do the swapping for you, as the sorted model doesn't let you change the order from the outside.

indeed, poking through the source for gtk reveals a call to g_array_sort under the hood, with a proxy that returns the value from your supplied callback. g_array_sort uses a GCompareFunc, which returns 1, 0, or -1, like the c library's qsort. Lists.html#GCompareFunc

muppet <scott at asofyet dot org>

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]