Clean up by using set_model instead which allows a reference

This commit is contained in:
Vivianne 2023-06-26 19:03:59 -07:00
parent 350640a223
commit bb9d9595eb

View file

@ -88,14 +88,10 @@ impl SimpleComponent for SampleListModel {
item.set_child(Some(&cell))
});
let list_store = gtk::gio::ListStore::new(gtk::glib::types::Type::OBJECT);
let samples = gtk::MultiSelection::new(Some(list_store));
let mut list_store = gtk::gio::ListStore::new(gtk::glib::types::Type::OBJECT);
let samples = gtk::MultiSelection::new(None::<gtk::gio::ListStore>);
samples.set_model(Some(&list_store));
// XXX: ideally I could use the above list_store, but it gets moved...?
let mut list_store = samples
.model()
.and_downcast::<gtk::gio::ListStore>()
.unwrap();
list_store.extend(
list_samples(&mut pool.get().expect("Expected a connection"))
.into_iter()
@ -108,6 +104,7 @@ impl SimpleComponent for SampleListModel {
gtk::gdk::FileList::static_type(),
gtk::gdk::DragAction::COPY,
);
drop_target.connect_drop(move |_, value, _, _| {
for f in value
.get::<gtk::gdk::FileList>()