Re: Infinite List



On 09/13/2012 09:34 AM, Nick Glynn wrote:
> I'm writing an app that shows information from a website - a similar app
> to Pattrn for Android but for Gnome- but don't want to have all
> data/images downloaded and present before the app starts.
> 
> What's the best widget/method to implement an Infinite List[1] style
> mechanism using Gtk where more data requests are fired either by a
> reload gesture/button or, preferably, by exposing the bottom of the list?

So there are a couple separate problems to deal with here. And depending
on the potential worst case you want to handle, there are different ways
of doing it.

One problem, is how do you want to store the content for all of those
items. Do you plan on doing that in memory? Do you want it in a local
database that gets queried per row?

If you want to handle it in memory, use a GtkListStore. You can have a
column that indicates this is the "last row", and use a
GtkCellRendererDataFunc to prepare the GtkCellRenderer appropriately.

On the GtkTreeViews "row-activated" signal, you can check if it is your
special row and fetch new data. Then append it to the list (or simply
insert right before your "load more data" row).

However, if relatively constant memory overhead is important and you are
working with millions of rows, then I would suggest a different UI
design :-)

FWIW, I think a tutorial for this pattern is a good idea. You aren't the
first, and won't be the last to ask this.

-- Christian


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