Created
August 5, 2023 13:23
-
-
Save saivert/a6d6fa938819063b33a4660c7f1e6d72 to your computer and use it in GitHub Desktop.
Liststore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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