From 54ef90442e0e719f7bd48b231af5b9c2f7aeec8a Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Sat, 15 Mar 2025 23:16:47 -0500 Subject: [PATCH] switch to libcosmics builtin rfd instead of our own --- Cargo.lock | 80 ++----------------------------------------- Cargo.toml | 5 +-- src/core/slide.rs | 5 +-- src/main.rs | 22 ------------ src/ui/presenter.rs | 2 +- src/ui/song_editor.rs | 17 ++++++--- 6 files changed, 22 insertions(+), 109 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d255f8a..862bd62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -324,25 +324,6 @@ dependencies = [ "libloading 0.8.6", ] -[[package]] -name = "ashpd" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac22eda5891cc086690cb6fa10121c0390de0e3b04eb269f2d766b00d3f2d81" -dependencies = [ - "async-fs 2.1.2", - "async-net", - "enumflags2", - "futures-channel", - "futures-util", - "once_cell", - "rand", - "serde", - "serde_repr", - "url", - "zbus 3.15.2", -] - [[package]] name = "ashpd" version = "0.8.1" @@ -424,18 +405,6 @@ dependencies = [ "slab", ] -[[package]] -name = "async-fs" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06" -dependencies = [ - "async-lock 2.8.0", - "autocfg", - "blocking", - "futures-lite 1.13.0", -] - [[package]] name = "async-fs" version = "2.1.2" @@ -506,17 +475,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "async-net" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b948000fad4873c1c9339d60f2623323a0cfd3816e5181033c6a5cb68b2accf7" -dependencies = [ - "async-io 2.4.0", - "blocking", - "futures-lite 2.6.0", -] - [[package]] name = "async-process" version = "1.8.1" @@ -4077,7 +4035,7 @@ dependencies = [ "image", "lazy_static", "palette 0.7.6", - "rfd 0.14.1", + "rfd", "ron 0.8.1", "serde", "slotmap", @@ -4217,7 +4175,6 @@ dependencies = [ "libcosmic", "miette", "pretty_assertions", - "rfd 0.12.1", "rodio", "ron 0.8.1", "serde", @@ -4228,6 +4185,7 @@ dependencies = [ "tokio", "tracing", "tracing-subscriber", + "url", ] [[package]] @@ -5877,31 +5835,6 @@ dependencies = [ "usvg", ] -[[package]] -name = "rfd" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c9e7b57df6e8472152674607f6cc68aa14a748a3157a857a94f516e11aeacc2" -dependencies = [ - "ashpd 0.6.8", - "async-io 1.13.0", - "block", - "dispatch", - "futures-util", - "js-sys", - "log", - "objc", - "objc-foundation", - "objc_id", - "pollster", - "raw-window-handle 0.5.2", - "urlencoding", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "windows-sys 0.48.0", -] - [[package]] name = "rfd" version = "0.14.1" @@ -8948,15 +8881,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "675d170b632a6ad49804c8cf2105d7c31eddd3312555cffd4b740e08e97c25e6" dependencies = [ "async-broadcast 0.5.1", - "async-executor", - "async-fs 1.6.0", - "async-io 1.13.0", - "async-lock 2.8.0", "async-process 1.8.1", "async-recursion", - "async-task", "async-trait", - "blocking", "byteorder", "derivative", "enumflags2", @@ -8991,7 +8918,7 @@ checksum = "bb97012beadd29e654708a0fdb4c84bc046f537aecfde2c3ee0a9e4b4d48c725" dependencies = [ "async-broadcast 0.7.2", "async-executor", - "async-fs 2.1.2", + "async-fs", "async-io 2.4.0", "async-lock 3.4.0", "async-process 2.3.0", @@ -9192,7 +9119,6 @@ dependencies = [ "libc", "serde", "static_assertions", - "url", "zvariant_derive 3.15.2", ] diff --git a/Cargo.toml b/Cargo.toml index d71a8e6..8b7cdea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ description = "A cli presentation system" [dependencies] clap = { version = "4.5.20", features = ["debug", "derive"] } -libcosmic = { git = "https://github.com/pop-os/libcosmic", features = ["debug", "winit", "tokio", "xdg-portal", "dbus-config", "a11y", "wgpu", "multi-window", "single-instance"] } +libcosmic = { git = "https://github.com/pop-os/libcosmic", features = ["debug", "winit", "tokio", "rfd", "dbus-config", "a11y", "wgpu", "multi-window", "single-instance"] } lexpr = "0.2.7" miette = { version = "7.2.0", features = ["fancy"] } pretty_assertions = "1.4.1" @@ -28,5 +28,6 @@ rodio = { version = "0.20.1", features = ["symphonia-all", "tracing"] } gstreamer = "0.23.3" gstreamer-app = "0.23.3" cosmic-time = "0.2.0" -rfd = { version = "0.12.1", features = ["xdg-portal"], default-features = false } +url = "2" +# rfd = { version = "0.12.1", features = ["xdg-portal"], default-features = false } diff --git a/src/core/slide.rs b/src/core/slide.rs index bcd67a1..05c3b34 100644 --- a/src/core/slide.rs +++ b/src/core/slide.rs @@ -1,5 +1,6 @@ -use cosmic::dialog::ashpd::url::Url; +// use cosmic::dialog::ashpd::url::Url; use crisp::types::{Keyword, Symbol, Value}; +use gstreamer::query::Uri; use iced_video_player::Video; use miette::{miette, Result}; use serde::{Deserialize, Serialize}; @@ -58,7 +59,7 @@ impl TryFrom for Video { value: Background, ) -> std::result::Result { Video::new( - &Url::from_file_path(value.path) + &url::Url::from_file_path(value.path) .map_err(|_| ParseError::BackgroundNotVideo)?, ) .map_err(|_| ParseError::BackgroundNotVideo) diff --git a/src/main.rs b/src/main.rs index d978efe..c5f154d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -455,29 +455,7 @@ impl cosmic::Application for App { }) } Message::Library(message) => { -<<<<<<< HEAD - // debug!(?message); - let (mut kind, mut index): (LibraryKind, i32) = - (LibraryKind::Song, 0); - let mut opened_item = false; - match message { - library::Message::OpenItem(item) => { - let Some(item) = item else { - return ().into(); - }; - debug!("opening: {:?}", item); - kind = item.0; - index = item.1; - opened_item = true; - } - _ => { - // debug!("none"); - () - } - }; -======= let mut song = Song::default(); ->>>>>>> 93b021e (fixed lots of bugs by return Action enums in song_editor and library) if let Some(library) = &mut self.library { match library.update(message) { library::Action::OpenItem(None) => { diff --git a/src/ui/presenter.rs b/src/ui/presenter.rs index b9edaf4..f23427e 100644 --- a/src/ui/presenter.rs +++ b/src/ui/presenter.rs @@ -2,7 +2,6 @@ use miette::{miette, IntoDiagnostic, Result}; use std::{fs::File, io::BufReader, path::PathBuf, sync::Arc}; use cosmic::{ - dialog::ashpd::url::Url, iced::{ alignment::Horizontal, font::{Family, Stretch, Style, Weight}, @@ -26,6 +25,7 @@ use cosmic::{ use iced_video_player::{gst_pbutils, Position, Video, VideoPlayer}; use rodio::{Decoder, OutputStream, Sink}; use tracing::{debug, error, info, warn}; +use url::Url; use crate::{ core::{service_items::ServiceItemModel, slide::Slide}, diff --git a/src/ui/song_editor.rs b/src/ui/song_editor.rs index d9c5958..296d4fb 100644 --- a/src/ui/song_editor.rs +++ b/src/ui/song_editor.rs @@ -1,6 +1,7 @@ use std::{io, path::PathBuf}; use cosmic::{ + dialog::file_chooser::open::Dialog, iced::{ font::{Family, Stretch, Style, Weight}, Font, Length, @@ -432,12 +433,18 @@ impl Default for SongEditor { } async fn pick_background() -> Result { - rfd::AsyncFileDialog::new() - .set_title("Choose a background...") - .pick_file() + let dialog = Dialog::new().title("Choose a background..."); + dialog + .open_file() .await - .ok_or(SongError::DialogClosed) - .map(|file| file.path().to_owned()) + .map_err(|_| SongError::DialogClosed) + .map(|file| file.url().to_file_path().unwrap()) + // rfd::AsyncFileDialog::new() + // .set_title("Choose a background...") + // .pick_file() + // .await + // .ok_or(SongError::DialogClosed) + // .map(|file| file.path().to_owned()) } #[derive(Debug, Clone)]