How tell GtkColumnView how many items (rows) to create?

Greetings,

I would like to display many (appx. 1,000 to 15,000) images – each of which has some processing – alongside other information in a scrollable view. Based on the GTK documentation, GtkColumnView seemed to be just the right widget suited for this (but I am open if anyone knows a better solution).

But on my current attempt GtkColumnView is creating and populating about a 70-100 items, of which only about 2 or 3 actually fit on screen at a time… this makes initial display, as well as scrolling, pretty slow… like up to 30 seconds between updates when dragging the scrollbar.

Any suggestions how to tell GtkColumnView how many items (rows) to create?

Or maybe I should use another approach?

Thank you in advance.

Hi,

AFAIK there is not way to control this.

A solution could be to display first a placeholder image, then load the real images in a background task (see Generating List Item Widgets Asynchronously - #4 by maxrdz )

There is an open bug listview: Have an easy way to get visible items (#4688) · Issues · GNOME / gtk · GitLab for tracking which items are visible, but it’s still “in design”…
If all your rows have the same height, and if you know its value and the number of items, then maybe you can use the scrollbar’s adjustment to guess what’s displayed, and load the corresponding images in priority.

1 Like

Thank you, I’ll take a look at those.

Or do you think maybe hooking into the snapshot() mechanism would be a good idea for this? I didn’t find good documentation for that yet, but as far as I can tell that only gets called when things are actually getting around to be drawn on screen? Because then I could move my costly processing into that phase/layer, and then my processing would only run for the items that are actually getting displayed? Any pointers on how would I do that?

Yeah, using snapshot() to detect if your widget is in the visible area could be an interesting lead.

A possible way to proceed (untested):

  • declare a new widget (let’s call it MyPicture), inheriting from GtkPicture, and override its snapshot virtual method
  • populate the columnview with MyPicture widgets, using a placeholder image
  • in the custom snapshot method, call the parent GtkPicture::snapshot with the same params, and trigger an asynchronous computation of your image, once done update the MyImage with the new data

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.