1

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:

  1. How do I put arbitrary Haskell data in a ListStore? Say I have defined data Cookie = Cookie [Text] Text. In GListStore's listStoreAppend :: (ObjectK b) => ListStore -> b -> IO (), what is b? How do I convert Cookie into an ObjectK? In the original C code, this parameter is a gpointer...
  2. How do I convert a Ptr () back into Cookie? The flowbox' bindModel has the type flowBoxBindModel :: (HasCallStack, IsListModel b) => FlowBox -> Maybe b -> (Ptr () -> IO Widget) -> IO (). To create a child widget, I need to convert Ptr (), which it gets from the ListStore, back into Cookie, 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.

Arthur
  • 193
  • 1
  • 9
  • I've found out what the ObjectK means. The passed value [must be a subclass of GObject](https://developer.gnome.org/gio/stable/GListStore.html#GListStore--item-type). I've already succeeded in passing in `GtkLabel`. The question how to convert a `Ptr ()` back into a `GtkLabel` so I can work with it remains however. – Arthur Jul 22 '17 at 12:20

0 Answers0