[libgsf] Thumbnailing: use gdk-pixbuf if available.



commit 51c921df20f9a06083467e6b3da5515a0495347b
Author: Morten Welinder <terra gnome org>
Date:   Fri Sep 25 19:25:00 2009 -0400

    Thumbnailing: use gdk-pixbuf if available.

 ChangeLog               |    4 ++++
 NEWS                    |    3 +++
 configure.in            |   22 ++++++++++++++++++++++
 thumbnailer/Makefile.am |    4 ++--
 thumbnailer/main.c      |   21 +++++++++++++++++++++
 5 files changed, 52 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9b5dc80..bef332d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-09-25  Morten Welinder  <terra gnome org>
+
+	* thumbnailer/main.c (call_convert): Use gdk_pixbuf if available.
+
 2009-09-25  Morten Welinder  <mwelinder gmail com>
 
 	* configure.in (libgsf_gnome_reqs): Remove gnome-vfs stuff.
diff --git a/NEWS b/NEWS
index 9341829..bf818e6 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,9 @@ libgsf 1.14.16
 Andreas:
 	* Add variant of OO_NS_FIELD.
 
+Caolan McNamara:
+        * Use gdk_pixbug for thumbnailing when available.  [#594359]
+
 Morten:
 	* Fix problem with errors to stdout.  [#592471]
 
diff --git a/configure.in b/configure.in
index 0efae97..73948f9 100644
--- a/configure.in
+++ b/configure.in
@@ -462,6 +462,28 @@ else
 fi
 AC_SUBST(BONOBO_REQ)
 
+want_gdk_pixbuf=no
+dnl check for gdk_pixbuf
+AC_ARG_WITH(gdk_pixbuf,
+    AC_HELP_STRING([--without-gdk-pixbuf],[disable the use of gdk-pixbuf]),
+    [case "${withval}" in
+    yes) want_gdk_pixbuf=yes ;;
+    no) want_gdk_pixbuf=no ;;
+    *) AC_MSG_ERROR(bad value ${withval} for --with-gdk-pixbuf) ;;
+    esac],
+    [want_gdk_pixbuf=auto]) dnl Default value
+
+if test $want_gdk_pixbuf = no ; then
+    AC_MSG_WARN([gdk-pixbuf support disabled, as requested (Use --with-gdk-pixbuf to enable)])
+else
+    PKG_CHECK_MODULES(GDK_PIXBUF, gdk-pixbuf-2.0,
+        [AC_DEFINE(HAVE_GDK_PIXBUF, 1, [Define if gdk-pixbuf is available])],
+	[if test $want_gdk_pixbuf = yes; then
+	    AC_MSG_ERROR([gdk-pixbuf support requested, but not available.])
+	 else
+	    AC_MSG_WARN([gdk-pixbuf support disabled, unable to find required version])
+	 fi])
+fi
 
 have_gnome=no
 if test $want_gnome = no ; then 
diff --git a/thumbnailer/Makefile.am b/thumbnailer/Makefile.am
index fe32046..1e033a5 100644
--- a/thumbnailer/Makefile.am
+++ b/thumbnailer/Makefile.am
@@ -1,7 +1,7 @@
 @INTLTOOL_SCHEMAS_RULE@
 
-AM_CPPFLAGS = -I$(top_srcdir) $(LIBGSF_CFLAGS) $(LIBXML_CFLAGS)
-LDADD = $(top_builddir)/gsf/libgsf-1.la $(LIBGSF_LIBS)
+AM_CPPFLAGS = -I$(top_srcdir) $(LIBGSF_CFLAGS) $(GDK_PIXBUF_CFLAGS) $(LIBXML_CFLAGS)
+LDADD = $(top_builddir)/gsf/libgsf-1.la $(LIBGSF_LIBS) $(GDK_PIXBUF_LIBS)
 
 bin_PROGRAMS = gsf-office-thumbnailer
 
diff --git a/thumbnailer/main.c b/thumbnailer/main.c
index b921fd4..985fd36 100644
--- a/thumbnailer/main.c
+++ b/thumbnailer/main.c
@@ -32,6 +32,11 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <glib.h>
+#include <gsf-config.h>
+
+#ifdef HAVE_GDK_PIXBUF
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#endif
 
 #ifdef HAVE_SETRLIMI
 #include <sys/resource.h>
@@ -62,6 +67,22 @@ call_convert (const char *in_filename, const char *out_filename, int thumb_size)
 	GError *error;
 	gint exit_status;
 
+#ifdef HAVE_GDK_PIXBUF
+	GdkPixbuf* pixbuf;
+
+	pixbuf = gdk_pixbuf_new_from_file_at_scale (in_filename,
+						    thumb_size, thumb_size,
+						    TRUE, NULL);
+	if (pixbuf) {
+		gboolean success = gdk_pixbuf_save (pixbuf,
+						    out_filename, "png",
+						    NULL, NULL);
+		g_object_unref (pixbuf);
+		if (success)
+			return;
+	}
+#endif
+
 	in_quote = g_shell_quote (in_filename);
 	out_quote = g_shell_quote (out_filename);
 	cmd_line = g_strdup_printf ("convert %s +matte -thumbnail %dx%d png:%s",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]