Add work details screen

This commit is contained in:
Elias Projahn 2020-10-11 18:03:40 +02:00
parent d741f463f5
commit b2ab93cefa
3 changed files with 118 additions and 0 deletions

View file

@ -19,6 +19,7 @@ enum BackendAction {
UpdateRecording(RecordingInsertion, Sender<Result<(), String>>),
GetRecordingsForPerson(i64, Sender<Vec<RecordingDescription>>),
GetRecordingsForEnsemble(i64, Sender<Vec<RecordingDescription>>),
GetRecordingsForWork(i64, Sender<Vec<RecordingDescription>>),
}
use BackendAction::*;
@ -140,6 +141,12 @@ impl Backend {
.send(recordings)
.expect("Failed to send result from database thread!");
}
GetRecordingsForWork(id, sender) => {
let recordings = db.get_recordings_for_work(id);
sender
.send(recordings)
.expect("Failed to send result from database thread!");
}
}
}
});
@ -421,4 +428,22 @@ impl Backend {
.send(GetRecordingsForEnsemble(id, sender))
.expect("Failed to send action to database thread!");
}
pub fn get_recordings_for_work<F: Fn(Vec<RecordingDescription>) -> () + 'static>(
&self,
id: i64,
callback: F,
) {
let (sender, receiver) =
glib::MainContext::channel::<Vec<RecordingDescription>>(glib::PRIORITY_DEFAULT);
receiver.attach(None, move |result| {
callback(result);
glib::Continue(true)
});
self.action_sender
.send(GetRecordingsForWork(id, sender))
.expect("Failed to send action to database thread!");
}
}