Save recording from editor

This commit is contained in:
Elias Projahn 2020-10-09 23:27:01 +02:00
parent bd3a61c4bf
commit 5a95db69fe
3 changed files with 41 additions and 1 deletions

View file

@ -16,6 +16,7 @@ enum BackendAction {
GetEnsemble(i64, Sender<Option<Ensemble>>),
DeleteEnsemble(i64, Sender<Result<(), String>>),
GetEnsembles(Sender<Vec<Ensemble>>),
UpdateRecording(RecordingInsertion, Sender<Result<(), String>>),
}
use BackendAction::*;
@ -119,6 +120,12 @@ impl Backend {
.send(ensembles)
.expect("Failed to send result from database thread!");
}
UpdateRecording(recording, sender) => {
db.update_recording(recording);
sender
.send(Ok(()))
.expect("Failed to send result from database thread!");
}
}
}
});
@ -346,4 +353,22 @@ impl Backend {
.send(GetEnsembles(sender))
.expect("Failed to send action to database thread!");
}
pub fn update_recording<F: Fn(Result<(), String>) -> () + 'static>(
&self,
recording: RecordingInsertion,
callback: F,
) {
let (sender, receiver) =
glib::MainContext::channel::<Result<(), String>>(glib::PRIORITY_DEFAULT);
receiver.attach(None, move |result| {
callback(result);
glib::Continue(true)
});
self.action_sender
.send(UpdateRecording(recording, sender))
.expect("Failed to send action to database thread!");
}
}