mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
Don't allow empty mediums
This commit is contained in:
parent
4a0251bcf4
commit
b45d1704c9
1 changed files with 44 additions and 35 deletions
|
|
@ -28,7 +28,10 @@ pub struct MediumEditor {
|
|||
|
||||
impl Screen<(Arc<ImportSession>, Option<Medium>), Medium> for MediumEditor {
|
||||
/// Create a new medium editor.
|
||||
fn new((session, medium): (Arc<ImportSession>, Option<Medium>), handle: NavigationHandle<Medium>) -> Rc<Self> {
|
||||
fn new(
|
||||
(session, medium): (Arc<ImportSession>, Option<Medium>),
|
||||
handle: NavigationHandle<Medium>,
|
||||
) -> Rc<Self> {
|
||||
// Create UI
|
||||
|
||||
let builder = gtk::Builder::from_resource("/de/johrpan/musicus/ui/medium_editor.ui");
|
||||
|
|
@ -65,7 +68,8 @@ impl Screen<(Arc<ImportSession>, Option<Medium>), Medium> for MediumEditor {
|
|||
this.handle.pop(None);
|
||||
}));
|
||||
|
||||
this.done_button.connect_clicked(clone!(@weak this => move |_| {
|
||||
this.done_button
|
||||
.connect_clicked(clone!(@weak this => move |_| {
|
||||
this.widget.set_visible_child_name("loading");
|
||||
spawn!(@clone this, async move {
|
||||
match this.save().await {
|
||||
|
|
@ -78,7 +82,8 @@ impl Screen<(Arc<ImportSession>, Option<Medium>), Medium> for MediumEditor {
|
|||
});
|
||||
}));
|
||||
|
||||
this.name_entry.connect_changed(clone!(@weak this => move |_| this.validate()));
|
||||
this.name_entry
|
||||
.connect_changed(clone!(@weak this => move |_| this.validate()));
|
||||
|
||||
add_button.connect_clicked(clone!(@weak this => move |_| {
|
||||
spawn!(@clone this, async move {
|
||||
|
|
@ -90,11 +95,13 @@ impl Screen<(Arc<ImportSession>, Option<Medium>), Medium> for MediumEditor {
|
|||
};
|
||||
|
||||
this.track_set_list.update(length);
|
||||
this.validate();
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
this.track_set_list.set_make_widget_cb(clone!(@weak this => move |index| {
|
||||
this.track_set_list
|
||||
.set_make_widget_cb(clone!(@weak this => move |index| {
|
||||
let track_set = &this.track_sets.borrow()[index];
|
||||
|
||||
let title = track_set.recording.work.get_title();
|
||||
|
|
@ -168,7 +175,9 @@ impl Screen<(Arc<ImportSession>, Option<Medium>), Medium> for MediumEditor {
|
|||
impl MediumEditor {
|
||||
/// Validate inputs and enable/disable saving.
|
||||
fn validate(&self) {
|
||||
self.done_button.set_sensitive(!self.name_entry.get_text().is_empty());
|
||||
self.done_button.set_sensitive(
|
||||
!self.name_entry.get_text().is_empty() && !self.track_sets.borrow().is_empty(),
|
||||
);
|
||||
}
|
||||
|
||||
/// Create the medium and, if necessary, upload it to the server.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue