summaryrefslogtreecommitdiff
path: root/backend/xps/xps-document.c
diff options
context:
space:
mode:
authorPerberos <[email protected]>2012-09-03 20:12:09 -0300
committerPerberos <[email protected]>2012-09-03 20:12:09 -0300
commit0cee6386acad57fdafb374fb389bc80fcf7e8546 (patch)
tree1bfd4c9b24f3fe7b4084a5df65021fcd2d71913c /backend/xps/xps-document.c
parent4a8dcdbda9863e1bfdab874487696152599aaea5 (diff)
downloadatril-0cee6386acad57fdafb374fb389bc80fcf7e8546.tar.bz2
atril-0cee6386acad57fdafb374fb389bc80fcf7e8546.tar.xz
adding thumbnail support for xps backend
Diffstat (limited to 'backend/xps/xps-document.c')
-rw-r--r--backend/xps/xps-document.c56
1 files changed, 56 insertions, 0 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;
+}
+