diff options
Diffstat (limited to 'src/gui/load.rs')
| -rw-r--r-- | src/gui/load.rs | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/gui/load.rs b/src/gui/load.rs index e075d0f..618f9dd 100644 --- a/src/gui/load.rs +++ b/src/gui/load.rs @@ -2,6 +2,7 @@ use gtk::glib; use gtk::prelude::*; use super::state::{View, ViewManager}; use std::rc::Rc; +use std::thread; use crate::index::Index; @@ -40,13 +41,30 @@ impl View for Load { splash.set_position(gtk::WindowPosition::Center); splash.set_resizable(false); splash.set_size_request(300, 200); - splash.add(>k::Label::new(Some("Loading"))); + + let container = gtk::Box::new(gtk::Orientation::Vertical, 0); + let spinner = gtk::Spinner::builder().active(true).build(); + + container.pack_start(>k::Label::new(Some("Loading")), false, false, 50); + container.pack_start(&spinner, false, true, 0); + + splash.add(&container); splash.show_all(); + + let (tx, rx) = glib::MainContext::channel(glib::Priority::default()); let path = uri.trim_start_matches("file://").to_string(); - let index = Index::from_file(&path); - vm.set_index(index); - vm.set_current_view("search"); - splash.close(); + + thread::spawn(move || { + let index = Index::from_file(&path); + tx.send(index).ok(); + }); + + rx.attach(None, move |index| { + vm.set_index(index); + vm.set_current_view("search"); + splash.close(); + glib::Continue(false) + }); } else { vm.set_current_view("welcome"); } |