diff --git a/Cargo.lock b/Cargo.lock index fbfce7d..d34c7c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -998,7 +998,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#4e18199444aecbc60f25a12e8adb91926aa5e653" +source = "git+https://github.com/pop-os/libcosmic?branch=dialog#6e8afc8341a4b5ef9ab453485ddf1acbbf256b72" dependencies = [ "atomicwrites", "cosmic-config-derive", @@ -1013,7 +1013,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#4e18199444aecbc60f25a12e8adb91926aa5e653" +source = "git+https://github.com/pop-os/libcosmic?branch=dialog#6e8afc8341a4b5ef9ab453485ddf1acbbf256b72" dependencies = [ "quote", "syn 1.0.109", @@ -1036,7 +1036,6 @@ dependencies = [ "log", "notify", "patch", - "rfd", "rust-embed", "serde", "syntect", @@ -1083,7 +1082,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#4e18199444aecbc60f25a12e8adb91926aa5e653" +source = "git+https://github.com/pop-os/libcosmic?branch=dialog#6e8afc8341a4b5ef9ab453485ddf1acbbf256b72" dependencies = [ "almost", "cosmic-config", @@ -2612,7 +2611,7 @@ dependencies = [ [[package]] name = "iced" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#4e18199444aecbc60f25a12e8adb91926aa5e653" +source = "git+https://github.com/pop-os/libcosmic?branch=dialog#6e8afc8341a4b5ef9ab453485ddf1acbbf256b72" dependencies = [ "iced_accessibility", "iced_core", @@ -2627,7 +2626,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#4e18199444aecbc60f25a12e8adb91926aa5e653" +source = "git+https://github.com/pop-os/libcosmic?branch=dialog#6e8afc8341a4b5ef9ab453485ddf1acbbf256b72" dependencies = [ "accesskit", "accesskit_winit", @@ -2636,7 +2635,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#4e18199444aecbc60f25a12e8adb91926aa5e653" +source = "git+https://github.com/pop-os/libcosmic?branch=dialog#6e8afc8341a4b5ef9ab453485ddf1acbbf256b72" dependencies = [ "bitflags 1.3.2", "instant", @@ -2652,7 +2651,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#4e18199444aecbc60f25a12e8adb91926aa5e653" +source = "git+https://github.com/pop-os/libcosmic?branch=dialog#6e8afc8341a4b5ef9ab453485ddf1acbbf256b72" dependencies = [ "futures", "iced_core", @@ -2665,7 +2664,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#4e18199444aecbc60f25a12e8adb91926aa5e653" +source = "git+https://github.com/pop-os/libcosmic?branch=dialog#6e8afc8341a4b5ef9ab453485ddf1acbbf256b72" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2688,7 +2687,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#4e18199444aecbc60f25a12e8adb91926aa5e653" +source = "git+https://github.com/pop-os/libcosmic?branch=dialog#6e8afc8341a4b5ef9ab453485ddf1acbbf256b72" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2701,7 +2700,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#4e18199444aecbc60f25a12e8adb91926aa5e653" +source = "git+https://github.com/pop-os/libcosmic?branch=dialog#6e8afc8341a4b5ef9ab453485ddf1acbbf256b72" dependencies = [ "iced_core", "iced_futures", @@ -2711,7 +2710,7 @@ dependencies = [ [[package]] name = "iced_style" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#4e18199444aecbc60f25a12e8adb91926aa5e653" +source = "git+https://github.com/pop-os/libcosmic?branch=dialog#6e8afc8341a4b5ef9ab453485ddf1acbbf256b72" dependencies = [ "iced_core", "once_cell", @@ -2721,7 +2720,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#4e18199444aecbc60f25a12e8adb91926aa5e653" +source = "git+https://github.com/pop-os/libcosmic?branch=dialog#6e8afc8341a4b5ef9ab453485ddf1acbbf256b72" dependencies = [ "bytemuck", "cosmic-text", @@ -2739,7 +2738,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#4e18199444aecbc60f25a12e8adb91926aa5e653" +source = "git+https://github.com/pop-os/libcosmic?branch=dialog#6e8afc8341a4b5ef9ab453485ddf1acbbf256b72" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2759,7 +2758,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#4e18199444aecbc60f25a12e8adb91926aa5e653" +source = "git+https://github.com/pop-os/libcosmic?branch=dialog#6e8afc8341a4b5ef9ab453485ddf1acbbf256b72" dependencies = [ "iced_renderer", "iced_runtime", @@ -2773,7 +2772,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#4e18199444aecbc60f25a12e8adb91926aa5e653" +source = "git+https://github.com/pop-os/libcosmic?branch=dialog#6e8afc8341a4b5ef9ab453485ddf1acbbf256b72" dependencies = [ "iced_graphics", "iced_runtime", @@ -3091,7 +3090,7 @@ checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#4e18199444aecbc60f25a12e8adb91926aa5e653" +source = "git+https://github.com/pop-os/libcosmic?branch=dialog#6e8afc8341a4b5ef9ab453485ddf1acbbf256b72" dependencies = [ "apply", "ashpd", @@ -3113,6 +3112,7 @@ dependencies = [ "iced_winit", "lazy_static", "palette", + "rfd", "slotmap", "taffy", "thiserror", @@ -4678,10 +4678,11 @@ dependencies = [ [[package]] name = "rfd" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c9e7b57df6e8472152674607f6cc68aa14a748a3157a857a94f516e11aeacc2" +checksum = "c0d8ab342bcc5436e04d3a4c1e09e17d74958bfaddf8d5fad6f85607df0f994f" dependencies = [ + "ashpd", "block", "dispatch", "glib-sys", diff --git a/Cargo.toml b/Cargo.toml index ddf703b..c138217 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,6 @@ lexical-sort = "0.3.1" log = "0.4.20" patch = "0.7.0" notify = "6.1.1" -#TODO: this is using gtk for file dialogues -rfd = { version = "0.12.0", optional = true } serde = { version = "1", features = ["serde_derive"] } tokio = { version = "1", features = ["process", "time"] } # Extra syntax highlighting @@ -35,9 +33,9 @@ features = ["syntect", "vi"] [dependencies.libcosmic] git = "https://github.com/pop-os/libcosmic" +branch = "dialog" default-features = false features = ["tokio", "winit"] -#path = "../libcosmic" #TODO: clean up and send changes upstream [dependencies.systemicons] @@ -47,8 +45,13 @@ git = "https://github.com/jackpot51/systemicons" fork = "0.1" [features] -default = ["rfd", "wgpu"] +default = ["xdg-portal", "wgpu"] +# Use RFD for file chooser dialogs +rfd = ["libcosmic/rfd"] +# Enable GPU rendering with 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 5aa3581..6360ad4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,9 @@ use cosmic::{ app::{message, Command, Core, Settings}, cosmic_config::{self, CosmicConfigEntry}, - cosmic_theme, executor, + cosmic_theme, + dialog::file_chooser, + executor, font::Font, iced::{ clipboard, event, @@ -1437,17 +1439,15 @@ impl Application for App { } }, Message::OpenFileDialog => { - #[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() + 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)); } - }, - |x| x, - ); + } + + message::none() + }); } Message::OpenFile(path) => { self.open_tab(Some(path));