[nautilus/wip/corey/thumbnail-large: 1/2] thumbnails: Store the desired thumbnail size




commit 3d9844af9ab304c9bc8cd1cc6eb03f2348d70c4c
Author: Corey Berla <corey berla me>
Date:   Thu Sep 29 14:27:37 2022 -0700

    thumbnails: Store the desired thumbnail size
    
    When we create the thumbnail factory, we set a size, let's make sure
    we use that same size when we retrieve the thumbnails.

 src/nautilus-thumbnails.c | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)
---
diff --git a/src/nautilus-thumbnails.c b/src/nautilus-thumbnails.c
index 790b4e36f..8515844a7 100644
--- a/src/nautilus-thumbnails.c
+++ b/src/nautilus-thumbnails.c
@@ -94,6 +94,8 @@ static GHashTable *thumbnails_to_make_hash = NULL;
  * to avoid adding it again. Lock thumbnails_mutex when accessing this. */
 static NautilusThumbnailInfo *currently_thumbnailing = NULL;
 
+static GnomeDesktopThumbnailSize thumbnail_size = -1;
+
 static gboolean
 get_file_mtime (const char *file_uri,
                 time_t     *mtime)
@@ -140,29 +142,31 @@ get_thumbnail_factory (void)
         GdkDisplay *display = gdk_display_get_default ();
         GListModel *monitors = gdk_display_get_monitors (display);
         gint max_scale = 1;
-        GnomeDesktopThumbnailSize size;
 
-        for (guint i = 0; i < g_list_model_get_n_items (monitors); i++)
+        if (thumbnail_size == -1)
         {
-            g_autoptr (GdkMonitor) monitor = g_list_model_get_item (monitors, i);
+            for (guint i = 0; i < g_list_model_get_n_items (monitors); i++)
+            {
+                g_autoptr (GdkMonitor) monitor = g_list_model_get_item (monitors, i);
 
-            max_scale = MAX (max_scale, gdk_monitor_get_scale_factor (monitor));
-        }
+                max_scale = MAX (max_scale, gdk_monitor_get_scale_factor (monitor));
+            }
 
-        if (max_scale <= 1)
-        {
-            size = GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE;
-        }
-        else if (max_scale <= 2)
-        {
-            size = GNOME_DESKTOP_THUMBNAIL_SIZE_XLARGE;
-        }
-        else
-        {
-            size = GNOME_DESKTOP_THUMBNAIL_SIZE_XXLARGE;
+            if (max_scale <= 1)
+            {
+                thumbnail_size = GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE;
+            }
+            else if (max_scale <= 2)
+            {
+                thumbnail_size = GNOME_DESKTOP_THUMBNAIL_SIZE_XLARGE;
+            }
+            else
+            {
+                thumbnail_size = GNOME_DESKTOP_THUMBNAIL_SIZE_XXLARGE;
+            }
         }
 
-        thumbnail_factory = gnome_desktop_thumbnail_factory_new (size);
+        thumbnail_factory = gnome_desktop_thumbnail_factory_new (thumbnail_size);
     }
 
     return thumbnail_factory;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]