gotk3 / gotk3

Go bindings for GTK3
ISC License
2.11k stars 230 forks source link

[Project question] I need gdk_device_get_history() #626

Open vaaleyard opened 4 years ago

vaaleyard commented 4 years ago

I'm making a simple program to draw on screen, and I need the gdk_device_get_history() function, but it's not implemented yet. And I think it won't be implemented soon (because I'm sure you have other priorities), so maybe I can try to implement it. Since I've never any created bindings for any library, I'm kind of lost. Do you have any suggestion on how can I start?

ryanerwin commented 4 years ago

Since I've never any created bindings for any library, I'm kind of lost. Do you have any suggestion on how can I start?

I'm probably in a similar situation to you, but nobody else has answered you, so I'll try my best.

I would start by going through the exercises on the go blog post about cgo

https://blog.golang.org/cgo

Then I would go through all of the exercises on the cgo documentation

https://golang.org/cmd/cgo/

Implementing gdk_device_get_history() doesn't look like an easy task, because not much of gdkdevice is implemented, and the few `device*` things that are implemented seem to have been deprecated.

I would use ripgrep -p liberally to search gotk3 for snippets that may be similar to the interface your working on, run them, and see what happens.

I would make very liberal use of pp.Println (from "github.com/k0kubun/pp") to dump the input and output from cgo functions until I internalized an understanding of what the data translation "looks like".

I would start with trying to implement gdk_device_get_name() because it's input and output are pretty simple.

If you can get that figured out after going through the examples, then look for slightly more complicated gdk_device_* functions until you work your way up to the gdk_device_get_history() that you are looking for. I would definitely not start with gdk_device_get_history because it has too many parameters - too many basic places to go wrong until your fairly proficient at creating bindings in cgo.