63 lines
1.5 KiB
Rust
63 lines
1.5 KiB
Rust
use std::path::PathBuf;
|
|
|
|
use gtk::prelude::*;
|
|
use relm4::factory::FactoryVecDeque;
|
|
use relm4::prelude::*;
|
|
use relm4::{
|
|
gtk, Component, ComponentController, ComponentParts, ComponentSender, SimpleComponent,
|
|
};
|
|
use walkdir::WalkDir;
|
|
|
|
use super::sheet_model::{SheetModel, SheetModelType};
|
|
|
|
pub struct SheetListingModel {
|
|
query: String,
|
|
sheets: FactoryVecDeque<SheetModel>,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct SheetListingInput {
|
|
pub query: String,
|
|
}
|
|
|
|
#[relm4::component(pub)]
|
|
impl SimpleComponent for SheetListingModel {
|
|
type Init = Vec<SheetModelType>;
|
|
type Input = SheetListingInput;
|
|
type Output = ();
|
|
|
|
view! {
|
|
#[root]
|
|
gtk::Box {
|
|
// set_orientation: gtk::Orientation::Vertical,
|
|
|
|
model.sheets.widget() -> >k::Box {
|
|
set_orientation: gtk::Orientation::Vertical,
|
|
set_spacing: 5,
|
|
},
|
|
}
|
|
}
|
|
|
|
fn init(
|
|
init: Self::Init,
|
|
root: &Self::Root,
|
|
sender: ComponentSender<Self>,
|
|
) -> ComponentParts<Self> {
|
|
let mut sheets = FactoryVecDeque::new(gtk::Box::default(), sender.input_sender());
|
|
for sheet_model_type in init {
|
|
sheets.guard().push_back(sheet_model_type);
|
|
}
|
|
|
|
let model = SheetListingModel {
|
|
query: String::new(),
|
|
sheets,
|
|
};
|
|
let widgets = view_output!();
|
|
ComponentParts { model, widgets }
|
|
}
|
|
|
|
fn update(&mut self, message: Self::Input, _sender: ComponentSender<Self>) {
|
|
self.query = message.query;
|
|
}
|
|
}
|