Fwd: Fwd: Iserting in a sortable tree



---------- Forwarded message ----------
From: Tim Müller <tim centricular net>
Date: Sep 8, 2005 2:17 PM
Subject: Re: Fwd: Iserting in a sortable tree
To: Razvan Gavril <razvan gavril gmail com>

On Thu, 2005-09-08 at 13:23 +0300, Razvan Gavril wrote:
Hi, i have a question that i also posted on the gtk-app-devel-list but
i didn't get any answer to it. In yout tutorial about GtkTreeView you
mentioned that you have to make sure that sorting is disabled during
mass insertion in the model. I can't find a way to disable the
sorting, and idead my insertion take a lot of time, cause i have some
real coplex sorting functions that are called during my mass
insertion. Can you help with a short how-to on this ?

Well, the information in the tutorial might be a bit outdated, I think
some work has gone into improving performance of the liststore in
particular in recent Gtk+ versions. I haven't really kept up to date
with all those changes, so take my advice with a grain of salt.

I _think_ at some point (Gtk-2.4? Gtk-2.6?)
gtk_tree_sortable_set_sort_column_id() was changed to accept the magic
value -2 which represents the unsorted stage (the function wouldn't
accept that value before because of an assertion that would not allow
it). So you might want to try that to switch off sorting temporarily
(check the gtk+ header files and/or API for the details, I'm sure
there's a #define/enum for that value).

If that doesn't work, you can try to block the tree model signals that
might trigger resorting, and manually force a resort after your
insertions. That's rather hacky though.

Writing your own treemodel is always an option as well of course ;-)

Hope this helps.

Cheers
-Tim


---------- Forwarded message ----------
From: Razvan Gavril <razvan gavril gmail com>
Date: Sep 7, 2005 3:38 PM
Subject: Iserting in a sortable tree
To: gtk-app-devel-list gnome org

Secondly, you should make sure that sorting is disabled while
you are doing your mass insertions, otherwise your store might
be resorted after each and every single row insertion, which
is going to be everything but fast.

I know it must be some simple thing that i missed when RTFM-ing but :
how to i disable sorting while inserting rows ?, now my sort function
is called after every insertion. :(


--
Razvan Gavril
razvan gavril gmail com



-- 
Razvan Gavril
razvan gavril gmail com



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