Hi all,
I'm still writing my first GUI with Gtk+3.
I'm stuck trying to insert elements in a ListStore
and view them on the TreeView
.
I created a GUI with Glade. My ListStore
has just one column of gchararray
type.
The problem is that when I try to insert strings in it I get only an empty row in the View.
I think this is the important part of the code:
...
fn main() {
let u = Rc::new(RefCell::new(Universe::new()));
if gtk::init().is_err(){
panic!("Fatal error! Unable to initialize Graphic Interface")
}
let builder = Builder::new();
builder.add_from_string(GLADE_SRC).unwrap();
...
let lights_list: ListStore = builder.get_object("light_list").unwrap();
/* Add light dialog */
let tmp_button: ToolButton = builder.get_object("add_light_btn").unwrap();
tmp_button.connect_clicked(clone!(
u, stat, window, lights_list => move |_| {
add_light(&window, stat.clone(), u.clone(), lights_list.clone());
}
));
...
gtk::main();
}
fn add_light(main_window: &ApplicationWindow, status_bar: Statusbar, universe: Rc<RefCell<Universe>>, list: ListStore){
...
let name: Entry = builder.get_object("light_name").unwrap();
let ok_bttn: Button = builder.get_object("add_light_ok").unwrap();
ok_bttn.connect_clicked(clone!(
add_dialog, name, builder, list => move |_| {
...
let name = Rc::new(...)
...
ok_button.connect_clicked(clone!(
add_dialog, status_bar, universe, name, builder, list => move |_| {
...
//let iter = list.append();
//let v = Value::from(universe.borrow().get_name(l));
//println!("{:?}", v);
//list.set_value(&iter, 0, &v);
let u = universe.borrow();
let name = u.get_name(l).unwrap();
println!("{}", name);
list.insert_with_values(None,
&[0],
&[&name]);
add_dialog.destroy();
}
...
add_dialog.run();
}
Anyway you can find the full source at main.rs\src - lcs.git -
Can someone help me to understand what am I doing wrong? Thank you!