image icon
This commit is contained in:
parent
6f17328eb1
commit
3850def414
2 changed files with 12 additions and 6 deletions
|
|
@ -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::{
|
use cosmic::{
|
||||||
iced::widget::{
|
iced::widget::{
|
||||||
checkbox, column, container, horizontal_space, pick_list, progress_bar, radio, row, slider,
|
checkbox, column, container, horizontal_space, pick_list, progress_bar, radio, row, slider,
|
||||||
|
|
@ -314,6 +314,7 @@ impl Application for Window {
|
||||||
])
|
])
|
||||||
.render()
|
.render()
|
||||||
),
|
),
|
||||||
|
list_view_section!("image", image_icon("firefox", 64).unwrap())
|
||||||
)
|
)
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
|
|
@ -356,8 +357,4 @@ impl Application for Window {
|
||||||
fn theme(&self) -> Theme {
|
fn theme(&self) -> Theme {
|
||||||
self.theme
|
self.theme
|
||||||
}
|
}
|
||||||
|
|
||||||
fn subscription(&self) -> iced_sctk::Subscription<Self::Message> {
|
|
||||||
Subscription::none()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use iced::{widget::svg, Length};
|
use iced::{widget::{svg, Image}, Length};
|
||||||
|
|
||||||
pub fn icon<Renderer>(name: &str, size: u16) -> svg::Svg<Renderer>
|
pub fn icon<Renderer>(name: &str, size: u16) -> svg::Svg<Renderer>
|
||||||
where
|
where
|
||||||
|
|
@ -22,3 +22,12 @@ where
|
||||||
.width(Length::Units(size))
|
.width(Length::Units(size))
|
||||||
.height(Length::Units(size))
|
.height(Length::Units(size))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn image_icon(name: &str, size: u16) -> Option<Image>
|
||||||
|
{
|
||||||
|
freedesktop_icons::lookup(name)
|
||||||
|
.with_size(size)
|
||||||
|
.with_cache()
|
||||||
|
.find().map(|path| Image::new(path).width(Length::Units(size))
|
||||||
|
.height(Length::Units(size)))
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue