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", "log",
"notify", "notify",
"patch", "patch",
"rfd",
"rust-embed", "rust-embed",
"serde", "serde",
"syntect", "syntect",
@ -4388,6 +4389,12 @@ dependencies = [
"windows-sys 0.52.0", "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]] [[package]]
name = "powerfmt" name = "powerfmt"
version = "0.2.0" version = "0.2.0"
@ -4697,7 +4704,9 @@ dependencies = [
"objc", "objc",
"objc-foundation", "objc-foundation",
"objc_id", "objc_id",
"pollster",
"raw-window-handle 0.5.2", "raw-window-handle 0.5.2",
"urlencoding",
"wasm-bindgen", "wasm-bindgen",
"wasm-bindgen-futures", "wasm-bindgen-futures",
"web-sys", "web-sys",
@ -5818,6 +5827,12 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "urlencoding"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
[[package]] [[package]]
name = "usvg" name = "usvg"
version = "0.37.0" version = "0.37.0"

View file

@ -36,6 +36,13 @@ features = ["syntect", "vi"]
git = "https://github.com/pop-os/libcosmic" git = "https://github.com/pop-os/libcosmic"
default-features = false default-features = false
features = ["tokio", "winit"] 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 #TODO: clean up and send changes upstream
[dependencies.systemicons] [dependencies.systemicons]
@ -45,13 +52,8 @@ git = "https://github.com/jackpot51/systemicons"
fork = "0.1" fork = "0.1"
[features] [features]
default = ["xdg-portal", "wgpu"] default = ["rfd", "wgpu"]
# Use RFD for file chooser dialogs
rfd = ["libcosmic/rfd"]
# Enable GPU rendering with WGPU
wgpu = ["libcosmic/wgpu"] wgpu = ["libcosmic/wgpu"]
# Use XDG portal dialogs on Linux
xdg-portal = ["libcosmic/xdg-portal"]
[patch.crates-io] [patch.crates-io]
smithay-client-toolkit = { git = "https://github.com/pop-os/client-toolkit", branch = "wayland-resize" } smithay-client-toolkit = { git = "https://github.com/pop-os/client-toolkit", branch = "wayland-resize" }

View file

@ -3,9 +3,7 @@
use cosmic::{ use cosmic::{
app::{message, Command, Core, Settings}, app::{message, Command, Core, Settings},
cosmic_config::{self, CosmicConfigEntry}, cosmic_config::{self, CosmicConfigEntry},
cosmic_theme, cosmic_theme, executor,
dialog::file_chooser,
executor,
font::Font, font::Font,
iced::{ iced::{
clipboard, event, clipboard, event,
@ -1439,15 +1437,17 @@ impl Application for App {
} }
}, },
Message::OpenFileDialog => { Message::OpenFileDialog => {
return cosmic::command::future(async { #[cfg(feature = "rfd")]
if let Ok(response) = file_chooser::open::Dialog::new().open_file().await { return Command::perform(
if let Ok(path) = response.url().to_file_path() { async {
return message::app(Message::OpenFile(path)); if let Some(handle) = rfd::AsyncFileDialog::new().pick_file().await {
message::app(Message::OpenFile(handle.path().to_owned()))
} else {
message::none()
} }
} },
|x| x,
message::none() );
});
} }
Message::OpenFile(path) => { Message::OpenFile(path) => {
self.open_tab(Some(path)); self.open_tab(Some(path));