diff --git a/cosmic-applet-status-area/src/components/status_menu.rs b/cosmic-applet-status-area/src/components/status_menu.rs index 0ab1f317..6aa0953c 100644 --- a/cosmic-applet-status-area/src/components/status_menu.rs +++ b/cosmic-applet-status-area/src/components/status_menu.rs @@ -26,6 +26,7 @@ pub struct State { expanded: Option, // TODO handle icon with multiple sizes? icon_handle: icon::Handle, + icon_theme_path: Option, click_event: Option<(i32, bool)>, } @@ -39,6 +40,7 @@ impl State { icon_handle: icon::from_name("application-default") .prefer_svg(true) .handle(), + icon_theme_path: None, click_event: None, }, iced::Task::none(), @@ -63,6 +65,7 @@ impl State { } Msg::Icon(update) => { let icon_name = update.name.unwrap_or_default(); + self.icon_theme_path = update.theme_path; // Use the icon pixmap if an icon was not defined by name. if icon_name.is_empty() { @@ -93,13 +96,18 @@ impl State { self.icon_handle = if Path::new(&icon_name).exists() { icon::from_path(Path::new(&icon_name).to_path_buf()).symbolic(true) } else { - icon::from_name(icon_name) - .prefer_svg(true) - .fallback(Some(IconFallback::Names(vec![ + let mut builder = icon::from_name(icon_name).prefer_svg(true).fallback(Some( + IconFallback::Names(vec![ "application-default".into(), "application-x-executable".into(), - ]))) - .handle() + ]), + )); + + if let Some(ref theme_path) = self.icon_theme_path { + builder = builder.with_extra_paths(vec![theme_path.clone()]); + } + + builder.handle() }; iced::Task::none() diff --git a/cosmic-applet-status-area/src/subscriptions/status_notifier_item.rs b/cosmic-applet-status-area/src/subscriptions/status_notifier_item.rs index fd51390e..c03f0f54 100644 --- a/cosmic-applet-status-area/src/subscriptions/status_notifier_item.rs +++ b/cosmic-applet-status-area/src/subscriptions/status_notifier_item.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-3.0-only use std::hash::Hash; +use std::path::PathBuf; use cosmic::iced::{self, Subscription}; use futures::{FutureExt, StreamExt}; @@ -27,7 +28,7 @@ pub struct Icon { pub struct IconUpdate { pub name: Option, pub pixmap: Option>, - // pub theme_path: Option, + pub theme_path: Option, } impl StatusNotifierItem { @@ -118,11 +119,11 @@ impl StatusNotifierItem { async fn icon_events(item_proxy: StatusNotifierItemProxy<'static>) -> IconUpdate { let icon_name = item_proxy.icon_name().await; let icon_pixmap = item_proxy.icon_pixmap().await; - // let icon_theme_path = item_proxy.icon_theme_path().await.map(PathBuf::from); + let icon_theme_path = item_proxy.icon_theme_path().await.map(PathBuf::from); IconUpdate { name: icon_name.ok(), pixmap: icon_pixmap.ok(), - // theme_path: icon_theme_path.ok().filter(|x| !x.as_os_str().is_empty()), + theme_path: icon_theme_path.ok().filter(|x| !x.as_os_str().is_empty()), } }