feat: handle opening network location in new window
This commit is contained in:
parent
c7e9828d7b
commit
08367c9ea6
5 changed files with 43 additions and 65 deletions
11
src/lib.rs
11
src/lib.rs
|
|
@ -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)?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue