[Xfce4-commits] <tumbler:nick/raw-thumbnailer> Implement a raw thumbnailer using libopenraw.

Nick Schermer noreply at xfce.org
Thu Nov 3 16:14:03 CET 2011


Updating branch refs/heads/nick/raw-thumbnailer
         to 9678fcbc942ae752571438ad7723e64b982a3302 (commit)
       from 14bcb51730324e875478d7b7b98093bd18cf8937 (commit)

commit 9678fcbc942ae752571438ad7723e64b982a3302
Author: Tam Merlant <tam.ille at free.fr>
Date:   Thu Nov 3 15:59:11 2011 +0100

    Implement a raw thumbnailer using libopenraw.

 AUTHORS                                            |    1 +
 NEWS                                               |    1 +
 acinclude.m4                                       |   24 +++
 configure.ac                                       |    7 +
 plugins/Makefile.am                                |    1 +
 .../Makefile.am                                    |   30 ++--
 .../raw-thumbnailer-plugin.c}                      |   20 +-
 plugins/raw-thumbnailer/raw-thumbnailer-provider.c |  138 +++++++++++++++
 plugins/raw-thumbnailer/raw-thumbnailer-provider.h |   43 +++++
 plugins/raw-thumbnailer/raw-thumbnailer.c          |  175 ++++++++++++++++++++
 plugins/raw-thumbnailer/raw-thumbnailer.h          |   46 +++++
 11 files changed, 461 insertions(+), 25 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index cdc8c55..1af9ec0 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -3,3 +3,4 @@ Philip Van Hoof <philip at codeminded.be>
 
 GStreamer video thumbnailer by Ross Burton <ross at linux.intel.com>
 ODF thumbnailer by Nick Schermer <nick at xfce.org>
