mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-27 04:07:25 +01:00
Use async functions for backend
This commit is contained in:
parent
95f939cb07
commit
711b6d97ff
12 changed files with 346 additions and 420 deletions
|
|
@ -9,6 +9,7 @@ pub struct InstrumentEditor<F>
|
|||
where
|
||||
F: Fn(Instrument) -> () + 'static,
|
||||
{
|
||||
backend: Rc<Backend>,
|
||||
window: gtk::Window,
|
||||
callback: F,
|
||||
id: i64,
|
||||
|
|
@ -42,6 +43,7 @@ where
|
|||
};
|
||||
|
||||
let result = Rc::new(InstrumentEditor {
|
||||
backend: backend,
|
||||
window: window,
|
||||
callback: callback,
|
||||
id: id,
|
||||
|
|
@ -58,10 +60,13 @@ where
|
|||
name: result.name_entry.get_text().to_string(),
|
||||
};
|
||||
|
||||
backend.update_instrument(instrument.clone(), clone!(@strong result => move |_| {
|
||||
result.window.close();
|
||||
(result.callback)(instrument.clone());
|
||||
}));
|
||||
let c = glib::MainContext::default();
|
||||
let clone = result.clone();
|
||||
c.spawn_local(async move {
|
||||
clone.backend.update_instrument(instrument.clone()).await.unwrap();
|
||||
clone.window.close();
|
||||
(clone.callback)(instrument.clone());
|
||||
});
|
||||
}));
|
||||
|
||||
result.window.set_transient_for(Some(parent));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue