spk121 / guile-gi

Bindings for GObject Introspection and libgirepository for Guile
GNU General Public License v3.0
58 stars 7 forks source link

Storing guile function (or whatever) in a gtktreestore column #95

Closed daym closed 3 years ago

daym commented 3 years ago

It would be nice if one could store a guile function (or whatever) in a GtkTreeStore column.

LordYuuma commented 3 years ago

Perhaps you could try wrapping your procedure in a closure. IIRC all you'd need would be support for storing it in a GValue, no?

daym commented 3 years ago

Yes, storing it in a GValue should be enough.

Do you mean GClosure? Is it supported in guile-gi to store a Guile procedure in a GClosure ?

G_TYPE_CLOSURE seems to be missing, but one can use <GClosure>. Fine.

LordYuuma commented 3 years ago

(gi types) should export procedure->closure if I'm not mistaken.

daym commented 3 years ago

Indeed, it works with that! Maybe I should read more guile-gi documentation--sorry.

daym commented 3 years ago

After having stored a procedure into a treeview cell like this, how do I get it back out so I can call it?

procedure->closure makes a GClosure which means I cannot return a guile function (in this case a guix <package> record) from my function.

Is there another way to store Guix <package>s into a tree?

LordYuuma commented 3 years ago

I don't think, that use case is currently supported. You need to retrieve Guix records from the closure for further low-level processing, am I correct? In other words, you can't restrict yourself to GTyped structures here, can you?

I feel as though using scm->pointer and pointer->scm from (system foreign) might be your safest bet here.