[PATCH] Don't load files for thumbnailing that we can't thumbnail anyway
- From: Alexander Larsson <alexl redhat com>
- Subject: [PATCH] Don't load files for thumbnailing that we can't thumbnail anyway
- Date: Fri, 18 Sep 2009 11:05:44 +0200
When zooming out we read the real image and use that as the thumbnail.
However, we should only do this for files gdk-pixbuf can read as other
things can't be read anyway and may potentially be very large (such as
videos) since the thumbnail size limit only applies for images.
---
libnautilus-private/nautilus-file.c | 3 +-
libnautilus-private/nautilus-thumbnails.c | 30 +++++++++++++++++++++++-----
libnautilus-private/nautilus-thumbnails.h | 1 +
3 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index 0f0751f..7dd6c94 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -4181,7 +4181,8 @@ nautilus_file_get_icon (NautilusFile *file,
since the zoom level 150% gives thumbnails at 144, which is
ok to scale up from 128. */
if (modified_size > 128*1.25 &&
- !file->details->thumbnail_wants_original) {
+ !file->details->thumbnail_wants_original &&
+ nautilus_can_thumbnail_internally (file)) {
/* Invalidate if we resize upward */
file->details->thumbnail_wants_original = TRUE;
nautilus_file_invalidate_attributes (file, NAUTILUS_FILE_ATTRIBUTE_THUMBNAIL);
diff --git a/libnautilus-private/nautilus-thumbnails.c b/libnautilus-private/nautilus-thumbnails.c
index 382f8c0..df9b438 100644
--- a/libnautilus-private/nautilus-thumbnails.c
+++ b/libnautilus-private/nautilus-thumbnails.c
@@ -770,17 +770,35 @@ get_types_table (void)
return image_mime_types;
}
-gboolean
-nautilus_thumbnail_is_mimetype_limited_by_size (const char *mime_type)
+static gboolean
+pixbuf_can_load_type (const char *mime_type)
{
GHashTable *image_mime_types;
-
+
image_mime_types = get_types_table ();
- if (g_hash_table_lookup (image_mime_types, mime_type)) {
- return TRUE;
+ if (g_hash_table_lookup (image_mime_types, mime_type)) {
+ return TRUE;
}
- return FALSE;
+ return FALSE;
+}
+
+gboolean
+nautilus_can_thumbnail_internally (NautilusFile *file)
+{
+ char *mime_type;
+ gboolean res;
+
+ mime_type = nautilus_file_get_mime_type (file);
+ res = pixbuf_can_load_type (mime_type);
+ g_free (mime_type);
+ return res;
+}
+
+gboolean
+nautilus_thumbnail_is_mimetype_limited_by_size (const char *mime_type)
+{
+ return pixbuf_can_load_type (mime_type);
}
gboolean
diff --git a/libnautilus-private/nautilus-thumbnails.h b/libnautilus-private/nautilus-thumbnails.h
index bfe0724..6128eb3 100644
--- a/libnautilus-private/nautilus-thumbnails.h
+++ b/libnautilus-private/nautilus-thumbnails.h
@@ -46,6 +46,7 @@ typedef void (* NautilusThumbnailAsyncLoadFunc) (NautilusThumbnailAsyncLoadHandl
/* Returns NULL if there's no thumbnail yet. */
void nautilus_create_thumbnail (NautilusFile *file);
gboolean nautilus_can_thumbnail (NautilusFile *file);
+gboolean nautilus_can_thumbnail_internally (NautilusFile *file);
gboolean nautilus_thumbnail_is_mimetype_limited_by_size
(const char *mime_type);
void nautilus_thumbnail_frame_image (GdkPixbuf **pixbuf);
--
1.6.2.5
--=-tYa6f9eh6FhNTut1oLvD--
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]