Implement sheet listing
No click effect or filtering yet
This commit is contained in:
62
src/main.rs
62
src/main.rs
@@ -1,12 +1,17 @@
|
||||
mod mcdu;
|
||||
mod sheet_listing;
|
||||
|
||||
use std::{env, path::PathBuf, process};
|
||||
|
||||
use gtk::prelude::*;
|
||||
use mcdu::McduModel;
|
||||
use relm4::prelude::*;
|
||||
use relm4::{gtk::PolicyType, prelude::*};
|
||||
use sheet_listing::SheetListingModel;
|
||||
|
||||
struct AppModel {
|
||||
text: String,
|
||||
mcdu: Controller<McduModel>,
|
||||
sheet_listing: Controller<SheetListingModel>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -18,7 +23,7 @@ enum AppInput {
|
||||
impl SimpleComponent for AppModel {
|
||||
type Input = AppInput;
|
||||
type Output = ();
|
||||
type Init = ();
|
||||
type Init = PathBuf;
|
||||
|
||||
view! {
|
||||
#[root]
|
||||
@@ -28,19 +33,33 @@ impl SimpleComponent for AppModel {
|
||||
set_title: Some("Play music!!!"),
|
||||
gtk::Box {
|
||||
set_orientation: gtk::Orientation::Horizontal,
|
||||
model.mcdu.widget(),
|
||||
#[name = "label"]
|
||||
gtk::Label {
|
||||
#[watch]
|
||||
set_label: &model.text,
|
||||
set_margin_all: 5,
|
||||
}
|
||||
gtk::Box {
|
||||
set_orientation: gtk::Orientation::Vertical,
|
||||
set_hexpand: true,
|
||||
gtk::ScrolledWindow {
|
||||
model.sheet_listing.widget(),
|
||||
set_vexpand: true,
|
||||
set_hexpand: true,
|
||||
// set_hscrollbar_policy: PolicyType::Never,
|
||||
},
|
||||
},
|
||||
gtk::Box {
|
||||
set_orientation: gtk::Orientation::Vertical,
|
||||
set_valign: gtk::Align::Center,
|
||||
model.mcdu.widget(),
|
||||
#[name = "label"]
|
||||
gtk::Label {
|
||||
#[watch]
|
||||
set_label: &model.text,
|
||||
set_margin_all: 5,
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn init(
|
||||
_init: Self::Init,
|
||||
path: Self::Init,
|
||||
window: &Self::Root,
|
||||
sender: ComponentSender<Self>,
|
||||
) -> relm4::ComponentParts<Self> {
|
||||
@@ -52,9 +71,14 @@ impl SimpleComponent for AppModel {
|
||||
mcdu::McduOutput::ButtonPress(c) => AppInput::McduInput(c),
|
||||
});
|
||||
|
||||
let sheet_listing = SheetListingModel::builder()
|
||||
.launch(path)
|
||||
.forward(sender.input_sender(), |_response| todo!());
|
||||
|
||||
let model = AppModel {
|
||||
text: String::from("Text: NONE"),
|
||||
text: String::from("Text: "),
|
||||
mcdu,
|
||||
sheet_listing,
|
||||
};
|
||||
|
||||
let widgets = view_output!();
|
||||
@@ -71,5 +95,19 @@ impl SimpleComponent for AppModel {
|
||||
|
||||
fn main() {
|
||||
let app = RelmApp::new("de.frajul.sheet-organizer");
|
||||
app.run::<AppModel>(());
|
||||
|
||||
let args: Vec<String> = env::args().collect();
|
||||
|
||||
if args.len() <= 1 {
|
||||
eprintln!("Please provide sheet folder path");
|
||||
process::exit(1);
|
||||
}
|
||||
let file_path = PathBuf::from(&args[1]);
|
||||
if !file_path.is_dir() {
|
||||
eprintln!("Sheet folder path is no dir or does not exist");
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
// Pass empty command line args to allow my own parsing
|
||||
app.with_args(Vec::new()).run::<AppModel>(file_path);
|
||||
}
|
||||
|
Reference in New Issue
Block a user