use abi_stable::traits::IntoReprC; use adw::prelude::*; use gtk::prelude::*; use relm4::{factory::FactoryView, gtk, prelude::*, FactorySender}; #[derive(Debug)] pub enum Msg {} #[derive(Debug)] pub enum OutputMsg { Update((String, String)), } pub struct PathItem { title: &'static str, path: String, } impl PathItem { pub fn new(title: &'static str, path: String) -> Self { Self { title, path } } } #[relm4::factory(pub)] impl FactoryComponent for PathItem { type ParentWidget = adw::PreferencesGroup; // type ParentInput = super::SettingMsg; type Input = (); type Output = OutputMsg; type Init = PathItem; type CommandOutput = (); view! { #[root] adw::EntryRow{ set_title: &self.title, set_text: &self.path, set_max_width_chars:100, connect_changed[sender] => move |s|{ let key = s.title().clone().into(); sender.output(OutputMsg::Update((key,s.text().to_string()))); }, add_suffix=>k::Switch{ set_height_request: 10, set_margin_vertical:15, set_hexpand: false, set_vexpand: false } } } fn init_model(init: Self::Init, index: &DynamicIndex, sender: FactorySender) -> Self { init } fn update(&mut self, message: Self::Input, sender: FactorySender) {} }