aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-08-04 02:42:45 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-08-11 09:52:20 +0800
commitf22e25d7352235c187059c4180c084cae3a28b74 (patch)
tree287efc60b69af59df3f6da3c265f66f9b939d0bd /widgets/misc
parentebb0e84a8c9d815eb23570c03f5fbcf416c4e35b (diff)
downloadgsoc2013-evolution-f22e25d7352235c187059c4180c084cae3a28b74.tar
gsoc2013-evolution-f22e25d7352235c187059c4180c084cae3a28b74.tar.gz
gsoc2013-evolution-f22e25d7352235c187059c4180c084cae3a28b74.tar.bz2
gsoc2013-evolution-f22e25d7352235c187059c4180c084cae3a28b74.tar.lz
gsoc2013-evolution-f22e25d7352235c187059c4180c084cae3a28b74.tar.xz
gsoc2013-evolution-f22e25d7352235c187059c4180c084cae3a28b74.tar.zst
gsoc2013-evolution-f22e25d7352235c187059c4180c084cae3a28b74.zip
Bug #580895 - Kill libgnomeui/gnome-thumbnail.h
Diffstat (limited to 'widgets/misc')
-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 e1afb45246..7d8984dba0 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);