bodil / vgtk

A declarative desktop UI framework for Rust built on GTK and Gtk-rs
http://bodil.lol/vgtk/
Other
1.05k stars 37 forks source link

How to add Items to ComboBoxText #49

Open Stefan99353 opened 4 years ago

Stefan99353 commented 4 years ago

I trying to make a ComboBox displaying some strings, but I can't figure out how I can add Items to the Combobox.

pepijndevos commented 3 years ago

I imagine that <ComboBox model=MyModel /> would work? I think that would map to https://gtk-rs.org/docs/gtk/trait.ComboBoxExt.html#tymethod.set_model

You'd have to pass it a TreeModel: https://gtk-rs.org/docs/gtk/struct.TreeModel.html

If you'd like something where you can say <ComboBoxText items=vec!() I think this requires writing a wrapper in https://github.com/bodil/vgtk/blob/master/vgtk/src/ext/mod.rs that calls the correct methods.