Revert "refactor: use libcosmic::dialog and make rfd optional"

This reverts commit a1c80efe69.
This commit is contained in:
Jeremy Soller 2024-01-30 18:53:40 -07:00
parent aac8b89e53
commit aee6b6ad31
3 changed files with 34 additions and 17 deletions

15
Cargo.lock generated
View file

@ -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"

View file

@ -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" }

View file

@ -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));