summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/xps/xps-document.c56
-rw-r--r--backend/xps/xps-document.h2
-rw-r--r--thumbnailer/Makefile.am5
-rw-r--r--thumbnailer/atril-thumbnailer-xps.schemas.in30
4 files changed, 92 insertions, 1 deletions
diff --git a/backend/xps/xps-document.c b/backend/xps/xps-document.c
index 891f2008..fc3c15c3 100644
--- a/backend/xps/xps-document.c
+++ b/backend/xps/xps-document.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
/* this file is part of atril, a mate document viewer
*
* Copyright (C) 2010 Carlos Garcia Campos <[email protected]>
@@ -26,6 +27,7 @@
#include "xps-document.h"
#include "ev-document-links.h"
#include "ev-document-misc.h"
+#include "ev-document-thumbnails.h"
#include "ev-document-print.h"
struct _XPSDocument {
@@ -42,6 +44,7 @@ struct _XPSDocumentClass {
static void xps_document_document_links_iface_init (EvDocumentLinksInterface *iface);
static void xps_document_document_print_iface_init (EvDocumentPrintInterface *iface);
+static void xps_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface);
EV_BACKEND_REGISTER_WITH_CODE (XPSDocument, xps_document,
{
@@ -49,6 +52,8 @@ EV_BACKEND_REGISTER_WITH_CODE (XPSDocument, xps_document,
xps_document_document_links_iface_init);
EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_PRINT,
xps_document_document_print_iface_init);
+ EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS,
+ xps_document_document_thumbnails_iface_init);
})
/* XPSDocument */
@@ -503,3 +508,54 @@ xps_document_document_print_iface_init (EvDocumentPrintInterface *iface)
iface->print_page = xps_document_print_print_page;
}
+static GdkPixbuf *
+xps_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
+ EvRenderContext *rc,
+ gboolean border)
+{
+ GdkPixbuf *thumbnail;
+ cairo_surface_t *surface;
+
+ surface = xps_document_render (EV_DOCUMENT (document), rc);
+
+ thumbnail = ev_document_misc_pixbuf_from_surface (surface);
+
+ cairo_surface_destroy (surface);
+
+ if (border) {
+ GdkPixbuf *tmp_pixbuf = thumbnail;
+
+ thumbnail = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf);
+ g_object_unref (tmp_pixbuf);
+ }
+
+ return thumbnail;
+}
+
+static void
+xps_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
+ EvRenderContext *rc,
+ gint *width,
+ gint *height)
+{
+ gdouble page_width, page_height;
+
+ xps_document_get_page_size (EV_DOCUMENT (document), rc->page,
+ &page_width, &page_height);
+
+ if (rc->rotation == 90 || rc->rotation == 270) {
+ *width = (gint) (page_height * rc->scale);
+ *height = (gint) (page_width * rc->scale);
+ } else {
+ *width = (gint) (page_width * rc->scale);
+ *height = (gint) (page_height * rc->scale);
+ }
+}
+
+static void
+xps_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface)
+{
+ iface->get_thumbnail = xps_document_thumbnails_get_thumbnail;
+ iface->get_dimensions = xps_document_thumbnails_get_dimensions;
+}
+
diff --git a/backend/xps/xps-document.h b/backend/xps/xps-document.h
index c5cc0cd6..e4b90437 100644
--- a/backend/xps/xps-document.h
+++ b/backend/xps/xps-document.h
@@ -38,7 +38,7 @@ typedef struct _XPSDocumentClass XPSDocumentClass;
GType xps_document_get_type (void) G_GNUC_CONST;
-G_MODULE_EXPORT GType register_evince_backend (GTypeModule *module);
+G_MODULE_EXPORT GType register_atril_backend (GTypeModule *module);
G_END_DECLS
diff --git a/thumbnailer/Makefile.am b/thumbnailer/Makefile.am
index 2a0b5501..776a9c67 100644
--- a/thumbnailer/Makefile.am
+++ b/thumbnailer/Makefile.am
@@ -33,6 +33,7 @@ schema_files = \
atril-thumbnailer-djvu.schemas.in \
atril-thumbnailer-comics.schemas.in \
atril-thumbnailer-ps.schemas.in \
+ atril-thumbnailer-xps.schemas.in \
atril-thumbnailer.schemas.in
if WITH_MATECONF
@@ -61,6 +62,10 @@ if ENABLE_COMICS
schema_DATA += atril-thumbnailer-comics.schemas
endif
+if ENABLE_XPS
+schema_DATA += atril-thumbnailer-xps.schemas
+endif
+
schemadir = $(MATECONF_SCHEMA_FILE_DIR)
install-data-local:
diff --git a/thumbnailer/atril-thumbnailer-xps.schemas.in b/thumbnailer/atril-thumbnailer-xps.schemas.in
new file mode 100644
index 00000000..9f07287d
--- /dev/null
+++ b/thumbnailer/atril-thumbnailer-xps.schemas.in
@@ -0,0 +1,30 @@
+<mateconfschemafile>
+ <schemalist>
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@oxps/enable</key>
+ <applyto>/desktop/mate/thumbnailers/application@oxps/enable</applyto>
+ <owner>atril</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/mate/thumbnailers/application@oxps/command</key>
+ <applyto>/desktop/mate/thumbnailers/application@oxps/command</applyto>
+ <owner>atril</owner>
+ <type>string</type>
+ <default>atril-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ </schemalist>
+</mateconfschemafile>