I'm trying to use the bindModel function of gtk3's flowbox, so that I can just give it a model and creation of child widgets, sorting, and filtering will be done for me.
The process of storing and retrieving data into this model isn't clear to me however, in two ways:
- How do I put arbitrary Haskell data in a ListStore? Say I have defined
data Cookie = Cookie [Text] Text
. In GListStore'slistStoreAppend :: (ObjectK b) => ListStore -> b -> IO ()
, what is b? How do I convertCookie
into anObjectK
? In the original C code, this parameter is a gpointer... - How do I convert a
Ptr ()
back intoCookie
? The flowbox' bindModel has the typeflowBoxBindModel :: (HasCallStack, IsListModel b) => FlowBox -> Maybe b -> (Ptr () -> IO Widget) -> IO ()
. To create a child widget, I need to convertPtr ()
, which it gets from the ListStore, back intoCookie
, but how?
So, to recap: If anyone could help make clear to me how (1) I put Haskell data in a C-defined ListStore; and (2) how I convert pointer back into its original data form?
Thanks in advance.
Note: I simplified some types, to emphasize the unclear parts.