diff --git a/Cargo.lock b/Cargo.lock index 8fd17a0..1855862 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1073,6 +1073,7 @@ dependencies = [ "log", "notify", "patch", + "rfd", "rust-embed", "serde", "syntect", @@ -4388,6 +4389,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "pollster" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" + [[package]] name = "powerfmt" version = "0.2.0" @@ -4697,7 +4704,9 @@ dependencies = [ "objc", "objc-foundation", "objc_id", + "pollster", "raw-window-handle 0.5.2", + "urlencoding", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -5818,6 +5827,12 @@ dependencies = [ "serde", ] +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + [[package]] name = "usvg" version = "0.37.0" diff --git a/Cargo.toml b/Cargo.toml index 20d75c3..9cfbfab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,13 @@ features = ["syntect", "vi"] git = "https://github.com/pop-os/libcosmic" default-features = false features = ["tokio", "winit"] +#path = "../libcosmic" + +[dependencies.rfd] +version = "0.13.0" +default-features = false +features = ["tokio", "xdg-portal"] +optional = true #TODO: clean up and send changes upstream [dependencies.systemicons] @@ -45,13 +52,8 @@ git = "https://github.com/jackpot51/systemicons" fork = "0.1" [features] -default = ["xdg-portal", "wgpu"] -# Use RFD for file chooser dialogs -rfd = ["libcosmic/rfd"] -# Enable GPU rendering with WGPU +default = ["rfd", "wgpu"] wgpu = ["libcosmic/wgpu"] -# Use XDG portal dialogs on Linux -xdg-portal = ["libcosmic/xdg-portal"] [patch.crates-io] smithay-client-toolkit = { git = "https://github.com/pop-os/client-toolkit", branch = "wayland-resize" } diff --git a/src/main.rs b/src/main.rs index 6493c8f..c835358 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,9 +3,7 @@ use cosmic::{ app::{message, Command, Core, Settings}, cosmic_config::{self, CosmicConfigEntry}, - cosmic_theme, - dialog::file_chooser, - executor, + cosmic_theme, executor, font::Font, iced::{ clipboard, event, @@ -1439,15 +1437,17 @@ impl Application for App { } }, Message::OpenFileDialog => { - return cosmic::command::future(async { - if let Ok(response) = file_chooser::open::Dialog::new().open_file().await { - if let Ok(path) = response.url().to_file_path() { - return message::app(Message::OpenFile(path)); + #[cfg(feature = "rfd")] + return Command::perform( + async { + if let Some(handle) = rfd::AsyncFileDialog::new().pick_file().await { + message::app(Message::OpenFile(handle.path().to_owned())) + } else { + message::none() } - } - - message::none() - }); + }, + |x| x, + ); } Message::OpenFile(path) => { self.open_tab(Some(path));