gotk4
gotk4 copied to clipboard
Missing bindings: Cannot read selected item of gtk.DropDown as string
used auto-gen bindings: func (self *DropDown) SelectedItem() *coreglib.Object (docs)
what the object should be based on online comments: gtk.StringObject (docs)
- required to transform the object into a string: https://docs.gtk.org/gtk4/method.StringObject.get_string.html
- problem: no bindings for
gtk.StringObject
note: could not find any filter that should exclude it (source)
the only workaround
- store your string values in your code and then find them using
func (self *DropDown) Selected() uint- requires same sorting
proposals
a) add binding for gtk.StringObject
b) do the magic internally and change return type of func (self *DropDown) SelectedItem() *coreglib.Object to the string value (rather dangerous, if item is in any custom case (depending on ListModel type) not a StringObject)
I think SelectedItem() returning *Object or Objector is correct. I'm not sure why there's no gtk.StringObject though?
If you want to try and find out, you can do GIR_VERBOSE=1 go generate |& /tmp/gir.out and grep 'StringObject' /tmp/gir.out.
I think
SelectedItem()returning*ObjectorObjectoris correct. I'm not sure why there's nogtk.StringObjectthough?
Yeah, no issue with return type, because it could be sth. else.
I also noticed that https://docs.gtk.org/gtk4/class.StringList.html has no bindings. Though right now I see no need for it, as the only func I've encountered so far that should take it as input param, will take []string instead in the bindings
If you want to try and find out, you can do GIR_VERBOSE=1 go generate |& /tmp/gir.out and grep 'StringObject' /tmp/gir.out.
My system is not set up for nix/docker, yet. I'll try to find some time next week to check it out and set it up
Ah, I forgot that my system is too old for gtk4. Upgrade is planned for January/early February.
So further investigating is not possible for me right now…