+Raw thumbnailer by Tam Merlant <tam.ille at free.fr>
diff --git a/NEWS b/NEWS
index b11c995..9eca36c 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@
 - Fix ownership race conditions when started twice (bug #8001).
 - Add an ODF thumbnailer plugin.
 - Add support for OpenRaster images in the ODF thumbnailer (bug #6108).
+- Add a raw image thumbnailer plugin.
 
 0.1.22
 ======
diff --git a/acinclude.m4 b/acinclude.m4
index a8215e0..a61bf3a 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -217,6 +217,30 @@ AC_MSG_RESULT([$ac_tumbler_odf_thumbnailer])
 
 
 
+dnl TUMBLER_RAW_THUMBNAILER()
+dnl
+dnl Check whether to build and install the libopenraw thumbnailer plugin.
+dnl
+AC_DEFUN([TUMBLER_RAW_THUMBNAILER],
+[
+AC_ARG_ENABLE([raw-thumbnailer], [AC_HELP_STRING([--disable-raw-thumbnailer], [Don't build the Raw video thumbnailer plugin])],
+  [ac_tumbler_raw_thumbnailer=$enableval], [ac_tumbler_raw_thumbnailer=yes])
+if test x"$ac_tumbler_raw_thumbnailer" = x"yes"; then
+  dnl Check for gdk-pixbuf
+  PKG_CHECK_MODULES([GDK_PIXBUF], [gdk-pixbuf-2.0 >= 2.14],
+  [
+    dnl Check for libopenraw
+    PKG_CHECK_MODULES([LIBOPENRAW_GNOME], [libopenraw-gnome-1.0 >= 0.0.4], [], [ac_tumbler_raw_thumbnailer=no])
+  ], [ac_tumbler_raw_thumbnailer=no])
+fi
+
+AC_MSG_CHECKING([whether to build the Raw thumbnailer plugin])
+AM_CONDITIONAL([TUMBLER_RAW_THUMBNAILER], [test x"$ac_tumbler_raw_thumbnailer" = x"yes"])
+AC_MSG_RESULT([$ac_tumbler_raw_thumbnailer])
+])
+
+
+
 dnl TUMBLER_XDG_CACHE()
 dnl
 dnl Check whether to build and install the freedesktop.org cache plugin.
diff --git a/configure.ac b/configure.ac
index 43646f7..7198cd1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -157,6 +157,7 @@ TUMBLER_FFMPEG_THUMBNAILER()
 TUMBLER_GSTREAMER_THUMBNAILER()
 TUMBLER_ODF_THUMBNAILER()
 TUMBLER_POPPLER_THUMBNAILER()
+TUMBLER_RAW_THUMBNAILER()
 TUMBLER_XDG_CACHE()
 
 dnl ***********************************
@@ -189,6 +190,7 @@ plugins/pixbuf-thumbnailer/Makefile
 plugins/ffmpeg-thumbnailer/Makefile
 plugins/odf-thumbnailer/Makefile
 plugins/poppler-thumbnailer/Makefile
+plugins/raw-thumbnailer/Makefile
 plugins/xdg-cache/Makefile
 po/Makefile.in
 tumbler/Makefile
@@ -242,6 +244,11 @@ echo "  * PDF/PS thumbnailer plugin using poppler:          yes"
 else
 echo "  * PDF/PS thumbnailer plugin using poppler:          no"
 fi
+if test x"$ac_tumbler_raw_thumbnailer" = x"yes"; then
+echo "  * Raw thumbnailer plugin using libopenraw:          yes"
+else
+echo "  * Raw thumbnailer plugin using libopenraw:          no"
+fi
 if test x"$ac_tumbler_xdg_cache" = x"yes"; then
 echo "  * Freedesktop.org cache plugin:                     yes"
 else
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index d85539f..aec18cc 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -25,4 +25,5 @@ SUBDIRS =								\
 	ffmpeg-thumbnailer						\
 	odf-thumbnailer							\
 	poppler-thumbnailer						\
+	raw-thumbnailer							\
 	xdg-cache
diff --git a/plugins/odf-thumbnailer/Makefile.am b/plugins/raw-thumbnailer/Makefile.am
similarity index 73%
copy from plugins/odf-thumbnailer/Makefile.am
copy to plugins/raw-thumbnailer/Makefile.am
index ac74a8a..c7e39c0 100644
--- a/plugins/odf-thumbnailer/Makefile.am
+++ b/plugins/raw-thumbnailer/Makefile.am
@@ -17,46 +17,46 @@
 # Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 # Boston, MA 02110-1301, USA.
 
-if TUMBLER_ODF_THUMBNAILER
+if TUMBLER_RAW_THUMBNAILER
 
 tumbler_plugindir = $(libdir)/tumbler-$(TUMBLER_VERSION_API)/plugins
 tumbler_plugin_LTLIBRARIES =						\
-	tumbler-odf-thumbnailer.la
+	tumbler-raw-thumbnailer.la
 
-tumbler_odf_thumbnailer_la_SOURCES =					\
-	odf-thumbnailer-plugin.c					\
-	odf-thumbnailer-provider.c					\
-	odf-thumbnailer-provider.h					\
-	odf-thumbnailer.c						\
-	odf-thumbnailer.h
+tumbler_raw_thumbnailer_la_SOURCES =					\
+	raw-thumbnailer-plugin.c					\
+	raw-thumbnailer-provider.c					\
+	raw-thumbnailer-provider.h					\
+	raw-thumbnailer.c						\
+	raw-thumbnailer.h
 
-tumbler_odf_thumbnailer_la_CFLAGS =					\
+tumbler_raw_thumbnailer_la_CFLAGS =					\
 	-I$(top_builddir)						\
 	-I$(top_builddir)/plugins					\
 	-I$(top_srcdir)							\
 	-I$(top_srcdir)/plugins						\
-	-DG_LOG_DOMAIN=\"tumbler-odf-thumbnailer\"			\
+	-DG_LOG_DOMAIN=\"tumbler-raw-thumbnailer\"			\
 	-DPACKAGE_LOCALE_DIR=\"$(localedir)\"				\
 	$(GDK_PIXBUF_CFLAGS)						\
 	$(GIO_CFLAGS)							\
 	$(GLIB_CFLAGS)							\
-	$(GSF_CFLAGS)							\
+	$(LIBOPENRAW_GNOME_CFLAGS)					\
 	$(PLATFORM_CPPFLAGS)
 
-tumbler_odf_thumbnailer_la_LDFLAGS =					\
+tumbler_raw_thumbnailer_la_LDFLAGS =					\
 	-avoid-version							\
 	-export-dynamic							\
 	-module								\
 	$(PLATFORM_LDFLAGS)
 
-tumbler_odf_thumbnailer_la_LIBADD =					\
+tumbler_raw_thumbnailer_la_LIBADD =					\
 	$(top_builddir)/tumbler/libtumbler-$(TUMBLER_VERSION_API).la	\
 	$(GDK_PIXBUF_LIBS)						\
 	$(GIO_LIBS)							\
 	$(GLIB_LIBS)							\
-	$(GSF_LIBS)
+	$(LIBOPENRAW_GNOME_LIBS)
 
-tumbler_odf_thumbnailer_la_DEPENDENCIES =				\
+tumbler_raw_thumbnailer_la_DEPENDENCIES =				\
 	$(top_builddir)/tumbler/libtumbler-$(TUMBLER_VERSION_API).la
 
 endif
diff --git a/plugins/jpeg-thumbnailer/jpeg-thumbnailer-plugin.c b/plugins/raw-thumbnailer/raw-thumbnailer-plugin.c
similarity index 79%
copy from plugins/jpeg-thumbnailer/jpeg-thumbnailer-plugin.c
copy to plugins/raw-thumbnailer/raw-thumbnailer-plugin.c
index 9544397..0be36ca 100644
--- a/plugins/jpeg-thumbnailer/jpeg-thumbnailer-plugin.c
+++ b/plugins/raw-thumbnailer/raw-thumbnailer-plugin.c
@@ -9,11 +9,11 @@
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU Library General Public License for more details.
  *
- * You should have received a copy of the GNU Library General 
- * Public License along with this library; if not, write to the 
+ * You should have received a copy of the GNU Library General
+ * Public License along with this library; if not, write to the
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301, USA.
  */
@@ -28,8 +28,8 @@
 
 #include <tumbler/tumbler.h>
 
-#include <jpeg-thumbnailer/jpeg-thumbnailer-provider.h>
-#include <jpeg-thumbnailer/jpeg-thumbnailer.h>
+#include "raw-thumbnailer-provider.h"
+#include "raw-thumbnailer.h"
 
 
 
@@ -59,15 +59,15 @@ tumbler_plugin_initialize (TumblerProviderPlugin *plugin)
     }
 
 #ifdef DEBUG
-  g_message (_("Initializing the Tumbler JPEG Thumbnailer plugin"));
+  g_message (_("Initializing the Tumbler Raw Thumbnailer plugin"));
 #endif
 
   /* register the types provided by this plugin */
-  jpeg_thumbnailer_register (plugin);
-  jpeg_thumbnailer_provider_register (plugin);
+  raw_thumbnailer_register (plugin);
+  raw_thumbnailer_provider_register (plugin);
 
   /* set up the plugin provider type list */
-  type_list[0] = TYPE_JPEG_THUMBNAILER_PROVIDER;
+  type_list[0] = TYPE_RAW_THUMBNAILER_PROVIDER;
 }
 
 
@@ -76,7 +76,7 @@ void
 tumbler_plugin_shutdown (void)
 {
 #ifdef DEBUG
-  g_message (_("Shutting down the Tumbler JPEG Thumbnailer plugin"));
+  g_message (_("Shutting down the Tumbler Raw Thumbnailer plugin"));
 #endif
 }
 
diff --git a/plugins/raw-thumbnailer/raw-thumbnailer-provider.c b/plugins/raw-thumbnailer/raw-thumbnailer-provider.c
new file mode 100644
index 0000000..de1b04b
--- /dev/null
+++ b/plugins/raw-thumbnailer/raw-thumbnailer-provider.c
@@ -0,0 +1,138 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <glib-object.h>
+
+/* #include <gdk-pixbuf/gdk-pixbuf.h> */
+
+#include <tumbler/tumbler.h>
+
+#include "raw-thumbnailer-provider.h"
+#include "raw-thumbnailer.h"
+
+
+
+static void   raw_thumbnailer_provider_thumbnailer_provider_init (TumblerThumbnailerProviderIface *iface);
+static GList *raw_thumbnailer_provider_get_thumbnailers          (TumblerThumbnailerProvider      *provider);
+
+
+
+struct _RawThumbnailerProviderClass
+{
+  GObjectClass __parent__;
+};
+
+struct _RawThumbnailerProvider
+{
+  GObject __parent__;
+};
+
+
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (RawThumbnailerProvider,
+                                raw_thumbnailer_provider,
+                                G_TYPE_OBJECT,
+                                0,
+                                TUMBLER_ADD_INTERFACE (TUMBLER_TYPE_THUMBNAILER_PROVIDER,
+                                                       raw_thumbnailer_provider_thumbnailer_provider_init));
+
+
+
+void
+raw_thumbnailer_provider_register (TumblerProviderPlugin *plugin)
+{
+  raw_thumbnailer_provider_register_type (G_TYPE_MODULE (plugin));
+}
+
+
+
+static void
+raw_thumbnailer_provider_class_init (RawThumbnailerProviderClass *klass)
+{
+}
+
+
+
+static void
+raw_thumbnailer_provider_class_finalize (RawThumbnailerProviderClass *klass)
+{
+}
+
+
+
+static void
+raw_thumbnailer_provider_thumbnailer_provider_init (TumblerThumbnailerProviderIface *iface)
+{
+  iface->get_thumbnailers = raw_thumbnailer_provider_get_thumbnailers;
+}
+
+
+
+static void
+raw_thumbnailer_provider_init (RawThumbnailerProvider *provider)
+{
+}
+
+
+
+static GList *
+raw_thumbnailer_provider_get_thumbnailers (TumblerThumbnailerProvider *provider)
+{
+  RawThumbnailer *thumbnailer;
+  GList          *thumbnailers = NULL;
+  GStrv           uri_schemes;
+  const gchar    *mime_types[] =
+  {
+    "image/x-adobe-dng",
+    "image/x-canon-cr2",
+    "image/x-canon-crw",
+    "image/x-epson-erf",
+    "image/x-nikon-nef",
+    "image/x-nikon-nrw",
+    "image/x-olympus-orf",
+    "image/x-panasonic-raw",
+    "image/x-panasonic-rw2",
+    "image/x-pentax-pef",
+    "image/x-sony-arw",
+    "image/x-minolta-mrw",
+    NULL
+  };
+
+  /* determine which URI schemes are supported by GIO */
+  uri_schemes = tumbler_util_get_supported_uri_schemes ();
+
+  /* create the raw thumbnailer */
+  thumbnailer = g_object_new (TYPE_RAW_THUMBNAILER,
+                              "uri-schemes", uri_schemes, "mime-types", mime_types,
+                              NULL);
+
+  /* free URI schemes and MIME types */
+  g_strfreev (uri_schemes);
+
+  /* add the thumbnailer to the list */
+  thumbnailers = g_list_append (thumbnailers, thumbnailer);
+
+  return thumbnailers;
+}
diff --git a/plugins/raw-thumbnailer/raw-thumbnailer-provider.h b/plugins/raw-thumbnailer/raw-thumbnailer-provider.h
new file mode 100644
index 0000000..019f6d5
--- /dev/null
+++ b/plugins/raw-thumbnailer/raw-thumbnailer-provider.h
@@ -0,0 +1,43 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RAW_THUMBNAILER_PROVIDER_H__
+#define __RAW_THUMBNAILER_PROVIDER_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define TYPE_RAW_THUMBNAILER_PROVIDER            (raw_thumbnailer_provider_get_type ())
+#define RAW_THUMBNAILER_PROVIDER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_RAW_THUMBNAILER_PROVIDER, RawThumbnailerProvider))
+#define RAW_THUMBNAILER_PROVIDER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_RAW_THUMBNAILER_PROVIDER, RawThumbnailerProviderClass))
+#define IS_RAW_THUMBNAILER_PROVIDER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_RAW_THUMBNAILER_PROVIDER))
+#define IS_RAW_THUMBNAILER_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_RAW_THUMBNAILER_PROVIDER)
+#define RAW_THUMBNAILER_PROVIDER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_RAW_THUMBNAILER_PROVIDER, RawThumbnailerProviderClass))
+
+typedef struct _RawThumbnailerProviderClass RawThumbnailerProviderClass;
+typedef struct _RawThumbnailerProvider      RawThumbnailerProvider;
+
+GType raw_thumbnailer_provider_get_type (void) G_GNUC_CONST;
+void  raw_thumbnailer_provider_register (TumblerProviderPlugin *plugin);
+
+G_END_DECLS
+
+#endif /* !__RAW_THUMBNAILER_PROVIDER_H__ */
diff --git a/plugins/raw-thumbnailer/raw-thumbnailer.c b/plugins/raw-thumbnailer/raw-thumbnailer.c
new file mode 100644
index 0000000..af3fd33
--- /dev/null
+++ b/plugins/raw-thumbnailer/raw-thumbnailer.c
@@ -0,0 +1,175 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
+ * Copyright (c) 2011 Tam Merlant <tam.ille at free.fr>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <sys/types.h>
+#include <fcntl.h>
+#include <memory.h>
+#include <setjmp.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <math.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+
+#include <tumbler/tumbler.h>
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <libopenraw-gnome/gdkpixbuf.h>
+
+#include "raw-thumbnailer.h"
+
+static void raw_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
+                                    GCancellable               *cancellable,
+                                    TumblerFileInfo            *info);
+
+
+
+struct _RawThumbnailerClass
+{
+  TumblerAbstractThumbnailerClass __parent__;
+};
+
+struct _RawThumbnailer
+{
+  TumblerAbstractThumbnailer __parent__;
+};
+
+
+
+G_DEFINE_DYNAMIC_TYPE (RawThumbnailer,
+                       raw_thumbnailer,
+                       TUMBLER_TYPE_ABSTRACT_THUMBNAILER);
+
+
+
+void
+raw_thumbnailer_register (TumblerProviderPlugin *plugin)
+{
+  raw_thumbnailer_register_type (G_TYPE_MODULE (plugin));
+}
+
+
+
+static void
+raw_thumbnailer_class_init (RawThumbnailerClass *klass)
+{
+  TumblerAbstractThumbnailerClass *abstractthumbnailer_class;
+
+  abstractthumbnailer_class = TUMBLER_ABSTRACT_THUMBNAILER_CLASS (klass);
+  abstractthumbnailer_class->create = raw_thumbnailer_create;
+}
+
+
+
+static void
+raw_thumbnailer_class_finalize (RawThumbnailerClass *klass)
+{
+}
+
+
+
+static void
+raw_thumbnailer_init (RawThumbnailer *thumbnailer)
+{
+}
+
+
+
+static void
+raw_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
+                        GCancellable               *cancellable,
+                        TumblerFileInfo            *info)
+{
+  TumblerThumbnailFlavor *flavor;
+  TumblerImageData        data;
+  TumblerThumbnail       *thumbnail;
+  const gchar            *uri;
+  gchar                  *path;
+  GdkPixbuf              *pixbuf = NULL;
+  GError                 *error = NULL;
+  GFile                  *file;
+  gint                    height;
+  gint                    width;
+
+  g_return_if_fail (IS_RAW_THUMBNAILER (thumbnailer));
+  g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+  g_return_if_fail (TUMBLER_IS_FILE_INFO (info));
+
+  /* do nothing if cancelled */
+  if (g_cancellable_is_cancelled (cancellable))
+    return;
+
+  uri = tumbler_file_info_get_uri (info);
+  file = g_file_new_for_uri (uri);
+
+  thumbnail = tumbler_file_info_get_thumbnail (info);
+  g_assert (thumbnail != NULL);
+
+  /* libopenraw only handles local IO */
+  path = g_file_get_path (file);
+  if (path != NULL && g_path_is_absolute (path))
+    {
+      flavor = tumbler_thumbnail_get_flavor (thumbnail);
+      g_assert (flavor != NULL);
+      tumbler_thumbnail_flavor_get_size (flavor, &width, &height);
+      g_object_unref (flavor);
+
+      pixbuf = or_gdkpixbuf_extract_rotated_thumbnail (path, MIN (width, height));
+    }
+
+  g_free (path);
+  g_object_unref (file);
+
+  if (pixbuf != NULL)
+    {
+      data.data = gdk_pixbuf_get_pixels (pixbuf);
+      data.has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
+      data.bits_per_sample = gdk_pixbuf_get_bits_per_sample (pixbuf);
+      data.width = gdk_pixbuf_get_width (pixbuf);
+      data.height = gdk_pixbuf_get_height (pixbuf);
+      data.rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+      data.colorspace = (TumblerColorspace) gdk_pixbuf_get_colorspace (pixbuf);
+
+      tumbler_thumbnail_save_image_data (thumbnail, &data,
+                                         tumbler_file_info_get_mtime (info),
+                                         NULL, &error);
+    }
+
+  if (error != NULL)
+    {
+      g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+      g_error_free (error);
+    }
+  else
+    {
+      g_signal_emit_by_name (thumbnailer, "ready", uri);
+      g_object_unref (pixbuf);
+    }
+
+  g_object_unref (thumbnail);
+}
diff --git a/plugins/raw-thumbnailer/raw-thumbnailer.h b/plugins/raw-thumbnailer/raw-thumbnailer.h
new file mode 100644
index 0000000..0155d22
--- /dev/null
+++ b/plugins/raw-thumbnailer/raw-thumbnailer.h
@@ -0,0 +1,46 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
+ * Copyright (c) 2011 Tam Merlant <tam.ille at free.fr>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RAW_THUMBNAILER_H__
+#define __RAW_THUMBNAILER_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define TYPE_RAW_THUMBNAILER            (raw_thumbnailer_get_type ())
+#define RAW_THUMBNAILER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_RAW_THUMBNAILER, RawThumbnailer))
+#define RAW_THUMBNAILER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_RAW_THUMBNAILER, RawThumbnailerClass))
+#define IS_RAW_THUMBNAILER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_RAW_THUMBNAILER))
+#define IS_RAW_THUMBNAILER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_RAW_THUMBNAILER)
+#define RAW_THUMBNAILER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_RAW_THUMBNAILER, RawThumbnailerClass))
+
+
+
+typedef struct _RawThumbnailerClass   RawThumbnailerClass;
+typedef struct _RawThumbnailer        RawThumbnailer;
+
+GType raw_thumbnailer_get_type (void) G_GNUC_CONST;
+void  raw_thumbnailer_register (TumblerProviderPlugin *plugin);
+
+G_END_DECLS
+
+#endif /* !__RAW_THUMBNAILER_H__ */


More information about the Xfce4-commits mailing list