Re: Infinite List



I'm happy to do it in memory - yes, there's an overhead if the user starts to view hundreds of patterns but it's unlikely and also the reason for loading on demand - they'll get bored before resource exhaustion.

I'll have a play with what you and John have suggested (I'll be developing in Vala for this so can't steal it as is) but I agree on the design pattern examples. Cookbook recipes and examples are a great way to showcase the toolkit and make it easier to pick up.

The Design Patterns book is a very good reference for how to make things look and feel but it's no good if people can't implement them from the get go and it would be nice to see this for Gtk (developer time permitting of course :)

Regards,
Nick


On 13 September 2012 21:18, Christian Hergert <chris dronelabs com> wrote:
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
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list



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