[nautilus/wip/antoniof/hidpi-and-icons-cleanup: 5/11] icon-info: Add HiDPI support for custom icons too
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/hidpi-and-icons-cleanup: 5/11] icon-info: Add HiDPI support for custom icons too
- Date: Thu, 1 Sep 2022 08:53:41 +0000 (UTC)
commit 50f863a3266ac0fd680a5300baebcdc9dc3afdaf
Author: António Fernandes <antoniof gnome org>
Date: Mon Aug 8 00:38:58 2022 +0100
icon-info: Add HiDPI support for custom icons too
The properties dialog provides the ability to set a custom icon.
These are not icon paintables, but rather loadable icons, just
like thumbnails are. Therefore, they need to be snapshot into
the real area too, otherwise they are going to be too large.
src/nautilus-icon-info.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/src/nautilus-icon-info.c b/src/nautilus-icon-info.c
index b5754518c..c6b1e9a92 100644
--- a/src/nautilus-icon-info.c
+++ b/src/nautilus-icon-info.c
@@ -337,7 +337,7 @@ nautilus_icon_info_lookup (GIcon *icon,
if (G_IS_LOADABLE_ICON (icon))
{
g_autoptr (GdkPixbuf) pixbuf = NULL;
- g_autoptr (GdkTexture) texture = NULL;
+ g_autoptr (GdkPaintable) paintable = NULL;
LoadableIconKey lookup_key;
LoadableIconKey *key;
GInputStream *stream;
@@ -376,10 +376,18 @@ nautilus_icon_info_lookup (GIcon *icon,
if (pixbuf != NULL)
{
- texture = gdk_texture_new_for_pixbuf (pixbuf);
+ double width = gdk_pixbuf_get_width (pixbuf) / scale;
+ double height = gdk_pixbuf_get_height (pixbuf) / scale;
+ g_autoptr (GdkTexture) texture = gdk_texture_new_for_pixbuf (pixbuf);
+ g_autoptr (GtkSnapshot) snapshot = gtk_snapshot_new ();
+
+ gdk_paintable_snapshot (GDK_PAINTABLE (texture),
+ GDK_SNAPSHOT (snapshot),
+ width, height);
+ paintable = gtk_snapshot_to_paintable (snapshot, NULL);
}
- icon_info = nautilus_icon_info_new_for_paintable (GDK_PAINTABLE (texture), scale);
+ icon_info = nautilus_icon_info_new_for_paintable (paintable, scale);
key = loadable_icon_key_new (icon, scale, size);
g_hash_table_insert (loadable_icon_cache, key, icon_info);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]