Implement open with buttons

This commit is contained in:
Jeremy Soller 2024-03-04 10:39:48 -07:00
parent a54957ddf2
commit ac4626d9cf
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
2 changed files with 23 additions and 5 deletions

View file

@ -145,6 +145,7 @@ pub enum Message {
NotifyEvent(notify::Event),
NotifyWatcher(WatcherWrapper),
OpenTerminal(Option<Entity>),
OpenWith(PathBuf, mime_app::MimeApp),
Paste(Option<Entity>),
PendingComplete(u64),
PendingError(u64, String),
@ -896,9 +897,9 @@ impl Application for App {
Ok(()) => {}
Err(err) => {
log::warn!(
"failed to launch terminal {:?} in {:?}: {}",
terminal.id,
"failed to open {:?} with terminal {:?}: {}",
path,
terminal.id,
err
)
}
@ -909,6 +910,21 @@ impl Application for App {
}
}
}
Message::OpenWith(path, app) => {
if let Some(mut command) = app.command(Some(path.clone())) {
match spawn_detached(&mut command) {
Ok(()) => {}
Err(err) => {
log::warn!("failed to open {:?} with {:?}: {}", path, app.id, err)
}
}
} else {
log::warn!("failed to get command for {:?}", app.id);
}
// Close Open With context view
self.core.window.show_context = false;
}
Message::Paste(_entity_opt) => {
log::warn!("TODO: PASTE");
}