diff --git a/examples/launcher/main.rs b/examples/launcher/main.rs index cf0db87c..0c79bc91 100644 --- a/examples/launcher/main.rs +++ b/examples/launcher/main.rs @@ -69,7 +69,7 @@ fn main() { search.set_placeholder_text(Some(" Type to search apps, or type '?' for more options.")); vbox.append(&search); - let listbox = gtk::ListBox::new(); + let mut listbox = gtk::ListBox::new(); vbox.append(&listbox); { @@ -110,10 +110,11 @@ fn main() { while let Some(event) = rx.recv().await { match event { Event::Search(search) => { - //TODO: is this the best way to clear a listbox? - while let Some(child) = listbox.last_child() { - listbox.remove(&child); + if let Some(child) = vbox.last_child() { + vbox.remove(&child); } + listbox = gtk::ListBox::new(); + vbox.append(&listbox); let _ = launcher.send(pop_launcher::Request::Search(search)).await; }