aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac22
-rw-r--r--e-util/e-icon-factory.c69
-rw-r--r--e-util/e-icon-factory.h2
-rw-r--r--widgets/misc/e-attachment.c50
4 files changed, 119 insertions, 24 deletions
diff --git a/configure.ac b/configure.ac
index 43d9030fe4..afd196c9e8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,6 +47,7 @@ m4_define([glib_minimum_version], [2.20.0])
m4_define([gtk_minimum_version], [2.16.0])
m4_define([eds_minimum_version], [evo_version])
m4_define([gnome_icon_theme_minimum_version], [2.19.91])
+m4_define([gnome_desktop_minimum_version], [2.26.0])
m4_define([libbonobo_minimum_version], [2.20.3])
m4_define([libbonoboui_minimum_version], [2.4.2])
m4_define([libgtkhtml_minimum_version], [3.25.4])
@@ -215,7 +216,8 @@ PKG_CHECK_MODULES([GNOME_PLATFORM],
libgnomecanvas-2.0 >= libgnomecanvas_minimum_version
libgnomeui-2.0 >= libgnomeui_minimum_version
libxml-2.0 >= libxml_minimum_version
- shared-mime-info >= shared_mime_info_minimum_version])
+ shared-mime-info >= shared_mime_info_minimum_version
+ gnome-desktop-2.0 >= gnome_desktop_minimum_version])
AC_SUBST(GNOME_PLATFORM_CFLAGS)
AC_SUBST(GNOME_PLATFORM_LIBS)
@@ -1353,22 +1355,6 @@ dnl --- Flags to get all the GNOME stuff
FULL_GNOME_DEPS="libbonoboui-2.0 gconf-2.0 gthread-2.0 gobject-2.0 libgnomeui-2.0 libglade-2.0"
-CPPFLAGS_save="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags-only-I libgnomeui-2.0`"
-AC_CHECK_HEADERS(libgnomeui/gnome-icon-lookup.h,,,
-[[
- #if HAVE_LIBGNOMEUI_GNOME_ICON_LOOKUP_H
- #include <libgnomeui/gnome-icon-lookup.h>
- #endif
-]])
-AC_CHECK_HEADERS(libgnomeui/gnome-thumbnail.h,,,
-[[
- #if HAVE_LIBGNOMEUI_GNOME_THUMBNAIL_H
- #include <libgnomeui/gnome-thumbnail.h>
- #endif
-]])
-CPPFLAGS="$CPPFLAGS_save"
-
PKG_CHECK_MODULES([HAL], [hal >= hal_minimum_version], [HAVE_HAL="yes"], [HAVE_HAL="no"])
if test "x$HAVE_HAL" = "xyes"; then
AC_DEFINE(HAVE_HAL, 1, [hal available])
@@ -1496,7 +1482,7 @@ else
E_UTIL_X11_CFLAGS=""
E_UTIL_X11_LIBS=""
fi
-EVO_SET_COMPILE_FLAGS(E_UTIL, libbonoboui-2.0 libglade-2.0 libgnomeui-2.0 libedataserver-$EDS_PACKAGE libedataserverui-$EDS_PACKAGE camel-$EDS_PACKAGE $mozilla_nspr, $THREADS_CFLAGS $MANUAL_NSPR_CFLAGS $E_UTIL_X11_CFLAGS, $THREADS_LIBS $MANUAL_NSPR_LIBS $E_UTIL_X11_LIBS)
+EVO_SET_COMPILE_FLAGS(E_UTIL, libbonoboui-2.0 libglade-2.0 gnome-desktop-2.0 libedataserver-$EDS_PACKAGE libedataserverui-$EDS_PACKAGE camel-$EDS_PACKAGE $mozilla_nspr, $THREADS_CFLAGS $MANUAL_NSPR_CFLAGS $E_UTIL_X11_CFLAGS, $THREADS_LIBS $MANUAL_NSPR_LIBS $E_UTIL_X11_LIBS)
AC_SUBST(E_UTIL_CFLAGS)
AC_SUBST(E_UTIL_LIBS)
diff --git a/e-util/e-icon-factory.c b/e-util/e-icon-factory.c
index 1336164347..496a96a7e4 100644
--- a/e-util/e-icon-factory.c
+++ b/e-util/e-icon-factory.c
@@ -30,10 +30,11 @@
#include <pthread.h>
-#ifdef HAVE_LIBGNOMEUI_GNOME_THUMBNAIL_H
-#include <libgnomeui/gnome-thumbnail.h>
-#endif
+#define GNOME_DESKTOP_USE_UNSTABLE_API
+#include <libgnomeui/gnome-desktop-thumbnail.h>
+#undef GNOME_DESKTOP_USE_UNSTABLE_API
+#include <glib/gstdio.h>
#include <gtk/gtk.h>
#include "e-icon-factory.h"
@@ -41,6 +42,7 @@
#include "art/broken-image-16.xpm"
#include "art/broken-image-24.xpm"
+
#define d(x)
typedef struct {
@@ -332,10 +334,65 @@ e_icon_factory_pixbuf_scale (GdkPixbuf *pixbuf, gint width, gint height)
if (height <= 0)
height = 1;
-#ifdef HAVE_LIBGNOMEUI_GNOME_THUMBNAIL_H
/* because this can only scale down, not up */
if (gdk_pixbuf_get_width (pixbuf) > width && gdk_pixbuf_get_height (pixbuf) > height)
- return gnome_thumbnail_scale_down_pixbuf (pixbuf, width, height);
-#endif
+ return gnome_desktop_thumbnail_scale_down_pixbuf (pixbuf, width, height);
+
return gdk_pixbuf_scale_simple (pixbuf, width, height, GDK_INTERP_BILINEAR);
}
+
+/**
+ * e_icon_factory_create_thumbnail
+ * Creates system thumbnail for a file filename.
+ * @param filename The file name to create the thumbnail for.
+ * @return Path to system thumbnail of the file; NULL if couldn't create it. Free it with g_free.
+ **/
+gchar *
+e_icon_factory_create_thumbnail (const gchar *filename)
+{
+ static GnomeDesktopThumbnailFactory *thumbnail_factory = NULL;
+ struct stat file_stat;
+ gchar *thumbnail = NULL;
+
+ g_return_val_if_fail (filename != NULL, NULL);
+
+ if (thumbnail_factory == NULL) {
+ thumbnail_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL);
+ }
+
+ if (g_stat (filename, &file_stat) != -1 && S_ISREG (file_stat.st_mode)) {
+ gchar *content_type, *mime = NULL;
+ gboolean uncertain = FALSE;
+
+ content_type = g_content_type_guess (filename, NULL, 0, &uncertain);
+ if (content_type)
+ mime = g_content_type_get_mime_type (content_type);
+
+ if (mime) {
+ gchar *uri = g_filename_to_uri (filename, NULL, NULL);
+
+ g_return_val_if_fail (uri != NULL, NULL);
+
+ thumbnail = gnome_desktop_thumbnail_factory_lookup (thumbnail_factory, uri, file_stat.st_mtime);
+ if (!thumbnail && gnome_desktop_thumbnail_factory_can_thumbnail (thumbnail_factory, uri, mime, file_stat.st_mtime)) {
+ GdkPixbuf *pixbuf;
+
+ pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (thumbnail_factory, uri, mime);
+
+ if (pixbuf) {
+ gnome_desktop_thumbnail_factory_save_thumbnail (thumbnail_factory, pixbuf, uri, file_stat.st_mtime);
+ g_object_unref (pixbuf);
+
+ thumbnail = gnome_desktop_thumbnail_factory_lookup (thumbnail_factory, uri, file_stat.st_mtime);
+ }
+ }
+
+ g_free (uri);
+ }
+
+ g_free (content_type);
+ g_free (mime);
+ }
+
+ return thumbnail;
+}
diff --git a/e-util/e-icon-factory.h b/e-util/e-icon-factory.h
index b8a4df972f..52ac332363 100644
--- a/e-util/e-icon-factory.h
+++ b/e-util/e-icon-factory.h
@@ -36,4 +36,6 @@ GdkPixbuf * e_icon_factory_pixbuf_scale (GdkPixbuf *pixbuf,
gint width,
gint height);
+gchar * e_icon_factory_create_thumbnail (const gchar *filename);
+
#endif /* _E_ICON_FACTORY_H_ */
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);