Skip to content

Commit

Permalink
fix: add cfg for unix only packages
Browse files Browse the repository at this point in the history
  • Loading branch information
edfloreshz authored and mmstick committed Dec 26, 2024
1 parent 58fc034 commit b2ce4cc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions src/desktop.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -62,13 +64,15 @@ pub struct DesktopEntryData {
pub prefers_dgpu: bool,
}

#[cfg(not(windows))]
pub fn load_applications<'a>(
locale: impl Into<Option<&'a str>>,
include_no_display: bool,
) -> Vec<DesktopEntryData> {
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()),
Expand All @@ -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<Option<&'a str>>,
app_ids: impl Iterator<Item = &'b str>,
Expand Down Expand Up @@ -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<Option<&'a str>>,
mut filter: F,
Expand All @@ -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<Option<&'a str>>,
path: impl AsRef<Path>,
Expand All @@ -160,6 +167,7 @@ pub fn load_desktop_file<'a>(
})
}

#[cfg(not(windows))]
impl DesktopEntryData {
fn from_desktop_entry<'a>(
locale: impl Into<Option<&'a str>>,
Expand Down Expand Up @@ -229,6 +237,7 @@ impl DesktopEntryData {
}
}

#[cfg(not(windows))]
pub async fn spawn_desktop_exec<S, I, K, V>(exec: S, env_vars: I, app_id: Option<&str>)
where
S: AsRef<str>,
Expand Down Expand Up @@ -293,6 +302,7 @@ where
}
}

#[cfg(not(windows))]
#[cfg(feature = "desktop-systemd-scope")]
#[zbus::proxy(
interface = "org.freedesktop.systemd1.Manager",
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down

0 comments on commit b2ce4cc

Please sign in to comment.