diff --git a/res/resources.xml b/res/resources.xml
index 9abcb6c..369155e 100644
--- a/res/resources.xml
+++ b/res/resources.xml
@@ -6,6 +6,7 @@
ui/instrument_editor.ui
ui/instrument_selector.ui
ui/part_editor.ui
+ ui/performance_editor.ui
ui/person_editor.ui
ui/person_selector.ui
ui/section_editor.ui
diff --git a/res/ui/performance_editor.ui b/res/ui/performance_editor.ui
new file mode 100644
index 0000000..7f44264
--- /dev/null
+++ b/res/ui/performance_editor.ui
@@ -0,0 +1,168 @@
+
+
+
+
+
+
diff --git a/src/database/database.rs b/src/database/database.rs
index e41e3ce..8ce18e2 100644
--- a/src/database/database.rs
+++ b/src/database/database.rs
@@ -291,7 +291,6 @@ impl Database {
.expect("Failed to load performances!")
.iter()
.map(|performance| PerformanceDescription {
- performance: performance.clone(),
person: performance.person.map(|id| {
self.get_person(id)
.expect("Could not find person for performance!")
diff --git a/src/database/models.rs b/src/database/models.rs
index ef391b8..e36f27c 100644
--- a/src/database/models.rs
+++ b/src/database/models.rs
@@ -86,19 +86,44 @@ impl From for WorkInsertion {
#[derive(Debug, Clone)]
pub struct PerformanceDescription {
- pub performance: Performance,
pub person: Option,
pub ensemble: Option,
pub role: Option,
}
impl PerformanceDescription {
+ pub fn get_title(&self) -> String {
+ let mut text = String::from(if self.is_person() {
+ self.unwrap_person().name_fl()
+ } else {
+ self.unwrap_ensemble().name
+ });
+
+ if self.has_role() {
+ text = text + " (" + &self.unwrap_role().name + ")";
+ }
+
+ text
+ }
+
pub fn is_person(&self) -> bool {
self.person.is_some()
}
+ pub fn unwrap_person(&self) -> Person {
+ self.person.clone().unwrap()
+ }
+
+ pub fn unwrap_ensemble(&self) -> Ensemble {
+ self.ensemble.clone().unwrap()
+ }
+
pub fn has_role(&self) -> bool {
- self.role.is_some()
+ self.role.clone().is_some()
+ }
+
+ pub fn unwrap_role(&self) -> Instrument {
+ self.role.clone().unwrap()
}
}
diff --git a/src/dialogs/mod.rs b/src/dialogs/mod.rs
index 95eb816..8aa65b5 100644
--- a/src/dialogs/mod.rs
+++ b/src/dialogs/mod.rs
@@ -13,6 +13,9 @@ pub use instrument_selector::*;
pub mod part_editor;
pub use part_editor::*;
+pub mod performance_editor;
+pub use performance_editor::*;
+
pub mod person_editor;
pub use person_editor::*;
diff --git a/src/dialogs/performance_editor.rs b/src/dialogs/performance_editor.rs
new file mode 100644
index 0000000..f4333eb
--- /dev/null
+++ b/src/dialogs/performance_editor.rs
@@ -0,0 +1,146 @@
+use super::*;
+use crate::backend::Backend;
+use crate::database::*;
+use glib::clone;
+use gtk::prelude::*;
+use gtk_macros::get_widget;
+use std::cell::RefCell;
+use std::rc::Rc;
+
+pub struct PerformanceEditor
+where
+ F: Fn(PerformanceDescription) -> () + 'static,
+{
+ backend: Rc,
+ window: gtk::Window,
+ callback: F,
+ save_button: gtk::Button,
+ person_label: gtk::Label,
+ ensemble_label: gtk::Label,
+ role_label: gtk::Label,
+ person: RefCell