diff options
| author | Peter Eisenmann <p3732@disroot.org> | 2025-01-31 06:16:26 +0000 |
|---|---|---|
| committer | Peter Eisenmann <p3732@getgoogleoff.me> | 2025-01-31 06:16:26 +0000 |
| commit | b1ef3d8de7907f85c3e3ff0907aa5e268e5da7c5 (patch) | |
| tree | 4c3b709c6097bca928b84166813cd4fdd010c855 | |
| parent | 36e7353ca94986093c653f466c98cd01cb834571 (diff) | |
thumbnail: Split thumbnail scale calculation into a functioncherry-pick-a940f71b
(cherry picked from commit 3bb125b0c1672c18395cf3e2ea90737a4e3b876f)
(cherry picked from commit a940f71b8e78780eb46c233892f8684236375c02)
Co-authored-by: Khalid Abu Shawarib <khalid.shawarib@gmail.com>
| -rw-r--r-- | src/nautilus-thumbnails.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/nautilus-thumbnails.c b/src/nautilus-thumbnails.c index 9be632fca..d81d704da 100644 --- a/src/nautilus-thumbnails.c +++ b/src/nautilus-thumbnails.c @@ -127,17 +127,17 @@ free_thumbnail_info (NautilusThumbnailInfo *info) g_free (info); } -static GnomeDesktopThumbnailFactory * -get_thumbnail_factory (void) +static GnomeDesktopThumbnailSize +get_thumbnail_scale (void) { - static GnomeDesktopThumbnailFactory *thumbnail_factory = NULL; + static gint max_scale = 0; + static GnomeDesktopThumbnailSize size; - if (G_UNLIKELY (thumbnail_factory == NULL)) + if (G_UNLIKELY (max_scale == 0)) { GdkDisplay *display = gdk_display_get_default (); GListModel *monitors = gdk_display_get_monitors (display); - gint max_scale = 1; - GnomeDesktopThumbnailSize size; + max_scale = 1; for (guint i = 0; i < g_list_model_get_n_items (monitors); i++) { @@ -158,6 +158,19 @@ get_thumbnail_factory (void) { size = GNOME_DESKTOP_THUMBNAIL_SIZE_XXLARGE; } + } + + return size; +} + +static GnomeDesktopThumbnailFactory * +get_thumbnail_factory (void) +{ + static GnomeDesktopThumbnailFactory *thumbnail_factory = NULL; + + if (G_UNLIKELY (thumbnail_factory == NULL)) + { + GnomeDesktopThumbnailSize size = get_thumbnail_scale (); thumbnail_factory = gnome_desktop_thumbnail_factory_new (size); } |
