From 8fa6a01d049905ce99eb9adf8415b2fa73611818 Mon Sep 17 00:00:00 2001 From: Hojjat Date: Mon, 18 May 2026 13:49:14 -0600 Subject: [PATCH] feat: add ability to provide extra paths to search for icons --- src/widget/icon/named.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/widget/icon/named.rs b/src/widget/icon/named.rs index c6bec75..8905030 100644 --- a/src/widget/icon/named.rs +++ b/src/widget/icon/named.rs @@ -39,6 +39,10 @@ pub struct Named { /// Prioritizes SVG over PNG pub prefer_svg: bool, + + /// Extra directories to search as flat paths before the icon theme chain. + #[setters(skip)] + pub extra_paths: Vec, } impl Named { @@ -52,19 +56,30 @@ impl Named { size: None, scale: None, prefer_svg: symbolic, + extra_paths: Vec::new(), } } + pub fn with_extra_paths(mut self, paths: Vec) -> Self { + self.extra_paths = paths; + self + } + #[cfg(all(unix, not(target_os = "macos")))] #[must_use] pub fn path(self) -> Option { let name = &*self.name; let fallback = &self.fallback; + let extra_paths = &self.extra_paths; let locate = |theme: &str, name| { let mut lookup = freedesktop_icons::lookup(name) .with_theme(theme.as_ref()) .with_cache(); + if !extra_paths.is_empty() { + lookup = lookup.with_extra_paths(extra_paths); + } + if let Some(scale) = self.scale { lookup = lookup.with_scale(scale); }