[Xfce4-commits] <tumbler:jeromeg/webkit-thumbnailer-rebased> First try at a webkit thumbnailer.
Jérôme Guelfucci
noreply at xfce.org
Sun Feb 24 14:42:01 CET 2013
Updating branch refs/heads/jeromeg/webkit-thumbnailer-rebased
to aa519ade6b5419c5f58d786fecaf2eabf0fb29c7 (commit)
from 8bdc6a810f1a8a45d0ecaf170d4938bebf05c91b (commit)
commit aa519ade6b5419c5f58d786fecaf2eabf0fb29c7
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date: Fri Mar 18 11:48:44 2011 +0100
First try at a webkit thumbnailer.
It does not work here because GtkOffscreenWindow crashes when shown.
Seems to be a Gtk bug which I'm investigating. I don't guarantee that it
will work for anyone as I obviously could not test it. For example, I
don't know what will happen when called on a huge HTML page.
acinclude.m4 | 59 ++++--
configure.ac | 26 ++-
plugins/Makefile.am | 17 +-
.../Makefile.am | 48 ++--
.../webkit-thumbnailer-plugin.c} | 15 +-
.../webkit-thumbnailer-provider.c} | 62 +++---
.../webkit-thumbnailer-provider.h | 44 ++++
.../webkit-thumbnailer.c} | 229 +++++++++++---------
plugins/webkit-thumbnailer/webkit-thumbnailer.h | 44 ++++
po/POTFILES.in | 3 +
10 files changed, 340 insertions(+), 207 deletions(-)
diff --git a/acinclude.m4 b/acinclude.m4
index 66e79d1..93a5098 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -2,18 +2,18 @@ dnl vi:set et ai sw=2 sts=2 ts=2: */
dnl -
dnl Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
dnl
-dnl This program is free software; you can redistribute it and/or
+dnl This program is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU General Public License as
-dnl published by the Free Software Foundation; either version 2 of
+dnl published by the Free Software Foundation; either version 2 of
dnl the License, or (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
-dnl You should have received a copy of the GNU General Public
-dnl License along with this program; if not, write to the Free
+dnl You should have received a copy of the GNU General Public
+dnl License along with this program; if not, write to the Free
dnl Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
dnl Boston, MA 02110-1301, USA.
@@ -48,8 +48,8 @@ AC_DEFUN([TUMBLER_FONT_THUMBNAILER],
AC_ARG_ENABLE([font-thumbnailer], [AC_HELP_STRING([--disable-font-thumbnailer], [Don't build the FreeType font thumbnailer plugin])],
[ac_tumbler_font_thumbnailer=$enableval], [ac_tumbler_font_thumbnailer=yes])
if test x"$ac_tumbler_font_thumbnailer" = x"yes"; then
- dnl Check for gdk-pixbuf
- PKG_CHECK_MODULES([GDK_PIXBUF], [gdk-pixbuf-2.0 >= 2.14],
+ dnl Check for gdk-pixbuf
+ PKG_CHECK_MODULES([GDK_PIXBUF], [gdk-pixbuf-2.0 >= 2.14],
[
dnl Check for FreeType 2.x
FREETYPE_LIBS=""
@@ -59,7 +59,7 @@ if test x"$ac_tumbler_font_thumbnailer" = x"yes"; then
AC_MSG_CHECKING([FREETYPE_CFLAGS])
FREETYPE_CFLAGS="`$FREETYPE_CONFIG --cflags`"
AC_MSG_RESULT([$FREETYPE_CFLAGS])
-
+
AC_MSG_CHECKING([FREETYPE_LIBS])
FREETYPE_LIBS="`$FREETYPE_CONFIG --libs`"
AC_MSG_RESULT([$FREETYPE_LIBS])
@@ -81,7 +81,7 @@ AC_MSG_RESULT([$ac_tumbler_font_thumbnailer])
dnl TUMBLER_JPEG_THUMBNAILER()
dnl
-dnl Check whether to build and install the JPEG thumbnailer plugin with
+dnl Check whether to build and install the JPEG thumbnailer plugin with
dnl EXIF support.
dnl
AC_DEFUN([TUMBLER_JPEG_THUMBNAILER],
@@ -89,8 +89,8 @@ AC_DEFUN([TUMBLER_JPEG_THUMBNAILER],
AC_ARG_ENABLE([jpeg-thumbnailer], [AC_HELP_STRING([--disable-jpeg-thumbnailer], [Don't build the JPEG thumbnailer plugin with EXIF support])],
[ac_tumbler_jpeg_thumbnailer=$enableval], [ac_tumbler_jpeg_thumbnailer=yes])
if test x"$ac_tumbler_jpeg_thumbnailer" = x"yes"; then
- dnl Check for gdk-pixbuf
- PKG_CHECK_MODULES([GDK_PIXBUF], [gdk-pixbuf-2.0 >= 2.14],
+ dnl Check for gdk-pixbuf
+ PKG_CHECK_MODULES([GDK_PIXBUF], [gdk-pixbuf-2.0 >= 2.14],
[
dnl Check for libjpeg
LIBJPEG_LIBS=""
@@ -131,7 +131,7 @@ AC_ARG_ENABLE([ffmpeg-thumbnailer], [AC_HELP_STRING([--disable-ffmpeg-thumbnaile
[ac_tumbler_ffmpeg_thumbnailer=$enableval], [ac_tumbler_ffmpeg_thumbnailer=yes])
if test x"$ac_tumbler_ffmpeg_thumbnailer" = x"yes"; then
dnl Check for gdk-pixbuf
- PKG_CHECK_MODULES([GDK_PIXBUF], [gdk-pixbuf-2.0 >= 2.14],
+ PKG_CHECK_MODULES([GDK_PIXBUF], [gdk-pixbuf-2.0 >= 2.14],
[
dnl Check for libffmpegthumbnailer
PKG_CHECK_MODULES([FFMPEGTHUMBNAILER], [libffmpegthumbnailer >= 2.0.0], [], [ac_tumbler_ffmpeg_thumbnailer=no])
@@ -182,7 +182,7 @@ AC_ARG_ENABLE([poppler-thumbnailer], [AC_HELP_STRING([--disable-poppler-thumbnai
[ac_tumbler_poppler_thumbnailer=$enableval], [ac_tumbler_poppler_thumbnailer=yes])
if test x"$ac_tumbler_poppler_thumbnailer" = x"yes"; then
dnl Check for gdk-pixbuf
- PKG_CHECK_MODULES([GDK_PIXBUF], [gdk-pixbuf-2.0 >= 2.14],
+ PKG_CHECK_MODULES([GDK_PIXBUF], [gdk-pixbuf-2.0 >= 2.14],
[
dnl Check for poppler-glib
PKG_CHECK_MODULES([POPPLER_GLIB], [poppler-glib >= 0.12.0], [], [ac_tumbler_poppler_thumbnailer=no])
@@ -264,6 +264,29 @@ fi
AC_MSG_CHECKING([whether to build the Cover thumbnailer plugin])
AM_CONDITIONAL([TUMBLER_COVER_THUMBNAILER], [test x"$ac_tumbler_cover_thumbnailer" = x"yes"])
AC_MSG_RESULT([$ac_tumbler_cover_thumbnailer])
+
+
+
+dnl TUMBLER_WEBKIT_THUMBNAILER()
+dnl
+dnl Check whether to build and install the Webkit HTML thumbnailer plugin.
+dnl
+AC_DEFUN([TUMBLER_WEBKIT_THUMBNAILER],
+[
+AC_ARG_ENABLE([webkit-thumbnailer], [AC_HELP_STRING([--disable-webkit-thumbnailer], [Don't build the Webkit HTML thumbnailer plugin])],
+ [ac_tumbler_webkit_thumbnailer=$enableval], [ac_tumbler_webkit_thumbnailer=yes])
+if test x"$ac_tumbler_webkit_thumbnailer" = x"yes"; then
+ dnl Check for gdk-pixbuf
+ PKG_CHECK_MODULES([GDK_PIXBUF], [gdk-pixbuf-2.0 >= 2.14],
+ [
+ dnl Check for webkit
+ PKG_CHECK_MODULES([WEBKIT], [webkit-1.0 >= 1.2.0], [], [ac_tumbler_webkit_thumbnailer=no])
+ ], [ac_tumbler_webkit_thumbnailer=no])
+fi
+
+AC_MSG_CHECKING([whether to build the Webkit HTML thumbnailer plugin])
+AM_CONDITIONAL([TUMBLER_WEBKIT_THUMBNAILER], [test x"$ac_tumbler_webkit_thumbnailer" = x"yes"])
+AC_MSG_RESULT([$ac_tumbler_webkit_thumbnailer])
])
@@ -277,14 +300,14 @@ AC_DEFUN([TUMBLER_XDG_CACHE],
AC_ARG_ENABLE([xdg-cache], [AC_HELP_STRING([--disable-xdg-cache], [Don't build the freedesktop.org cache plugin])],
[ac_tumbler_xdg_cache=$enableval], [ac_tumbler_xdg_cache=yes])
if test x"$ac_tumbler_xdg_cache" = x"yes"; then
- dnl Check for gdk-pixbuf
- PKG_CHECK_MODULES([GDK_PIXBUF], [gdk-pixbuf-2.0 >= 2.14],
+ dnl Check for gdk-pixbuf
+ PKG_CHECK_MODULES([GDK_PIXBUF], [gdk-pixbuf-2.0 >= 2.14],
[
dnl Check for PNG libraries
- PKG_CHECK_MODULES(PNG, libpng >= 1.2.0, [have_libpng=yes],
+ PKG_CHECK_MODULES(PNG, libpng >= 1.2.0, [have_libpng=yes],
[
dnl libpng.pc not found, try with libpng12.pc
- PKG_CHECK_MODULES(PNG, libpng12 >= 1.2.0, [have_libpng=yes],
+ PKG_CHECK_MODULES(PNG, libpng12 >= 1.2.0, [have_libpng=yes],
[
have_libpng=no
ac_tumbler_xdg_cache=no
@@ -297,3 +320,5 @@ AC_MSG_CHECKING([whether to build the freedesktop.org cache plugin])
AM_CONDITIONAL([TUMBLER_XDG_CACHE], [test x"$ac_tumbler_xdg_cache" = x"yes"])
AC_MSG_RESULT([$ac_tumbler_xdg_cache])
])
+
+
diff --git a/configure.ac b/configure.ac
index b19bc60..8a974ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,19 +1,19 @@
# vi:set et ai sw=2 sts=2 ts=2: */
# -
# Copyright (c) 2009-2011 Jannis Pohlmann <jannis at xfce.org>
-#
-# This program is free software; you can redistribute it and/or
+#
+# 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
+# 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
+# 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
+#
+# 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.
@@ -134,7 +134,7 @@ AC_ARG_VAR([DBUS_BINDING_TOOL], [Tool to generate C bindings from XML D-Bus inte
AC_PATH_PROG([DBUS_BINDING_TOOL], [dbus-binding-tool], [no])
if test x"$DBUS_BINDING_TOOL" = x"no"; then
AC_MSG_ERROR([could not find dbus-binding-tool in \$PATH. You can run
- ./configure DBUS_BINDING_TOOL=/path/to/dbus-binding-tool to define
+ ./configure DBUS_BINDING_TOOL=/path/to/dbus-binding-tool to define
a custom location for it.])
fi
@@ -160,6 +160,7 @@ TUMBLER_GSTREAMER_THUMBNAILER()
TUMBLER_ODF_THUMBNAILER()
TUMBLER_POPPLER_THUMBNAILER()
TUMBLER_RAW_THUMBNAILER()
+TUMBLER_WEBKIT_THUMBNAILER()
TUMBLER_XDG_CACHE()
dnl ***********************************
@@ -194,6 +195,7 @@ plugins/ffmpeg-thumbnailer/Makefile
plugins/odf-thumbnailer/Makefile
plugins/poppler-thumbnailer/Makefile
plugins/raw-thumbnailer/Makefile
+plugins/webkit-thumbnailer/Makefile
plugins/xdg-cache/Makefile
po/Makefile.in
tumbler/Makefile
@@ -257,9 +259,13 @@ echo " * RAW thumbnailer plugin using libopenraw: yes"
else
echo " * RAW thumbnailer plugin using libopenraw: no"
fi
+if test x"$ac_tumbler_webkit_thumbnailer" = x"yes"; then
+echo " * HTML thumbnailer plugin using Webkit: yes"
+else
+echo " * HTML thumbnailer plugin using Webkit: no"
+fi
if test x"$ac_tumbler_xdg_cache" = x"yes"; then
echo " * Freedesktop.org cache plugin: yes"
else
echo " * Freedesktop.org cache plugin: no"
fi
-echo
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index f2c9f5f..57abb1b 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,19 +1,19 @@
# vi:set ts=8 sw=8 noet ai nocindent:
# -
# Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
-#
-# This program is free software; you can redistribute it and/or
+#
+# 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
+# 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
+# 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
+#
+# 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.
@@ -27,4 +27,5 @@ SUBDIRS = \
odf-thumbnailer \
poppler-thumbnailer \
raw-thumbnailer \
+ webkit-thumbnailer \
xdg-cache
diff --git a/plugins/pixbuf-thumbnailer/Makefile.am b/plugins/webkit-thumbnailer/Makefile.am
similarity index 57%
copy from plugins/pixbuf-thumbnailer/Makefile.am
copy to plugins/webkit-thumbnailer/Makefile.am
index 2852a46..24c6668 100644
--- a/plugins/pixbuf-thumbnailer/Makefile.am
+++ b/plugins/webkit-thumbnailer/Makefile.am
@@ -1,62 +1,62 @@
# vi:set ts=8 sw=8 noet ai nocindent:
# -
-# Copyright (c) 2009-2012 Jannis Pohlmann <jannis at xfce.org>
-#
-# This program is free software; you can redistribute it and/or
+# Copyright (c) 2011 Jérôme Guelfucci <jeromeg at 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
+# 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
+# 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
+#
+# 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 TUMBLER_PIXBUF_THUMBNAILER
+if TUMBLER_WEBKIT_THUMBNAILER
tumbler_plugindir = $(libdir)/tumbler-$(TUMBLER_VERSION_API)/plugins
tumbler_plugin_LTLIBRARIES = \
- tumbler-pixbuf-thumbnailer.la
+ tumbler-webkit-thumbnailer.la
-tumbler_pixbuf_thumbnailer_la_SOURCES = \
- pixbuf-thumbnailer-plugin.c \
- pixbuf-thumbnailer-provider.c \
- pixbuf-thumbnailer-provider.h \
- pixbuf-thumbnailer.c \
- pixbuf-thumbnailer.h
+tumbler_webkit_thumbnailer_la_SOURCES = \
+ webkit-thumbnailer-plugin.c \
+ webkit-thumbnailer-provider.c \
+ webkit-thumbnailer-provider.h \
+ webkit-thumbnailer.c \
+ webkit-thumbnailer.h
-tumbler_pixbuf_thumbnailer_la_CFLAGS = \
+tumbler_webkit_thumbnailer_la_CFLAGS = \
-I$(top_builddir) \
-I$(top_builddir)/plugins \
-I$(top_srcdir) \
-I$(top_srcdir)/plugins \
- -DG_LOG_DOMAIN=\"tumbler-pixbuf-thumbnailer\" \
+ -DG_LOG_DOMAIN=\"tumbler-webkit-thumbnailer\" \
-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
$(GDK_PIXBUF_CFLAGS) \
$(GIO_CFLAGS) \
$(GLIB_CFLAGS) \
- $(PLATFORM_CFLAGS) \
+ $(WEBKIT_CFLAGS) \
$(PLATFORM_CPPFLAGS)
-tumbler_pixbuf_thumbnailer_la_LDFLAGS = \
+tumbler_webkit_thumbnailer_la_LDFLAGS = \
-avoid-version \
-export-dynamic \
-module \
$(PLATFORM_LDFLAGS)
-tumbler_pixbuf_thumbnailer_la_LIBADD = \
+tumbler_webkit_thumbnailer_la_LIBADD = \
$(top_builddir)/tumbler/libtumbler-$(TUMBLER_VERSION_API).la \
$(GDK_PIXBUF_LIBS) \
$(GIO_LIBS) \
$(GLIB_LIBS) \
- -lm
+ $(WEBKIT_LIBS)
-tumbler_pixbuf_thumbnailer_la_DEPENDENCIES = \
+tumbler_webkit_thumbnailer_la_DEPENDENCIES = \
$(top_builddir)/tumbler/libtumbler-$(TUMBLER_VERSION_API).la
endif
diff --git a/plugins/raw-thumbnailer/raw-thumbnailer-plugin.c b/plugins/webkit-thumbnailer/webkit-thumbnailer-plugin.c
similarity index 81%
copy from plugins/raw-thumbnailer/raw-thumbnailer-plugin.c
copy to plugins/webkit-thumbnailer/webkit-thumbnailer-plugin.c
index ec49bed..871e22e 100644
--- a/plugins/raw-thumbnailer/raw-thumbnailer-plugin.c
+++ b/plugins/webkit-thumbnailer/webkit-thumbnailer-plugin.c
@@ -1,6 +1,7 @@
/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
* Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
+ * Copyright (c) 2011 Jérôme Guelfucci <jeromeg 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
@@ -28,8 +29,8 @@
#include <tumbler/tumbler.h>
-#include "raw-thumbnailer-provider.h"
-#include "raw-thumbnailer.h"
+#include <webkit-thumbnailer/webkit-thumbnailer-provider.h>
+#include <webkit-thumbnailer/webkit-thumbnailer.h>
@@ -59,15 +60,15 @@ tumbler_plugin_initialize (TumblerProviderPlugin *plugin)
}
#ifdef DEBUG
- g_print ("Initializing the Tumbler RAW Thumbnailer plugin\n");
+ g_message (_("Initializing the Tumbler Webkit HTML thumbnailer plugin"));
#endif
/* register the types provided by this plugin */
- raw_thumbnailer_register (plugin);
- raw_thumbnailer_provider_register (plugin);
+ webkit_thumbnailer_register (plugin);
+ webkit_thumbnailer_provider_register (plugin);
/* set up the plugin provider type list */
- type_list[0] = TYPE_RAW_THUMBNAILER_PROVIDER;
+ type_list[0] = TYPE_WEBKIT_THUMBNAILER_PROVIDER;
}
@@ -76,7 +77,7 @@ void
tumbler_plugin_shutdown (void)
{
#ifdef DEBUG
- g_print ("Shutting down the Tumbler RAW Thumbnailer plugin\n");
+ g_message (_("Shutting down the Tumbler Webkit HTML thumbnailer plugin"));
#endif
}
diff --git a/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer-provider.c b/plugins/webkit-thumbnailer/webkit-thumbnailer-provider.c
similarity index 59%
copy from plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer-provider.c
copy to plugins/webkit-thumbnailer/webkit-thumbnailer-provider.c
index b76adee..08501c3 100644
--- a/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer-provider.c
+++ b/plugins/webkit-thumbnailer/webkit-thumbnailer-provider.c
@@ -1,7 +1,7 @@
/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
* Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
- * Copyright (c) 2010 Lionel Le Folgoc <mrpouit at ubuntu.com>
+ * Copyright (c) 2011 Jérôme Guelfucci <jeromeg 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
@@ -30,97 +30,89 @@
#include <tumbler/tumbler.h>
-#include <ffmpeg-thumbnailer/ffmpeg-thumbnailer-provider.h>
-#include <ffmpeg-thumbnailer/ffmpeg-thumbnailer.h>
+#include <webkit-thumbnailer/webkit-thumbnailer-provider.h>
+#include <webkit-thumbnailer/webkit-thumbnailer.h>
-static void ffmpeg_thumbnailer_provider_thumbnailer_provider_init (TumblerThumbnailerProviderIface *iface);
-static GList *ffmpeg_thumbnailer_provider_get_thumbnailers (TumblerThumbnailerProvider *provider);
+static void webkit_thumbnailer_provider_thumbnailer_provider_init (TumblerThumbnailerProviderIface *iface);
+static GList *webkit_thumbnailer_provider_get_thumbnailers (TumblerThumbnailerProvider *provider);
-struct _FfmpegThumbnailerProviderClass
+struct _WebkitThumbnailerProviderClass
{
GObjectClass __parent__;
};
-struct _FfmpegThumbnailerProvider
+struct _WebkitThumbnailerProvider
{
GObject __parent__;
};
-G_DEFINE_DYNAMIC_TYPE_EXTENDED (FfmpegThumbnailerProvider,
- ffmpeg_thumbnailer_provider,
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (WebkitThumbnailerProvider,
+ webkit_thumbnailer_provider,
G_TYPE_OBJECT,
0,
TUMBLER_ADD_INTERFACE (TUMBLER_TYPE_THUMBNAILER_PROVIDER,
- ffmpeg_thumbnailer_provider_thumbnailer_provider_init));
+ webkit_thumbnailer_provider_thumbnailer_provider_init));
void
-ffmpeg_thumbnailer_provider_register (TumblerProviderPlugin *plugin)
+webkit_thumbnailer_provider_register (TumblerProviderPlugin *plugin)
{
- ffmpeg_thumbnailer_provider_register_type (G_TYPE_MODULE (plugin));
+ webkit_thumbnailer_provider_register_type (G_TYPE_MODULE (plugin));
}
static void
-ffmpeg_thumbnailer_provider_class_init (FfmpegThumbnailerProviderClass *klass)
+webkit_thumbnailer_provider_class_init (WebkitThumbnailerProviderClass *klass)
{
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
}
static void
-ffmpeg_thumbnailer_provider_class_finalize (FfmpegThumbnailerProviderClass *klass)
+webkit_thumbnailer_provider_class_finalize (WebkitThumbnailerProviderClass *klass)
{
}
static void
-ffmpeg_thumbnailer_provider_thumbnailer_provider_init (TumblerThumbnailerProviderIface *iface)
+webkit_thumbnailer_provider_thumbnailer_provider_init (TumblerThumbnailerProviderIface *iface)
{
- iface->get_thumbnailers = ffmpeg_thumbnailer_provider_get_thumbnailers;
+ iface->get_thumbnailers = webkit_thumbnailer_provider_get_thumbnailers;
}
static void
-ffmpeg_thumbnailer_provider_init (FfmpegThumbnailerProvider *provider)
+webkit_thumbnailer_provider_init (WebkitThumbnailerProvider *provider)
{
}
static GList *
-ffmpeg_thumbnailer_provider_get_thumbnailers (TumblerThumbnailerProvider *provider)
+webkit_thumbnailer_provider_get_thumbnailers (TumblerThumbnailerProvider *provider)
{
static const gchar *mime_types[] =
{
- "video/jpeg",
- "video/mp4",
- "video/mp2t",
- "video/mpeg",
- "video/quicktime",
- "video/x-ms-asf",
- "video/x-ms-wm",
- "video/x-ms-wmv",
- "video/x-msvideo",
- "video/x-flv",
- "application/x-flash-video",
- "application/vnd.rn-realmedia",
- "video/3gpp",
- "video/x-matroska",
- "video/ogg",
+ "text/html",
+ "application/xhtml+xml",
+ "x-scheme-handler/http",
+ "x-scheme-handler/https",
NULL
};
- FfmpegThumbnailer *thumbnailer;
+ WebkitThumbnailer *thumbnailer;
GList *thumbnailers = NULL;
GStrv uri_schemes;
@@ -128,7 +120,7 @@ ffmpeg_thumbnailer_provider_get_thumbnailers (TumblerThumbnailerProvider *provid
uri_schemes = tumbler_util_get_supported_uri_schemes ();
/* create the pixbuf thumbnailer */
- thumbnailer = g_object_new (TYPE_FFMPEG_THUMBNAILER,
+ thumbnailer = g_object_new (TYPE_WEBKIT_THUMBNAILER,
"uri-schemes", uri_schemes, "mime-types", mime_types,
NULL);
diff --git a/plugins/webkit-thumbnailer/webkit-thumbnailer-provider.h b/plugins/webkit-thumbnailer/webkit-thumbnailer-provider.h
new file mode 100644
index 0000000..4ee34d6
--- /dev/null
+++ b/plugins/webkit-thumbnailer/webkit-thumbnailer-provider.h
@@ -0,0 +1,44 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
+ * Copyright (c) 2011 Jérôme Guelfucci <jeromeg 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 __WEBKIT_THUMBNAILER_PROVIDER_H__
+#define __WEBKIT_THUMBNAILER_PROVIDER_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS;
+
+#define TYPE_WEBKIT_THUMBNAILER_PROVIDER (webkit_thumbnailer_provider_get_type ())
+#define WEBKIT_THUMBNAILER_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_WEBKIT_THUMBNAILER_PROVIDER, WebkitThumbnailerProvider))
+#define WEBKIT_THUMBNAILER_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_WEBKIT_THUMBNAILER_PROVIDER, WebkitThumbnailerProviderClass))
+#define IS_WEBKIT_THUMBNAILER_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_WEBKIT_THUMBNAILER_PROVIDER))
+#define IS_WEBKIT_THUMBNAILER_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_WEBKIT_THUMBNAILER_PROVIDER)
+#define WEBKIT_THUMBNAILER_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_WEBKIT_THUMBNAILER_PROVIDER, WebkitThumbnailerProviderClass))
+
+typedef struct _WebkitThumbnailerProviderClass WebkitThumbnailerProviderClass;
+typedef struct _WebkitThumbnailerProvider WebkitThumbnailerProvider;
+
+GType webkit_thumbnailer_provider_get_type (void) G_GNUC_CONST;
+void webkit_thumbnailer_provider_register (TumblerProviderPlugin *plugin);
+
+G_END_DECLS;
+
+#endif /* !__WEBKIT_THUMBNAILER_PROVIDER_H__ */
diff --git a/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c b/plugins/webkit-thumbnailer/webkit-thumbnailer.c
similarity index 52%
copy from plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c
copy to plugins/webkit-thumbnailer/webkit-thumbnailer.c
index 04cbb9d..cab6fe3 100644
--- a/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c
+++ b/plugins/webkit-thumbnailer/webkit-thumbnailer.c
@@ -1,7 +1,7 @@
/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
* Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
- * Copyright (c) 2010 Lionel Le Folgoc <mrpouit at ubuntu.com>
+ * Copyright (c) 2011 Jérôme Guelfucci <jeromeg 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
@@ -10,11 +10,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.
*/
@@ -31,91 +31,134 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <libffmpegthumbnailer/videothumbnailerc.h>
+#include <webkit/webkit.h>
#include <tumbler/tumbler.h>
-#include <ffmpeg-thumbnailer/ffmpeg-thumbnailer.h>
+#include <webkit-thumbnailer/webkit-thumbnailer.h>
+#define LOAD_TIMEOUT 1000
-static void ffmpeg_thumbnailer_finalize (GObject *object);
-static void ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
+
+static void webkit_thumbnailer_finalize (GObject *object);
+static void webkit_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
GCancellable *cancellable,
TumblerFileInfo *info);
-struct _FfmpegThumbnailerClass
+struct _WebkitThumbnailerClass
{
TumblerAbstractThumbnailerClass __parent__;
};
-struct _FfmpegThumbnailer
+struct _WebkitThumbnailer
{
TumblerAbstractThumbnailer __parent__;
- video_thumbnailer *video;
+ GtkWidget *offscreen;
+ GtkWidget *view;
+ GdkPixbuf *tmp;
};
-G_DEFINE_DYNAMIC_TYPE (FfmpegThumbnailer,
- ffmpeg_thumbnailer,
+G_DEFINE_DYNAMIC_TYPE (WebkitThumbnailer,
+ webkit_thumbnailer,
TUMBLER_TYPE_ABSTRACT_THUMBNAILER);
void
-ffmpeg_thumbnailer_register (TumblerProviderPlugin *plugin)
+webkit_thumbnailer_register (TumblerProviderPlugin *plugin)
{
- ffmpeg_thumbnailer_register_type (G_TYPE_MODULE (plugin));
+ webkit_thumbnailer_register_type (G_TYPE_MODULE (plugin));
}
static void
-ffmpeg_thumbnailer_class_init (FfmpegThumbnailerClass *klass)
+webkit_thumbnailer_class_init (WebkitThumbnailerClass *klass)
{
TumblerAbstractThumbnailerClass *abstractthumbnailer_class;
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = ffmpeg_thumbnailer_finalize;
+ gobject_class->finalize = webkit_thumbnailer_finalize;
abstractthumbnailer_class = TUMBLER_ABSTRACT_THUMBNAILER_CLASS (klass);
- abstractthumbnailer_class->create = ffmpeg_thumbnailer_create;
+ abstractthumbnailer_class->create = webkit_thumbnailer_create;
}
static void
-ffmpeg_thumbnailer_class_finalize (FfmpegThumbnailerClass *klass)
+webkit_thumbnailer_class_finalize (WebkitThumbnailerClass *klass)
+{
+}
+
+
+
+static gboolean
+cb_offscreen_damage (GtkWidget *widget,
+ GdkEventExpose *event,
+ GtkWidget *view)
{
+ gtk_widget_queue_draw (view);
+
+ return TRUE;
}
static void
-ffmpeg_thumbnailer_init (FfmpegThumbnailer *thumbnailer)
+webkit_thumbnailer_init (WebkitThumbnailer *thumbnailer)
{
- /* initialize libffmpegthumbnailer with default parameters */
- thumbnailer->video = video_thumbnailer_create ();
- thumbnailer->video->seek_percentage = 15;
- thumbnailer->video->overlay_film_strip = 1;
- thumbnailer->video->thumbnail_image_type = Png;
+ WebKitWebSettings *settings;
+
+ gtk_init (NULL, NULL);
+
+ thumbnailer->offscreen = gtk_offscreen_window_new ();
+ thumbnailer->view = webkit_web_view_new ();
+ thumbnailer->tmp = NULL;
+
+ /* create a new websettings and disable potential threats */
+ settings = webkit_web_settings_new ();
+
+ g_object_set (G_OBJECT(settings),
+ "enable-scripts", FALSE,
+ "enable-plugins", FALSE,
+ "enable-html5-database", FALSE,
+ "enable-html5-local-storage", FALSE,
+ "enable-java-applet", FALSE,
+ NULL);
+
+ /* apply the result to the web view */
+ webkit_web_view_set_settings (WEBKIT_WEB_VIEW(thumbnailer->view),
+ settings);
+
+ gtk_container_add (GTK_CONTAINER (thumbnailer->offscreen),
+ thumbnailer->view);
+
+ gtk_widget_show (thumbnailer->offscreen);
+ gtk_widget_queue_draw (thumbnailer->offscreen);
+
+ g_signal_connect (thumbnailer->offscreen,
+ "damage-event",
+ G_CALLBACK (cb_offscreen_damage),
+ thumbnailer->view);
}
static void
-ffmpeg_thumbnailer_finalize (GObject *object)
+webkit_thumbnailer_finalize (GObject *object)
{
- FfmpegThumbnailer *thumbnailer = FFMPEG_THUMBNAILER (object);
+ WebkitThumbnailer *thumbnailer = WEBKIT_THUMBNAILER (object);
- /* release the libffmpegthumbnailer video object */
- video_thumbnailer_destroy (thumbnailer->video);
+ gtk_widget_destroy (thumbnailer->offscreen);
- (*G_OBJECT_CLASS (ffmpeg_thumbnailer_parent_class)->finalize) (object);
+ (*G_OBJECT_CLASS (webkit_thumbnailer_parent_class)->finalize) (object);
}
@@ -149,38 +192,59 @@ generate_pixbuf (GdkPixbuf *source,
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),
+ return gdk_pixbuf_scale_simple (source, MAX (dest_width, 1), MAX (dest_height, 1),
GDK_INTERP_BILINEAR);
}
static void
-ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
+cb_view_load_finished (GtkWidget *web_view,
+ WebKitWebFrame *web_frame,
+ WebkitThumbnailer *thumbnailer)
+{
+ thumbnailer->tmp =
+ gtk_offscreen_window_get_pixbuf (GTK_OFFSCREEN_WINDOW (thumbnailer->offscreen));
+
+ gtk_main_quit ();
+}
+
+
+
+static gboolean
+cb_load_timeout (gpointer data)
+{
+ gtk_main_quit ();
+
+ return FALSE;
+}
+
+
+
+static void
+webkit_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
GCancellable *cancellable,
TumblerFileInfo *info)
{
- image_data *v_data;
- GInputStream *v_stream;
- GdkPixbuf *v_pixbuf;
- FfmpegThumbnailer *ffmpeg_thumbnailer = FFMPEG_THUMBNAILER (thumbnailer);
+ GdkPixbuf *pixbuf;
+ WebkitThumbnailer *webkit_thumbnailer;
TumblerThumbnailFlavor *flavor;
TumblerThumbnail *thumbnail;
TumblerImageData data;
- GdkPixbuf *pixbuf;
- GFile *file;
GError *error = NULL;
gint dest_width;
gint dest_height;
- gchar *path;
const gchar *uri;
- g_return_if_fail (IS_FFMPEG_THUMBNAILER (thumbnailer));
+ g_return_if_fail (IS_WEBKIT_THUMBNAILER (thumbnailer));
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+
g_return_if_fail (TUMBLER_IS_FILE_INFO (info));
+ webkit_thumbnailer = WEBKIT_THUMBNAILER (thumbnailer);
+
/* do nothing if cancelled */
- if (g_cancellable_is_cancelled (cancellable))
+ if (g_cancellable_is_cancelled (cancellable))
return;
/* fetch required info */
@@ -190,77 +254,29 @@ ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
tumbler_thumbnail_flavor_get_size (flavor, &dest_width, &dest_height);
g_object_unref (flavor);
- /* prepare the video thumbnailer */
- ffmpeg_thumbnailer->video->thumbnail_size = MAX (dest_width, dest_height);
- v_data = video_thumbnailer_create_image_data ();
-
uri = tumbler_file_info_get_uri (info);
- /* try to open the source file for reading */
- file = g_file_new_for_uri (uri);
-
- if (g_file_is_native (file))
- {
- path = g_file_get_path (file);
- }
- else
- {
- /* there was an error, emit error signal */
- g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_INVALID_FORMAT,
- _("Thumbnail could not be inferred from file contents"));
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
- g_error_free (error);
-
- /* clean up */
- g_object_unref (file);
- g_object_unref (thumbnail);
- video_thumbnailer_destroy_image_data (v_data);
- return;
- }
- g_object_unref (file);
-
- /* try to generate a thumbnail */
- if (video_thumbnailer_generate_thumbnail_to_buffer (ffmpeg_thumbnailer->video, path, v_data) != 0)
- {
- /* there was an error, emit error signal */
- g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_INVALID_FORMAT,
- _("Thumbnail could not be inferred from file contents"));
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
- g_error_free (error);
-
- /* clean up */
- g_free (path);
- g_object_unref (thumbnail);
- video_thumbnailer_destroy_image_data (v_data);
- return;
- }
- g_free (path);
-
- v_stream = g_memory_input_stream_new_from_data (v_data->image_data_ptr,
- v_data->image_data_size, NULL);
-
- if (v_stream == NULL)
- {
- /* there was an error, emit error signal */
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
- g_error_free (error);
+ /* schedule a timeout to avoid waiting forever */
+ g_timeout_add_seconds (LOAD_TIMEOUT, cb_load_timeout, NULL);
- /* clean up */
- g_object_unref (thumbnail);
- video_thumbnailer_destroy_image_data (v_data);
- return;
- }
+ /* load the page in the web view */
+ webkit_web_view_load_uri (WEBKIT_WEB_VIEW (webkit_thumbnailer->view),
+ uri);
- v_pixbuf = gdk_pixbuf_new_from_stream (v_stream, cancellable, &error);
+ /* retrieve the thumbnail once the page is loaded */
+ g_signal_connect (webkit_thumbnailer->view,
+ "load-finished",
+ G_CALLBACK (cb_view_load_finished),
+ webkit_thumbnailer);
- g_object_unref (v_stream);
- video_thumbnailer_destroy_image_data (v_data);
+ /* wait until the page is loaded */
+ gtk_main ();
- if (v_pixbuf == NULL)
+ if (webkit_thumbnailer->tmp == NULL)
{
/* emit an error signal */
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
- g_error_free (error);
+ g_signal_emit_by_name (thumbnailer, "error", uri, TUMBLER_ERROR_NO_CONTENT,
+ _("Failed to retrieve the content of this HMTL file"));
/* clean up */
g_object_unref (thumbnail);
@@ -269,7 +285,7 @@ ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
}
/* generate a valid thumbnail */
- pixbuf = generate_pixbuf (v_pixbuf, dest_width, dest_height);
+ pixbuf = generate_pixbuf (webkit_thumbnailer->tmp, dest_width, dest_height);
g_assert (pixbuf != NULL);
@@ -303,5 +319,6 @@ ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
/* clean up */
g_object_unref (thumbnail);
g_object_unref (pixbuf);
- g_object_unref (v_pixbuf);
+ g_object_unref (webkit_thumbnailer->tmp);
+ webkit_thumbnailer->tmp = NULL;
}
diff --git a/plugins/webkit-thumbnailer/webkit-thumbnailer.h b/plugins/webkit-thumbnailer/webkit-thumbnailer.h
new file mode 100644
index 0000000..e3389f9
--- /dev/null
+++ b/plugins/webkit-thumbnailer/webkit-thumbnailer.h
@@ -0,0 +1,44 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
+ * Copyright (c) 2011 Jérôme Guelfucci <jeromeg 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 __WEBKIT_THUMBNAILER_H__
+#define __WEBKIT_THUMBNAILER_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS;
+
+#define TYPE_WEBKIT_THUMBNAILER (webkit_thumbnailer_get_type ())
+#define WEBKIT_THUMBNAILER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_WEBKIT_THUMBNAILER, WebkitThumbnailer))
+#define WEBKIT_THUMBNAILER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_WEBKIT_THUMBNAILER, WebkitThumbnailerClass))
+#define IS_WEBKIT_THUMBNAILER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_WEBKIT_THUMBNAILER))
+#define IS_WEBKIT_THUMBNAILER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_WEBKIT_THUMBNAILER)
+#define WEBKIT_THUMBNAILER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_WEBKIT_THUMBNAILER, WebkitThumbnailerClass))
+
+typedef struct _WebkitThumbnailerClass WebkitThumbnailerClass;
+typedef struct _WebkitThumbnailer WebkitThumbnailer;
+
+GType webkit_thumbnailer_get_type (void) G_GNUC_CONST;
+void webkit_thumbnailer_register (TumblerProviderPlugin *plugin);
+
+G_END_DECLS;
+
+#endif /* !__WEBKIT_THUMBNAILER_H__ */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8fa4abb..4ffe184 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -41,6 +41,9 @@ plugins/poppler-thumbnailer/poppler-thumbnailer-plugin.c
plugins/poppler-thumbnailer/poppler-thumbnailer.c
plugins/raw-thumbnailer/raw-thumbnailer.c
plugins/raw-thumbnailer/raw-thumbnailer-plugin.c
+plugins/webkit-thumbnailer/webkit-thumbnailer.c
+plugins/webkit-thumbnailer/webkit-thumbnailer-plugin.c
+plugins/webkit-thumbnailer/webkit-thumbnailer-provider.c
plugins/xdg-cache/xdg-cache-thumbnail.c
plugins/xdg-cache/xdg-cache-plugin.c
plugins/xdg-cache/xdg-cache-cache.c
More information about the Xfce4-commits
mailing list