From adc2c7e8718a4cde58872c0ebea9ecd835ed82f0 Mon Sep 17 00:00:00 2001 From: wiiznokes <78230769+wiiznokes@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:34:36 +0200 Subject: [PATCH] chore: update freedesktop-desktop-entry to 0.7.5 --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- cosmic-app-list/src/app.rs | 21 ++++++--------------- cosmic-panel-button/Cargo.toml | 2 +- cosmic-panel-button/src/main.rs | 3 ++- 5 files changed, 14 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 579dc4b9..4e8b1dc1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -929,7 +929,7 @@ dependencies = [ "cosmic-app-list-config", "cosmic-client-toolkit", "cosmic-protocols", - "freedesktop-desktop-entry 0.6.2", + "freedesktop-desktop-entry 0.7.5", "futures", "i18n-embed 0.14.1", "i18n-embed-fl 0.8.0", @@ -1313,7 +1313,7 @@ name = "cosmic-panel-button" version = "0.1.0" dependencies = [ "cosmic-config", - "freedesktop-desktop-entry 0.6.2", + "freedesktop-desktop-entry 0.7.5", "libcosmic", "serde", "tracing", @@ -2268,9 +2268,9 @@ dependencies = [ [[package]] name = "freedesktop-desktop-entry" -version = "0.6.2" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33809936d2fa9ac78750c5c04696a7aabdb09f928454957c77a2c8247f5ff98" +checksum = "d83c9c25bc7e0ff18c6fee324db310497622be235fd45c0f7347ab81981a941e" dependencies = [ "dirs 5.0.1", "gettext-rs", diff --git a/Cargo.toml b/Cargo.toml index 7ead905e..78ff46b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,7 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } tracing-log = "0.2.0" cosmic-config = { git = "https://github.com/pop-os/libcosmic" } serde = { version = "1.0.152", features = ["derive"] } -freedesktop-desktop-entry = "0.6.1" +freedesktop-desktop-entry = "0.7.5" [profile.release] lto = "fat" diff --git a/cosmic-app-list/src/app.rs b/cosmic-app-list/src/app.rs index 4756a270..919dc901 100755 --- a/cosmic-app-list/src/app.rs +++ b/cosmic-app-list/src/app.rs @@ -588,24 +588,15 @@ where I: AsRef, L: AsRef, { - let srcs = fde::Iter::new(fde::default_paths()) - .filter_map(|p| fs::read_to_string(&p).ok().and_then(|e| Some((p, e)))) - .collect::>(); - - let entries = srcs - .iter() - .filter_map(|(p, data)| DesktopEntry::from_str(p, data, locales).ok()) + let entries = fde::Iter::new(fde::default_paths()) + .entries(Some(locales)) .collect::>(); ids.iter() .map(|id| { - fde::matching::get_best_match( - &[id], - &entries, - fde::matching::MatchAppIdOptions::default(), - ) - .unwrap_or(&fde::DesktopEntry::from_appid(id.as_ref())) - .to_owned() + fde::matching::find_entry_from_appid(entries.iter(), id.as_ref()) + .unwrap_or(&fde::DesktopEntry::from_appid(id.as_ref())) + .to_owned() }) .collect_vec() } @@ -1006,7 +997,7 @@ impl cosmic::Application for CosmicAppList { } Message::DndData(file_path) => { if let Some(DndOffer { dock_item, .. }) = self.dnd_offer.as_mut() { - if let Ok(de) = fde::DesktopEntry::from_path(file_path, &self.locales) { + if let Ok(de) = fde::DesktopEntry::from_path(file_path, Some(&self.locales)) { self.item_ctr += 1; *dock_item = Some(DockItem { id: self.item_ctr, diff --git a/cosmic-panel-button/Cargo.toml b/cosmic-panel-button/Cargo.toml index 4e759b48..8f49828d 100644 --- a/cosmic-panel-button/Cargo.toml +++ b/cosmic-panel-button/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "GPL-3.0" [dependencies] -freedesktop-desktop-entry = "0.6.2" +freedesktop-desktop-entry.workspace = true libcosmic.workspace = true tracing-log.workspace = true tracing-subscriber.workspace = true diff --git a/cosmic-panel-button/src/main.rs b/cosmic-panel-button/src/main.rs index bd5b9ed7..9ca43fa4 100644 --- a/cosmic-panel-button/src/main.rs +++ b/cosmic-panel-button/src/main.rs @@ -154,10 +154,11 @@ pub fn main() -> iced::Result { let filename = format!("{id}.desktop"); let mut desktop = None; let locales = get_languages_from_env(); + for mut path in freedesktop_desktop_entry::default_paths() { path.push(&filename); if let Ok(bytes) = fs::read_to_string(&path) { - if let Ok(entry) = DesktopEntry::from_str(&path, &bytes, &locales) { + if let Ok(entry) = DesktopEntry::from_str(&path, &bytes, Some(&locales)) { desktop = Some(Desktop { name: entry .name(&locales)