Skip to content

Instantly share code, notes, and snippets.

@saivert
Created August 5, 2023 13:23
Show Gist options
  • Save saivert/a6d6fa938819063b33a4660c7f1e6d72 to your computer and use it in GitHub Desktop.
Save saivert/a6d6fa938819063b33a4660c7f1e6d72 to your computer and use it in GitHub Desktop.
Liststore
let list_store = gio::ListStore::new(glib::Object::static_type());
let obj: glib::Object = glib::Object::new();
unsafe {
// Use set_data so we don't have to implement a subclass with a real property.
obj.set_data::<String>("hoy", "nice".to_string());
}
list_store.append(&obj);
let v: Vec<glib::Object> = list_store.into_iter().map(|x| {x.unwrap().clone()}).collect();
unsafe {
let o = v[0].data::<String>("hoy").expect("hoy").as_ref();
println!("This should say \"nice\" {o}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment