[nautilus/wip/antoniof/hidpi-and-icons-cleanup: 4/11] general: Support HiDPI icons again
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/hidpi-and-icons-cleanup: 4/11] general: Support HiDPI icons again
- Date: Thu, 1 Sep 2022 08:53:41 +0000 (UTC)
commit 09ae899e2606b500b2530bf8aea563127e903167
Author: António Fernandes <antoniof gnome org>
Date: Mon Aug 8 00:23:22 2022 +0100
general: Support HiDPI icons again
This brings back a feature originally introduced by commit 0d4555d76f86ba2d49f48836b7eea11f1adfb2fd
Back then, it used gdk_cairo_surface_create_from_pixbuf() to apply the
scaling factor, but in GTK 4 we can no longer consume cairo surfaces
directly. Instead, we are to use paintables.
For themed icons we already use GtkIconPaintable, which just works.
src/nautilus-grid-cell.c | 4 +++-
src/nautilus-name-cell.c | 4 +++-
src/nautilus-properties-window.c | 2 --
3 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/src/nautilus-grid-cell.c b/src/nautilus-grid-cell.c
index 2e7538d76..bf19a36a1 100644
--- a/src/nautilus-grid-cell.c
+++ b/src/nautilus-grid-cell.c
@@ -34,15 +34,17 @@ update_icon (NautilusGridCell *self)
GtkStyleContext *style_context;
NautilusFile *file;
guint icon_size;
+ gint scale_factor;
g_autofree gchar *thumbnail_path = NULL;
item = nautilus_view_cell_get_item (NAUTILUS_VIEW_CELL (self));
g_return_if_fail (item != NULL);
file = nautilus_view_item_get_file (item);
icon_size = nautilus_view_item_get_icon_size (item);
+ scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (self));
flags = NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS;
- icon_paintable = nautilus_file_get_icon_paintable (file, icon_size, 1, flags);
+ icon_paintable = nautilus_file_get_icon_paintable (file, icon_size, scale_factor, flags);
gtk_picture_set_paintable (GTK_PICTURE (self->icon), icon_paintable);
/* Set the same height and width for all icons regardless of aspect ratio.
diff --git a/src/nautilus-name-cell.c b/src/nautilus-name-cell.c
index bab99561b..a58415f9e 100644
--- a/src/nautilus-name-cell.c
+++ b/src/nautilus-name-cell.c
@@ -128,6 +128,7 @@ update_icon (NautilusNameCell *self)
NautilusViewItem *item;
NautilusFile *file;
guint icon_size;
+ gint scale_factor;
int icon_height;
int extra_margin;
g_autofree gchar *thumbnail_path = NULL;
@@ -137,9 +138,10 @@ update_icon (NautilusNameCell *self)
file = nautilus_view_item_get_file (item);
icon_size = nautilus_view_item_get_icon_size (item);
+ scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (self));
flags = NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS;
- icon_paintable = nautilus_file_get_icon_paintable (file, icon_size, 1, flags);
+ icon_paintable = nautilus_file_get_icon_paintable (file, icon_size, scale_factor, flags);
gtk_picture_set_paintable (GTK_PICTURE (self->icon), icon_paintable);
/* Set the same width for all icons regardless of aspect ratio.
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index cfa500259..a2d5cc206 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -564,8 +564,6 @@ get_image_for_properties_window (NautilusPropertiesWindow *self,
gint icon_scale;
icon_scale = gtk_widget_get_scale_factor (GTK_WIDGET (self));
- /* FIXME: Temporary regression: HiDPI icons not supported, ignore scale. */
- icon_scale = 1;
for (l = self->original_files; l != NULL; l = l->next)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]