Re: Speed of GtkListStore additions O(n^2)?



Hi,

Linus Walleij <triad df lth se> writes:

> Then I happen to need to blank the store and refill it repeatedly. And
> there doesn't seem to be a good way to turn sorting _off_ once you turned
> it on, so any subsequent fills will be O(n^2) anyway.
>
> Any suggestions? Or will I simply have to destroy the ListStore (and thus
> the ListView) and create a new one each time I want to do something like
> this?

What we are doing in gimp (plug-ins/dbbrowser/dbbrowser_utils.c) is
the following:

  dbbrowser->store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
  gtk_tree_view_set_model (GTK_TREE_VIEW (dbbrowser->tv),
                           GTK_TREE_MODEL (dbbrowser->store));
  g_object_unref (dbbrowser->store);

  /*  fill the store  */

  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (dbbrowser->store),
                                        0, GTK_SORT_ASCENDING);

The views keeps alive and the new store is filled reasonably fast and
sorted afterwards.


Sven




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