owickstrom / gi-gtk-declarative

Declarative GTK+ programming in Haskell
https://owickstrom.github.io/gi-gtk-declarative/
288 stars 35 forks source link

Changing runInWindow to return the final state. #9

Closed locallycompact closed 5 years ago

locallycompact commented 6 years ago

Hello, I'm new to gtk. I'm looking at situations like the FileChooser example and wondering how best to compose it with larger applications. Would it make sense to change run or runInWindow to return the final state?

runInWindow :: Typeable event => Gtk.Window -> App state event -> IO state

so that the window can run to completion as if it were a sub-app, provide a result (the filepath), and then the parent application's logic can interpret the result how it wants? Are there reasons this may/may not make sense as a strategy?

Thanks

owickstrom commented 6 years ago

Hi! Thanks for the suggestion, and this absolutely makes sense! I can't really see how it would be a problem. It would be possible then to do a part of an application, like a dialog prompting for some input, in a declarative fashion, and call that from within a more imperative GTK+ application.

The API has changed slightly, so the function that you'd want to modify is:

https://github.com/owickstrom/gi-gtk-declarative/blob/master/gi-gtk-declarative-app-simple/src/GI

Wo/Gtk/Declarative/App/Simple.hs#L82

Would you like to send a PR?

locallycompact commented 6 years ago

Yup, will do.