mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
Show recordings in main window
This commit is contained in:
parent
5a95db69fe
commit
baea690ae6
5 changed files with 84 additions and 2 deletions
|
|
@ -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!");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue