GNOME Bugzilla – Bug 791839
Port to GtkFlowBox
Last modified: 2018-01-08 09:37:27 UTC
.
Created attachment 365835 [details] [review] collection: Decorate a Gtk.ListStore to manage items Using a Gtk.ListStore we can let Gtk.ListBox and Gtk.FlowBox bind to the same model, and apply both filtering and sorting at the same place. These changes require project-wide tweaks in the way we iterate over CollectionItems. For this, a Collection.foreach was introduced. We use the classic C for loop for the other cases where loop control instructions are necessary. A step back in this implementation in comparison to the previous one is that now the removal of items is done in linear time.
Created attachment 365836 [details] [review] collection: Insert items sorted This way we will be able to get rid of GtkListBox.sort_func and do the sorting at the model side when ListView will be binded to Collection directly.
Created attachment 365837 [details] [review] list-view: Bind GtkListBox to Collection model We used to subscribe to the item_added and item_removed signals of Collection and insert the rows accordingly. Now the ListView listbox is binded directly to the Collection model and therefore the model-view mapping is done automatically. The changes in app.vala and app-window.vala are temporary so we don't brake the current implementation of IconView.
Created attachment 365838 [details] [review] icon-view: Port to GtkFlowBox Finally IconView can be directly binded to Collection the same way as ListView is. This is one important step towards providing full independence between the model and the views. We can also now revert the app.vala, app-window.vala hack introduced before to prevent the IconView to break while ListView was being ported.
Created attachment 365839 [details] [review] collection: Handle hidden items at the model side A hidden item is a newly create item (machine) where the user is still visualizing the wizard, and therefore should'nt be presented in the views. Both views (IconView and ListView) used to handle the hidden_items independently, duplicating the code and logic. Now we can handle the hidden_items in a single place, in the Collection object as a result of the decoupling of model and view recently introduced.
Created attachment 366201 [details] [review] list-view: Drop items connections There's no need anymore to subscribe to item changes since the GLib.ListStore will update the view accordingly whenever an item notifies any change.
Created attachment 366286 [details] [review] icon-view: Align machine_name with the thumbnail Prevent long names from expading the widget.
Created attachment 366287 [details] [review] app, collection: Don't directly populate the views We no longer need to populate ListView and IconView since now their children are directly binded from the Collection model.
Created attachment 366288 [details] [review] list-view: Use container remove signal to trigger cleanup Instead of relying on our own remove_item handler we can connect to the "remove" signal of the list_view and trigger the cleanup code which removes the item from the size group.
Created attachment 366289 [details] [review] list-view: Use container "add" signal to setup child Instead of relying on our own add_item handler we can now connect to the "add" signal of the list_view directly.
Created attachment 366290 [details] [review] i-collection-view: Drop "add_item" and "remove_item" methods The interface between the collection and the views no longer needs to handle addition and removal of items since all the views are directly binded to the collection model.
Created attachment 366291 [details] [review] icon-view: Set action popover relative to thumbnail This way we can guarantee that the popover won't be weirdly positioned based on the length of the machine name.
This work can be tested in this wip branch ~> https://git.gnome.org/browse/gnome-boxes/log/?h=wip/feborges/flowbox
Attachment 365835 [details] pushed as 749638d - collection: Decorate a Gtk.ListStore to manage items Attachment 365836 [details] pushed as acf9aa7 - collection: Insert items sorted Attachment 365837 [details] pushed as d2c9267 - list-view: Bind GtkListBox to Collection model Attachment 365838 [details] pushed as c9f4d6d - icon-view: Port to GtkFlowBox Attachment 365839 [details] pushed as c653310 - collection: Handle hidden items at the model side Attachment 366286 [details] pushed as d92f744 - icon-view: Align machine_name with the thumbnail Attachment 366287 [details] pushed as 5ef3372 - app, collection: Don't directly populate the views Attachment 366288 [details] pushed as 3ee8564 - list-view: Use container remove signal to trigger cleanup Attachment 366289 [details] pushed as b239f8d - list-view: Use container "add" signal to setup child Attachment 366290 [details] pushed as 2f8da4a - i-collection-view: Drop "add_item" and "remove_item" methods Attachment 366291 [details] pushed as 1847faa - icon-view: Set action popover relative to thumbnail I am merging these changes so we can test them in the trenches in the unstable 3.27.4 release.