From da7bb154d27d3b872867223a5df60df8f5fb6e7d Mon Sep 17 00:00:00 2001 From: Perberos Date: Wed, 9 Nov 2011 18:44:56 -0300 Subject: renaming evince to atril --- thumbnailer/Makefile.am | 38 +-- thumbnailer/atril-thumbnailer-comics.schemas.in | 106 ++++++++ thumbnailer/atril-thumbnailer-djvu.schemas.in | 30 +++ thumbnailer/atril-thumbnailer-dvi.schemas.in | 83 ++++++ thumbnailer/atril-thumbnailer-ps.schemas.in | 154 +++++++++++ thumbnailer/atril-thumbnailer.c | 309 +++++++++++++++++++++++ thumbnailer/atril-thumbnailer.schemas.in | 80 ++++++ thumbnailer/evince-thumbnailer-comics.schemas.in | 106 -------- thumbnailer/evince-thumbnailer-djvu.schemas.in | 30 --- thumbnailer/evince-thumbnailer-dvi.schemas.in | 83 ------ thumbnailer/evince-thumbnailer-ps.schemas.in | 154 ----------- thumbnailer/evince-thumbnailer.c | 309 ----------------------- thumbnailer/evince-thumbnailer.schemas.in | 80 ------ 13 files changed, 781 insertions(+), 781 deletions(-) create mode 100644 thumbnailer/atril-thumbnailer-comics.schemas.in create mode 100644 thumbnailer/atril-thumbnailer-djvu.schemas.in create mode 100644 thumbnailer/atril-thumbnailer-dvi.schemas.in create mode 100644 thumbnailer/atril-thumbnailer-ps.schemas.in create mode 100644 thumbnailer/atril-thumbnailer.c create mode 100644 thumbnailer/atril-thumbnailer.schemas.in delete mode 100644 thumbnailer/evince-thumbnailer-comics.schemas.in delete mode 100644 thumbnailer/evince-thumbnailer-djvu.schemas.in delete mode 100644 thumbnailer/evince-thumbnailer-dvi.schemas.in delete mode 100644 thumbnailer/evince-thumbnailer-ps.schemas.in delete mode 100644 thumbnailer/evince-thumbnailer.c delete mode 100644 thumbnailer/evince-thumbnailer.schemas.in (limited to 'thumbnailer') diff --git a/thumbnailer/Makefile.am b/thumbnailer/Makefile.am index bc5a3314..dd1590a5 100644 --- a/thumbnailer/Makefile.am +++ b/thumbnailer/Makefile.am @@ -1,39 +1,39 @@ -bin_PROGRAMS = evince-thumbnailer +bin_PROGRAMS = atril-thumbnailer -evince_thumbnailer_SOURCES = \ - evince-thumbnailer.c +atril_thumbnailer_SOURCES = \ + atril-thumbnailer.c -evince_thumbnailer_CPPFLAGS = \ - -DEVINCEDATADIR=\"$(pkgdatadir)\" \ +atril_thumbnailer_CPPFLAGS = \ + -DATRILDATADIR=\"$(pkgdatadir)\" \ -I$(top_srcdir) \ -I$(top_builddir) \ -DMATELOCALEDIR=\"$(datadir)/locale\" \ -DMATEICONDIR=\""$(datadir)/pixmaps"\" \ $(AM_CPPFLAGS) -evince_thumbnailer_CFLAGS = \ +atril_thumbnailer_CFLAGS = \ $(FRONTEND_CFLAGS) \ $(DISABLE_DEPRECATED) \ $(WARN_CFLAGS) \ $(AM_CFLAGS) -evince_thumbnailer_LDFLAGS = $(AM_LDFLAGS) +atril_thumbnailer_LDFLAGS = $(AM_LDFLAGS) if PLATFORM_WIN32 -evince_thumbnailer_LDFLAGS += -mwindows +atril_thumbnailer_LDFLAGS += -mwindows endif -evince_thumbnailer_LDADD = \ +atril_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 + atril-thumbnailer-dvi.schemas.in \ + atril-thumbnailer-djvu.schemas.in \ + atril-thumbnailer-comics.schemas.in \ + atril-thumbnailer-ps.schemas.in \ + atril-thumbnailer.schemas.in if WITH_MATECONF @@ -42,23 +42,23 @@ if WITH_MATECONF schema_DATA = if ENABLE_PDF -schema_DATA += evince-thumbnailer.schemas +schema_DATA += atril-thumbnailer.schemas endif if ENABLE_PS -schema_DATA += evince-thumbnailer-ps.schemas +schema_DATA += atril-thumbnailer-ps.schemas endif if ENABLE_DJVU -schema_DATA += evince-thumbnailer-djvu.schemas +schema_DATA += atril-thumbnailer-djvu.schemas endif if ENABLE_DVI -schema_DATA += evince-thumbnailer-dvi.schemas +schema_DATA += atril-thumbnailer-dvi.schemas endif if ENABLE_COMICS -schema_DATA += evince-thumbnailer-comics.schemas +schema_DATA += atril-thumbnailer-comics.schemas endif schemadir = $(MATECONF_SCHEMA_FILE_DIR) diff --git a/thumbnailer/atril-thumbnailer-comics.schemas.in b/thumbnailer/atril-thumbnailer-comics.schemas.in new file mode 100644 index 00000000..49496d51 --- /dev/null +++ b/thumbnailer/atril-thumbnailer-comics.schemas.in @@ -0,0 +1,106 @@ + + + + + /schemas/desktop/mate/thumbnailers/application@x-cbz/enable + /desktop/mate/thumbnailers/application@x-cbz/enable + atril + bool + true + + + + + + + + + /schemas/desktop/mate/thumbnailers/application@x-cbz/command + /desktop/mate/thumbnailers/application@x-cbz/command + atril + string + atril-thumbnailer -s %s %u %o + + + + + + + + /schemas/desktop/mate/thumbnailers/application@x-cbr/enable + /desktop/mate/thumbnailers/application@x-cbr/enable + atril + bool + true + + + + + + + + + /schemas/desktop/mate/thumbnailers/application@x-cbr/command + /desktop/mate/thumbnailers/application@x-cbr/command + atril + string + atril-thumbnailer -s %s %u %o + + + + + + + + + /schemas/desktop/mate/thumbnailers/application@x-cb7/enable + /desktop/mate/thumbnailers/application@x-cb7/enable + atril + bool + true + + + + + + + + + /schemas/desktop/mate/thumbnailers/application@x-cb7/command + /desktop/mate/thumbnailers/application@x-cb7/command + atril + string + atril-thumbnailer -s %s %u %o + + + + + + + + /schemas/desktop/mate/thumbnailers/application@x-cbt/enable + /desktop/mate/thumbnailers/application@x-cbt/enable + atril + bool + true + + + + + + + + + /schemas/desktop/mate/thumbnailers/application@x-cbt/command + /desktop/mate/thumbnailers/application@x-cbt/command + atril + string + atril-thumbnailer -s %s %u %o + + + + + + + + diff --git a/thumbnailer/atril-thumbnailer-djvu.schemas.in b/thumbnailer/atril-thumbnailer-djvu.schemas.in new file mode 100644 index 00000000..bb0b216f --- /dev/null +++ b/thumbnailer/atril-thumbnailer-djvu.schemas.in @@ -0,0 +1,30 @@ + + + + + /schemas/desktop/mate/thumbnailers/image@vnd.djvu/enable + /desktop/mate/thumbnailers/image@vnd.djvu/enable + atril + bool + true + + + + + + + + + /schemas/desktop/mate/thumbnailers/image@vnd.djvu/command + /desktop/mate/thumbnailers/image@vnd.djvu/command + atril + string + atril-thumbnailer -s %s %u %o + + + + + + + + diff --git a/thumbnailer/atril-thumbnailer-dvi.schemas.in b/thumbnailer/atril-thumbnailer-dvi.schemas.in new file mode 100644 index 00000000..bad7e853 --- /dev/null +++ b/thumbnailer/atril-thumbnailer-dvi.schemas.in @@ -0,0 +1,83 @@ + + + + + /schemas/desktop/mate/thumbnailers/application@x-dvi/enable + /desktop/mate/thumbnailers/application@x-dvi/enable + atril + bool + true + + + + + + + + + /schemas/desktop/mate/thumbnailers/application@x-dvi/command + /desktop/mate/thumbnailers/application@x-dvi/command + atril + string + atril-thumbnailer -s %s %u %o + + + + + + + + + /schemas/desktop/mate/thumbnailers/application@x-gzdvi/enable + /desktop/mate/thumbnailers/application@x-gzdvi/enable + atril + bool + true + + + + + + + + + /schemas/desktop/mate/thumbnailers/application@x-gzdvi/command + /desktop/mate/thumbnailers/application@x-gzdvi/command + atril + string + atril-thumbnailer -s %s %u %o + + + + + + + + + /schemas/desktop/mate/thumbnailers/application@x-bzdvi/enable + /desktop/mate/thumbnailers/application@x-bzdvi/enable + atril + bool + true + + + + + + + + + /schemas/desktop/mate/thumbnailers/application@x-bzdvi/command + /desktop/mate/thumbnailers/application@x-bzdvi/command + atril + string + atril-thumbnailer -s %s %u %o + + + + + + + + + diff --git a/thumbnailer/atril-thumbnailer-ps.schemas.in b/thumbnailer/atril-thumbnailer-ps.schemas.in new file mode 100644 index 00000000..c8192e5a --- /dev/null +++ b/thumbnailer/atril-thumbnailer-ps.schemas.in @@ -0,0 +1,154 @@ + + + + + /schemas/desktop/mate/thumbnailers/application@postscript/enable + /desktop/mate/thumbnailers/application@postscript/enable + atril + bool + true + + + + + + + + /schemas/desktop/mate/thumbnailers/application@postscript/command + /desktop/mate/thumbnailers/application@postscript/command + atril + string + atril-thumbnailer -s %s %u %o + + + + + + + + + /schemas/desktop/mate/thumbnailers/application@x-bzpostscript/enable + /desktop/mate/thumbnailers/application@x-bzpostscript/enable + atril + bool + true + + + + + + + + /schemas/desktop/mate/thumbnailers/application@x-bzpostscript/command + /desktop/mate/thumbnailers/application@x-bzpostscript/command + atril + string + atril-thumbnailer -s %s %u %o + + + + + + + + + /schemas/desktop/mate/thumbnailers/application@x-gzpostscript/enable + /desktop/mate/thumbnailers/application@x-gzpostscript/enable + atril + bool + true + + + + + + + + /schemas/desktop/mate/thumbnailers/application@x-gzpostscript/command + /desktop/mate/thumbnailers/application@x-gzpostscript/command + atril + string + atril-thumbnailer -s %s %u %o + + + + + + + + + /schemas/desktop/mate/thumbnailers/image@x-eps/enable + /desktop/mate/thumbnailers/image@x-eps/enable + atril + bool + true + + + + + + + + /schemas/desktop/mate/thumbnailers/image@x-eps/command + /desktop/mate/thumbnailers/image@x-eps/command + atril + string + atril-thumbnailer -s %s %u %o + + + + + + + + + /schemas/desktop/mate/thumbnailers/image@x-bzeps/enable + /desktop/mate/thumbnailers/image@x-bzeps/enable + atril + bool + true + + + + + + + + /schemas/desktop/mate/thumbnailers/image@x-bzeps/command + /desktop/mate/thumbnailers/image@x-bzeps/command + atril + string + atril-thumbnailer -s %s %u %o + + + + + + + + + /schemas/desktop/mate/thumbnailers/image@x-gzeps/enable + /desktop/mate/thumbnailers/image@x-gzeps/enable + atril + bool + true + + + + + + + + /schemas/desktop/mate/thumbnailers/image@x-gzeps/command + /desktop/mate/thumbnailers/image@x-gzeps/command + atril + string + atril-thumbnailer -s %s %u %o + + + + + + + + diff --git a/thumbnailer/atril-thumbnailer.c b/thumbnailer/atril-thumbnailer.c new file mode 100644 index 00000000..7dfc79a5 --- /dev/null +++ b/thumbnailer/atril-thumbnailer.c @@ -0,0 +1,309 @@ +/* + Copyright (C) 2005 Fernando Herrera + + 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 + +#include + +#include + +#include +#include + +#ifdef G_OS_WIN32 +#include +#include +#if !(_WIN32_WINNT >= 0x0500) +#error "_WIN32_WINNT must be defined >= 0x0500" +#endif +#include +#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, " " }, + { 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 * +atril_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 +atril_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", "atril", overlaid_icon_name, NULL); + g_free (dir); +#else + gchar *overlaid_icon_path = g_strdup_printf ("%s/%s", ATRILDATADIR, 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 +atril_thumbnail_pngenc_get_async (struct AsyncData *data) +{ + ev_document_doc_mutex_lock (); + data->success = atril_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 = atril_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) atril_thumbnail_pngenc_get_async, + &data, FALSE, NULL); + + gtk_main (); + + g_object_unref (document); + ev_shutdown (); + + return data.success ? 0 : -2; + } + + if (!atril_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/atril-thumbnailer.schemas.in b/thumbnailer/atril-thumbnailer.schemas.in new file mode 100644 index 00000000..19d1d4da --- /dev/null +++ b/thumbnailer/atril-thumbnailer.schemas.in @@ -0,0 +1,80 @@ + + + + + /schemas/desktop/mate/thumbnailers/application@pdf/enable + /desktop/mate/thumbnailers/application@pdf/enable + atril + bool + true + + Enable thumbnailing of PDF Documents + Boolean options available: true enables thumbnailing and false disables the creation of new thumbnails + + + + + + /schemas/desktop/mate/thumbnailers/application@pdf/command + /desktop/mate/thumbnailers/application@pdf/command + atril + string + atril-thumbnailer -s %s %u %o + + Thumbnail command for PDF Documents + Valid command plus arguments for the PDF Document thumbnailer. See Caja thumbnailer documentation for more information. + + + + + /schemas/desktop/mate/thumbnailers/application@x-bzpdf/enable + /desktop/mate/thumbnailers/application@x-bzpdf/enable + atril + bool + true + + Enable thumbnailing of PDF Documents + Boolean options available: true enables thumbnailing and false disables the creation of new thumbnails + + + + + + /schemas/desktop/mate/thumbnailers/application@x-bzpdf/command + /desktop/mate/thumbnailers/application@x-bzpdf/command + atril + string + atril-thumbnailer -s %s %u %o + + Thumbnail command for PDF Documents + Valid command plus arguments for the PDF Document thumbnailer. See Caja thumbnailer documentation for more information. + + + + + /schemas/desktop/mate/thumbnailers/application@x-gzpdf/enable + /desktop/mate/thumbnailers/application@x-gzpdf/enable + atril + bool + true + + Enable thumbnailing of PDF Documents + Boolean options available: true enables thumbnailing and false disables the creation of new thumbnails + + + + + + /schemas/desktop/mate/thumbnailers/application@x-gzpdf/command + /desktop/mate/thumbnailers/application@x-gzpdf/command + atril + string + atril-thumbnailer -s %s %u %o + + Thumbnail command for PDF Documents + Valid command plus arguments for the PDF Document thumbnailer. See Caja thumbnailer documentation for more information. + + + + + diff --git a/thumbnailer/evince-thumbnailer-comics.schemas.in b/thumbnailer/evince-thumbnailer-comics.schemas.in deleted file mode 100644 index 2f00a802..00000000 --- a/thumbnailer/evince-thumbnailer-comics.schemas.in +++ /dev/null @@ -1,106 +0,0 @@ - - - - - /schemas/desktop/mate/thumbnailers/application@x-cbz/enable - /desktop/mate/thumbnailers/application@x-cbz/enable - evince - bool - true - - - - - - - - - /schemas/desktop/mate/thumbnailers/application@x-cbz/command - /desktop/mate/thumbnailers/application@x-cbz/command - evince - string - evince-thumbnailer -s %s %u %o - - - - - - - - /schemas/desktop/mate/thumbnailers/application@x-cbr/enable - /desktop/mate/thumbnailers/application@x-cbr/enable - evince - bool - true - - - - - - - - - /schemas/desktop/mate/thumbnailers/application@x-cbr/command - /desktop/mate/thumbnailers/application@x-cbr/command - evince - string - evince-thumbnailer -s %s %u %o - - - - - - - - - /schemas/desktop/mate/thumbnailers/application@x-cb7/enable - /desktop/mate/thumbnailers/application@x-cb7/enable - evince - bool - true - - - - - - - - - /schemas/desktop/mate/thumbnailers/application@x-cb7/command - /desktop/mate/thumbnailers/application@x-cb7/command - evince - string - evince-thumbnailer -s %s %u %o - - - - - - - - /schemas/desktop/mate/thumbnailers/application@x-cbt/enable - /desktop/mate/thumbnailers/application@x-cbt/enable - evince - bool - true - - - - - - - - - /schemas/desktop/mate/thumbnailers/application@x-cbt/command - /desktop/mate/thumbnailers/application@x-cbt/command - evince - string - evince-thumbnailer -s %s %u %o - - - - - - - - diff --git a/thumbnailer/evince-thumbnailer-djvu.schemas.in b/thumbnailer/evince-thumbnailer-djvu.schemas.in deleted file mode 100644 index 4ea35272..00000000 --- a/thumbnailer/evince-thumbnailer-djvu.schemas.in +++ /dev/null @@ -1,30 +0,0 @@ - - - - - /schemas/desktop/mate/thumbnailers/image@vnd.djvu/enable - /desktop/mate/thumbnailers/image@vnd.djvu/enable - evince - bool - true - - - - - - - - - /schemas/desktop/mate/thumbnailers/image@vnd.djvu/command - /desktop/mate/thumbnailers/image@vnd.djvu/command - evince - string - evince-thumbnailer -s %s %u %o - - - - - - - - diff --git a/thumbnailer/evince-thumbnailer-dvi.schemas.in b/thumbnailer/evince-thumbnailer-dvi.schemas.in deleted file mode 100644 index eab49a61..00000000 --- a/thumbnailer/evince-thumbnailer-dvi.schemas.in +++ /dev/null @@ -1,83 +0,0 @@ - - - - - /schemas/desktop/mate/thumbnailers/application@x-dvi/enable - /desktop/mate/thumbnailers/application@x-dvi/enable - evince - bool - true - - - - - - - - - /schemas/desktop/mate/thumbnailers/application@x-dvi/command - /desktop/mate/thumbnailers/application@x-dvi/command - evince - string - evince-thumbnailer -s %s %u %o - - - - - - - - - /schemas/desktop/mate/thumbnailers/application@x-gzdvi/enable - /desktop/mate/thumbnailers/application@x-gzdvi/enable - evince - bool - true - - - - - - - - - /schemas/desktop/mate/thumbnailers/application@x-gzdvi/command - /desktop/mate/thumbnailers/application@x-gzdvi/command - evince - string - evince-thumbnailer -s %s %u %o - - - - - - - - - /schemas/desktop/mate/thumbnailers/application@x-bzdvi/enable - /desktop/mate/thumbnailers/application@x-bzdvi/enable - evince - bool - true - - - - - - - - - /schemas/desktop/mate/thumbnailers/application@x-bzdvi/command - /desktop/mate/thumbnailers/application@x-bzdvi/command - evince - string - evince-thumbnailer -s %s %u %o - - - - - - - - - diff --git a/thumbnailer/evince-thumbnailer-ps.schemas.in b/thumbnailer/evince-thumbnailer-ps.schemas.in deleted file mode 100644 index 6866ef5a..00000000 --- a/thumbnailer/evince-thumbnailer-ps.schemas.in +++ /dev/null @@ -1,154 +0,0 @@ - - - - - /schemas/desktop/mate/thumbnailers/application@postscript/enable - /desktop/mate/thumbnailers/application@postscript/enable - evince - bool - true - - - - - - - - /schemas/desktop/mate/thumbnailers/application@postscript/command - /desktop/mate/thumbnailers/application@postscript/command - evince - string - evince-thumbnailer -s %s %u %o - - - - - - - - - /schemas/desktop/mate/thumbnailers/application@x-bzpostscript/enable - /desktop/mate/thumbnailers/application@x-bzpostscript/enable - evince - bool - true - - - - - - - - /schemas/desktop/mate/thumbnailers/application@x-bzpostscript/command - /desktop/mate/thumbnailers/application@x-bzpostscript/command - evince - string - evince-thumbnailer -s %s %u %o - - - - - - - - - /schemas/desktop/mate/thumbnailers/application@x-gzpostscript/enable - /desktop/mate/thumbnailers/application@x-gzpostscript/enable - evince - bool - true - - - - - - - - /schemas/desktop/mate/thumbnailers/application@x-gzpostscript/command - /desktop/mate/thumbnailers/application@x-gzpostscript/command - evince - string - evince-thumbnailer -s %s %u %o - - - - - - - - - /schemas/desktop/mate/thumbnailers/image@x-eps/enable - /desktop/mate/thumbnailers/image@x-eps/enable - evince - bool - true - - - - - - - - /schemas/desktop/mate/thumbnailers/image@x-eps/command - /desktop/mate/thumbnailers/image@x-eps/command - evince - string - evince-thumbnailer -s %s %u %o - - - - - - - - - /schemas/desktop/mate/thumbnailers/image@x-bzeps/enable - /desktop/mate/thumbnailers/image@x-bzeps/enable - evince - bool - true - - - - - - - - /schemas/desktop/mate/thumbnailers/image@x-bzeps/command - /desktop/mate/thumbnailers/image@x-bzeps/command - evince - string - evince-thumbnailer -s %s %u %o - - - - - - - - - /schemas/desktop/mate/thumbnailers/image@x-gzeps/enable - /desktop/mate/thumbnailers/image@x-gzeps/enable - evince - bool - true - - - - - - - - /schemas/desktop/mate/thumbnailers/image@x-gzeps/command - /desktop/mate/thumbnailers/image@x-gzeps/command - evince - string - evince-thumbnailer -s %s %u %o - - - - - - - - diff --git a/thumbnailer/evince-thumbnailer.c b/thumbnailer/evince-thumbnailer.c deleted file mode 100644 index 23ad92b0..00000000 --- a/thumbnailer/evince-thumbnailer.c +++ /dev/null @@ -1,309 +0,0 @@ -/* - Copyright (C) 2005 Fernando Herrera - - 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 - -#include - -#include - -#include -#include - -#ifdef G_OS_WIN32 -#include -#include -#if !(_WIN32_WINNT >= 0x0500) -#error "_WIN32_WINNT must be defined >= 0x0500" -#endif -#include -#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, " " }, - { 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 deleted file mode 100644 index 6dafb8f0..00000000 --- a/thumbnailer/evince-thumbnailer.schemas.in +++ /dev/null @@ -1,80 +0,0 @@ - - - - - /schemas/desktop/mate/thumbnailers/application@pdf/enable - /desktop/mate/thumbnailers/application@pdf/enable - evince - bool - true - - Enable thumbnailing of PDF Documents - Boolean options available: true enables thumbnailing and false disables the creation of new thumbnails - - - - - - /schemas/desktop/mate/thumbnailers/application@pdf/command - /desktop/mate/thumbnailers/application@pdf/command - evince - string - evince-thumbnailer -s %s %u %o - - Thumbnail command for PDF Documents - Valid command plus arguments for the PDF Document thumbnailer. See Caja thumbnailer documentation for more information. - - - - - /schemas/desktop/mate/thumbnailers/application@x-bzpdf/enable - /desktop/mate/thumbnailers/application@x-bzpdf/enable - evince - bool - true - - Enable thumbnailing of PDF Documents - Boolean options available: true enables thumbnailing and false disables the creation of new thumbnails - - - - - - /schemas/desktop/mate/thumbnailers/application@x-bzpdf/command - /desktop/mate/thumbnailers/application@x-bzpdf/command - evince - string - evince-thumbnailer -s %s %u %o - - Thumbnail command for PDF Documents - Valid command plus arguments for the PDF Document thumbnailer. See Caja thumbnailer documentation for more information. - - - - - /schemas/desktop/mate/thumbnailers/application@x-gzpdf/enable - /desktop/mate/thumbnailers/application@x-gzpdf/enable - evince - bool - true - - Enable thumbnailing of PDF Documents - Boolean options available: true enables thumbnailing and false disables the creation of new thumbnails - - - - - - /schemas/desktop/mate/thumbnailers/application@x-gzpdf/command - /desktop/mate/thumbnailers/application@x-gzpdf/command - evince - string - evince-thumbnailer -s %s %u %o - - Thumbnail command for PDF Documents - Valid command plus arguments for the PDF Document thumbnailer. See Caja thumbnailer documentation for more information. - - - - - -- cgit v1.2.1