mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-04-19 19:34:24 +02:00
fix(image): not scaling icons for hidpi
This commit is contained in:
parent
20949a7744
commit
db0868a3fc
1 changed files with 9 additions and 6 deletions
|
@ -143,7 +143,9 @@ impl<'a> ImageProvider<'a> {
|
|||
|
||||
fn load_into_image_sync(&self, image: >k::Image) -> Result<()> {
|
||||
let pixbuf = match &self.location {
|
||||
ImageLocation::Icon { name, theme } => self.get_from_icon(name, theme),
|
||||
ImageLocation::Icon { name, theme } => {
|
||||
self.get_from_icon(name, theme, image.scale_factor())
|
||||
}
|
||||
ImageLocation::Local(path) => self.get_from_file(path),
|
||||
ImageLocation::Steam(steam_id) => self.get_from_steam_id(steam_id),
|
||||
#[cfg(feature = "http")]
|
||||
|
@ -156,11 +158,12 @@ impl<'a> ImageProvider<'a> {
|
|||
}
|
||||
|
||||
/// Attempts to get a `Pixbuf` from the GTK icon theme.
|
||||
fn get_from_icon(&self, name: &str, theme: &IconTheme) -> Result<Pixbuf> {
|
||||
let pixbuf = match theme.lookup_icon(name, self.size, IconLookupFlags::empty()) {
|
||||
Some(_) => theme.load_icon(name, self.size, IconLookupFlags::FORCE_SIZE),
|
||||
None => Ok(None),
|
||||
}?;
|
||||
fn get_from_icon(&self, name: &str, theme: &IconTheme, scale: i32) -> Result<Pixbuf> {
|
||||
let pixbuf =
|
||||
match theme.lookup_icon_for_scale(name, self.size, scale, IconLookupFlags::empty()) {
|
||||
Some(_) => theme.load_icon(name, self.size, IconLookupFlags::FORCE_SIZE),
|
||||
None => Ok(None),
|
||||
}?;
|
||||
|
||||
pixbuf.map_or_else(
|
||||
|| Err(Report::msg("Icon theme does not contain icon '{name}'")),
|
||||
|
|
Loading…
Add table
Reference in a new issue