diamondburned / gotk4

Autogenerated GTK4 bindings for Go
GNU Affero General Public License v3.0
525 stars 20 forks source link

SearchEntry does not appear to implement Editable interface correctly #115

Closed christian-schulze closed 1 year ago

christian-schulze commented 1 year ago
searchBar := gtk.NewSearchBar()
searchBar.SetVAlign(gtk.AlignStart)
searchBar.SetKeyCaptureWidget(window)
box.Append(searchBar)

searchEntry := gtk.NewSearchEntry()
searchEntry.SetHExpand(true)
searchBar.ConnectEntry(searchEntry)
box.Append(searchEntry)

On building I get the following error:

./main.go:41:25: cannot use searchEntry (variable of type gtk.SearchEntry) as gtk.Editabler value in argument to searchBar.ConnectEntry: gtk.SearchEntry does not implement gtk.Editabler (*gtk.SearchEntry.Editable is a field, not a method)

SearchEntry has an Editable field struct which has an Editable function, but that Editable function should exist on SearchEntry instead.

This looks like a name collision issue, Editable struct vs Editable function attached to Editable struct.

I'd love to have a go at fixing this myself but so far have been unable to figure out where to override this. I believe the fix should be to rename the Editable field on SearchEntry to something else.

Is there an example in the generation code where this kind of thing has been done before?

diamondburned commented 1 year ago

Is there an example in the generation code where this kind of thing has been done before?

Yes! gendata.go specifically contains a lot of the code to manually fix quirky errors like these.

Ideally, I would love to have the generator itself figure out rather than manually going through functions over time, but overriding it manually is probably the easiest way to do it.

christian-schulze commented 1 year ago

Yes! gendata.go specifically contains a lot of the code to manually fix quirky errors like these.

Ideally, I would love to have the generator itself figure out rather than manually going through functions over time, but overriding it manually is probably the easiest way to do it.

Thanks for the tip @diamondburned, will give this a shot this evening.

christian-schulze commented 1 year ago

116 addresses this issue