From 9dbe70f01ead8b57f6183021edc34b374110f45b Mon Sep 17 00:00:00 2001 From: Olivier Duchateau Date: Fri, 7 Jun 2019 12:55:31 +0200 Subject: [PATCH] Add rsvg-thumbnailer plugin --- acinclude.m4 | 23 ++ configure.ac | 7 + plugins/Makefile.am | 1 + plugins/rsvg-thumbnailer/Makefile.am | 47 ++++ .../rsvg-thumbnailer-plugin.c | 91 +++++++ .../rsvg-thumbnailer-provider.c | 122 +++++++++ .../rsvg-thumbnailer-provider.h | 44 +++ plugins/rsvg-thumbnailer/rsvg-thumbnailer.c | 255 ++++++++++++++++++ plugins/rsvg-thumbnailer/rsvg-thumbnailer.h | 44 +++ po/POTFILES.in | 1 + tumblerd/tumbler.rc | 9 +- 11 files changed, 643 insertions(+), 1 deletion(-) create mode 100644 plugins/rsvg-thumbnailer/Makefile.am create mode 100644 plugins/rsvg-thumbnailer/rsvg-thumbnailer-plugin.c create mode 100644 plugins/rsvg-thumbnailer/rsvg-thumbnailer-provider.c create mode 100644 plugins/rsvg-thumbnailer/rsvg-thumbnailer-provider.h create mode 100644 plugins/rsvg-thumbnailer/rsvg-thumbnailer.c create mode 100644 plugins/rsvg-thumbnailer/rsvg-thumbnailer.h diff --git a/acinclude.m4 b/acinclude.m4 index 596917b..fe7f644 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -304,3 +304,26 @@ AM_CONDITIONAL([TUMBLER_DESKTOP_THUMBNAILER], [test x"$ac_tumbler_desktop_thumbn AC_MSG_RESULT([$ac_tumbler_desktop_thumbnailer]) ]) + + +dnl TUMBLER_RSVG_THUMBNAILER() +dnl +dnl Check whether to build the librsvg thumbnailer plugin. +dnl +AC_DEFUN([TUMBLER_RSVG_THUMBNAILER], +[ +AC_ARG_ENABLE([rsvg-thumbnailer], [AC_HELP_STRING([--disable-rsvg-thumbnailer], [Don't build the librsvg thumbnailer plugin])], + [ac_tumbler_rsvg_thumbnailer=$enableval], [ac_tumbler_rsvg_thumbnailer=yes]) +if test x"$ac_tumbler_rsvg_thumbnailer" = x"yes"; then + dnl Check for gdk-pixbuf + PKG_CHECK_MODULES([GDK_PIXBUF], [gdk-pixbuf-2.0 >= 2.14], + [ + dnl Check for librsvg + PKG_CHECK_MODULES([RSVG], [librsvg-2.0 >= 2.44.0], [], [ac_tumbler_rsvg_thumbnailer=no]) + ], [ac_tumbler_rsvg_thumbnailer=no]) +fi + +AC_MSG_CHECKING([whether to build the librsvg thumbnailer plugin]) +AM_CONDITIONAL([TUMBLER_RSVG_THUMBNAILER], [test x"$ac_tumbler_rsvg_thumbnailer" = x"yes"]) +AC_MSG_RESULT([$ac_tumbler_rsvg_thumbnailer]) +]) diff --git a/configure.ac b/configure.ac index d5a7a1f..6595eae 100644 --- a/configure.ac +++ b/configure.ac @@ -163,6 +163,7 @@ TUMBLER_POPPLER_THUMBNAILER() TUMBLER_RAW_THUMBNAILER() TUMBLER_XDG_CACHE() TUMBLER_DESKTOP_THUMBNAILER() +TUMBLER_RSVG_THUMBNAILER() dnl *********************************** dnl *** Check for debugging support *** @@ -198,6 +199,7 @@ plugins/poppler-thumbnailer/Makefile plugins/raw-thumbnailer/Makefile plugins/xdg-cache/Makefile plugins/desktop-thumbnailer/Makefile +plugins/rsvg-thumbnailer/Makefile po/Makefile.in tumbler/Makefile tumbler/tumbler-1.pc @@ -270,4 +272,9 @@ echo " * Loading thumbnailers from .thumbnailer files: yes" else echo " * Loading thumbnailers from .thumbnailer files: no" fi +if test x"$ac_tumbler_rsvg_thumbnailer" = x"yes"; then +echo " * SVG thumbnailer plugin using librsvg: yes" +else +echo " * SVG thumbnailer plugin using librsvg: no" +fi echo diff --git a/plugins/Makefile.am b/plugins/Makefile.am index f2b5307..656427b 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -28,4 +28,5 @@ SUBDIRS = \ poppler-thumbnailer \ raw-thumbnailer \ desktop-thumbnailer \ + rsvg-thumbnailer \ xdg-cache diff --git a/plugins/rsvg-thumbnailer/Makefile.am b/plugins/rsvg-thumbnailer/Makefile.am new file mode 100644 index 0000000..0fa2b95 --- /dev/null +++ b/plugins/rsvg-thumbnailer/Makefile.am @@ -0,0 +1,47 @@ +# vi:set ts=8 sw=8 noet ai nocindent: + +if TUMBLER_RSVG_THUMBNAILER + +tumbler_plugindir = $(libdir)/tumbler-$(TUMBLER_VERSION_API)/plugins +tumbler_plugin_LTLIBRARIES = \ + tumbler-rsvg-thumbnailer.la + +tumbler_rsvg_thumbnailer_la_SOURCES = \ + rsvg-thumbnailer-plugin.c \ + rsvg-thumbnailer-provider.c \ + rsvg-thumbnailer-provider.h \ + rsvg-thumbnailer.c \ + rsvg-thumbnailer.h + +tumbler_rsvg_thumbnailer_la_CFLAGS = \ + -I$(top_builddir) \ + -I$(top_builddir)/plugins \ + -I$(top_srcdir) \ + -I$(top_srcdir)/plugins \ + -DG_LOG_DOMAIN=\"tumbler-rsvg-thumbnailer\" \ + -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \ + $(GDK_PIXBUF_CFLAGS) \ + $(GIO_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(RSVG_CFLAGS) \ + $(PLATFORM_CFLAGS) \ + $(PLATFORM_CPPFLAGS) + +tumbler_rsvg_thumbnailer_la_LDFLAGS = \ + -avoid-version \ + -export-dynamic \ + -module \ + $(PLATFORM_LDFLAGS) + +tumbler_rsvg_thumbnailer_la_LIBADD = \ + $(top_builddir)/tumbler/libtumbler-$(TUMBLER_VERSION_API).la \ + $(GDK_PIXBUF_LIBS) \ + $(GIO_LIBS) \ + $(GLIB_LIBS) \ + $(RSVG_LIBS) \ + -lm + +tumbler_rsvg_thumbnailer_la_DEPENDENCIES = \ + $(top_builddir)/tumbler/libtumbler-$(TUMBLER_VERSION_API).la + +endif diff --git a/plugins/rsvg-thumbnailer/rsvg-thumbnailer-plugin.c b/plugins/rsvg-thumbnailer/rsvg-thumbnailer-plugin.c new file mode 100644 index 0000000..f1518a0 --- /dev/null +++ b/plugins/rsvg-thumbnailer/rsvg-thumbnailer-plugin.c @@ -0,0 +1,91 @@ +/* vi:set et ai sw=2 sts=2 ts=2: */ +/*- + * Copyright (c) 2010 Jannis Pohlmann + * + * 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 +#endif + +#include +#include +#include + +#include + +#include "rsvg-thumbnailer-provider.h" +#include "rsvg-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_print ("Initializing the Tumbler Rsvg Thumbnailer plugin\n"); +#endif + + /* register the types provided by this plugin */ + rsvg_thumbnailer_register (plugin); + rsvg_thumbnailer_provider_register (plugin); + + /* set up the plugin provider type list */ + type_list[0] = TYPE_RSVG_THUMBNAILER_PROVIDER; +} + + + +void +tumbler_plugin_shutdown (void) +{ +#ifdef DEBUG + g_print ("Shutting down the Tumbler Rsvg Thumbnailer plugin\n"); +#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/rsvg-thumbnailer/rsvg-thumbnailer-provider.c b/plugins/rsvg-thumbnailer/rsvg-thumbnailer-provider.c new file mode 100644 index 0000000..0d723d6 --- /dev/null +++ b/plugins/rsvg-thumbnailer/rsvg-thumbnailer-provider.c @@ -0,0 +1,122 @@ +/* vi:set et ai sw=2 sts=2 ts=2: */ +/*- + * Copyright (c) 2010 Jannis Pohlmann + * Copyright (c) 2019 Olivier Duchateau + * + * 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 +#endif + +#include +#include + +#include + +#include "rsvg-thumbnailer-provider.h" +#include "rsvg-thumbnailer.h" + + + +static void rsvg_thumbnailer_provider_thumbnailer_provider_init (TumblerThumbnailerProviderIface *iface); +static GList *rsvg_thumbnailer_provider_get_thumbnailers (TumblerThumbnailerProvider *provider); + + + +struct _RsvgThumbnailerProviderClass +{ + GObjectClass __parent__; +}; + +struct _RsvgThumbnailerProvider +{ + GObject __parent__; +}; + + + +G_DEFINE_DYNAMIC_TYPE_EXTENDED (RsvgThumbnailerProvider, + rsvg_thumbnailer_provider, + G_TYPE_OBJECT, + 0, + TUMBLER_ADD_INTERFACE (TUMBLER_TYPE_THUMBNAILER_PROVIDER, + rsvg_thumbnailer_provider_thumbnailer_provider_init)); + + + +void +rsvg_thumbnailer_provider_register (TumblerProviderPlugin *plugin) +{ + rsvg_thumbnailer_provider_register_type (G_TYPE_MODULE (plugin)); +} + + + +static void +rsvg_thumbnailer_provider_class_init (RsvgThumbnailerProviderClass *klass) +{ +} + + + +static void +rsvg_thumbnailer_provider_class_finalize (RsvgThumbnailerProviderClass *klass) +{ +} + + + +static void +rsvg_thumbnailer_provider_thumbnailer_provider_init (TumblerThumbnailerProviderIface *iface) +{ + iface->get_thumbnailers = rsvg_thumbnailer_provider_get_thumbnailers; +} + + + +static void +rsvg_thumbnailer_provider_init (RsvgThumbnailerProvider *provider) +{ +} + + + +static GList * +rsvg_thumbnailer_provider_get_thumbnailers (TumblerThumbnailerProvider *provider) +{ + RsvgThumbnailer *thumbnailer; + static const gchar *mime_types[] = + { + "image/svg+xml", + "image/svg+xml-compressed", + NULL + }; + GStrv uri_schemes; + + /* determine which URI schemes are supported by GIO */ + uri_schemes = tumbler_util_get_supported_uri_schemes (); + + thumbnailer = g_object_new (TYPE_RSVG_THUMBNAILER, + "uri-schemes", uri_schemes, + "mime-types", mime_types, + NULL); + + g_strfreev (uri_schemes); + + return g_list_append (NULL, thumbnailer); +} diff --git a/plugins/rsvg-thumbnailer/rsvg-thumbnailer-provider.h b/plugins/rsvg-thumbnailer/rsvg-thumbnailer-provider.h new file mode 100644 index 0000000..b3382b7 --- /dev/null +++ b/plugins/rsvg-thumbnailer/rsvg-thumbnailer-provider.h @@ -0,0 +1,44 @@ +/* vi:set et ai sw=2 sts=2 ts=2: */ +/*- + * Copyright (c) 2010 Jannis Pohlmann + * Copyright (c) 2019 Olivier Duchateau + * + * 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 __RSVG_THUMBNAILER_PROVIDER_H__ +#define __RSVG_THUMBNAILER_PROVIDER_H__ + +#include + +G_BEGIN_DECLS; + +#define TYPE_RSVG_THUMBNAILER_PROVIDER (rsvg_thumbnailer_provider_get_type ()) +#define RSVG_THUMBNAILER_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_RSVG_THUMBNAILER_PROVIDER, RsvgThumbnailerProvider)) +#define RSVG_THUMBNAILER_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_RSVG_THUMBNAILER_PROVIDER, RsvgThumbnailerProviderClass)) +#define IS_RSVG_THUMBNAILER_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_RSVG_THUMBNAILER_PROVIDER)) +#define IS_RSVG_THUMBNAILER_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_RSVG_THUMBNAILER_PROVIDER) +#define RSVG_THUMBNAILER_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_RSVG_THUMBNAILER_PROVIDER, RsvgThumbnailerProviderClass)) + +typedef struct _RsvgThumbnailerProviderClass RsvgThumbnailerProviderClass; +typedef struct _RsvgThumbnailerProvider RsvgThumbnailerProvider; + +GType rsvg_thumbnailer_provider_get_type (void) G_GNUC_CONST; +void rsvg_thumbnailer_provider_register (TumblerProviderPlugin *plugin); + +G_END_DECLS; + +#endif /* !__RSVG_THUMBNAILER_PROVIDER_H__ */ diff --git a/plugins/rsvg-thumbnailer/rsvg-thumbnailer.c b/plugins/rsvg-thumbnailer/rsvg-thumbnailer.c new file mode 100644 index 0000000..1ab8c47 --- /dev/null +++ b/plugins/rsvg-thumbnailer/rsvg-thumbnailer.c @@ -0,0 +1,255 @@ +/* vi:set et ai sw=2 sts=2 ts=2: */ +/*- + * Copyright (c) 2010 Jannis Pohlmann + * Copyright (c) 2019 Olivier Duchateau + * + * 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 +#endif + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "rsvg-thumbnailer.h" + + +static GdkPixbuf *rsvg_pixbuf_scaled (GdkPixbuf *source, + TumblerThumbnail *thumbnail); +static void rsvg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, + GCancellable *cancellable, + TumblerFileInfo *info); + + + +struct _RsvgThumbnailerClass +{ + TumblerAbstractThumbnailerClass __parent__; +}; + +struct _RsvgThumbnailer +{ + TumblerAbstractThumbnailer __parent__; +}; + + + +G_DEFINE_DYNAMIC_TYPE (RsvgThumbnailer, + rsvg_thumbnailer, + TUMBLER_TYPE_ABSTRACT_THUMBNAILER); + + + +void +rsvg_thumbnailer_register (TumblerProviderPlugin *plugin) +{ + rsvg_thumbnailer_register_type (G_TYPE_MODULE (plugin)); +} + + + +static void +rsvg_thumbnailer_class_init (RsvgThumbnailerClass *klass) +{ + TumblerAbstractThumbnailerClass *abstractthumbnailer_class; + + abstractthumbnailer_class = TUMBLER_ABSTRACT_THUMBNAILER_CLASS (klass); + abstractthumbnailer_class->create = rsvg_thumbnailer_create; +} + + + +static void +rsvg_thumbnailer_class_finalize (RsvgThumbnailerClass *klass) +{ +} + + + +static void +rsvg_thumbnailer_init (RsvgThumbnailer *thumbnailer) +{ +} + + + +static GdkPixbuf * +rsvg_pixbuf_scaled (GdkPixbuf *source, + TumblerThumbnail *thumbnail) +{ + TumblerThumbnailFlavor *flavor; + gdouble hratio; + gdouble wratio; + gint dest_width; + gint dest_height; + gint width; + gint height; + + g_return_val_if_fail (TUMBLER_IS_THUMBNAIL (thumbnail), NULL); + + flavor = tumbler_thumbnail_get_flavor (thumbnail); + tumbler_thumbnail_flavor_get_size (flavor, &dest_width, &dest_height); + g_object_unref (flavor); + + /* width and height of (original) pixbuf */ + width = gdk_pixbuf_get_width (source); + height = gdk_pixbuf_get_height (source); + + if (width <= dest_width && height <= dest_height) + return g_object_ref (source); + + /* determine which axis needs to be scaled down more */ + wratio = (gdouble) width / (gdouble) dest_width; + hratio = (gdouble) height / (gdouble) dest_height; + + /* adjust the other axis */ + if (hratio > wratio) + dest_width = rint (width / hratio); + else + dest_height = rint (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 +rsvg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, + GCancellable *cancellable, + TumblerFileInfo *info) +{ + TumblerImageData data; + TumblerThumbnail *thumbnail; + const gchar *uri; + GdkPixbuf *source_pixbuf; + GdkPixbuf *pixbuf; + GError *error = NULL; + GFile *file; + RsvgHandle *handle; + GFileInputStream *stream; + + g_return_if_fail (IS_RSVG_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); + + /* try to load the SVG file */ + file = g_file_new_for_uri (uri); + + handle = rsvg_handle_new (); + rsvg_handle_set_base_gfile (handle, file); + + stream = g_file_read (file, NULL, &error); + g_object_unref (file); + if (stream == NULL) + { + 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, "error", uri, + TUMBLER_ERROR_NO_CONTENT, + "Failed to open stream"); + } + return; + } + + if (!rsvg_handle_read_stream_sync (handle, + G_INPUT_STREAM (stream), + NULL, &error)) + { + g_signal_emit_by_name (thumbnailer, "error", uri, error->code, + error->message); + g_error_free (error); + + g_object_unref (stream); + g_object_unref (handle); + + return; + } + + /* get the pixbuf (not yet scaled, if needed) */ + if (!rsvg_handle_close (handle, &error)) + { + g_signal_emit_by_name (thumbnailer, "error", uri, error->code, + error->message); + g_error_free (error); + + g_object_unref (stream); + g_object_unref (handle); + + return; + } + source_pixbuf = rsvg_handle_get_pixbuf (handle); + + /* release allocated RsvgHandle object */ + g_object_unref (handle); + + thumbnail = tumbler_file_info_get_thumbnail (info); + g_assert (thumbnail != NULL); + + pixbuf = rsvg_pixbuf_scaled (source_pixbuf, thumbnail); + g_assert (pixbuf != NULL); + g_object_unref (source_pixbuf); + + 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, + TUMBLER_ERROR_SAVE_FAILED, + "Thumbnail has not been saved"); + 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/rsvg-thumbnailer/rsvg-thumbnailer.h b/plugins/rsvg-thumbnailer/rsvg-thumbnailer.h new file mode 100644 index 0000000..440cb4f --- /dev/null +++ b/plugins/rsvg-thumbnailer/rsvg-thumbnailer.h @@ -0,0 +1,44 @@ +/* vi:set et ai sw=2 sts=2 ts=2: */ +/*- + * Copyright (c) 2010 Jannis Pohlmann + * Copyright (c) 2019 Olivier Duchateau + * + * 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 __RSVG_THUMBNAILER_H__ +#define __RSVG_THUMBNAILER_H__ + +#include + +G_BEGIN_DECLS; + +#define TYPE_RSVG_THUMBNAILER (rsvg_thumbnailer_get_type ()) +#define RSVG_THUMBNAILER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_RSVG_THUMBNAILER, RsvgThumbnailer)) +#define RSVG_THUMBNAILER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_RSVG_THUMBNAILER, RsvgThumbnailerClass)) +#define IS_RSVG_THUMBNAILER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_RSVG_THUMBNAILER)) +#define IS_RSVG_THUMBNAILER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_RSVG_THUMBNAILER) +#define RSVG_THUMBNAILER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_RSVG_THUMBNAILER, RsvgThumbnailerClass)) + +typedef struct _RsvgThumbnailerClass RsvgThumbnailerClass; +typedef struct _RsvgThumbnailer RsvgThumbnailer; + +GType rsvg_thumbnailer_get_type (void) G_GNUC_CONST; +void rsvg_thumbnailer_register (TumblerProviderPlugin *plugin); + +G_END_DECLS; + +#endif /* !__RSVG_THUMBNAILER_H__ */ diff --git a/po/POTFILES.in b/po/POTFILES.in index 6def9ac..b17d8b8 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -47,3 +47,4 @@ plugins/xdg-cache/xdg-cache-cache.c plugins/desktop-thumbnailer/desktop-thumbnailer.c plugins/desktop-thumbnailer/desktop-thumbnailer-plugin.c plugins/desktop-thumbnailer/desktop-thumbnailer-provider.c +plugins/rsvg-thumbnailer/rsvg-thumbnailer-plugin.c diff --git a/tumblerd/tumbler.rc b/tumblerd/tumbler.rc index 865d2cf..b3fde94 100644 --- a/tumblerd/tumbler.rc +++ b/tumblerd/tumbler.rc @@ -21,6 +21,13 @@ # Image Thumbnailers ### +# SVG support (even compressed format) +[RsvgThumbnailer] +Disabled=false +Priority=4 +Locations= +MaxFileSize=209715200 + # Jpeg thumbnailer (from exif data if possible) [JPEGThumbnailer] Disabled=false @@ -101,4 +108,4 @@ MaxFileSize=209715200 Disabled=false Priority=1 Locations= -MaxFileSize=2147483648 \ No newline at end of file +MaxFileSize=2147483648 -- 2.20.1