summaryrefslogtreecommitdiff
path: root/plugins/pixbuf-thumbnailer
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis@xfce.org>2009-06-08 20:31:41 +0200
committerJannis Pohlmann <jannis@xfce.org>2009-06-08 20:31:41 +0200
commit9d5f1b7b03bd0ad50365fa8186a0d9bce690f31d (patch)
tree9aed893b732fd3266c52fdbed77a1ac754199879 /plugins/pixbuf-thumbnailer
parent04bb883f2b53aea6f848672ee7dea42cf7a6af86 (diff)
downloadtumbler-9d5f1b7b03bd0ad50365fa8186a0d9bce690f31d.tar.gz
Add plugin interface for cache and thumbnailer implementations.
This is a major refactoring of the source code. Amongst others, the classes TumblerProviderFactory, TumblerThumbnailer, TumblerAbstractThumbnailer, TumblerThumbnailerProvider, TumblerCache, TumblerCacheProvider and TumblerFileInfo have been added. From now on tumbler supports different storage backends and thumbnailers as plugins. Storage backends have to implement TumblerCache, thumbnailers have to implement TumblerThumbnailer. Plugins have to implement three methods: tumbler_plugin_initialize(), tumbler_plugin_shutdown() and tumbler_plugin_get_types(). The latter is expected to return a list of provider types for cache or thumbnailer implementations. Two example plugins have been added, one for the XDG thumbnail cache and one for a GdkPixbuf based thumbnailer. The code of tumblerd was updated to reflect these changes in libtumbler.
Diffstat (limited to 'plugins/pixbuf-thumbnailer')
-rw-r--r--plugins/pixbuf-thumbnailer/Makefile.am56
-rw-r--r--plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-plugin.c91
-rw-r--r--plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-provider.c170
-rw-r--r--plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-provider.h44
-rw-r--r--plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-thumbnailer.c243
-rw-r--r--plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-thumbnailer.h43
6 files changed, 647 insertions, 0 deletions
diff --git a/plugins/pixbuf-thumbnailer/Makefile.am b/plugins/pixbuf-thumbnailer/Makefile.am
new file mode 100644
index 0000000..c37e99c
--- /dev/null
+++ b/plugins/pixbuf-thumbnailer/Makefile.am
@@ -0,0 +1,56 @@
+# vi:set ts=8 sw=8 noet ai nocindent:
+# -
+# Copyright (c) 2009 Jannis Pohlmann <jannis@xfce.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+if ENABLE_PIXBUF_THUMBNAILER
+
+tumbler_plugindir = $(libdir)/tumbler-$(TUMBLER_VERSION_API)/plugins
+tumbler_plugin_LTLIBRARIES = \
+ tumbler-pixbuf-thumbnailer.la
+
+tumbler_pixbuf_thumbnailer_la_SOURCES = \
+ pixbuf-thumbnailer-plugin.c \
+ pixbuf-thumbnailer-provider.c \
+ pixbuf-thumbnailer-provider.h \
+ pixbuf-thumbnailer-thumbnailer.c \
+ pixbuf-thumbnailer-thumbnailer.h
+
+tumbler_pixbuf_thumbnailer_la_CFLAGS = \
+ -I$(top_builddir) \
+ -I$(top_builddir)/plugins \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/plugins \
+ -DG_LOG_DOMAIN=\"tumbler-pixbuf-thumbnailer\" \
+ -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
+ $(GDK_PIXBUF_CFLAGS) \
+ $(GIO_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(PLATFORM_CPPFLAGS)
+
+tumbler_pixbuf_thumbnailer_la_LDFLAGS = \
+ -avoid-version \
+ -export-dynamic \
+ -module \
+ $(PLATFORM_LDFLAGS)
+
+tumbler_pixbuf_thumbnailer_la_LIBADD = \
+ $(GDK_PIXBUF_LIBS) \
+ $(GIO_LIBS) \
+ $(GLIB_LIBS)
+
+endif
diff --git a/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-plugin.c b/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-plugin.c
new file mode 100644
index 0000000..4267c71
--- /dev/null
+++ b/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-plugin.c
@@ -0,0 +1,91 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2009 Jannis Pohlmann <jannis@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/gi18n.h>
+#include <glib-object.h>
+
+#include <tumbler/tumbler.h>
+
+#include <pixbuf-thumbnailer/pixbuf-thumbnailer-provider.h>
+#include <pixbuf-thumbnailer/pixbuf-thumbnailer-thumbnailer.h>
+
+
+
+G_MODULE_EXPORT void tumbler_plugin_initialize (TumblerProviderPlugin *plugin);
+G_MODULE_EXPORT void tumbler_plugin_shutdown (void);
+G_MODULE_EXPORT void tumbler_plugin_get_types (const GType **types,
+ gint *n_types);
+
+
+
+static GType type_list[1];
+
+
+
+void
+tumbler_plugin_initialize (TumblerProviderPlugin *plugin)
+{
+ const gchar *mismatch;
+
+ /* verify that the tumbler versions are compatible */
+ mismatch = tumbler_check_version (TUMBLER_MAJOR_VERSION, TUMBLER_MINOR_VERSION,
+ TUMBLER_MICRO_VERSION);
+ if (G_UNLIKELY (mismatch != NULL))
+ {
+ g_warning (_("Version mismatch: %s"), mismatch);
+ return;
+ }
+
+#ifdef DEBUG
+ g_message (_("Initializing the Tumbler Pixbuf Thumbnailer plugin"));
+#endif
+
+ /* register the types provided by this plugin */
+ pixbuf_thumbnailer_provider_register (plugin);
+ pixbuf_thumbnailer_thumbnailer_register (plugin);
+
+ /* set up the plugin provider type list */
+ type_list[0] = PIXBUF_THUMBNAILER_TYPE_PROVIDER;
+}
+
+
+
+void
+tumbler_plugin_shutdown (void)
+{
+#ifdef DEBUG
+ g_message (_("Shutting down the Tumbler Pixbuf Thumbnailer plugin"));
+#endif
+}
+
+
+
+void
+tumbler_plugin_get_types (const GType **types,
+ gint *n_types)
+{
+ *types = type_list;
+ *n_types = G_N_ELEMENTS (type_list);
+}
diff --git a/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-provider.c b/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-provider.c
new file mode 100644
index 0000000..774e3fc
--- /dev/null
+++ b/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-provider.c
@@ -0,0 +1,170 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2009 Jannis Pohlmann <jannis@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 <pixbuf-thumbnailer/pixbuf-thumbnailer-provider.h>
+#include <pixbuf-thumbnailer/pixbuf-thumbnailer-thumbnailer.h>
+
+
+
+static void pixbuf_thumbnailer_provider_thumbnailer_provider_init (TumblerThumbnailerProviderIface *iface);
+static GList *pixbuf_thumbnailer_provider_get_thumbnailers (TumblerThumbnailerProvider *provider);
+
+
+
+struct _PixbufThumbnailerProviderClass
+{
+ GObjectClass __parent__;
+};
+
+struct _PixbufThumbnailerProvider
+{
+ GObject __parent__;
+};
+
+
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (PixbufThumbnailerProvider,
+ pixbuf_thumbnailer_provider,
+ G_TYPE_OBJECT,
+ 0,
+ G_IMPLEMENT_INTERFACE (TUMBLER_TYPE_THUMBNAILER_PROVIDER,
+ pixbuf_thumbnailer_provider_thumbnailer_provider_init));
+
+
+
+void
+pixbuf_thumbnailer_provider_register (TumblerProviderPlugin *plugin)
+{
+ pixbuf_thumbnailer_provider_register_type (G_TYPE_MODULE (plugin));
+}
+
+
+
+static void
+pixbuf_thumbnailer_provider_class_init (PixbufThumbnailerProviderClass *klass)
+{
+ GObjectClass *gobject_class;
+
+ /* Determine the parent type class */
+ pixbuf_thumbnailer_provider_parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class = G_OBJECT_CLASS (klass);
+}
+
+
+
+static void
+pixbuf_thumbnailer_provider_class_finalize (PixbufThumbnailerProviderClass *klass)
+{
+}
+
+
+
+static void
+pixbuf_thumbnailer_provider_thumbnailer_provider_init (TumblerThumbnailerProviderIface *iface)
+{
+ iface->get_thumbnailers = pixbuf_thumbnailer_provider_get_thumbnailers;
+}
+
+
+
+static void
+pixbuf_thumbnailer_provider_init (PixbufThumbnailerProvider *provider)
+{
+}
+
+
+
+static GList *
+pixbuf_thumbnailer_provider_get_thumbnailers (TumblerThumbnailerProvider *provider)
+{
+ PixbufThumbnailerThumbnailer *thumbnailer;
+ static const gchar *uri_schemes[] = { "file", "sftp", "http", NULL, };
+ GHashTable *types;
+ GSList *formats;
+ GSList *fp;
+ GList *keys;
+ GList *lp;
+ GList *thumbnailers = NULL;
+ GStrv format_types;
+ GStrv mime_types;
+ gint n;
+
+ /* create a hash table to collect unique MIME types */
+ types = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+ /* get a list of all formats supported by GdkPixbuf */
+ formats = gdk_pixbuf_get_formats ();
+
+ /* iterate over all formats */
+ for (fp = formats; fp != NULL; fp = fp->next)
+ {
+ /* ignore the disabled ones */
+ if (!gdk_pixbuf_format_is_disabled (fp->data))
+ {
+ /* get a list of MIME types supported by this format */
+ format_types = gdk_pixbuf_format_get_mime_types (fp->data);
+
+ /* put them all in the unqiue MIME type hash table */
+ for (n = 0; format_types != NULL && format_types[n] != NULL; ++n)
+ g_hash_table_replace (types, g_strdup (format_types[n]), NULL);
+
+ /* free the string array */
+ g_strfreev (format_types);
+ }
+ }
+
+ /* free the format list */
+ g_slist_free (formats);
+
+ /* get a list with all unique MIME types */
+ keys = g_hash_table_get_keys (types);
+
+ /* allocate a string array for them */
+ mime_types = g_new0 (gchar *, g_list_length (keys) + 1);
+
+ /* copy all MIME types into the string array */
+ for (lp = keys, n = 0; lp != NULL; lp = lp->next, ++n)
+ mime_types[n] = g_strdup (lp->data);
+
+ /* NULL-terminate the array */
+ mime_types[n] = NULL;
+
+ /* create the pixbuf thumbnailer */
+ thumbnailer = g_object_new (PIXBUF_THUMBNAILER_TYPE_THUMBNAILER,
+ "uri-schemes", uri_schemes, "mime-types", mime_types,
+ NULL);
+
+ /* add the thumbnailer to the list */
+ thumbnailers = g_list_append (thumbnailers, thumbnailer);
+
+ return thumbnailers;
+}
diff --git a/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-provider.h b/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-provider.h
new file mode 100644
index 0000000..cf10b6b
--- /dev/null
+++ b/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-provider.h
@@ -0,0 +1,44 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2009 Jannis Pohlmann <jannis@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 __PIXBUF_THUMBNAILER_PROVIDER_H__
+#define __PIXBUF_THUMBNAILER_PROVIDER_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS;
+
+#define PIXBUF_THUMBNAILER_TYPE_PROVIDER (pixbuf_thumbnailer_provider_get_type ())
+#define PIXBUF_THUMBNAILER_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIXBUF_THUMBNAILER_TYPE_PROVIDER, PixbufThumbnailerProvider))
+#define PIXBUF_THUMBNAILER_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIXBUF_THUMBNAILER_TYPE_PROVIDER, PixbufThumbnailerProviderClass))
+#define PIXBUF_THUMBNAILER_IS_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIXBUF_THUMBNAILER_TYPE_PROVIDER))
+#define PIXBUF_THUMBNAILER_IS_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIXBUF_THUMBNAILER_TYPE_PROVIDER)
+#define PIXBUF_THUMBNAILER_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIXBUF_THUMBNAILER_TYPE_PROVIDER, PixbufThumbnailerProviderClass))
+
+typedef struct _PixbufThumbnailerProviderPrivate PixbufThumbnailerProviderPrivate;
+typedef struct _PixbufThumbnailerProviderClass PixbufThumbnailerProviderClass;
+typedef struct _PixbufThumbnailerProvider PixbufThumbnailerProvider;
+
+GType pixbuf_thumbnailer_provider_get_type (void) G_GNUC_CONST;
+void pixbuf_thumbnailer_provider_register (TumblerProviderPlugin *plugin);
+
+G_END_DECLS;
+
+#endif /* !__PIXBUF_THUMBNAILER_PROVIDER_H__ */
diff --git a/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-thumbnailer.c b/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-thumbnailer.c
new file mode 100644
index 0000000..5df04a3
--- /dev/null
+++ b/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-thumbnailer.c
@@ -0,0 +1,243 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2009 Jannis Pohlmann <jannis@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 <math.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+#include <tumbler/tumbler.h>
+
+#include <pixbuf-thumbnailer/pixbuf-thumbnailer-thumbnailer.h>
+
+
+
+static void pixbuf_thumbnailer_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
+ const gchar *uri,
+ const gchar *mime_hint);
+
+
+
+struct _PixbufThumbnailerThumbnailerClass
+{
+ TumblerAbstractThumbnailerClass __parent__;
+};
+
+struct _PixbufThumbnailerThumbnailer
+{
+ TumblerAbstractThumbnailer __parent__;
+};
+
+
+
+G_DEFINE_DYNAMIC_TYPE (PixbufThumbnailerThumbnailer,
+ pixbuf_thumbnailer_thumbnailer,
+ TUMBLER_TYPE_ABSTRACT_THUMBNAILER);
+
+
+
+void
+pixbuf_thumbnailer_thumbnailer_register (TumblerProviderPlugin *plugin)
+{
+ pixbuf_thumbnailer_thumbnailer_register_type (G_TYPE_MODULE (plugin));
+}
+
+
+
+static void
+pixbuf_thumbnailer_thumbnailer_class_init (PixbufThumbnailerThumbnailerClass *klass)
+{
+ TumblerAbstractThumbnailerClass *abstractthumbnailer_class;
+
+ /* Determine the parent type class */
+ pixbuf_thumbnailer_thumbnailer_parent_class = g_type_class_peek_parent (klass);
+
+ abstractthumbnailer_class = TUMBLER_ABSTRACT_THUMBNAILER_CLASS (klass);
+ abstractthumbnailer_class->create = pixbuf_thumbnailer_thumbnailer_create;
+}
+
+
+
+static void
+pixbuf_thumbnailer_thumbnailer_class_finalize (PixbufThumbnailerThumbnailerClass *klass)
+{
+}
+
+
+
+static void
+pixbuf_thumbnailer_thumbnailer_init (PixbufThumbnailerThumbnailer *thumbnailer)
+{
+}
+
+
+
+static GdkPixbuf *
+generate_pixbuf (GdkPixbuf *source,
+ TumblerThumbnailFlavor flavor)
+{
+ gdouble hratio;
+ gdouble wratio;
+ gint dest_width;
+ gint dest_height;
+ gint source_width;
+ gint source_height;
+
+ /* determine the source pixbuf dimensions */
+ source_width = gdk_pixbuf_get_width (source);
+ source_height = gdk_pixbuf_get_height (source);
+
+ /* determine the desired size for this flavor */
+ tumbler_thumbnail_flavor_get_size (flavor, &dest_width, &dest_height);
+
+ /* return the same pixbuf if no scaling is required */
+ if (source_width <= dest_width && source_height <= dest_height)
+ return g_object_ref (source);
+
+ if (flavor == TUMBLER_THUMBNAIL_FLAVOR_CROPPED)
+ {
+ /* TODO unsupported */
+ }
+ else
+ {
+ /* determine which axis needs to be scaled down more */
+ wratio = (gdouble) source_width / (gdouble) dest_width;
+ hratio = (gdouble) source_height / (gdouble) dest_height;
+
+ /* adjust the other axis */
+ if (hratio > wratio)
+ dest_width = rint (source_width / hratio);
+ else
+ dest_height = rint (source_height / wratio);
+ }
+
+ /* scale the pixbuf down to the desired size */
+ return gdk_pixbuf_scale_simple (source, MAX (dest_width, 1), MAX (dest_height, 1),
+ GDK_INTERP_BILINEAR);
+}
+
+
+
+static void
+pixbuf_thumbnailer_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
+ const gchar *uri,
+ const gchar *mime_hint)
+{
+ TumblerThumbnailFlavor *flavors;
+ TumblerThumbnailFlavor flavor;
+ GFileInputStream *stream;
+ TumblerFileInfo *info;
+ GHashTable *pixbufs;
+ GdkPixbuf *source_pixbuf;
+ GdkPixbuf *pixbuf;
+ guint64 mtime;
+ GError *error = NULL;
+ GFile *file;
+ GList *lp;
+ GList *thumbnails;
+ guint n;
+
+ g_return_if_fail (PIXBUF_THUMBNAILER_IS_THUMBNAILER (thumbnailer));
+ g_return_if_fail (uri != NULL && *uri != '\0');
+
+ /* create the file info for this URI */
+ info = tumbler_file_info_new (uri);
+
+ /* try to load the file information */
+ if (!tumbler_file_info_load (info, NULL, &error))
+ {
+ g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_error_free (error);
+ g_object_unref (info);
+ return;
+ }
+
+ /* try to open the source file for reading */
+ file = g_file_new_for_uri (uri);
+ stream = g_file_read (file, NULL, &error);
+ g_object_unref (file);
+
+ if (stream == NULL)
+ {
+ g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_error_free (error);
+ g_object_unref (info);
+ return;
+ }
+
+ source_pixbuf = gdk_pixbuf_new_from_stream (G_INPUT_STREAM (stream), NULL, &error);
+ g_object_unref (stream);
+
+ if (source_pixbuf == NULL)
+ {
+ g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_error_free (error);
+ g_object_unref (info);
+ return;
+ }
+
+ flavors = tumbler_thumbnail_get_flavors ();
+ pixbufs = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref);
+
+ for (n = 0; flavors[n] != TUMBLER_THUMBNAIL_FLAVOR_INVALID; ++n)
+ {
+ pixbuf = generate_pixbuf (source_pixbuf, flavors[n]);
+
+ if (pixbuf != NULL)
+ g_hash_table_insert (pixbufs, GINT_TO_POINTER (flavors[n]), pixbuf);
+ }
+
+ mtime = tumbler_file_info_get_mtime (info);
+
+ thumbnails = tumbler_file_info_get_thumbnails (info);
+
+ for (lp = thumbnails; error == NULL && lp != NULL; lp = lp->next)
+ {
+ if (tumbler_thumbnail_load (lp->data, NULL, &error))
+ if (tumbler_thumbnail_needs_update (lp->data, uri, mtime))
+ {
+ flavor = tumbler_thumbnail_get_flavor (lp->data);
+ pixbuf = g_hash_table_lookup (pixbufs, GINT_TO_POINTER (flavor));
+
+ if (pixbuf != NULL)
+ tumbler_thumbnail_save_pixbuf (lp->data, pixbuf, mtime, 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_hash_table_unref (pixbufs);
+ g_object_unref (source_pixbuf);
+ g_object_unref (info);
+}
diff --git a/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-thumbnailer.h b/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-thumbnailer.h
new file mode 100644
index 0000000..3570c00
--- /dev/null
+++ b/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer-thumbnailer.h
@@ -0,0 +1,43 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2009 Jannis Pohlmann <jannis@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 __PIXBUF_THUMBNAILER_THUMBNAILER_H__
+#define __PIXBUF_THUMBNAILER_THUMBNAILER_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS;
+
+#define PIXBUF_THUMBNAILER_TYPE_THUMBNAILER (pixbuf_thumbnailer_thumbnailer_get_type ())
+#define PIXBUF_THUMBNAILER_THUMBNAILER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIXBUF_THUMBNAILER_TYPE_THUMBNAILER, PixbufThumbnailerThumbnailer))
+#define PIXBUF_THUMBNAILER_THUMBNAILER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIXBUF_THUMBNAILER_TYPE_THUMBNAILER, PixbufThumbnailerThumbnailerClass))
+#define PIXBUF_THUMBNAILER_IS_THUMBNAILER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIXBUF_THUMBNAILER_TYPE_THUMBNAILER))
+#define PIXBUF_THUMBNAILER_IS_THUMBNAILER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIXBUF_THUMBNAILER_TYPE_THUMBNAILER)
+#define PIXBUF_THUMBNAILER_THUMBNAILER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIXBUF_THUMBNAILER_TYPE_THUMBNAILER, PixbufThumbnailerThumbnailerClass))
+
+typedef struct _PixbufThumbnailerThumbnailerClass PixbufThumbnailerThumbnailerClass;
+typedef struct _PixbufThumbnailerThumbnailer PixbufThumbnailerThumbnailer;
+
+GType pixbuf_thumbnailer_thumbnailer_get_type (void) G_GNUC_CONST;
+void pixbuf_thumbnailer_thumbnailer_register (TumblerProviderPlugin *plugin);
+
+G_END_DECLS;
+
+#endif /* !__PIXBUF_THUMBNAILER_THUMBNAILER_H__ */