mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-01 18:51:04 +02:00
Merge pull request #121 from JakeStanger/fix/icon-scale
fix(image): not scaling images for hidpi
This commit is contained in:
commit
03cd263095
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<()> {
|
fn load_into_image_sync(&self, image: >k::Image) -> Result<()> {
|
||||||
let pixbuf = match &self.location {
|
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::Local(path) => self.get_from_file(path),
|
||||||
ImageLocation::Steam(steam_id) => self.get_from_steam_id(steam_id),
|
ImageLocation::Steam(steam_id) => self.get_from_steam_id(steam_id),
|
||||||
#[cfg(feature = "http")]
|
#[cfg(feature = "http")]
|
||||||
|
@ -156,11 +158,12 @@ impl<'a> ImageProvider<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to get a `Pixbuf` from the GTK icon theme.
|
/// Attempts to get a `Pixbuf` from the GTK icon theme.
|
||||||
fn get_from_icon(&self, name: &str, theme: &IconTheme) -> Result<Pixbuf> {
|
fn get_from_icon(&self, name: &str, theme: &IconTheme, scale: i32) -> Result<Pixbuf> {
|
||||||
let pixbuf = match theme.lookup_icon(name, self.size, IconLookupFlags::empty()) {
|
let pixbuf =
|
||||||
Some(_) => theme.load_icon(name, self.size, IconLookupFlags::FORCE_SIZE),
|
match theme.lookup_icon_for_scale(name, self.size, scale, IconLookupFlags::empty()) {
|
||||||
None => Ok(None),
|
Some(_) => theme.load_icon(name, self.size, IconLookupFlags::FORCE_SIZE),
|
||||||
}?;
|
None => Ok(None),
|
||||||
|
}?;
|
||||||
|
|
||||||
pixbuf.map_or_else(
|
pixbuf.map_or_else(
|
||||||
|| Err(Report::msg("Icon theme does not contain icon '{name}'")),
|
|| Err(Report::msg("Icon theme does not contain icon '{name}'")),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue