The Wayback Machine - https://web.archive.org/web/20201010131403/https://github.com/elementary/mail/pull/286
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Custom ListBox widget for ConversationList #286

Merged
merged 19 commits into from Dec 4, 2018
Merged

Conversation

@davidmhewitt
Copy link
Member

@davidmhewitt davidmhewitt commented Oct 22, 2018

Supersedes #235

Instead of using a TreeView and the obvious shortcomings of not being able to use Gtk.Widgets anymore to construct the list of conversations, this PR implements a custom ListBox implementation that is much more efficient than the GTK one.

Instead of creating a Gtk.Widet for every single row in the ListBox, visible or not. We use a pool of a small number of widgets that get recycled/re-mapped to the underlying datastore as they scroll in and out of view. The sizing of the scrollbar is worked out on the average height of each row, multiplied by the number of rows in the data store. So, for ListBoxes where every row is an equal height (like in this case), the scrollbar is perfectly mapped. For varying height widgets, it works reasonably well, but you see some slight amount of jumping in the scrollbar, especially for small lists.

This implementation is not perfectly API compatible with the existing GTK ListBox, but I've tried to keep quite a few of the property names the same to make transition reasonably easy. I think using this in Mail and seeing how well it works out and seeing if anything needs fixing or adding would be a good thing. Then it can be moved out to Granite if it's useful elsewhere or I'll look at porting it to C and submitting upstream.

My gmail inbox has ~12000 items and master will not load that folder at all, even after leaving it 10+ minutes. It just keeps burning through memory and never actually loading. With this, it loads in <1 second (note: there is a separate issue where if the folder has changed, the EDS backend refreshes the folder before Mail displays anything, which takes a short while). The best way to test is to allow mail to load a folder for the first time and then switch back and forth between two folders, as this is purely the speed of populating the listbox rather than waiting for the mail backend.

Still to do:

  • Check I haven't broken anything during the merge and branch name changes
  • Fix code style
  • Add documentation
@harisvsulaiman
Copy link

@harisvsulaiman harisvsulaiman commented Oct 22, 2018

This should be merged into granite.
This is similar to recyclerview on Android. This could improve performance of a number of apps.

@eyelash
Copy link
Contributor

@eyelash eyelash commented Oct 23, 2018

In case you're not aware of it, upstream GTK is already working on such a widget. This is for GTK4, though. Maybe there could be some collaboration on a single implementation that would work for both GTK and elementary.

davidmhewitt and others added 5 commits Oct 27, 2018
@tintou
Copy link
Member

@tintou tintou commented Dec 4, 2018

@davidmhewitt I'm tempted to merge it just now because it feels way better with this change 😍

@davidmhewitt
Copy link
Member Author

@davidmhewitt davidmhewitt commented Dec 4, 2018

Sure, I could add documentation afterwards. It still needs some good testing though. I can't remember if there any any issues outstanding with selections or keyboard navigation etc...

But, I guess it'll get wider testing if it's in master.

@tintou tintou merged commit 2a63384 into master Dec 4, 2018
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@tintou tintou deleted the optimised-listbox branch Dec 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.