After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 791839 - Port to GtkFlowBox
Port to GtkFlowBox
Status: RESOLVED FIXED
Product: gnome-boxes
Classification: Applications
Component: general
3.27.x
Other Linux
: Normal normal
: --
Assigned To: GNOME Boxes maintainer(s)
GNOME Boxes maintainer(s)
Depends on:
Blocks: 792204
 
 
Reported: 2017-12-21 11:56 UTC by Felipe Borges
Modified: 2018-01-08 09:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
collection: Decorate a Gtk.ListStore to manage items (9.35 KB, patch)
2017-12-21 11:57 UTC, Felipe Borges
committed Details | Review
collection: Insert items sorted (1.04 KB, patch)
2017-12-21 11:57 UTC, Felipe Borges
committed Details | Review
list-view: Bind GtkListBox to Collection model (4.46 KB, patch)
2017-12-21 11:57 UTC, Felipe Borges
committed Details | Review
icon-view: Port to GtkFlowBox (31.42 KB, patch)
2017-12-21 11:57 UTC, Felipe Borges
committed Details | Review
collection: Handle hidden items at the model side (6.37 KB, patch)
2017-12-21 11:57 UTC, Felipe Borges
committed Details | Review
list-view: Drop items connections (2.63 KB, patch)
2018-01-02 13:21 UTC, Felipe Borges
none Details | Review
icon-view: Align machine_name with the thumbnail (1.38 KB, patch)
2018-01-04 13:35 UTC, Felipe Borges
committed Details | Review
app, collection: Don't directly populate the views (1.90 KB, patch)
2018-01-04 13:35 UTC, Felipe Borges
committed Details | Review
list-view: Use container remove signal to trigger cleanup (1.68 KB, patch)
2018-01-04 13:35 UTC, Felipe Borges
committed Details | Review
list-view: Use container "add" signal to setup child (1.51 KB, patch)
2018-01-04 13:35 UTC, Felipe Borges
committed Details | Review
i-collection-view: Drop "add_item" and "remove_item" methods (2.19 KB, patch)
2018-01-04 13:35 UTC, Felipe Borges
committed Details | Review
icon-view: Set action popover relative to thumbnail (1.57 KB, patch)
2018-01-04 13:36 UTC, Felipe Borges
committed Details | Review

Description Felipe Borges 2017-12-21 11:56:04 UTC
.
Comment 1 Felipe Borges 2017-12-21 11:57:02 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.
Comment 2 Felipe Borges 2017-12-21 11:57:07 UTC
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.
Comment 3 Felipe Borges 2017-12-21 11:57:11 UTC
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.
Comment 4 Felipe Borges 2017-12-21 11:57:16 UTC
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.
Comment 5 Felipe Borges 2017-12-21 11:57:21 UTC
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.
Comment 6 Felipe Borges 2018-01-02 13:21:21 UTC
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.
Comment 7 Felipe Borges 2018-01-04 13:35:37 UTC
Created attachment 366286 [details] [review]
icon-view: Align machine_name with the thumbnail

Prevent long names from expading the widget.
Comment 8 Felipe Borges 2018-01-04 13:35:42 UTC
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.
Comment 9 Felipe Borges 2018-01-04 13:35:46 UTC
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.
Comment 10 Felipe Borges 2018-01-04 13:35:51 UTC
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.
Comment 11 Felipe Borges 2018-01-04 13:35:56 UTC
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.
Comment 12 Felipe Borges 2018-01-04 13:36:01 UTC
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.
Comment 13 Felipe Borges 2018-01-04 14:02:25 UTC
This work can be tested in this wip branch ~> https://git.gnome.org/browse/gnome-boxes/log/?h=wip/feborges/flowbox
Comment 14 Felipe Borges 2018-01-08 09:36:44 UTC
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.