Make search work again
This commit is contained in:
@@ -1,23 +1,28 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use gtk::prelude::*;
|
||||
use log::debug;
|
||||
use relm4::factory::FactoryVecDeque;
|
||||
use relm4::prelude::*;
|
||||
use relm4::{
|
||||
gtk, Component, ComponentController, ComponentParts, ComponentSender, SimpleComponent,
|
||||
};
|
||||
use relm4::{prelude::*, RelmListBoxExt};
|
||||
use walkdir::WalkDir;
|
||||
|
||||
use super::sheet_model::{SheetModel, SheetModelType};
|
||||
use super::sheet_model::{OnQueryUpdate, SheetModel, SheetModelType};
|
||||
|
||||
pub struct SheetListingModel {
|
||||
query: String,
|
||||
sheets: FactoryVecDeque<SheetModel>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SheetListingInput {
|
||||
pub query: String,
|
||||
pub enum SheetListingInput {
|
||||
Query(String),
|
||||
ListBoxRowClicked(i32),
|
||||
}
|
||||
|
||||
pub struct SheetModelSelected {
|
||||
sheet_model_type: SheetModelType,
|
||||
}
|
||||
|
||||
#[relm4::component(pub)]
|
||||
@@ -31,10 +36,14 @@ impl SimpleComponent for SheetListingModel {
|
||||
gtk::Box {
|
||||
// set_orientation: gtk::Orientation::Vertical,
|
||||
|
||||
model.sheets.widget() -> >k::ListBox {
|
||||
model.sheets.widget() -> &relm4::gtk::ListBox {
|
||||
set_hexpand: true,
|
||||
// set_orientation: gtk::Orientation::Vertical,
|
||||
// set_spacing: 5,
|
||||
connect_row_activated[sender] => move |list_box, row| {
|
||||
let index = list_box.index_of_child(row).unwrap();
|
||||
sender.input(SheetListingInput::ListBoxRowClicked(index));
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -49,15 +58,20 @@ impl SimpleComponent for SheetListingModel {
|
||||
sheets.guard().push_back(sheet_model_type);
|
||||
}
|
||||
|
||||
let model = SheetListingModel {
|
||||
query: String::new(),
|
||||
sheets,
|
||||
};
|
||||
let model = SheetListingModel { sheets };
|
||||
let widgets = view_output!();
|
||||
ComponentParts { model, widgets }
|
||||
}
|
||||
|
||||
fn update(&mut self, message: Self::Input, _sender: ComponentSender<Self>) {
|
||||
self.query = message.query;
|
||||
match message {
|
||||
SheetListingInput::Query(query) => {
|
||||
self.sheets.broadcast(OnQueryUpdate { query });
|
||||
}
|
||||
SheetListingInput::ListBoxRowClicked(index) => {
|
||||
let x = self.sheets.get(index as usize).unwrap();
|
||||
debug!("clicked: {}!!!!!", x.label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user