Support browsing for application in open with dialog

This commit is contained in:
Jeremy Soller 2024-10-03 15:16:17 -06:00
parent fef57ee031
commit 7f60a0c710
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
3 changed files with 61 additions and 12 deletions

View file

@ -7,10 +7,11 @@ use cosmic::widget;
pub use mime_guess::Mime;
use once_cell::sync::Lazy;
use std::{
cmp::Ordering, collections::HashMap, env, path::PathBuf, process, sync::Mutex, time::Instant,
cmp::Ordering, collections::HashMap, env, ffi::OsString, path::PathBuf, process, sync::Mutex,
time::Instant,
};
pub fn exec_to_command(exec: &str, path_opt: Option<PathBuf>) -> Option<process::Command> {
pub fn exec_to_command(exec: &str, path_opt: Option<OsString>) -> Option<process::Command> {
let args_vec: Vec<String> = shlex::split(exec)?;
let mut args = args_vec.iter();
let mut command = process::Command::new(args.next()?);
@ -46,7 +47,7 @@ pub struct MimeApp {
impl MimeApp {
//TODO: move to libcosmic, support multiple files
pub fn command(&self, path_opt: Option<PathBuf>) -> Option<process::Command> {
pub fn command(&self, path_opt: Option<OsString>) -> Option<process::Command> {
exec_to_command(self.exec.as_deref()?, path_opt)
}
}