GNOME Bugzilla – Bug 695735
Convert from GdMainView to EggFlowBox (or something similar)
Last modified: 2014-08-27 14:23:14 UTC
I think we should try to encapsulate the world view in its own class in preparation to experimenting with using EggFlowBox instead of Gd.MainView (as a matter of fact I would prefer that the WorldView class used composition intead of inheritance and hid the Gd.MainView and the TreeModel to the outside code, but for now this is just the minimal patch). Incidentally, if instead of setting the model after creating the view, I try the follwing this.parent({ model: new WorldModel(world), view_type: Gd.MainViewType.ICON }); then gjs crashes hard (segfault, not JS exception)
Created attachment 238746 [details] [review] Factor out a WorldView class
I don't like hiding the model inside the view. It breaks the mvc split. If you want to have a custom class that inherits from Gd.MainView, that's fine, but the model should be created by the window (or even better, by the application) and passed down. Also, I'd like to investigate the gjs segfault.
Ok, found the bug: GdMainView:model is a construct property, but GdMainView:view-type is not - yet, setting model relies on setting view-type to build the inner view.
(In reply to comment #2) > I don't like hiding the model inside the view. It breaks the mvc split. > That's why I think we should use composition instead of inheritance: to not call it "view" lets call it "WorldPanel" the world panel would be a widget that contains a View and the owns model. The Window has no business knowing the model and the view of each page, it is an high level object that contains the world panel and the city panel. A refactoring to use EggFlowBox would be just an internal implementation detail of the world panel with no impact on the window
(In reply to comment #3) > Ok, found the bug: GdMainView:model is a construct property, but > GdMainView:view-type is not - yet, setting model relies on setting view-type to > build the inner view. Cool thanks for investigating, so a bug in libgd? should gjs still be able to survive?
Yes, it's a bug in libgd. And funnily, I had found it two weeks ago, reported as bug 694533, and then completely forgot of it.
Ok, so, I decided to experiment myself with eggflowbox. The end result does not look good, but I'm posting it anyway, at least it's feedback. If you want to try it, you need to patch egg-list-box with bug 681224, otherwise the build system is unable to pick it.
Created attachment 239403 [details] [review] Add egg-list-box For the main view we want to use a flow box, which is provided by EggListBox until merged into Gtk.
Created attachment 239404 [details] [review] [WIP] Convert from GdMainView to EggFlowBox EggFlowBox frees us from GtkTreeModel, so we can implement our data structures directly in JS. It also frees us from GtkCellRenderer, allowing custom complex widgets. The disadvantage is that the selection model is that of a GtkIconView, so we (temporarily) lose the separate selection mode and the check boxes to indicate selection.
My (untested) idea for the selection was to turn off the builtin selection stuff and use GtkOverlay to put a checkbox over each widget
Comment on attachment 238746 [details] [review] Factor out a WorldView class Attachment 238746 [details] pushed as 2357985 - Factor out a WorldView class
After doing some more work on this, I pushed wip/egg-flow-box, with details of what's missing. We should try to get those changes integrated in egg-flow-box (maybe as a egg-content-view?) before making the switch.
Not interesting any more.