Re: 'Huge list' widget



On Mon, 24 Mar 2003, Lionel Ulmer wrote:

> First, my requirements :
>
>  - displays just 'plain text' lines (no need for columns) where only the
>    color may change (ie no embedded icons, font change, ...)
>
>  - pretty huge lists (can go up into the 100.000 items)
>
>  - filling need to be fast as the list is built in a working thread and it's
>    a time-out handler which fills (by polling the working thread) the list
>    for the GUI (so I do not want the UI to freeze each time the time-out
>    handler adds element to the list).
>
> I looked a bit at how GtkTreeView handles these requirements and it's pretty
> slow (at least on my box and will even be slower 'in production' on
> relatively ancient Sun workstations). Moreover, either we let GTK handle  all
> the list, or all the data will be twice in memory. In my case, it's not
> possible to let GTK handle it so it's also very memory intensive.

What you could do, I think, is define your own class of list models.

The GtkTreeView only needs to be given a GObject which implements the
GtkTreeModel interface (check out the signature of
gtk_tree_view_set_model()). The GtkListStore and GtkTreeStore classes are
just particular implementations of the GtkTreeModel.

This is not very difficult to do, though a bit laborious (That's why
they came up with C++ :)

This also solves the problem about having all the data twice in memory:
your data structure *becomes* the `GtkTreeStore' you use, so you don't
need to have extra copies.

One example of this kind of thing is in the source for gconf: there the
tree in never built: its nodes are created as the user browses the gconf
tree. (Another example, maybe a bit exotic but fun, would be an locally
finite infinite tree which can be finitely computed (like the full tree
of moves in a chess game) Here it is impossible to keep the data in
memory, because you just can't, but you could come up with a
implementation of the GtkTreeModel interface which provides the data to
a view; the gconf case is rather similar to this, actually)

> So my idea was to write what I call a 'user-space list widget'. That means
> that the widget would only know about the list items displayed on screen (on
> scroll, it would each time ask for the new list items to display).

This is a bit different, because this would, I guess, break the separation
between the view and the model of your list (which is kind of sad, since
that scheme is very nicely thought out)

-- m

-----------------------------------------------------------------------
Mariano Suarez Alvarez
Departamento de Matematica - Universidad Nacional de Rosario
Pellegrini 250 - Rosario 2000 - Argentina

    De la observacion de la irreductibilidad de las creencias ultimas
    he sacado la mayor leccion de mi vida. Aprendi a respetar las ideas
    ajenas, a detenerme ante el secreto de las conciencias, a entender
    antes de discutir, a discutir antes de condenar. Y como estoy en
    vena de confesiones, hago una mas, quizas superflua: detesto con
    toda mi alma a los fanaticos.

    Norberto Bobbio, Italia civil.

-----------------------------------------------------------------------




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