Move open command handler to workspace global action

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld
2021-04-12 14:18:24 -07:00
co-authored by Nathan Sobo
parent 3247f49954
commit 2332b7e06b
4 changed files with 29 additions and 27 deletions
+3 -21
View File
@@ -16,27 +16,9 @@ fn main() {
let app = gpui::App::new(assets::Assets).unwrap();
let (_, settings_rx) = settings::channel(&app.font_cache()).unwrap();
app.set_menus(menus::menus(settings_rx.clone()));
app.on_menu_command(move |command, arg, ctx| match command {
"app:open" => {
if let Some(paths) = ctx.platform().prompt_for_paths(PathPromptOptions {
files: true,
directories: true,
multiple: true,
}) {
ctx.dispatch_global_action(
"workspace:open_paths",
OpenParams {
paths,
settings: arg
.unwrap()
.downcast_ref::<Receiver<Settings>>()
.unwrap()
.clone(),
},
);
}
}
_ => ctx.dispatch_global_action(command, ()),
app.on_menu_command(move |command, arg, ctx| {
eprintln!("command: {:?} {:?}", command, arg);
ctx.dispatch_global_action_with_dyn_arg(command, arg.unwrap_or(&()))
})
.run(move |ctx| {
workspace::init(ctx);