mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
Add medium editor skeleton
This commit is contained in:
parent
18600c310f
commit
585bc74df0
4 changed files with 135 additions and 1 deletions
|
|
@ -0,0 +1,75 @@
|
|||
use super::disc_source::DiscSource;
|
||||
use crate::backend::Backend;
|
||||
// use crate::editors::{TrackSetEditor, TrackSource};
|
||||
use crate::widgets::{Navigator, NavigatorScreen};
|
||||
use crate::widgets::new_list::List;
|
||||
use glib::clone;
|
||||
use gtk::prelude::*;
|
||||
use gtk_macros::get_widget;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
/// A dialog for editing metadata while importing music into the music library.
|
||||
pub struct MediumEditor {
|
||||
backend: Rc<Backend>,
|
||||
source: DiscSource,
|
||||
widget: gtk::Box,
|
||||
navigator: RefCell<Option<Rc<Navigator>>>,
|
||||
}
|
||||
|
||||
impl MediumEditor {
|
||||
/// Create a new medium editor.
|
||||
pub fn new(backend: Rc<Backend>, source: DiscSource) -> Rc<Self> {
|
||||
// Create UI
|
||||
|
||||
let builder = gtk::Builder::from_resource("/de/johrpan/musicus/ui/medium_editor.ui");
|
||||
|
||||
get_widget!(builder, gtk::Box, widget);
|
||||
get_widget!(builder, gtk::Button, back_button);
|
||||
get_widget!(builder, gtk::Button, add_button);
|
||||
get_widget!(builder, gtk::Frame, frame);
|
||||
|
||||
let list = List::new("No recordings added.");
|
||||
frame.add(&list.widget);
|
||||
|
||||
let this = Rc::new(Self {
|
||||
backend,
|
||||
source,
|
||||
widget,
|
||||
navigator: RefCell::new(None),
|
||||
});
|
||||
|
||||
// Connect signals and callbacks
|
||||
|
||||
back_button.connect_clicked(clone!(@strong this => move |_| {
|
||||
let navigator = this.navigator.borrow().clone();
|
||||
if let Some(navigator) = navigator {
|
||||
navigator.pop();
|
||||
}
|
||||
}));
|
||||
|
||||
add_button.connect_clicked(clone!(@strong this => move |_| {
|
||||
let navigator = this.navigator.borrow().clone();
|
||||
if let Some(navigator) = navigator {
|
||||
// let editor = TrackSetEditor::new(this.backend.clone(), this.source.clone());
|
||||
// navigator.push(editor);
|
||||
}
|
||||
}));
|
||||
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
impl NavigatorScreen for MediumEditor {
|
||||
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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue