feat: handle opening network location in new window

This commit is contained in:
Ashley Wulber 2025-07-14 18:10:14 -04:00 committed by Jeremy Soller
parent c7e9828d7b
commit 08367c9ea6
5 changed files with 43 additions and 65 deletions

View file

@ -80,6 +80,7 @@ pub fn desktop() -> Result<(), Box<dyn std::error::Error>> {
state,
mode: app::Mode::Desktop,
locations,
uris: Vec::new()
};
cosmic::app::run::<App>(settings, flags)?;
@ -98,6 +99,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut daemonize = true;
let mut locations = Vec::new();
let mut uris = Vec::new();
for arg in env::args().skip(1) {
let location = if &arg == "--no-daemon" {
daemonize = false;
@ -111,14 +113,18 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
} else {
//TODO: support more URLs
let path = match url::Url::parse(&arg) {
Ok(url) => match url.to_file_path() {
Ok(url) if url.scheme() == "file" => match url.to_file_path() {
Ok(path) => path,
Err(()) => {
log::warn!("invalid argument {:?}", arg);
continue;
}
},
Err(_) => PathBuf::from(arg),
Ok(url) => {
uris.push(url);
continue;
}
_ => PathBuf::from(arg),
};
match fs::canonicalize(&path) {
Ok(absolute) => Location::Path(absolute),
@ -160,6 +166,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
state,
mode: app::Mode::App,
locations,
uris
};
cosmic::app::run::<App>(settings, flags)?;