staus-area: Initial support to use IconThemePath for icon loading

We should use a more complicated method to lookup the icon from the
theme, but `cosmic-freedesktop-icons` will need some changes to be able
to accomodate a custom theme path.

This is probably an improvement. Anything that uses `IconThemePath`
is likely not working currently, so it won't make things worse.
This commit is contained in:
Ian Douglas Scott 2025-11-04 12:55:59 -08:00 committed by Jacob Kauffmann
parent 080f07e0b4
commit d04314957b
2 changed files with 17 additions and 4 deletions

View file

@ -8,6 +8,7 @@ use cosmic::{
iced,
widget::icon,
};
use std::path::{Path, PathBuf};
use crate::subscriptions::status_notifier_item::{IconUpdate, Layout, StatusNotifierItem};
@ -26,6 +27,7 @@ pub struct State {
icon_name: String,
// TODO handle icon with multiple sizes?
icon_pixmap: Option<icon::Handle>,
icon_theme_path: Option<PathBuf>,
click_event: Option<(i32, bool)>,
}
@ -38,6 +40,7 @@ impl State {
expanded: None,
icon_name: String::new(),
icon_pixmap: None,
icon_theme_path: None,
click_event: None,
},
iced::Task::none(),
@ -78,6 +81,7 @@ impl State {
}
icon::from_raster_pixels(i.width as u32, i.height as u32, i.bytes)
}));
self.icon_theme_path = update.theme_path;
iced::Task::none()
}
@ -138,6 +142,10 @@ impl State {
self.icon_pixmap.as_ref()
}
pub fn icon_theme_path(&self) -> Option<&Path> {
self.icon_theme_path.as_deref()
}
pub fn popup_view(&self) -> cosmic::Element<'_, Msg> {
if let Some(layout) = self.layout.as_ref() {
layout_view(layout, self.expanded)