fix(status-area): add fallback for icon lookup by name
This commit is contained in:
parent
290439b9b9
commit
6ab2aeca2b
1 changed files with 13 additions and 9 deletions
|
|
@ -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) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue