mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 11:47:25 +01:00
Return medium from medium editor
This commit is contained in:
parent
c0de0acca9
commit
545bacabab
3 changed files with 10 additions and 23 deletions
|
|
@ -29,22 +29,7 @@
|
||||||
</child>
|
</child>
|
||||||
<child type="end">
|
<child type="end">
|
||||||
<object class="GtkButton" id="done_button">
|
<object class="GtkButton" id="done_button">
|
||||||
<property name="sensitive">False</property>
|
<property name="icon-name">object-select-symbolic</property>
|
||||||
<child>
|
|
||||||
<object class="GtkStack" id="done_stack">
|
|
||||||
<property name="transition-type">crossfade</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkSpinner" id="spinner">
|
|
||||||
<property name="spinning">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImage" id="done">
|
|
||||||
<property name="icon-name">object-select-symbolic</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<style>
|
<style>
|
||||||
<class name="suggested-action"/>
|
<class name="suggested-action"/>
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,9 @@ impl Screen<Arc<ImportSession>, ()> for ImportScreen {
|
||||||
|
|
||||||
add_button.connect_clicked(clone!(@weak this => move |_| {
|
add_button.connect_clicked(clone!(@weak this => move |_| {
|
||||||
spawn!(@clone this, async move {
|
spawn!(@clone this, async move {
|
||||||
push!(this.handle, MediumEditor, Arc::clone(&this.session)).await;
|
if let Some(medium) = push!(this.handle, MediumEditor, Arc::clone(&this.session)).await {
|
||||||
|
this.select_medium(medium);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
/// A dialog for editing metadata while importing music into the music library.
|
/// A dialog for editing metadata while importing music into the music library.
|
||||||
pub struct MediumEditor {
|
pub struct MediumEditor {
|
||||||
handle: NavigationHandle<()>,
|
handle: NavigationHandle<Medium>,
|
||||||
session: Arc<ImportSession>,
|
session: Arc<ImportSession>,
|
||||||
widget: gtk::Stack,
|
widget: gtk::Stack,
|
||||||
done_button: gtk::Button,
|
done_button: gtk::Button,
|
||||||
|
|
@ -27,9 +27,9 @@ pub struct MediumEditor {
|
||||||
track_sets: RefCell<Vec<TrackSetData>>,
|
track_sets: RefCell<Vec<TrackSetData>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Screen<Arc<ImportSession>, ()> for MediumEditor {
|
impl Screen<Arc<ImportSession>, Medium> for MediumEditor {
|
||||||
/// Create a new medium editor.
|
/// Create a new medium editor.
|
||||||
fn new(session: Arc<ImportSession>, handle: NavigationHandle<()>) -> Rc<Self> {
|
fn new(session: Arc<ImportSession>, handle: NavigationHandle<Medium>) -> Rc<Self> {
|
||||||
// Create UI
|
// Create UI
|
||||||
|
|
||||||
let builder = gtk::Builder::from_resource("/de/johrpan/musicus/ui/medium_editor.ui");
|
let builder = gtk::Builder::from_resource("/de/johrpan/musicus/ui/medium_editor.ui");
|
||||||
|
|
@ -72,7 +72,7 @@ impl Screen<Arc<ImportSession>, ()> 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(_) => this.handle.pop(Some(())),
|
Ok(medium) => this.handle.pop(Some(medium)),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
this.status_page.set_description(Some(&err.to_string()));
|
this.status_page.set_description(Some(&err.to_string()));
|
||||||
this.widget.set_visible_child_name("error");
|
this.widget.set_visible_child_name("error");
|
||||||
|
|
@ -135,7 +135,7 @@ impl Screen<Arc<ImportSession>, ()> for MediumEditor {
|
||||||
|
|
||||||
impl MediumEditor {
|
impl MediumEditor {
|
||||||
/// Save the medium and possibly upload it to the server.
|
/// Save the medium and possibly upload it to the server.
|
||||||
async fn save(&self) -> Result<()> {
|
async fn save(&self) -> Result<Medium> {
|
||||||
let name = self.name_entry.get_text().to_string();
|
let name = self.name_entry.get_text().to_string();
|
||||||
|
|
||||||
// Create a new directory in the music library path for the imported medium.
|
// Create a new directory in the music library path for the imported medium.
|
||||||
|
|
@ -199,7 +199,7 @@ impl MediumEditor {
|
||||||
|
|
||||||
self.handle.backend.library_changed();
|
self.handle.backend.library_changed();
|
||||||
|
|
||||||
Ok(())
|
Ok(medium)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue