aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc/e-attachment.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-08-04 02:42:45 +0800
committerMilan Crha <mcrha@redhat.com>2009-08-04 02:42:45 +0800
commit290cd2b1acc2f22d22c46b39fd1361d3048abe5e (patch)
tree633d737cf8f2a92ddcf3cca603e3d5999fce1aec /widgets/misc/e-attachment.c
parenta5309fa72c8b84c68ee6c53432f896318940eda9 (diff)
downloadgsoc2013-evolution-290cd2b1acc2f22d22c46b39fd1361d3048abe5e.tar
gsoc2013-evolution-290cd2b1acc2f22d22c46b39fd1361d3048abe5e.tar.gz
gsoc2013-evolution-290cd2b1acc2f22d22c46b39fd1361d3048abe5e.tar.bz2
gsoc2013-evolution-290cd2b1acc2f22d22c46b39fd1361d3048abe5e.tar.lz
gsoc2013-evolution-290cd2b1acc2f22d22c46b39fd1361d3048abe5e.tar.xz
gsoc2013-evolution-290cd2b1acc2f22d22c46b39fd1361d3048abe5e.tar.zst
gsoc2013-evolution-290cd2b1acc2f22d22c46b39fd1361d3048abe5e.zip
Bug #580895 - Kill libgnomeui/gnome-thumbnail.h
Diffstat (limited to 'widgets/misc/e-attachment.c')
-rw-r--r--widgets/misc/e-attachment.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c
index 39df9ad20b..a5adcc6f33 100644
--- a/widgets/misc/e-attachment.c
+++ b/widgets/misc/e-attachment.c
@@ -31,7 +31,11 @@
#include <camel/camel-stream-mem.h>
#include <camel/camel-stream-null.h>
#include <camel/camel-stream-vfs.h>
+#include <camel/camel-stream-fs.h>
+#include <libedataserver/e-data-server-util.h>
+
+#include "e-util/e-icon-factory.h"
#include "e-util/e-util.h"
#include "e-util/e-mktemp.h"
#include "e-attachment-store.h"
@@ -99,6 +103,48 @@ enum {
static gpointer parent_class;
+static gboolean
+create_system_thumbnail (EAttachment *attachment, GIcon **icon)
+{
+ GFile *file;
+ gchar *thumbnail = NULL;
+
+ g_return_val_if_fail (attachment != NULL, FALSE);
+ g_return_val_if_fail (icon != NULL, FALSE);
+
+ file = e_attachment_get_file (attachment);
+
+ if (file && g_file_has_uri_scheme (file, "file")) {
+ gchar *path = g_file_get_path (file);
+ if (path) {
+ thumbnail = e_icon_factory_create_thumbnail (path);
+ g_free (path);
+ }
+ }
+
+ if (thumbnail) {
+ GFile *gf = g_file_new_for_path (thumbnail);
+
+ g_return_val_if_fail (gf != NULL, FALSE);
+ if (*icon)
+ g_object_unref (*icon);
+
+ *icon = g_file_icon_new (gf);
+ g_object_unref (gf);
+
+ if (file) {
+ GFileInfo *fi = e_attachment_get_file_info (attachment);
+
+ if (fi)
+ g_file_info_set_attribute_byte_string (fi, G_FILE_ATTRIBUTE_THUMBNAIL_PATH, thumbnail);
+ }
+ }
+
+ g_free (thumbnail);
+
+ return thumbnail != NULL;
+}
+
static gchar *
attachment_get_default_charset (void)
{
@@ -229,6 +275,10 @@ attachment_update_icon_column (EAttachment *attachment)
icon = g_file_icon_new (file);
g_object_unref (file);
+ /* try the system thumbnailer */
+ } else if (create_system_thumbnail (attachment, &icon)) {
+ /* actually do nothing, just use the icon */
+
/* Else use the standard icon for the content type. */
} else if (icon != NULL)
g_object_ref (icon);