gotk4 icon indicating copy to clipboard operation
gotk4 copied to clipboard

Missing bindings: Cannot read selected item of gtk.DropDown as string

Open MJacred opened this issue 2 years ago • 4 comments

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)

MJacred avatar Dec 16 '22 20:12 MJacred

I think SelectedItem() returning *Object or Objector is correct. I'm not sure why there's no gtk.StringObject though?

diamondburned avatar Dec 17 '22 00:12 diamondburned

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.

diamondburned avatar Dec 17 '22 00:12 diamondburned

I think SelectedItem() returning *Object or Objector is correct. I'm not sure why there's no gtk.StringObject though?

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

MJacred avatar Dec 17 '22 12:12 MJacred

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…

MJacred avatar Dec 17 '22 13:12 MJacred