Avoid some errors using insensitive buttons

This commit is contained in:
Elias Projahn 2025-03-29 17:53:04 +01:00
parent a371e356f7
commit 43b07c73dc
11 changed files with 88 additions and 49 deletions

View file

@ -72,6 +72,10 @@ template $MusicusAlbumEditor: Adw.NavigationPage {
title: _("_Create album");
use-underline: true;
activated => $save() swapped;
styles [
"suggested-action",
]
}
}
}

View file

@ -42,6 +42,10 @@ template $MusicusEnsembleEditor: Adw.NavigationPage {
title: _("_Create ensemble");
use-underline: true;
activated => $save() swapped;
styles [
"suggested-action",
]
}
}
}

View file

@ -42,6 +42,10 @@ template $MusicusInstrumentEditor: Adw.NavigationPage {
title: _("_Create instrument");
use-underline: true;
activated => $save() swapped;
styles [
"suggested-action",
]
}
}
}

View file

@ -42,6 +42,10 @@ template $MusicusPersonEditor: Adw.NavigationPage {
title: _("_Create person");
use-underline: true;
activated => $save() swapped;
styles [
"suggested-action",
]
}
}
}

View file

@ -264,6 +264,10 @@ template $MusicusProgramEditor: Adw.NavigationPage {
title: _("_Save program");
use-underline: true;
activated => $save() swapped;
styles [
"suggested-action",
]
}
}
}

View file

@ -131,7 +131,12 @@ template $MusicusRecordingEditor: Adw.NavigationPage {
Adw.ButtonRow save_row {
title: _("_Create recording");
use-underline: true;
sensitive: false;
activated => $save() swapped;
styles [
"suggested-action",
]
}
}
}

View file

@ -42,6 +42,10 @@ template $MusicusRoleEditor: Adw.NavigationPage {
title: _("_Create role");
use-underline: true;
activated => $save() swapped;
styles [
"suggested-action",
]
}
}
}

View file

@ -89,7 +89,12 @@ template $MusicusTracksEditor: Adw.NavigationPage {
Adw.ButtonRow save_row {
title: _("_Import tracks");
use-underline: true;
sensitive: false;
activated => $save() swapped;
styles [
"suggested-action",
]
}
}
}

View file

@ -126,6 +126,10 @@ template $MusicusWorkEditor: Adw.NavigationPage {
title: _("_Create work");
use-underline: true;
activated => $save() swapped;
styles [
"suggested-action",
]
}
}
}

View file

@ -250,6 +250,7 @@ impl RecordingEditor {
.composers_string()
.unwrap_or_else(|| gettext("No composers")),
);
self.imp().save_row.set_sensitive(true);
self.imp().work.replace(Some(work));
}
@ -344,10 +345,10 @@ impl RecordingEditor {
#[template_callback]
fn save(&self) {
if let Some(work) = &*self.imp().work.borrow() {
let library = self.imp().library.get().unwrap();
// TODO: No work selected?
let work = self.imp().work.borrow().as_ref().unwrap().clone();
let work = work.to_owned();
let year = self.imp().year_row.value() as i32;
let performers = self
@ -380,3 +381,4 @@ impl RecordingEditor {
self.imp().navigation.get().unwrap().pop();
}
}
}

View file

@ -227,6 +227,7 @@ impl TracksEditor {
self.imp().tracks_label.set_sensitive(true);
self.imp().track_list.set_sensitive(true);
self.imp().save_row.set_sensitive(true);
self.imp().recording.replace(Some(recording));
}
@ -304,6 +305,7 @@ impl TracksEditor {
#[template_callback]
fn save(&self) {
if let Some(recording) = &*self.imp().recording.borrow() {
for track in self.imp().removed_tracks.borrow_mut().drain(..) {
self.library().delete_track(&track).unwrap();
}
@ -320,7 +322,6 @@ impl TracksEditor {
.update_track(&track.track_id, index as i32, track_data.parts)
.unwrap(),
TrackLocation::System(path) => {
if let Some(recording) = &*self.imp().recording.borrow() {
self.library()
.import_track(
&path,
@ -329,9 +330,6 @@ impl TracksEditor {
track_data.parts,
)
.unwrap();
} else {
log::error!("Failed to save track: No recording set.");
}
}
}
@ -341,3 +339,4 @@ impl TracksEditor {
self.navigation().pop();
}
}
}