Show persons and ensembles in main window

This commit is contained in:
Elias Projahn 2020-10-10 12:01:22 +02:00
parent 9101fb053d
commit cca722dcba
4 changed files with 157 additions and 27 deletions

View file

@ -18,6 +18,7 @@ enum BackendAction {
GetEnsembles(Sender<Vec<Ensemble>>),
UpdateRecording(RecordingInsertion, Sender<Result<(), String>>),
GetRecordingsForPerson(i64, Sender<Vec<RecordingDescription>>),
GetRecordingsForEnsemble(i64, Sender<Vec<RecordingDescription>>),
}
use BackendAction::*;
@ -133,6 +134,12 @@ impl Backend {
.send(recordings)
.expect("Failed to send result from database thread!");
}
GetRecordingsForEnsemble(id, sender) => {
let recordings = db.get_recordings_for_ensemble(id);
sender
.send(recordings)
.expect("Failed to send result from database thread!");
}
}
}
});
@ -396,4 +403,22 @@ impl Backend {
.send(GetRecordingsForPerson(id, sender))
.expect("Failed to send action to database thread!");
}
pub fn get_recordings_for_ensemble<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(GetRecordingsForEnsemble(id, sender))
.expect("Failed to send action to database thread!");
}
}