feat: allow specifying arguments for custom plugins
Some checks failed
/ cargo-fmtcheck (push) Has been cancelled
/ cargo-clippy (push) Has been cancelled
/ cargo-test (push) Has been cancelled
/ appimage (push) Has been cancelled

This commit is contained in:
Gabriele Musco 2025-07-18 07:46:34 +02:00
commit 8311adc3dd

View file

@ -31,6 +31,7 @@ pub enum AddCustomPluginWinMsg {
Present, Present,
Close, Close,
OnNameChange(String), OnNameChange(String),
OnArgsChange(String),
OnExecPathChange(Option<String>), OnExecPathChange(Option<String>),
Add, Add,
} }
@ -95,7 +96,11 @@ impl SimpleComponent for AddCustomPluginWin {
"", "",
clone!( clone!(
#[strong] sender, #[strong] sender,
move |row| sender.input(Self::Input::OnNameChange(row.text().to_string())) move |row| sender.input(
Self::Input::OnNameChange(
row.text().to_string()
)
)
) )
), ),
add: &file_row( add: &file_row(
@ -105,9 +110,23 @@ impl SimpleComponent for AddCustomPluginWin {
Some(model.parent.clone()), Some(model.parent.clone()),
clone!( clone!(
#[strong] sender, #[strong] sender,
move |path_s| sender.input(Self::Input::OnExecPathChange(path_s)) move |path_s| sender.input(
Self::Input::OnExecPathChange(path_s)
)
) )
) ),
add: &entry_row(
"Plugin Arguments",
"",
clone!(
#[strong] sender,
move |row| sender.input(
Self::Input::OnArgsChange(
row.text().to_string()
)
)
)
),
}, },
}, },
}, },
@ -139,6 +158,17 @@ impl SimpleComponent for AddCustomPluginWin {
self.plugin.name = name; self.plugin.name = name;
self.set_can_add(self.plugin.validate()); self.set_can_add(self.plugin.validate());
} }
Self::Input::OnArgsChange(args) => {
let args = args.trim().to_string();
self.plugin.args = if args.is_empty() {
None
} else {
// it's fine to have them joined
// since they will ultimately be
// passed as a joined string
Some(vec![args])
}
}
Self::Input::OnExecPathChange(ep) => { Self::Input::OnExecPathChange(ep) => {
self.plugin.exec_path = ep.map(PathBuf::from); self.plugin.exec_path = ep.map(PathBuf::from);
self.set_can_add(self.plugin.validate()); self.set_can_add(self.plugin.validate());