Better way to clear GtkListBox
This commit is contained in:
parent
38bca9d5ad
commit
0d0f7cb82e
1 changed files with 5 additions and 5 deletions
|
|
@ -21,7 +21,6 @@ fn icon_source(icon: >k::Image, source: &Option<pop_launcher::IconSource>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum Event {
|
enum Event {
|
||||||
Response(pop_launcher::Response),
|
Response(pop_launcher::Response),
|
||||||
Search(String),
|
Search(String),
|
||||||
|
|
@ -70,7 +69,7 @@ fn main() {
|
||||||
search.set_placeholder_text(Some(" Type to search apps, or type '?' for more options."));
|
search.set_placeholder_text(Some(" Type to search apps, or type '?' for more options."));
|
||||||
vbox.append(&search);
|
vbox.append(&search);
|
||||||
|
|
||||||
let listbox = gtk::ListBox::new();
|
let mut listbox = gtk::ListBox::new();
|
||||||
vbox.append(&listbox);
|
vbox.append(&listbox);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -109,10 +108,11 @@ fn main() {
|
||||||
while let Some(event) = rx.recv().await {
|
while let Some(event) = rx.recv().await {
|
||||||
match event {
|
match event {
|
||||||
Event::Search(search) => {
|
Event::Search(search) => {
|
||||||
//TODO: is this the best way to clear a listbox?
|
if let Some(child) = vbox.last_child() {
|
||||||
while let Some(child) = listbox.last_child() {
|
vbox.remove(&child);
|
||||||
listbox.remove(&child);
|
|
||||||
}
|
}
|
||||||
|
listbox = gtk::ListBox::new();
|
||||||
|
vbox.append(&listbox);
|
||||||
|
|
||||||
let _ = launcher.send(pop_launcher::Request::Search(search)).await;
|
let _ = launcher.send(pop_launcher::Request::Search(search)).await;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue