Re: TreeView: slow and very slow



Lars Clausen wrote on Sat, 22 Feb 2003 17:40:17 -0600:

> I use a ListStore+TreeView with CellRendererText
> to display the items, and I'm finding it to be extremely slow. 
> How can I reduce the update time?

If you are using Win32, you can set the environment variable 
PANGO_WIN32_NO_UNISCRIBE which disables GTK+s use of the Microsoft Uniscribe 
DLLs.  The good news is that it speeds up GtkTreeView display/scroll operations 
considerably; the bad news is that you are disabling some i18n font-rendering 
functionality.

> It gets even worse when the ListStore is sorted, then insertion takes 42
> seconds!  But once the list has been displayed, sorting it takes only 2
> seconds.  Thus, it'd be better to turn off sorting while inserting and turn
>it back on afterwards, but where do I find what column sorts?

Whenever I want to clear a GtkListStore, add a large number of rows, and sort 
them I follow this procedure:

1) Clear the GtkListStore with gtk_list_store_clear().

2) Force the GtkListStore back into an unsorted state with: 
     GTK_LIST_STORE(liststore)->sort_column_id = -2;
This fools the GtkListStore into thinking that it has never been sorted before 
and makes the "gtk_list_store_append() / gtk_list_store_set()" operation take 
less time.  

3) Add many rows to the GtkListStore with many "gtk_list_store_append() / 
gtk_list_store_set()" operations.

4) Sort the GtkListStore with gtk_tree_sortable_set_sort_column_id().

I hope this helps.

--
Ken Rastatter, Design Engineer
Sensotec, Inc.
2080 Arlingate Lane, Columbus, Ohio, 43228-4112 USA

Voice: (614)850-5000 Fax: (614)850-6041 Toll Free: 1-800-848-6564
Home Page:  http://www.sensotec.com





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