mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
Support metadata updates
This commit is contained in:
parent
cb90f02073
commit
456af4a1df
31 changed files with 2930 additions and 2161 deletions
|
|
@ -21,6 +21,8 @@ mod imp {
|
|||
#[template_child]
|
||||
pub name_editor: TemplateChild<TranslationEditor>,
|
||||
#[template_child]
|
||||
pub enable_updates_row: TemplateChild<adw::SwitchRow>,
|
||||
#[template_child]
|
||||
pub save_row: TemplateChild<adw::ButtonRow>,
|
||||
}
|
||||
|
||||
|
|
@ -81,6 +83,9 @@ impl EnsembleEditor {
|
|||
.set(ensemble.ensemble_id.clone())
|
||||
.unwrap();
|
||||
obj.imp().name_editor.set_translation(&ensemble.name);
|
||||
obj.imp()
|
||||
.enable_updates_row
|
||||
.set_active(ensemble.enable_updates);
|
||||
}
|
||||
|
||||
obj
|
||||
|
|
@ -99,11 +104,14 @@ impl EnsembleEditor {
|
|||
fn save(&self) {
|
||||
let library = self.imp().library.get().unwrap();
|
||||
let name = self.imp().name_editor.translation();
|
||||
let enable_updates = self.imp().enable_updates_row.is_active();
|
||||
|
||||
if let Some(ensemble_id) = self.imp().ensemble_id.get() {
|
||||
library.update_ensemble(ensemble_id, name).unwrap();
|
||||
library
|
||||
.update_ensemble(ensemble_id, name, enable_updates)
|
||||
.unwrap();
|
||||
} else {
|
||||
let ensemble = library.create_ensemble(name).unwrap();
|
||||
let ensemble = library.create_ensemble(name, enable_updates).unwrap();
|
||||
self.emit_by_name::<()>("created", &[&ensemble]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ mod imp {
|
|||
#[template_child]
|
||||
pub name_editor: TemplateChild<TranslationEditor>,
|
||||
#[template_child]
|
||||
pub enable_updates_row: TemplateChild<adw::SwitchRow>,
|
||||
#[template_child]
|
||||
pub save_row: TemplateChild<adw::ButtonRow>,
|
||||
}
|
||||
|
||||
|
|
@ -81,6 +83,9 @@ impl InstrumentEditor {
|
|||
.set(instrument.instrument_id.clone())
|
||||
.unwrap();
|
||||
obj.imp().name_editor.set_translation(&instrument.name);
|
||||
obj.imp()
|
||||
.enable_updates_row
|
||||
.set_active(instrument.enable_updates);
|
||||
}
|
||||
|
||||
obj
|
||||
|
|
@ -102,11 +107,14 @@ impl InstrumentEditor {
|
|||
fn save(&self) {
|
||||
let library = self.imp().library.get().unwrap();
|
||||
let name = self.imp().name_editor.translation();
|
||||
let enable_updates = self.imp().enable_updates_row.is_active();
|
||||
|
||||
if let Some(instrument_id) = self.imp().instrument_id.get() {
|
||||
library.update_instrument(instrument_id, name).unwrap();
|
||||
library
|
||||
.update_instrument(instrument_id, name, enable_updates)
|
||||
.unwrap();
|
||||
} else {
|
||||
let instrument = library.create_instrument(name).unwrap();
|
||||
let instrument = library.create_instrument(name, enable_updates).unwrap();
|
||||
self.emit_by_name::<()>("created", &[&instrument]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ mod imp {
|
|||
#[template_child]
|
||||
pub name_editor: TemplateChild<TranslationEditor>,
|
||||
#[template_child]
|
||||
pub enable_updates_row: TemplateChild<adw::SwitchRow>,
|
||||
#[template_child]
|
||||
pub save_row: TemplateChild<adw::ButtonRow>,
|
||||
}
|
||||
|
||||
|
|
@ -78,6 +80,9 @@ impl PersonEditor {
|
|||
obj.imp().save_row.set_title(&gettext("_Save changes"));
|
||||
obj.imp().person_id.set(person.person_id.clone()).unwrap();
|
||||
obj.imp().name_editor.set_translation(&person.name);
|
||||
obj.imp()
|
||||
.enable_updates_row
|
||||
.set_active(person.enable_updates);
|
||||
}
|
||||
|
||||
obj
|
||||
|
|
@ -96,11 +101,14 @@ impl PersonEditor {
|
|||
fn save(&self) {
|
||||
let library = self.imp().library.get().unwrap();
|
||||
let name = self.imp().name_editor.translation();
|
||||
let enable_updates = self.imp().enable_updates_row.is_active();
|
||||
|
||||
if let Some(person_id) = self.imp().person_id.get() {
|
||||
library.update_person(person_id, name).unwrap();
|
||||
library
|
||||
.update_person(person_id, name, enable_updates)
|
||||
.unwrap();
|
||||
} else {
|
||||
let person = library.create_person(name).unwrap();
|
||||
let person = library.create_person(name, enable_updates).unwrap();
|
||||
self.emit_by_name::<()>("created", &[&person]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ mod imp {
|
|||
#[template_child]
|
||||
pub ensemble_list: TemplateChild<gtk::ListBox>,
|
||||
#[template_child]
|
||||
pub enable_updates_row: TemplateChild<adw::SwitchRow>,
|
||||
#[template_child]
|
||||
pub save_row: TemplateChild<adw::ButtonRow>,
|
||||
}
|
||||
|
||||
|
|
@ -250,6 +252,11 @@ impl RecordingEditor {
|
|||
.composers_string()
|
||||
.unwrap_or_else(|| gettext("No composers")),
|
||||
);
|
||||
|
||||
self.imp()
|
||||
.enable_updates_row
|
||||
.set_active(work.enable_updates);
|
||||
|
||||
self.imp().save_row.set_sensitive(true);
|
||||
self.imp().work.replace(Some(work));
|
||||
}
|
||||
|
|
@ -367,13 +374,22 @@ impl RecordingEditor {
|
|||
.map(|e| e.ensemble())
|
||||
.collect::<Vec<EnsemblePerformer>>();
|
||||
|
||||
let enable_updates = self.imp().enable_updates_row.is_active();
|
||||
|
||||
if let Some(recording_id) = self.imp().recording_id.get() {
|
||||
library
|
||||
.update_recording(recording_id, work, Some(year), performers, ensembles)
|
||||
.update_recording(
|
||||
recording_id,
|
||||
work,
|
||||
Some(year),
|
||||
performers,
|
||||
ensembles,
|
||||
enable_updates,
|
||||
)
|
||||
.unwrap();
|
||||
} else {
|
||||
let recording = library
|
||||
.create_recording(work, Some(year), performers, ensembles)
|
||||
.create_recording(work, Some(year), performers, ensembles, enable_updates)
|
||||
.unwrap();
|
||||
self.emit_by_name::<()>("created", &[&recording]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ mod imp {
|
|||
#[template_child]
|
||||
pub name_editor: TemplateChild<TranslationEditor>,
|
||||
#[template_child]
|
||||
pub enable_updates_row: TemplateChild<adw::SwitchRow>,
|
||||
#[template_child]
|
||||
pub save_row: TemplateChild<adw::ButtonRow>,
|
||||
}
|
||||
|
||||
|
|
@ -73,6 +75,7 @@ impl RoleEditor {
|
|||
obj.imp().save_row.set_title(&gettext("_Save changes"));
|
||||
obj.imp().role_id.set(role.role_id.clone()).unwrap();
|
||||
obj.imp().name_editor.set_translation(&role.name);
|
||||
obj.imp().enable_updates_row.set_active(role.enable_updates);
|
||||
}
|
||||
|
||||
obj
|
||||
|
|
@ -91,11 +94,12 @@ impl RoleEditor {
|
|||
fn save(&self) {
|
||||
let library = self.imp().library.get().unwrap();
|
||||
let name = self.imp().name_editor.translation();
|
||||
let enable_updates = self.imp().enable_updates_row.is_active();
|
||||
|
||||
if let Some(role_id) = self.imp().role_id.get() {
|
||||
library.update_role(role_id, name).unwrap();
|
||||
library.update_role(role_id, name, enable_updates).unwrap();
|
||||
} else {
|
||||
let role = library.create_role(name).unwrap();
|
||||
let role = library.create_role(name, enable_updates).unwrap();
|
||||
self.emit_by_name::<()>("created", &[&role]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ mod imp {
|
|||
#[template_child]
|
||||
pub instrument_list: TemplateChild<gtk::ListBox>,
|
||||
#[template_child]
|
||||
pub enable_updates_row: TemplateChild<adw::SwitchRow>,
|
||||
#[template_child]
|
||||
pub save_row: TemplateChild<adw::ButtonRow>,
|
||||
}
|
||||
|
||||
|
|
@ -193,6 +195,8 @@ impl WorkEditor {
|
|||
for instrument in &work.instruments {
|
||||
obj.add_instrument_row(instrument.clone());
|
||||
}
|
||||
|
||||
obj.imp().enable_updates_row.set_active(work.enable_updates);
|
||||
}
|
||||
|
||||
obj
|
||||
|
|
@ -366,6 +370,8 @@ impl WorkEditor {
|
|||
.map(|r| r.instrument())
|
||||
.collect::<Vec<Instrument>>();
|
||||
|
||||
let enable_updates = self.imp().enable_updates_row.is_active();
|
||||
|
||||
if self.imp().is_part_editor.get() {
|
||||
let work_id = self
|
||||
.imp()
|
||||
|
|
@ -380,17 +386,18 @@ impl WorkEditor {
|
|||
parts,
|
||||
persons: composers,
|
||||
instruments,
|
||||
enable_updates,
|
||||
};
|
||||
|
||||
self.emit_by_name::<()>("created", &[&part]);
|
||||
} else {
|
||||
if let Some(work_id) = self.imp().work_id.get() {
|
||||
library
|
||||
.update_work(work_id, name, parts, composers, instruments)
|
||||
.update_work(work_id, name, parts, composers, instruments, enable_updates)
|
||||
.unwrap();
|
||||
} else {
|
||||
let work = library
|
||||
.create_work(name, parts, composers, instruments)
|
||||
.create_work(name, parts, composers, instruments, enable_updates)
|
||||
.unwrap();
|
||||
self.emit_by_name::<()>("created", &[&work]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue