[eog] EogFileChooser: Use GnomeThumbnailFactory to create preview image
- From: Felix Riemann <friemann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [eog] EogFileChooser: Use GnomeThumbnailFactory to create preview image
- Date: Wed, 14 Mar 2012 19:40:56 +0000 (UTC)
commit 57116d58a1bc7447bd02991ae7902d06a239dbed
Author: Felix Riemann <friemann gnome org>
Date: Wed Mar 14 20:35:50 2012 +0100
EogFileChooser: Use GnomeThumbnailFactory to create preview image
Do this if no thumbnail exists yet. Avoids displaying too large thumbs
for images that have yet to be thumbnailed, breaking the file open dialog.
https://bugzilla.gnome.org/show_bug.cgi?id=671944
src/eog-file-chooser.c | 37 ++++++++++++++++++++++++++++---------
1 files changed, 28 insertions(+), 9 deletions(-)
---
diff --git a/src/eog-file-chooser.c b/src/eog-file-chooser.c
index f0a2569..75d55c3 100644
--- a/src/eog-file-chooser.c
+++ b/src/eog-file-chooser.c
@@ -347,7 +347,8 @@ update_preview_cb (GtkFileChooser *file_chooser, gpointer data)
file_info = g_file_query_info (file,
G_FILE_ATTRIBUTE_TIME_MODIFIED ","
G_FILE_ATTRIBUTE_STANDARD_TYPE ","
- G_FILE_ATTRIBUTE_STANDARD_SIZE,
+ G_FILE_ATTRIBUTE_STANDARD_SIZE ","
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
0, NULL, NULL);
g_object_unref (file);
@@ -358,19 +359,37 @@ update_preview_cb (GtkFileChooser *file_chooser, gpointer data)
mtime = g_file_info_get_attribute_uint64 (file_info,
G_FILE_ATTRIBUTE_TIME_MODIFIED);
thumb_path = gnome_desktop_thumbnail_factory_lookup (priv->thumb_factory, uri, mtime);
- if (thumb_path == NULL) {
- /* read files smaller than 100kb directly */
- if (g_file_info_get_size (file_info) <= 100000) {
- /* FIXME: we should then output also the image dimensions */
- thumb_path = gtk_file_chooser_get_preview_filename (file_chooser);
- }
- }
if (thumb_path != NULL && g_file_test (thumb_path, G_FILE_TEST_EXISTS)) {
/* try to load and display preview thumbnail */
pixbuf = gdk_pixbuf_new_from_file (thumb_path, NULL);
+ } else if (g_file_info_get_size (file_info) <= 100000) {
+ /* read files smaller than 100kb directly */
+
+ gchar *mime_type = g_content_type_get_mime_type (
+ g_file_info_get_content_type (file_info));
+
+
+ if (G_LIKELY (mime_type)) {
+ gboolean can_thumbnail, has_failed;
+
+ can_thumbnail = gnome_desktop_thumbnail_factory_can_thumbnail (
+ priv->thumb_factory,
+ uri, mime_type, mtime);
+ has_failed = gnome_desktop_thumbnail_factory_has_valid_failed_thumbnail (
+ priv->thumb_factory,
+ uri, mtime);
+
+ if (G_LIKELY (can_thumbnail && !has_failed))
+ pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (
+ priv->thumb_factory, uri, mime_type);
+
+ g_free (mime_type);
+ }
+ }
- have_preview = (pixbuf != NULL);
+ if (pixbuf != NULL) {
+ have_preview = TRUE;
set_preview_pixbuf (EOG_FILE_CHOOSER (file_chooser), pixbuf,
g_file_info_get_size (file_info));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]