summaryrefslogtreecommitdiff
path: root/thumbnailer
diff options
context:
space:
mode:
Diffstat (limited to 'thumbnailer')
-rw-r--r--thumbnailer/Makefile.am83
-rw-r--r--thumbnailer/evince-thumbnailer-comics.schemas.in106
-rw-r--r--thumbnailer/evince-thumbnailer-djvu.schemas.in30
-rw-r--r--thumbnailer/evince-thumbnailer-dvi.schemas.in83
-rw-r--r--thumbnailer/evince-thumbnailer-ps.schemas.in154
-rw-r--r--thumbnailer/evince-thumbnailer.c309
-rw-r--r--thumbnailer/evince-thumbnailer.schemas.in80
7 files changed, 845 insertions, 0 deletions
diff --git a/thumbnailer/Makefile.am b/thumbnailer/Makefile.am
new file mode 100644
index 00000000..bc5a3314
--- /dev/null
+++ b/thumbnailer/Makefile.am
@@ -0,0 +1,83 @@
+
+bin_PROGRAMS = evince-thumbnailer
+
+evince_thumbnailer_SOURCES = \
+ evince-thumbnailer.c
+
+evince_thumbnailer_CPPFLAGS = \
+ -DEVINCEDATADIR=\"$(pkgdatadir)\" \
+ -I$(top_srcdir) \
+ -I$(top_builddir) \
+ -DMATELOCALEDIR=\"$(datadir)/locale\" \
+ -DMATEICONDIR=\""$(datadir)/pixmaps"\" \
+ $(AM_CPPFLAGS)
+
+evince_thumbnailer_CFLAGS = \
+ $(FRONTEND_CFLAGS) \
+ $(DISABLE_DEPRECATED) \
+ $(WARN_CFLAGS) \
+ $(AM_CFLAGS)
+
+evince_thumbnailer_LDFLAGS = $(AM_LDFLAGS)
+
+if PLATFORM_WIN32
+evince_thumbnailer_LDFLAGS += -mwindows
+endif
+
+evince_thumbnailer_LDADD = \
+ $(top_builddir)/libdocument/libevdocument.la \
+ $(FRONTEND_LIBS)
+
+schema_files = \
+ evince-thumbnailer-dvi.schemas.in \
+ evince-thumbnailer-djvu.schemas.in \
+ evince-thumbnailer-comics.schemas.in \
+ evince-thumbnailer-ps.schemas.in \
+ evince-thumbnailer.schemas.in
+
+if WITH_MATECONF
+
+@INTLTOOL_SCHEMAS_RULE@
+
+schema_DATA =
+
+if ENABLE_PDF
+schema_DATA += evince-thumbnailer.schemas
+endif
+
+if ENABLE_PS
+schema_DATA += evince-thumbnailer-ps.schemas
+endif
+
+if ENABLE_DJVU
+schema_DATA += evince-thumbnailer-djvu.schemas
+endif
+
+if ENABLE_DVI
+schema_DATA += evince-thumbnailer-dvi.schemas
+endif
+
+if ENABLE_COMICS
+schema_DATA += evince-thumbnailer-comics.schemas
+endif
+
+schemadir = $(MATECONF_SCHEMA_FILE_DIR)
+
+install-data-local:
+if MATECONF_SCHEMAS_INSTALL
+ if test -z "$(DESTDIR)" ; then \
+ for p in $(schema_DATA) ; do \
+ MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-install-rule $(top_builddir)/thumbnailer/$$p >&1 > /dev/null; \
+ done \
+ fi
+endif
+
+endif # WITH_MATECONF
+
+EXTRA_DIST = \
+ $(schema_files)
+
+DISTCLEANFILES = \
+ $(schema_DATA)
+
+-include $(top_srcdir)/git.mk
diff --git a/thumbnailer/evince-thumbnailer-comics.schemas.in b/thumbnailer/evince-thumbnailer-comics.schemas.in
new file mode 100644
index 00000000..2f00a802
--- /dev/null
+++ b/thumbnailer/evince-thumbnailer-comics.schemas.in
@@ -0,0 +1,106 @@
+<mateconfschemafile>
+ <schemalist>
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-cbz/enable</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-cbz/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-cbz/command</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-cbz/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-cbr/enable</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-cbr/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-cbr/command</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-cbr/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-cb7/enable</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-cb7/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-cb7/command</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-cb7/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-cbt/enable</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-cbt/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-cbt/command</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-cbt/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ </schemalist>
+</mateconfschemafile>
diff --git a/thumbnailer/evince-thumbnailer-djvu.schemas.in b/thumbnailer/evince-thumbnailer-djvu.schemas.in
new file mode 100644
index 00000000..4ea35272
--- /dev/null
+++ b/thumbnailer/evince-thumbnailer-djvu.schemas.in
@@ -0,0 +1,30 @@
+<mateconfschemafile>
+ <schemalist>
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/[email protected]/enable</key>
+ <applyto>/desktop/mate/thumbnailers/[email protected]/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/[email protected]/command</key>
+ <applyto>/desktop/mate/thumbnailers/[email protected]/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ </schemalist>
+</mateconfschemafile>
diff --git a/thumbnailer/evince-thumbnailer-dvi.schemas.in b/thumbnailer/evince-thumbnailer-dvi.schemas.in
new file mode 100644
index 00000000..eab49a61
--- /dev/null
+++ b/thumbnailer/evince-thumbnailer-dvi.schemas.in
@@ -0,0 +1,83 @@
+<mateconfschemafile>
+ <schemalist>
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-dvi/enable</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-dvi/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-dvi/command</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-dvi/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-gzdvi/enable</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-gzdvi/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-gzdvi/command</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-gzdvi/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-bzdvi/enable</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-bzdvi/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-bzdvi/command</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-bzdvi/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ </schemalist>
+</mateconfschemafile>
diff --git a/thumbnailer/evince-thumbnailer-ps.schemas.in b/thumbnailer/evince-thumbnailer-ps.schemas.in
new file mode 100644
index 00000000..6866ef5a
--- /dev/null
+++ b/thumbnailer/evince-thumbnailer-ps.schemas.in
@@ -0,0 +1,154 @@
+<mateconfschemafile>
+ <schemalist>
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@postscript/enable</key>
+ <applyto>/desktop/mate/thumbnailers/application@postscript/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@postscript/command</key>
+ <applyto>/desktop/mate/thumbnailers/application@postscript/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-bzpostscript/enable</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-bzpostscript/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-bzpostscript/command</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-bzpostscript/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-gzpostscript/enable</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-gzpostscript/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-gzpostscript/command</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-gzpostscript/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/image@x-eps/enable</key>
+ <applyto>/desktop/mate/thumbnailers/image@x-eps/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/image@x-eps/command</key>
+ <applyto>/desktop/mate/thumbnailers/image@x-eps/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/image@x-bzeps/enable</key>
+ <applyto>/desktop/mate/thumbnailers/image@x-bzeps/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/image@x-bzeps/command</key>
+ <applyto>/desktop/mate/thumbnailers/image@x-bzeps/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/image@x-gzeps/enable</key>
+ <applyto>/desktop/mate/thumbnailers/image@x-gzeps/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/image@x-gzeps/command</key>
+ <applyto>/desktop/mate/thumbnailers/image@x-gzeps/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ </schemalist>
+</mateconfschemafile>
diff --git a/thumbnailer/evince-thumbnailer.c b/thumbnailer/evince-thumbnailer.c
new file mode 100644
index 00000000..23ad92b0
--- /dev/null
+++ b/thumbnailer/evince-thumbnailer.c
@@ -0,0 +1,309 @@
+/*
+ Copyright (C) 2005 Fernando Herrera <[email protected]>
+
+ 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.
+*/
+
+#include <config.h>
+
+#include <evince-document.h>
+
+#include <gio/gio.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef G_OS_WIN32
+#include <io.h>
+#include <conio.h>
+#if !(_WIN32_WINNT >= 0x0500)
+#error "_WIN32_WINNT must be defined >= 0x0500"
+#endif
+#include <windows.h>
+#endif
+
+#define THUMBNAIL_SIZE 128
+
+static gint size = THUMBNAIL_SIZE;
+static const gchar **file_arguments;
+
+static const GOptionEntry goption_options[] = {
+ { "size", 's', 0, G_OPTION_ARG_INT, &size, NULL, "SIZE" },
+ { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &file_arguments, NULL, "<input> <ouput>" },
+ { NULL }
+};
+
+struct AsyncData {
+ EvDocument *document;
+ const gchar *output;
+ gint size;
+ gboolean success;
+};
+
+static void
+delete_temp_file (GFile *file)
+{
+ ev_tmp_file_unlink (file);
+ g_object_unref (file);
+}
+
+static EvDocument *
+evince_thumbnailer_get_document (GFile *file)
+{
+ EvDocument *document = NULL;
+ gchar *uri;
+ GFile *tmp_file = NULL;
+ GError *error = NULL;
+
+ if (!g_file_is_native (file)) {
+ gchar *base_name, *template;
+
+ base_name = g_file_get_basename (file);
+ template = g_strdup_printf ("document.XXXXXX-%s", base_name);
+ g_free (base_name);
+
+ tmp_file = ev_mkstemp_file (template, &error);
+ g_free (template);
+ if (!tmp_file) {
+ g_printerr ("Error loading remote document: %s\n", error->message);
+ g_error_free (error);
+
+ return NULL;
+ }
+
+ g_file_copy (file, tmp_file, G_FILE_COPY_OVERWRITE,
+ NULL, NULL, NULL, &error);
+ if (error) {
+ g_printerr ("Error loading remote document: %s\n", error->message);
+ g_error_free (error);
+ g_object_unref (tmp_file);
+
+ return NULL;
+ }
+ uri = g_file_get_uri (tmp_file);
+ } else {
+ uri = g_file_get_uri (file);
+ }
+
+ document = ev_document_factory_get_document (uri, &error);
+ if (tmp_file) {
+ if (document) {
+ g_object_weak_ref (G_OBJECT (document),
+ (GWeakNotify)delete_temp_file,
+ tmp_file);
+ } else {
+ ev_tmp_file_unlink (tmp_file);
+ g_object_unref (tmp_file);
+ }
+ }
+ g_free (uri);
+ if (error) {
+ if (error->domain == EV_DOCUMENT_ERROR &&
+ error->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
+ /* FIXME: Create a thumb for cryp docs */
+ g_error_free (error);
+ return NULL;
+ }
+ g_printerr ("Error loading document: %s\n", error->message);
+ g_error_free (error);
+ return NULL;
+ }
+
+ return document;
+}
+
+static gboolean
+evince_thumbnail_pngenc_get (EvDocument *document, const char *thumbnail, int size)
+{
+ EvRenderContext *rc;
+ double width, height;
+ GdkPixbuf *pixbuf;
+ EvPage *page;
+
+ page = ev_document_get_page (document, 0);
+
+ ev_document_get_page_size (document, 0, &width, &height);
+
+ rc = ev_render_context_new (page, 0, size / width);
+ pixbuf = ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (document),
+ rc, FALSE);
+ g_object_unref (rc);
+ g_object_unref (page);
+
+ if (pixbuf != NULL) {
+ const char *overlaid_icon_name = NULL;
+
+ if (overlaid_icon_name) {
+ GdkPixbuf *overlaid_pixbuf;
+
+#ifdef G_OS_WIN32
+ gchar *dir = g_win32_get_package_installation_directory_of_module (NULL);
+ gchar *overlaid_icon_path = g_build_filename (dir, "share", "evince", overlaid_icon_name, NULL);
+ g_free (dir);
+#else
+ gchar *overlaid_icon_path = g_strdup_printf ("%s/%s", EVINCEDATADIR, overlaid_icon_name);
+#endif
+ overlaid_pixbuf = gdk_pixbuf_new_from_file (overlaid_icon_path, NULL);
+ g_free (overlaid_icon_path);
+ if (overlaid_pixbuf != NULL) {
+ int delta_height, delta_width;
+
+ delta_width = gdk_pixbuf_get_width (pixbuf) -
+ gdk_pixbuf_get_width (overlaid_pixbuf);
+ delta_height = gdk_pixbuf_get_height (pixbuf) -
+ gdk_pixbuf_get_height (overlaid_pixbuf);
+
+ gdk_pixbuf_composite (overlaid_pixbuf, pixbuf,
+ delta_width, delta_height,
+ gdk_pixbuf_get_width (overlaid_pixbuf),
+ gdk_pixbuf_get_height (overlaid_pixbuf),
+ delta_width, delta_height,
+ 1, 1,
+ GDK_INTERP_NEAREST, 100);
+
+ g_object_unref (overlaid_pixbuf);
+ }
+ }
+
+ if (gdk_pixbuf_save (pixbuf, thumbnail, "png", NULL, NULL)) {
+ g_object_unref (pixbuf);
+ return TRUE;
+ }
+
+ g_object_unref (pixbuf);
+ }
+
+ return FALSE;
+}
+
+static gpointer
+evince_thumbnail_pngenc_get_async (struct AsyncData *data)
+{
+ ev_document_doc_mutex_lock ();
+ data->success = evince_thumbnail_pngenc_get (data->document,
+ data->output,
+ data->size);
+ ev_document_doc_mutex_unlock ();
+
+ g_idle_add ((GSourceFunc)gtk_main_quit, NULL);
+
+ return NULL;
+}
+
+static void
+print_usage (GOptionContext *context)
+{
+ gchar *help;
+
+ help = g_option_context_get_help (context, TRUE, NULL);
+ g_print ("%s", help);
+ g_free (help);
+}
+
+int
+main (int argc, char *argv[])
+{
+ EvDocument *document;
+ GOptionContext *context;
+ const char *input;
+ const char *output;
+ GFile *file;
+ GError *error = NULL;
+
+ context = g_option_context_new ("- MATE Document Thumbnailer");
+ g_option_context_add_main_entries (context, goption_options, NULL);
+
+ if (!g_option_context_parse (context, &argc, &argv, &error)) {
+ g_printerr ("%s\n", error->message);
+ g_error_free (error);
+ print_usage (context);
+ g_option_context_free (context);
+
+ return -1;
+ }
+
+ input = file_arguments ? file_arguments[0] : NULL;
+ output = input ? file_arguments[1] : NULL;
+ if (!input || !output) {
+ print_usage (context);
+ g_option_context_free (context);
+
+ return -1;
+ }
+
+ g_option_context_free (context);
+
+ if (size < 1) {
+ g_print ("Size cannot be smaller than 1 pixel\n");
+ return -1;
+ }
+
+ input = file_arguments[0];
+ output = file_arguments[1];
+
+ g_type_init ();
+
+ if (!g_thread_supported ())
+ g_thread_init (NULL);
+
+ if (!ev_init ())
+ return -1;
+
+ file = g_file_new_for_commandline_arg (input);
+ document = evince_thumbnailer_get_document (file);
+ g_object_unref (file);
+
+ if (!document) {
+ ev_shutdown ();
+ return -2;
+ }
+
+ if (!EV_IS_DOCUMENT_THUMBNAILS (document)) {
+ g_object_unref (document);
+ ev_shutdown ();
+ return -2;
+ }
+
+ if (EV_IS_ASYNC_RENDERER (document)) {
+ struct AsyncData data;
+
+ gtk_init (&argc, &argv);
+
+ data.document = document;
+ data.output = output;
+ data.size = size;
+
+ g_thread_create ((GThreadFunc) evince_thumbnail_pngenc_get_async,
+ &data, FALSE, NULL);
+
+ gtk_main ();
+
+ g_object_unref (document);
+ ev_shutdown ();
+
+ return data.success ? 0 : -2;
+ }
+
+ if (!evince_thumbnail_pngenc_get (document, output, size)) {
+ g_object_unref (document);
+ ev_shutdown ();
+ return -2;
+ }
+
+ g_object_unref (document);
+ ev_shutdown ();
+
+ return 0;
+}
diff --git a/thumbnailer/evince-thumbnailer.schemas.in b/thumbnailer/evince-thumbnailer.schemas.in
new file mode 100644
index 00000000..6dafb8f0
--- /dev/null
+++ b/thumbnailer/evince-thumbnailer.schemas.in
@@ -0,0 +1,80 @@
+<mateconfschemafile>
+ <schemalist>
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@pdf/enable</key>
+ <applyto>/desktop/mate/thumbnailers/application@pdf/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short>Enable thumbnailing of PDF Documents</short>
+ <long>Boolean options available: true enables thumbnailing and false disables the creation of new thumbnails</long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@pdf/command</key>
+ <applyto>/desktop/mate/thumbnailers/application@pdf/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short>Thumbnail command for PDF Documents</short>
+ <long>Valid command plus arguments for the PDF Document thumbnailer. See Caja thumbnailer documentation for more information.</long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-bzpdf/enable</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-bzpdf/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short>Enable thumbnailing of PDF Documents</short>
+ <long>Boolean options available: true enables thumbnailing and false disables the creation of new thumbnails</long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-bzpdf/command</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-bzpdf/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short>Thumbnail command for PDF Documents</short>
+ <long>Valid command plus arguments for the PDF Document thumbnailer. See Caja thumbnailer documentation for more information.</long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-gzpdf/enable</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-gzpdf/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short>Enable thumbnailing of PDF Documents</short>
+ <long>Boolean options available: true enables thumbnailing and false disables the creation of new thumbnails</long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@x-gzpdf/command</key>
+ <applyto>/desktop/mate/thumbnailers/application@x-gzpdf/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short>Thumbnail command for PDF Documents</short>
+ <long>Valid command plus arguments for the PDF Document thumbnailer. See Caja thumbnailer documentation for more information.</long>
+ </locale>
+ </schema>
+
+ </schemalist>
+</mateconfschemafile>