From b2ce4ccea2b0e4c8aa6ee319d1cb580856fcea5a Mon Sep 17 00:00:00 2001 From: Eduardo Flores Date: Thu, 26 Dec 2024 12:14:41 +0100 Subject: [PATCH] fix: add cfg for unix only packages --- src/desktop.rs | 20 +++++++++++++++----- src/lib.rs | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/desktop.rs b/src/desktop.rs index 21b50aca340..c8a7ab9e9d7 100644 --- a/src/desktop.rs +++ b/src/desktop.rs @@ -1,10 +1,10 @@ +#[cfg(not(windows))] pub use freedesktop_desktop_entry::DesktopEntry; +#[cfg(not(windows))] pub use mime::Mime; -use std::{ - borrow::Cow, - ffi::OsStr, - path::{Path, PathBuf}, -}; +use std::path::{Path, PathBuf}; +#[cfg(not(windows))] +use std::{borrow::Cow, ffi::OsStr}; #[derive(Debug, Clone, PartialEq, Eq)] pub enum IconSource { @@ -42,12 +42,14 @@ impl Default for IconSource { } } +#[cfg(not(windows))] #[derive(Debug, Clone, PartialEq)] pub struct DesktopAction { pub name: String, pub exec: String, } +#[cfg(not(windows))] #[derive(Debug, Clone, PartialEq, Default)] pub struct DesktopEntryData { pub id: String, @@ -62,6 +64,7 @@ pub struct DesktopEntryData { pub prefers_dgpu: bool, } +#[cfg(not(windows))] pub fn load_applications<'a>( locale: impl Into>, include_no_display: bool, @@ -69,6 +72,7 @@ pub fn load_applications<'a>( load_applications_filtered(locale, |de| include_no_display || !de.no_display()) } +#[cfg(not(windows))] pub fn app_id_or_fallback_matches(app_id: &str, entry: &DesktopEntryData) -> bool { let lowercase_wm_class = match entry.wm_class.as_ref() { Some(s) => Some(s.to_lowercase()), @@ -80,6 +84,7 @@ pub fn app_id_or_fallback_matches(app_id: &str, entry: &DesktopEntryData) -> boo || app_id.to_lowercase() == entry.name.to_lowercase() } +#[cfg(not(windows))] pub fn load_applications_for_app_ids<'a, 'b>( locale: impl Into>, app_ids: impl Iterator, @@ -123,6 +128,7 @@ pub fn load_applications_for_app_ids<'a, 'b>( applications } +#[cfg(not(windows))] pub fn load_applications_filtered<'a, F: FnMut(&DesktopEntry) -> bool>( locale: impl Into>, mut filter: F, @@ -148,6 +154,7 @@ pub fn load_applications_filtered<'a, F: FnMut(&DesktopEntry) -> bool>( .collect() } +#[cfg(not(windows))] pub fn load_desktop_file<'a>( locale: impl Into>, path: impl AsRef, @@ -160,6 +167,7 @@ pub fn load_desktop_file<'a>( }) } +#[cfg(not(windows))] impl DesktopEntryData { fn from_desktop_entry<'a>( locale: impl Into>, @@ -229,6 +237,7 @@ impl DesktopEntryData { } } +#[cfg(not(windows))] pub async fn spawn_desktop_exec(exec: S, env_vars: I, app_id: Option<&str>) where S: AsRef, @@ -293,6 +302,7 @@ where } } +#[cfg(not(windows))] #[cfg(feature = "desktop-systemd-scope")] #[zbus::proxy( interface = "org.freedesktop.systemd1.Manager", diff --git a/src/lib.rs b/src/lib.rs index 886ae55939e..3e583d131fa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -75,7 +75,7 @@ pub mod keyboard_nav; #[cfg(feature = "desktop")] pub mod desktop; -#[cfg(feature = "process")] +#[cfg(all(feature = "process", not(windows)))] pub mod process; #[cfg(feature = "wayland")]