Closed ludat closed 5 years ago
Oh, yeah I think I wanted to deprecate it, but it seems I mistakenly did so without adding any CHANGELOG entry. It's really a bad hack that should be replaced with support for custom widgets, but I haven't gotten around to adding those yet.
Would it be OK for you to use the fork until custom widgets are in? Then it should be much more flexible to interface with the underlying GTK+ widgets. Sorry for the inconvenience!
No problem :smile:, I got the fork working, IMO the afterCreated has a place, I needed it to configure the initial options for a ComboBoxText, and I'm not sure if I would prefer to create a custom widget for that, maybe if this lib provided those commons initialization use-cases built in
Don't get me wrong I think the CustomWidget definitely is a better abstraction but I think afterCreated
is a good primitive, since gtk expects the user to trivially be able to run code after creating the component I think having afterCreate
is the more pragmatic approach to avoid rewriting a lot of binding for gtk
PS: kudos for making this great lib, I haven't gotten around making something with gtk until this lib appeared :clap: :clap:
That's a good point! Let's keep it for now.
Do you have it in shape to send a PR? Depending on from revision you forked, there might be some stuff around "collected attributes" that you need to change. In short, all attributes in the list passed to widget
/bin
/container
are collected into a Collected
structure for more efficient look-ups and diff calculation.
The afterCreate
hooks might need to be collected separately, into their own list in the Collected
type, but as they would only be called on widget creation we wouldn't have to do any diffing between old and new afterCreate
hooks. In fact, we couldn't, as they're IO actions. This behaviour should be documented in the afterCreate
Haddocks. I'd be happy to do the documentation later, if you want to create a PR with your changes as they are.
Thanks!
And thank you for the kind words, I'm really glad it inspired you to go build something! :smile:
I imagine there is some reason to avoid calling the afterCreated.
https://github.com/owickstrom/gi-gtk-declarative/blob/master/gi-gtk-declarative/src/GI/Gtk/Declarative/SingleWidget.hs#L52
I guess that was a mistake, I'll create a local fork so I can use the lib, if you want a PR I can create it.