diamondburned/gotk4

No proper type conversion generated for signals

pekim opened this issue · 7 comments

pekim commented
app := gtk.NewApplication("uk.co.pekim.Mige", gio.ApplicationHandlesOpen)
app.ConnectOpen(func(files []gio.Filer, hint string) {
	fmt.Println(len(files))
})
panic: reflect.Value.Convert: value of type unsafe.Pointer cannot be converted to type []gio.Filer [recovered]
	panic: closure error: unexpected panic caught: reflect.Value.Convert: value of type unsafe.Pointer cannot be converted to type []gio.Filer

Right, the ConnectX method generation is not perfect. I'll have to figure out proper type conversion generation for the signals. I'll keep this issue open until that's implemented.

pekim commented

#60 (comment)

should be fixed along with #58

No change I'm afraid. The same conversion failure occurs.

Oh yeah, #58 is unimplemented. I'm planning on rebasing some work from the subclassing branch over once it works, but the large changes will take me a while and I currently can't work on large, time-consuming changes.

This issue is a bit more tedious than I anticipated. How exactly should I index a C.gpointer of underlying type *C.GFile? Go complains that unsafe.Slice((*C.GFile)(nil), 0) is not valid because it cannot get the size of a GFile instance, which is kind of weird.

Should I be doing unsafe.Slice((*C.GObject)(nil), 0)?

It turns out (to nobody's surprise) that the parameter's type is actually GFile** despite the GIR data saying otherwise.

@pekim can you try commit c88e9b8? It should now be possible to do

app.ConnectOpen(func(files []gio.Filer, hint string) {
	fmt.Println(len(files))
})
pekim commented

Yes, that works. Thank you very much.