Move implementations from example to libcosmic

This commit is contained in:
Jeremy Soller 2022-09-30 09:35:55 -06:00
parent 699e474427
commit 5ad54bd3b1
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE
13 changed files with 162 additions and 122 deletions

18
src/widget/icon.rs Normal file
View file

@ -0,0 +1,18 @@
use iced::widget::svg;
pub fn icon(name: &str, size: u16) -> svg::Svg {
let handle = match freedesktop_icons::lookup(name)
.with_size(size)
.with_theme("Pop")
.with_cache()
.force_svg()
.find()
{
Some(path) => svg::Handle::from_path(path),
None => {
eprintln!("icon '{}' size {} not found", name, size);
svg::Handle::from_memory(Vec::new())
},
};
svg::Svg::new(handle)
}