fix(status-area): add fallback for icon lookup by name

This commit is contained in:
Michael Aaron Murphy 2026-01-13 18:32:11 +01:00 committed by Ashley Wulber
parent 290439b9b9
commit 6ab2aeca2b

View file

@ -6,7 +6,7 @@ use cosmic::{
applet::{menu_button, token::subscription::TokenRequest}, applet::{menu_button, token::subscription::TokenRequest},
cctk::sctk::reexports::calloop, cctk::sctk::reexports::calloop,
iced, iced,
widget::icon, widget::icon::{self, IconFallback},
}; };
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
@ -89,15 +89,19 @@ impl State {
} }
} }
// If the defined icon is a path, load the icon by path. // Load icon by path if the name is a path.
if Path::new(&icon_name).exists() { self.icon_handle = if Path::new(&icon_name).exists() {
self.icon_handle = icon::from_path(Path::new(&icon_name).to_path_buf()).symbolic(true)
icon::from_path(Path::new(&icon_name).to_path_buf()).symbolic(true); } else {
return iced::Task::none(); icon::from_name(icon_name)
} .prefer_svg(true)
.fallback(Some(IconFallback::Names(vec![
"application-default".into(),
"application-x-executable".into(),
])))
.handle()
};
// Load the icon by name from a system icon theme.
self.icon_handle = icon::from_name(icon_name).prefer_svg(true).handle();
iced::Task::none() iced::Task::none()
} }
Msg::Click(id, is_submenu) => { Msg::Click(id, is_submenu) => {