Hello!
I currently have a ListBox, however I’m adding in the range of 1000 widgets inside and I’m filtering them. The listbox takes ~500ms to get populated the first time (and the GUI is frozen for that time), and memory use is quite high. Filtering then is fast enough though. I’m aware that ListBox is not the right widget if I want to have many items in the list. I’ve discarded this solution for my use-case due to the performance.
What I do want is something like a listbox… Each entry will contain an icon, formatted text, a button on which you can click that opens a popover, and there are several different row types mixed together in the same list (which is not a problem with ListBox).
I tried making a TreeView afterwards. The plan was to write a custom cell renderer that would draw the cell contents using cairo & use the ‘activate’ to catch clicks and display my popover if the user clicked on the spot of the button. And the TreeView can be lazy/reuse rows. But that didn’t work out because I have different row types, it would get very messy with TreeView & CellRenderer which are not meant for that, and setting up a CellRenderer & TreeView is quite boilerplaty.
That brings me to my current plan… Use a DrawingArea and draw the rows manually. They can have the same height per row type, I can catch click events, and I was going to draw the cells with cairo with the TreeView as well anyway.
I have two questions regarding that approach:
-
is going for a DrawingArea the right approach in my case? I know it’ll work, maybe it’s more work than it could be, but I have no better idea.
-
If using a DrawingArea, I’ll need a scrollbar, and the “virtual” area is going to be quite large – since I intend to “simulate” a ListBox like that. Often it’s advised to use a DrawingArea within a ScrolledWindow, and setting the height of the DrawingArea to the wanted value. However I intended to handle the scrolling myself, having a DrawingArea of the display size (not the virtual size) and a separate scrollbar, assuming the ScrolledWindow approach would take considerably more memory. But the ScrolledWindow approach is often mentioned on internet as though it doesn’t have any minuses. I guess it’s technically possible that it would only use the memory required for the ‘display’ area, not the one for the ‘virtual’ area. So my question is, is it way more efficient to have DrawingArea of the display size & a separate scrollbar as opposed to having a very large DrawingArea inside a ScrolledWindow? Or is the performance (speed, memory use) difference not that large?
Thank you, I’m aware this is a long read…
emmanuel