mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 11:47:25 +01:00
Show errors in medium editor
This commit is contained in:
parent
3e130985c4
commit
3e22e67efd
2 changed files with 94 additions and 6 deletions
|
|
@ -165,5 +165,77 @@
|
||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkStackPage">
|
||||||
|
<property name="name">error</property>
|
||||||
|
<property name="child">
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="AdwHeaderBar">
|
||||||
|
<property name="show-start-title-buttons">false</property>
|
||||||
|
<property name="show-end-title-buttons">false</property>
|
||||||
|
<property name="title-widget">
|
||||||
|
<object class="AdwWindowTitle">
|
||||||
|
<property name="title" translatable="yes">Error</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="AdwStatusPage" id="status_page">
|
||||||
|
<property name="icon-name">dialog-error-symbolic</property>
|
||||||
|
<property name="title">Error</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="try_again_button">
|
||||||
|
<property name="label" translatable="yes">Try again</property>
|
||||||
|
<property name="hexpand">true</property>
|
||||||
|
<property name="vexpand">true</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkStackPage">
|
||||||
|
<property name="name">disc_error</property>
|
||||||
|
<property name="child">
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="AdwHeaderBar">
|
||||||
|
<property name="show-start-title-buttons">false</property>
|
||||||
|
<property name="show-end-title-buttons">false</property>
|
||||||
|
<property name="title-widget">
|
||||||
|
<object class="AdwWindowTitle">
|
||||||
|
<property name="title" translatable="yes">Error</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="AdwStatusPage" id="disc_status_page">
|
||||||
|
<property name="icon-name">action-unavailable-symbolic</property>
|
||||||
|
<property name="title">Error</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="cancel_button">
|
||||||
|
<property name="label" translatable="yes">Cancel</property>
|
||||||
|
<property name="hexpand">true</property>
|
||||||
|
<property name="vexpand">true</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ pub struct MediumEditor {
|
||||||
done: gtk::Image,
|
done: gtk::Image,
|
||||||
name_entry: gtk::Entry,
|
name_entry: gtk::Entry,
|
||||||
publish_switch: gtk::Switch,
|
publish_switch: gtk::Switch,
|
||||||
|
status_page: libadwaita::StatusPage,
|
||||||
|
disc_status_page: libadwaita::StatusPage,
|
||||||
track_set_list: Rc<List>,
|
track_set_list: Rc<List>,
|
||||||
track_sets: RefCell<Vec<TrackSetData>>,
|
track_sets: RefCell<Vec<TrackSetData>>,
|
||||||
}
|
}
|
||||||
|
|
@ -42,6 +44,10 @@ impl Screen<Rc<Box<dyn Source>>, ()> for MediumEditor {
|
||||||
get_widget!(builder, gtk::Switch, publish_switch);
|
get_widget!(builder, gtk::Switch, publish_switch);
|
||||||
get_widget!(builder, gtk::Button, add_button);
|
get_widget!(builder, gtk::Button, add_button);
|
||||||
get_widget!(builder, gtk::Frame, frame);
|
get_widget!(builder, gtk::Frame, frame);
|
||||||
|
get_widget!(builder, libadwaita::StatusPage, status_page);
|
||||||
|
get_widget!(builder, gtk::Button, try_again_button);
|
||||||
|
get_widget!(builder, libadwaita::StatusPage, disc_status_page);
|
||||||
|
get_widget!(builder, gtk::Button, cancel_button);
|
||||||
|
|
||||||
let list = List::new();
|
let list = List::new();
|
||||||
frame.set_child(Some(&list.widget));
|
frame.set_child(Some(&list.widget));
|
||||||
|
|
@ -55,6 +61,8 @@ impl Screen<Rc<Box<dyn Source>>, ()> for MediumEditor {
|
||||||
done,
|
done,
|
||||||
name_entry,
|
name_entry,
|
||||||
publish_switch,
|
publish_switch,
|
||||||
|
status_page,
|
||||||
|
disc_status_page,
|
||||||
track_set_list: list,
|
track_set_list: list,
|
||||||
track_sets: RefCell::new(Vec::new()),
|
track_sets: RefCell::new(Vec::new()),
|
||||||
});
|
});
|
||||||
|
|
@ -69,10 +77,10 @@ impl Screen<Rc<Box<dyn Source>>, ()> for MediumEditor {
|
||||||
this.widget.set_visible_child_name("loading");
|
this.widget.set_visible_child_name("loading");
|
||||||
spawn!(@clone this, async move {
|
spawn!(@clone this, async move {
|
||||||
match this.save().await {
|
match this.save().await {
|
||||||
Ok(_) => (),
|
Ok(_) => this.handle.pop(Some(())),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// TODO: Display errors.
|
this.status_page.set_description(Some(&err.to_string()));
|
||||||
println!("{:?}", err);
|
this.widget.set_visible_child_name("error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -118,11 +126,19 @@ impl Screen<Rc<Box<dyn Source>>, ()> for MediumEditor {
|
||||||
row.upcast()
|
row.upcast()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
try_again_button.connect_clicked(clone!(@weak this => move |_| {
|
||||||
|
this.widget.set_visible_child_name("content");
|
||||||
|
}));
|
||||||
|
|
||||||
|
cancel_button.connect_clicked(clone!(@weak this => move |_| {
|
||||||
|
this.handle.pop(None);
|
||||||
|
}));
|
||||||
|
|
||||||
spawn!(@clone this, async move {
|
spawn!(@clone this, async move {
|
||||||
match this.source.copy().await {
|
match this.source.copy().await {
|
||||||
Err(error) => {
|
Err(err) => {
|
||||||
// TODO: Present error.
|
this.disc_status_page.set_description(Some(&err.to_string()));
|
||||||
println!("Failed to copy source: {}", error);
|
this.widget.set_visible_child_name("disc_error");
|
||||||
},
|
},
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
this.done_stack.set_visible_child(&this.done);
|
this.done_stack.set_visible_child(&this.done);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue