Commit 9e19f5c2 authored by Cosimo Cecchi's avatar Cosimo Cecchi Committed by Cosimo Cecchi

Always use the thumbnails regardless of the original file size if it has

2008-03-18  Cosimo Cecchi  <cosimoc@gnome.org>

	* libnautilus-private/nautilus-file.c:
	(nautilus_file_should_show_thumbnail):
	* libnautilus-private/nautilus-thumbnails.c: (get_types_table),
	(nautilus_thumbnail_is_mimetype_limited_by_size):
	* libnautilus-private/nautilus-thumbnails.h:
	Always use the thumbnails regardless of the original file size if
	it has been already generated (#501268).
	Also, reimplement image	mimetypes table to determine if we have
	to check for file size limit.

svn path=/trunk/; revision=13952
parent 07ac17a9
2008-03-18 Cosimo Cecchi <cosimoc@gnome.org>
* libnautilus-private/nautilus-file.c:
(nautilus_file_should_show_thumbnail):
* libnautilus-private/nautilus-thumbnails.c: (get_types_table),
(nautilus_thumbnail_is_mimetype_limited_by_size):
* libnautilus-private/nautilus-thumbnails.h:
Always use the thumbnails regardless of the original file size if
it has been already generated (#501268).
Also, reimplement image mimetypes table to determine if we have
to check for file size limit.
2008-03-17 A. Walton <awalton@svn.gnome.org>
* libnautilus-private/nautilus-icon-info.h:
......
......@@ -3186,19 +3186,6 @@ static int cached_thumbnail_limit;
static int cached_thumbnail_size;
static int show_image_thumbs;
static gboolean
mimetype_limited_by_size (const char *mime_type)
{
/* TODO: re-add */
/*
if (g_hash_table_lookup (factory->image_mime_types, mime_type)) {
return TRUE;
}
*/
return FALSE;
}
GFilesystemPreviewType
nautilus_file_get_filesystem_use_preview (NautilusFile *file)
{
......@@ -3229,7 +3216,11 @@ nautilus_file_should_show_thumbnail (NautilusFile *file)
mime_type = "application/octet-stream";
}
if (mimetype_limited_by_size (mime_type) &&
/* If the thumbnail has already been created, don't care about the size
* of the original file.
*/
if (nautilus_thumbnail_is_mimetype_limited_by_size (mime_type) &&
file->details->thumbnail_path == NULL &&
nautilus_file_get_size (file) > (unsigned int)cached_thumbnail_limit) {
return FALSE;
}
......
......@@ -114,6 +114,14 @@ static NautilusThumbnailInfo *currently_thumbnailing = NULL;
static GnomeThumbnailFactory *thumbnail_factory = NULL;
static const char *types [] = {
"image/x-bmp", "image/x-ico", "image/jpeg", "image/gif",
"image/png", "image/pnm", "image/ras", "image/tga",
"image/tiff", "image/wbmp", "image/bmp", "image/x-xbitmap",
"image/x-xpixmap"
};
static GHashTable *image_mime_types = NULL;
static int thumbnail_icon_size = 0;
static gboolean
......@@ -728,6 +736,36 @@ thumbnail_thread_notify_file_changed (gpointer image_uri)
return FALSE;
}
static GHashTable *
get_types_table (void)
{
int i;
if (image_mime_types == NULL) {
image_mime_types = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 0; i < G_N_ELEMENTS (types); i++) {
g_hash_table_insert (image_mime_types,
(gpointer) types [i],
GUINT_TO_POINTER (1));
}
}
return image_mime_types;
}
gboolean
nautilus_thumbnail_is_mimetype_limited_by_size (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;
}
return FALSE;
}
gboolean
nautilus_can_thumbnail (NautilusFile *file)
{
......
......@@ -46,6 +46,8 @@ 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_thumbnail_is_mimetype_limited_by_size
(const char *mime_type);
void nautilus_thumbnail_frame_image (GdkPixbuf **pixbuf);
GdkPixbuf *nautilus_thumbnail_unframe_image (GdkPixbuf *pixbuf);
GdkPixbuf *nautilus_thumbnail_load_image (const char *path,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment