widget/icon: Bundle icons on macOS, not just Windows

This commit is contained in:
Ian Douglas Scott 2026-04-14 11:53:33 -07:00 committed by Michael Murphy
parent 0d69cd9183
commit 46d9f0c344
4 changed files with 10 additions and 8 deletions

View file

@ -170,12 +170,12 @@ cosmic-config = { path = "cosmic-config", features = ["dbus"] }
cosmic-settings-daemon = { git = "https://github.com/pop-os/dbus-settings-bindings" }
zbus = { version = "5.14.0", default-features = false }
[target.'cfg(unix)'.dependencies]
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
freedesktop-icons = { package = "cosmic-freedesktop-icons", git = "https://github.com/pop-os/freedesktop-icons" }
freedesktop-desktop-entry = { version = "0.8.1", optional = true }
shlex = { version = "1.3.0", optional = true }
[target.'cfg(not(unix))'.dependencies]
[target.'cfg(any(not(unix), target_os = "macos"))'.dependencies]
# Used to embed bundled icons for non-unix platforms.
phf = { version = "0.13.1", features = ["macros"] }

View file

@ -3,7 +3,9 @@ use std::env;
fn main() {
println!("cargo::rerun-if-changed=build.rs");
if env::var_os("CARGO_CFG_UNIX").is_none() {
if env::var_os("CARGO_CFG_UNIX").is_none()
|| env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("macos")
{
generate_bundled_icons();
}
}

View file

@ -4,12 +4,12 @@
//! Embedded icons for platforms which do not support icon themes yet.
/// Icon bundling is not enabled on unix platforms.
#[cfg(unix)]
#[cfg(all(unix, not(target_os = "macos")))]
pub fn get(icon_name: &str) -> Option<super::Data> {
None
}
#[cfg(not(unix))]
#[cfg(any(not(unix), target_os = "macos"))]
/// Get a bundled icon on non-unix platforms.
pub fn get(icon_name: &str) -> Option<super::Data> {
ICONS
@ -17,5 +17,5 @@ pub fn get(icon_name: &str) -> Option<super::Data> {
.map(|bytes| super::Data::Svg(crate::iced::widget::svg::Handle::from_memory(*bytes)))
}
#[cfg(not(unix))]
#[cfg(any(not(unix), target_os = "macos"))]
include!(concat!(env!("OUT_DIR"), "/bundled_icons.rs"));

View file

@ -52,7 +52,7 @@ impl Named {
}
}
#[cfg(not(windows))]
#[cfg(all(unix, not(target_os = "macos")))]
#[must_use]
pub fn path(self) -> Option<PathBuf> {
let name = &*self.name;
@ -107,7 +107,7 @@ impl Named {
result
}
#[cfg(windows)]
#[cfg(any(not(unix), target_os = "macos"))]
#[must_use]
pub fn path(self) -> Option<PathBuf> {
//TODO: implement icon lookup for Windows