-
Notifications
You must be signed in to change notification settings - Fork 35
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
Implement TreeView with patchable models #42
Comments
@owickstrom I'm interested in implementing this but it definitely requires discussion and your sign-off on the design before I can start working on it. |
The idea of a model underlying a widget recurs in GTK, for instance, |
Thanks for the proposal! I hope I can get some time this weekend to look more closely at it. 👍 |
One subtle thing here is that the widget itself can update the model. Users can drag-and-drop to reorder rows, rows can be editable, etc. We need some way to feed this back into the application state (via events probably) without the changes in the application state immediately triggering another update, causing model inconsistency and infinite loops. |
@owickstrom Have you gotten a chance to look at this more closely? I'd really like to start implementing it. |
Hey, sorry it took a while longer. OK, so in this library I've deliberately not used the concept of models from GTK+. As you say, they effectively implement a bidrectional mutating data flow between the application state and the widgets, and I want gi-gtk-declarative to be unidirectional. The only way for information from the user interface to flow back up to the application logic is through events. (I should document this stuff in some sort of general guidelines for gi-gtk-declarative widget implementation.) I'm not sure I like the "unidirectional" terminology much, but it as at least established in the React world. When it comes to the I propose you start by defining such data types for the Does that make sense? Please ask more questions if you have any. I'm glad your here and want to help implement more widget support! 🙂 |
Basic Proposal
A
GtkTreeView
is associated with an instance ofGtkTreeModel
which is what actually gets mutated in order to add or remove nodes from the tree (commonlyGtkListStore
orGtkTreeStore
).One way to handle this would be to have a new declarative widget type View
and corresponding smart constructor
Plus a declarative implementation of columns, lists, and trees.
The
Patchable
instance for aViewWidget
should recurse into themodel
and build an operation to update the underlyingGtkListStore
orGtkTreeStore
.Possible enhancements
Model
type could be provided to e.g. change the diff algorithm used to generate patches for lists or trees.The text was updated successfully, but these errors were encountered: