2020-12-02 15:41:19 +01:00
|
|
|
use super::work_part::WorkPartEditor;
|
|
|
|
|
use super::work_section::WorkSectionEditor;
|
|
|
|
|
use crate::backend::Backend;
|
2020-11-08 20:23:53 +01:00
|
|
|
use crate::database::*;
|
2020-12-02 15:41:19 +01:00
|
|
|
use crate::selectors::{InstrumentSelector, PersonSelector};
|
|
|
|
|
use crate::widgets::{List, Navigator, NavigatorScreen};
|
2020-11-29 00:12:23 +01:00
|
|
|
use anyhow::Result;
|
2020-11-08 20:23:53 +01:00
|
|
|
use gettextrs::gettext;
|
|
|
|
|
use glib::clone;
|
|
|
|
|
use gtk::prelude::*;
|
|
|
|
|
use gtk_macros::get_widget;
|
2021-01-29 15:17:27 +01:00
|
|
|
use libadwaita::prelude::*;
|
2020-11-08 20:23:53 +01:00
|
|
|
use std::cell::RefCell;
|
|
|
|
|
use std::convert::TryInto;
|
|
|
|
|
use std::rc::Rc;
|
|
|
|
|
|
|
|
|
|
/// Either a work part or a work section.
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
|
enum PartOrSection {
|
2020-11-17 15:52:47 +01:00
|
|
|
Part(WorkPart),
|
|
|
|
|
Section(WorkSection),
|
2020-11-08 20:23:53 +01:00
|
|
|
}
|
|
|
|
|
|
2021-01-25 14:00:57 +01:00
|
|
|
impl PartOrSection {
|
|
|
|
|
pub fn get_title(&self) -> String {
|
|
|
|
|
match self {
|
|
|
|
|
PartOrSection::Part(part) => part.title.clone(),
|
|
|
|
|
PartOrSection::Section(section) => section.title.clone(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-08 20:23:53 +01:00
|
|
|
/// A widget for editing and creating works.
|
|
|
|
|
pub struct WorkEditor {
|
2020-12-02 15:41:19 +01:00
|
|
|
widget: gtk::Stack,
|
2020-11-08 20:23:53 +01:00
|
|
|
backend: Rc<Backend>,
|
|
|
|
|
save_button: gtk::Button,
|
|
|
|
|
title_entry: gtk::Entry,
|
2020-11-29 00:12:23 +01:00
|
|
|
info_bar: gtk::InfoBar,
|
2021-01-29 15:17:27 +01:00
|
|
|
composer_row: libadwaita::ActionRow,
|
2020-11-29 00:12:23 +01:00
|
|
|
upload_switch: gtk::Switch,
|
2021-01-25 14:00:57 +01:00
|
|
|
instrument_list: Rc<List>,
|
|
|
|
|
part_list: Rc<List>,
|
2020-11-28 21:45:22 +01:00
|
|
|
id: String,
|
2020-11-08 20:23:53 +01:00
|
|
|
composer: RefCell<Option<Person>>,
|
|
|
|
|
instruments: RefCell<Vec<Instrument>>,
|
|
|
|
|
structure: RefCell<Vec<PartOrSection>>,
|
2020-11-17 15:52:47 +01:00
|
|
|
saved_cb: RefCell<Option<Box<dyn Fn(Work) -> ()>>>,
|
2020-12-02 15:41:19 +01:00
|
|
|
navigator: RefCell<Option<Rc<Navigator>>>,
|
2020-11-08 20:23:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl WorkEditor {
|
2020-12-02 15:41:19 +01:00
|
|
|
/// Create a new work editor widget and optionally initialize it.
|
|
|
|
|
pub fn new(backend: Rc<Backend>, work: Option<Work>) -> Rc<Self> {
|
2020-11-08 20:23:53 +01:00
|
|
|
// Create UI
|
|
|
|
|
|
|
|
|
|
let builder = gtk::Builder::from_resource("/de/johrpan/musicus/ui/work_editor.ui");
|
|
|
|
|
|
2020-11-29 00:12:23 +01:00
|
|
|
get_widget!(builder, gtk::Stack, widget);
|
2020-12-02 15:41:19 +01:00
|
|
|
get_widget!(builder, gtk::Button, back_button);
|
2020-11-08 20:23:53 +01:00
|
|
|
get_widget!(builder, gtk::Button, save_button);
|
2020-11-29 00:12:23 +01:00
|
|
|
get_widget!(builder, gtk::InfoBar, info_bar);
|
2020-11-08 20:23:53 +01:00
|
|
|
get_widget!(builder, gtk::Entry, title_entry);
|
|
|
|
|
get_widget!(builder, gtk::Button, composer_button);
|
2021-01-29 15:17:27 +01:00
|
|
|
get_widget!(builder, libadwaita::ActionRow, composer_row);
|
2020-11-29 00:12:23 +01:00
|
|
|
get_widget!(builder, gtk::Switch, upload_switch);
|
2021-01-25 14:00:57 +01:00
|
|
|
get_widget!(builder, gtk::Frame, instrument_frame);
|
2020-11-08 20:23:53 +01:00
|
|
|
get_widget!(builder, gtk::Button, add_instrument_button);
|
2021-01-25 14:00:57 +01:00
|
|
|
get_widget!(builder, gtk::Frame, structure_frame);
|
2020-11-08 20:23:53 +01:00
|
|
|
get_widget!(builder, gtk::Button, add_part_button);
|
|
|
|
|
get_widget!(builder, gtk::Button, add_section_button);
|
|
|
|
|
|
2021-01-25 14:00:57 +01:00
|
|
|
let instrument_list = List::new();
|
|
|
|
|
instrument_frame.set_child(Some(&instrument_list.widget));
|
2020-11-08 20:23:53 +01:00
|
|
|
|
2021-01-25 14:00:57 +01:00
|
|
|
let part_list = List::new();
|
2021-01-25 16:26:44 +01:00
|
|
|
part_list.set_enable_dnd(true);
|
2021-01-25 14:00:57 +01:00
|
|
|
structure_frame.set_child(Some(&part_list.widget));
|
2020-11-08 20:23:53 +01:00
|
|
|
|
|
|
|
|
let (id, composer, instruments, structure) = match work {
|
|
|
|
|
Some(work) => {
|
|
|
|
|
title_entry.set_text(&work.title);
|
|
|
|
|
|
|
|
|
|
let mut structure = Vec::new();
|
|
|
|
|
|
|
|
|
|
for part in work.parts {
|
|
|
|
|
structure.push(PartOrSection::Part(part));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for section in work.sections {
|
|
|
|
|
structure.insert(
|
|
|
|
|
section.before_index.try_into().unwrap(),
|
|
|
|
|
PartOrSection::Section(section),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(work.id, Some(work.composer), work.instruments, structure)
|
|
|
|
|
}
|
2020-11-28 21:45:22 +01:00
|
|
|
None => (generate_id(), None, Vec::new(), Vec::new()),
|
2020-11-08 20:23:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let this = Rc::new(Self {
|
|
|
|
|
widget,
|
|
|
|
|
backend,
|
|
|
|
|
save_button,
|
|
|
|
|
id,
|
2020-11-29 00:12:23 +01:00
|
|
|
info_bar,
|
2020-11-08 20:23:53 +01:00
|
|
|
title_entry,
|
2021-01-25 14:00:57 +01:00
|
|
|
composer_row,
|
2020-11-29 00:12:23 +01:00
|
|
|
upload_switch,
|
2020-11-08 20:23:53 +01:00
|
|
|
instrument_list,
|
|
|
|
|
part_list,
|
|
|
|
|
composer: RefCell::new(composer),
|
|
|
|
|
instruments: RefCell::new(instruments),
|
|
|
|
|
structure: RefCell::new(structure),
|
|
|
|
|
saved_cb: RefCell::new(None),
|
2020-12-02 15:41:19 +01:00
|
|
|
navigator: RefCell::new(None),
|
2020-11-08 20:23:53 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Connect signals and callbacks
|
|
|
|
|
|
2020-12-02 15:41:19 +01:00
|
|
|
back_button.connect_clicked(clone!(@strong this => move |_| {
|
|
|
|
|
let navigator = this.navigator.borrow().clone();
|
|
|
|
|
if let Some(navigator) = navigator {
|
|
|
|
|
navigator.pop();
|
2020-11-08 20:23:53 +01:00
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
2020-11-29 00:12:23 +01:00
|
|
|
this.save_button
|
|
|
|
|
.connect_clicked(clone!(@strong this => move |_| {
|
|
|
|
|
let context = glib::MainContext::default();
|
|
|
|
|
let clone = this.clone();
|
|
|
|
|
context.spawn_local(async move {
|
|
|
|
|
clone.widget.set_visible_child_name("loading");
|
|
|
|
|
match clone.clone().save().await {
|
|
|
|
|
Ok(_) => {
|
2020-12-02 15:41:19 +01:00
|
|
|
let navigator = clone.navigator.borrow().clone();
|
|
|
|
|
if let Some(navigator) = navigator {
|
|
|
|
|
navigator.pop();
|
|
|
|
|
}
|
2020-11-29 00:12:23 +01:00
|
|
|
}
|
|
|
|
|
Err(_) => {
|
|
|
|
|
clone.info_bar.set_revealed(true);
|
|
|
|
|
clone.widget.set_visible_child_name("content");
|
|
|
|
|
}
|
2020-11-08 20:23:53 +01:00
|
|
|
}
|
|
|
|
|
|
2020-11-29 00:12:23 +01:00
|
|
|
});
|
|
|
|
|
}));
|
2020-11-08 20:23:53 +01:00
|
|
|
|
|
|
|
|
composer_button.connect_clicked(clone!(@strong this => move |_| {
|
2020-12-02 15:41:19 +01:00
|
|
|
let navigator = this.navigator.borrow().clone();
|
|
|
|
|
if let Some(navigator) = navigator {
|
|
|
|
|
let selector = PersonSelector::new(this.backend.clone());
|
2020-11-22 11:17:27 +01:00
|
|
|
|
2020-12-02 15:41:19 +01:00
|
|
|
selector.set_selected_cb(clone!(@strong this, @strong navigator => move |person| {
|
|
|
|
|
this.show_composer(person);
|
|
|
|
|
this.composer.replace(Some(person.clone()));
|
|
|
|
|
navigator.clone().pop();
|
|
|
|
|
}));
|
2020-11-22 11:17:27 +01:00
|
|
|
|
2020-12-02 15:41:19 +01:00
|
|
|
navigator.push(selector);
|
|
|
|
|
}
|
2020-11-08 20:23:53 +01:00
|
|
|
}));
|
|
|
|
|
|
2021-01-25 14:00:57 +01:00
|
|
|
this.instrument_list.set_make_widget_cb(clone!(@strong this => move |index| {
|
|
|
|
|
let instrument = &this.instruments.borrow()[index];
|
|
|
|
|
|
|
|
|
|
let delete_button = gtk::Button::from_icon_name(Some("user-trash-symbolic"));
|
|
|
|
|
delete_button.set_valign(gtk::Align::Center);
|
|
|
|
|
|
|
|
|
|
delete_button.connect_clicked(clone!(@strong this => move |_| {
|
|
|
|
|
let length = {
|
|
|
|
|
let mut instruments = this.instruments.borrow_mut();
|
|
|
|
|
instruments.remove(index);
|
|
|
|
|
instruments.len()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.instrument_list.update(length);
|
|
|
|
|
}));
|
|
|
|
|
|
2021-01-29 15:17:27 +01:00
|
|
|
let row = libadwaita::ActionRow::new();
|
2021-01-25 14:00:57 +01:00
|
|
|
row.set_title(Some(&instrument.name));
|
|
|
|
|
row.add_suffix(&delete_button);
|
|
|
|
|
|
|
|
|
|
row.upcast()
|
|
|
|
|
}));
|
2020-11-08 20:23:53 +01:00
|
|
|
|
|
|
|
|
add_instrument_button.connect_clicked(clone!(@strong this => move |_| {
|
2020-12-02 15:41:19 +01:00
|
|
|
let navigator = this.navigator.borrow().clone();
|
|
|
|
|
if let Some(navigator) = navigator {
|
|
|
|
|
let selector = InstrumentSelector::new(this.backend.clone());
|
2020-11-28 23:07:31 +01:00
|
|
|
|
2020-12-02 15:41:19 +01:00
|
|
|
selector.set_selected_cb(clone!(@strong this, @strong navigator => move |instrument| {
|
2021-01-25 14:00:57 +01:00
|
|
|
let length = {
|
|
|
|
|
let mut instruments = this.instruments.borrow_mut();
|
|
|
|
|
instruments.push(instrument.clone());
|
|
|
|
|
instruments.len()
|
2020-12-02 15:41:19 +01:00
|
|
|
};
|
2020-11-08 20:23:53 +01:00
|
|
|
|
2021-01-25 14:00:57 +01:00
|
|
|
this.instrument_list.update(length);
|
2020-12-02 15:41:19 +01:00
|
|
|
navigator.clone().pop();
|
|
|
|
|
}));
|
2020-11-28 23:07:31 +01:00
|
|
|
|
2020-12-02 15:41:19 +01:00
|
|
|
navigator.push(selector);
|
|
|
|
|
}
|
2020-11-08 20:23:53 +01:00
|
|
|
}));
|
|
|
|
|
|
2021-01-25 14:00:57 +01:00
|
|
|
this.part_list.set_make_widget_cb(clone!(@strong this => move |index| {
|
|
|
|
|
let pos = &this.structure.borrow()[index];
|
2020-11-08 20:23:53 +01:00
|
|
|
|
2021-01-25 14:00:57 +01:00
|
|
|
let delete_button = gtk::Button::from_icon_name(Some("user-trash-symbolic"));
|
|
|
|
|
delete_button.set_valign(gtk::Align::Center);
|
2020-11-08 20:23:53 +01:00
|
|
|
|
2021-01-25 14:00:57 +01:00
|
|
|
delete_button.connect_clicked(clone!(@strong this => move |_| {
|
2021-01-25 16:26:44 +01:00
|
|
|
let length = {
|
|
|
|
|
let mut structure = this.structure.borrow_mut();
|
|
|
|
|
structure.remove(index);
|
|
|
|
|
structure.len()
|
|
|
|
|
};
|
2020-11-08 20:23:53 +01:00
|
|
|
|
2021-01-25 16:26:44 +01:00
|
|
|
this.part_list.update(length);
|
2021-01-25 14:00:57 +01:00
|
|
|
}));
|
2020-11-08 20:23:53 +01:00
|
|
|
|
2021-01-25 14:00:57 +01:00
|
|
|
let edit_button = gtk::Button::from_icon_name(Some("document-edit-symbolic"));
|
|
|
|
|
edit_button.set_valign(gtk::Align::Center);
|
2020-11-08 20:23:53 +01:00
|
|
|
|
2021-01-25 14:00:57 +01:00
|
|
|
edit_button.connect_clicked(clone!(@strong this => move |_| {
|
|
|
|
|
let navigator = this.navigator.borrow().clone();
|
|
|
|
|
if let Some(navigator) = navigator {
|
2020-12-02 15:41:19 +01:00
|
|
|
match this.structure.borrow()[index].clone() {
|
|
|
|
|
PartOrSection::Part(part) => {
|
|
|
|
|
let editor = WorkPartEditor::new(this.backend.clone(), Some(part));
|
|
|
|
|
|
|
|
|
|
editor.set_ready_cb(clone!(@strong this, @strong navigator => move |part| {
|
2021-01-25 14:00:57 +01:00
|
|
|
let length = {
|
|
|
|
|
let mut structure = this.structure.borrow_mut();
|
|
|
|
|
structure[index] = PartOrSection::Part(part);
|
|
|
|
|
structure.len()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.part_list.update(length);
|
2020-12-02 15:41:19 +01:00
|
|
|
navigator.clone().pop();
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
navigator.push(editor);
|
|
|
|
|
}
|
|
|
|
|
PartOrSection::Section(section) => {
|
|
|
|
|
let editor = WorkSectionEditor::new(Some(section));
|
|
|
|
|
|
|
|
|
|
editor.set_ready_cb(clone!(@strong this, @strong navigator => move |section| {
|
2021-01-25 14:00:57 +01:00
|
|
|
let length = {
|
|
|
|
|
let mut structure = this.structure.borrow_mut();
|
|
|
|
|
structure[index] = PartOrSection::Section(section);
|
|
|
|
|
structure.len()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.part_list.update(length);
|
2020-12-02 15:41:19 +01:00
|
|
|
navigator.clone().pop();
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
navigator.push(editor);
|
|
|
|
|
}
|
2020-11-08 20:23:53 +01:00
|
|
|
}
|
|
|
|
|
}
|
2021-01-25 14:00:57 +01:00
|
|
|
}));
|
2020-11-08 20:23:53 +01:00
|
|
|
|
2021-01-29 15:17:27 +01:00
|
|
|
let row = libadwaita::ActionRow::new();
|
2021-01-25 14:00:57 +01:00
|
|
|
row.set_activatable(true);
|
|
|
|
|
row.set_title(Some(&pos.get_title()));
|
|
|
|
|
row.add_suffix(&delete_button);
|
|
|
|
|
row.add_suffix(&edit_button);
|
|
|
|
|
row.set_activatable_widget(Some(&edit_button));
|
|
|
|
|
|
|
|
|
|
if let PartOrSection::Part(_) = pos {
|
|
|
|
|
// TODO: Replace with better solution to differentiate parts and sections.
|
|
|
|
|
row.set_margin_start(12);
|
2020-11-08 20:23:53 +01:00
|
|
|
}
|
2021-01-25 14:00:57 +01:00
|
|
|
|
|
|
|
|
row.upcast()
|
2020-11-08 20:23:53 +01:00
|
|
|
}));
|
|
|
|
|
|
2021-01-25 16:26:44 +01:00
|
|
|
this.part_list.set_move_cb(clone!(@strong this => move |old_index, new_index| {
|
|
|
|
|
let length = {
|
|
|
|
|
let mut structure = this.structure.borrow_mut();
|
|
|
|
|
structure.swap(old_index, new_index);
|
|
|
|
|
structure.len()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.part_list.update(length);
|
|
|
|
|
}));
|
|
|
|
|
|
2021-01-25 14:00:57 +01:00
|
|
|
add_part_button.connect_clicked(clone!(@strong this => move |_| {
|
|
|
|
|
let navigator = this.navigator.borrow().clone();
|
|
|
|
|
if let Some(navigator) = navigator {
|
|
|
|
|
let editor = WorkPartEditor::new(this.backend.clone(), None);
|
|
|
|
|
|
|
|
|
|
editor.set_ready_cb(clone!(@strong this, @strong navigator => move |part| {
|
|
|
|
|
let length = {
|
|
|
|
|
let mut structure = this.structure.borrow_mut();
|
|
|
|
|
structure.push(PartOrSection::Part(part));
|
|
|
|
|
structure.len()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.part_list.update(length);
|
|
|
|
|
navigator.clone().pop();
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
navigator.push(editor);
|
2020-11-08 20:23:53 +01:00
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
2021-01-25 14:00:57 +01:00
|
|
|
add_section_button.connect_clicked(clone!(@strong this => move |_| {
|
|
|
|
|
let navigator = this.navigator.borrow().clone();
|
|
|
|
|
if let Some(navigator) = navigator {
|
|
|
|
|
let editor = WorkSectionEditor::new(None);
|
|
|
|
|
|
|
|
|
|
editor.set_ready_cb(clone!(@strong this, @strong navigator => move |section| {
|
|
|
|
|
let length = {
|
|
|
|
|
let mut structure = this.structure.borrow_mut();
|
|
|
|
|
structure.push(PartOrSection::Section(section));
|
|
|
|
|
structure.len()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.part_list.update(length);
|
|
|
|
|
navigator.clone().pop();
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
navigator.push(editor);
|
2020-11-08 20:23:53 +01:00
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
// Initialization
|
|
|
|
|
|
|
|
|
|
if let Some(composer) = &*this.composer.borrow() {
|
|
|
|
|
this.show_composer(composer);
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-25 14:00:57 +01:00
|
|
|
this.instrument_list.update(this.instruments.borrow().len());
|
|
|
|
|
this.part_list.update(this.structure.borrow().len());
|
2020-11-08 20:23:53 +01:00
|
|
|
|
|
|
|
|
this
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// The closure to call when a work was created.
|
2020-11-17 15:52:47 +01:00
|
|
|
pub fn set_saved_cb<F: Fn(Work) -> () + 'static>(&self, cb: F) {
|
2020-11-08 20:23:53 +01:00
|
|
|
self.saved_cb.replace(Some(Box::new(cb)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Update the UI according to person.
|
|
|
|
|
fn show_composer(&self, person: &Person) {
|
2021-01-25 14:00:57 +01:00
|
|
|
self.composer_row.set_title(Some(&gettext("Composer")));
|
|
|
|
|
self.composer_row.set_subtitle(Some(&person.name_fl()));
|
2020-11-08 20:23:53 +01:00
|
|
|
self.save_button.set_sensitive(true);
|
|
|
|
|
}
|
2020-11-29 00:12:23 +01:00
|
|
|
|
|
|
|
|
/// Save the work and possibly upload it to the server.
|
|
|
|
|
async fn save(self: Rc<Self>) -> Result<()> {
|
|
|
|
|
let mut section_count: usize = 0;
|
|
|
|
|
let mut parts = Vec::new();
|
|
|
|
|
let mut sections = Vec::new();
|
|
|
|
|
|
|
|
|
|
for (index, pos) in self.structure.borrow().iter().enumerate() {
|
|
|
|
|
match pos {
|
|
|
|
|
PartOrSection::Part(part) => parts.push(part.clone()),
|
|
|
|
|
PartOrSection::Section(section) => {
|
|
|
|
|
let mut section = section.clone();
|
|
|
|
|
section.before_index = index - section_count;
|
|
|
|
|
sections.push(section);
|
|
|
|
|
section_count += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let work = Work {
|
|
|
|
|
id: self.id.clone(),
|
2021-01-25 14:00:57 +01:00
|
|
|
title: self.title_entry.get_text().unwrap().to_string(),
|
2020-11-29 00:12:23 +01:00
|
|
|
composer: self
|
|
|
|
|
.composer
|
|
|
|
|
.borrow()
|
|
|
|
|
.clone()
|
|
|
|
|
.expect("Tried to create work without composer!"),
|
|
|
|
|
instruments: self.instruments.borrow().clone(),
|
|
|
|
|
parts: parts,
|
|
|
|
|
sections: sections,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let upload = self.upload_switch.get_active();
|
|
|
|
|
if upload {
|
|
|
|
|
self.backend.post_work(&work).await?;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.backend
|
|
|
|
|
.db()
|
|
|
|
|
.update_work(work.clone().into())
|
|
|
|
|
.await
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
self.backend.library_changed();
|
|
|
|
|
|
|
|
|
|
if let Some(cb) = &*self.saved_cb.borrow() {
|
|
|
|
|
cb(work.clone());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
2020-11-08 20:23:53 +01:00
|
|
|
}
|
2020-12-02 15:41:19 +01:00
|
|
|
|
|
|
|
|
impl NavigatorScreen for WorkEditor {
|
|
|
|
|
fn attach_navigator(&self, navigator: Rc<Navigator>) {
|
|
|
|
|
self.navigator.replace(Some(navigator));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn get_widget(&self) -> gtk::Widget {
|
|
|
|
|
self.widget.clone().upcast()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn detach_navigator(&self) {
|
|
|
|
|
self.navigator.replace(None);
|
|
|
|
|
}
|
|
|
|
|
}
|