diff --git a/examples/cosmic-sctk/src/window.rs b/examples/cosmic-sctk/src/window.rs index 3951ee8..d913f78 100644 --- a/examples/cosmic-sctk/src/window.rs +++ b/examples/cosmic-sctk/src/window.rs @@ -1,4 +1,4 @@ -use cosmic::widget::{expander, nav_bar, nav_bar_page, nav_bar_section}; +use cosmic::widget::{expander, nav_bar, nav_bar_page, nav_bar_section, image_icon}; use cosmic::{ iced::widget::{ checkbox, column, container, horizontal_space, pick_list, progress_bar, radio, row, slider, @@ -314,6 +314,7 @@ impl Application for Window { ]) .render() ), + list_view_section!("image", image_icon("firefox", 64).unwrap()) ) .into(); @@ -356,8 +357,4 @@ impl Application for Window { fn theme(&self) -> Theme { self.theme } - - fn subscription(&self) -> iced_sctk::Subscription { - Subscription::none() - } } diff --git a/src/widget/icon.rs b/src/widget/icon.rs index 92399ab..01f89d8 100644 --- a/src/widget/icon.rs +++ b/src/widget/icon.rs @@ -1,4 +1,4 @@ -use iced::{widget::svg, Length}; +use iced::{widget::{svg, Image}, Length}; pub fn icon(name: &str, size: u16) -> svg::Svg where @@ -22,3 +22,12 @@ where .width(Length::Units(size)) .height(Length::Units(size)) } + +pub fn image_icon(name: &str, size: u16) -> Option +{ + freedesktop_icons::lookup(name) + .with_size(size) + .with_cache() + .find().map(|path| Image::new(path).width(Length::Units(size)) + .height(Length::Units(size))) +}