Show recordings in main window

This commit is contained in:
Elias Projahn 2020-10-10 00:22:45 +02:00
parent 5a95db69fe
commit baea690ae6
5 changed files with 84 additions and 2 deletions

View file

@ -17,6 +17,7 @@ enum BackendAction {
DeleteEnsemble(i64, Sender<Result<(), String>>),
GetEnsembles(Sender<Vec<Ensemble>>),
UpdateRecording(RecordingInsertion, Sender<Result<(), String>>),
GetRecordingsForPerson(i64, Sender<Vec<RecordingDescription>>),
}
use BackendAction::*;
@ -126,6 +127,12 @@ impl Backend {
.send(Ok(()))
.expect("Failed to send result from database thread!");
}
GetRecordingsForPerson(id, sender) => {
let recordings = db.get_recordings_for_person(id);
sender
.send(recordings)
.expect("Failed to send result from database thread!");
}
}
}
});
@ -371,4 +378,22 @@ impl Backend {
.send(UpdateRecording(recording, sender))
.expect("Failed to send action to database thread!");
}
pub fn get_recordings_for_person<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(GetRecordingsForPerson(id, sender))
.expect("Failed to send action to database thread!");
}
}