[nautilus/gnome-3-20] Don't show thumbnails for small zoom levels



commit 6ed964542df4208050b22aac1b7ca2c0901ab4ef
Author: Alexandru Pandelea <alexandru pandelea gmail com>
Date:   Thu Mar 3 07:30:43 2016 +0200

    Don't show thumbnails for small zoom levels
    
    When the zoom level is too small, thumbnails become useless, as they are
    so small that they don't give any information.
    
    The solution to this problem is to use mimetype icons when the zoom
    level is too small
    
    In order to achieve this, there was added a function that returns
    false if the zoom is too small, nautilus_thumbnail_is_limited_by_zoom.
    Therefore, if it returns false, the mimetype icon will be used.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=752805

 libnautilus-private/nautilus-file.c |   21 ++++++++++++++++++++-
 libnautilus-private/nautilus-file.h |    3 +++
 2 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index 22e29dd..8bdfcfd 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -4581,6 +4581,24 @@ nautilus_file_get_thumbnail_icon (NautilusFile *file,
        return icon;
 }
 
+gboolean nautilus_thumbnail_is_limited_by_zoom (int size, int scale,
+                                                NautilusFileIconFlags flags)
+{
+       int zoom_level;
+
+       if (flags & NAUTILUS_FILE_ICON_FLAGS_FORCE_THUMBNAIL_SIZE) {
+               zoom_level = size * scale;
+       } else {
+               zoom_level = size * scale *
+                            cached_thumbnail_size / NAUTILUS_CANVAS_ICON_SIZE_SMALL;
+       }
+
+       if (zoom_level <= NAUTILUS_LIST_ICON_SIZE_SMALL)
+               return FALSE;
+
+       return TRUE;
+}
+
 NautilusIconInfo *
 nautilus_file_get_icon (NautilusFile *file,
                        int size,
@@ -4608,7 +4626,8 @@ nautilus_file_get_icon (NautilusFile *file,
               flags & NAUTILUS_FILE_ICON_FLAGS_FORCE_THUMBNAIL_SIZE);
 
        if (flags & NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS &&
-           nautilus_file_should_show_thumbnail (file)) {
+           nautilus_file_should_show_thumbnail (file) &&
+           nautilus_thumbnail_is_limited_by_zoom (size, scale, flags)) {
                icon = nautilus_file_get_thumbnail_icon (file, size, scale, flags);
        }
 
diff --git a/libnautilus-private/nautilus-file.h b/libnautilus-private/nautilus-file.h
index 363fbff..a6a657e 100644
--- a/libnautilus-private/nautilus-file.h
+++ b/libnautilus-private/nautilus-file.h
@@ -210,6 +210,9 @@ NautilusRequestStatus   nautilus_file_get_deep_counts                   (Nautilu
                                                                         gboolean                        
force);
 gboolean                nautilus_file_should_show_thumbnail             (NautilusFile                   
*file);
 gboolean                nautilus_file_should_show_directory_item_count  (NautilusFile                   
*file);
+gboolean                nautilus_thumbnail_is_limited_by_zoom           (int                            size,
+                                                                         int                            
scale,
+                                                                         NautilusFileIconFlags          
flags);
 
 void                    nautilus_file_set_search_relevance              (NautilusFile                   
*file,
                                                                         gdouble                         
relevance);


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