forked from 1b-agent/opencadstudio-upstream
Add-ons had no way to request a file picker — only the host's own Open dialog. PluginFileDialog lets a plugin tool ask the host to open a native picker; on selection the host dispatches "<command> <path>" back to the plugin with original case preserved (bypassing the command-line upper-casing that mangles case-sensitive paths on Linux/macOS). The demo plugin gains an Import tool exercising it. Part of the #100 extensibility epic (surfaced in #106). Co-Authored-By: Claude Opus 4.8 <[email protected]>
17 lines
561 B
Rust
17 lines
561 B
Rust
use crate::plugin::host::HostSession;
|
|
|
|
pub fn handle(host: &mut HostSession<'_>, cmd: &str) -> bool {
|
|
// "DP_IMPORT <path>" arrives from ModuleEvent::PluginFileDialog with the
|
|
// path in its original case (the command line is bypassed).
|
|
if let Some(path) = cmd.strip_prefix("DP_IMPORT ") {
|
|
host.push_info(&format!("demo_plugin imported: {path}"));
|
|
return true;
|
|
}
|
|
match cmd {
|
|
"DP_HELLO" => {
|
|
host.push_info("Hello from demo_plugin (plugin host OK).");
|
|
true
|
|
}
|
|
_ => false,
|
|
}
|
|
} |