static void pdf_selection_iface_init (EvSelectionIface *iface);
static void pdf_document_page_transition_iface_init (EvDocumentTransitionIface *iface);
static void pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails,
- gint page,
- gint size,
+ EvRenderContext *rc,
gint *width,
gint *height);
static int pdf_document_get_n_pages (EvDocument *document);
if (pdf_document->fonts_iter) {
poppler_fonts_iter_free (pdf_document->fonts_iter);
}
+
+ G_OBJECT_CLASS (pdf_document_parent_class)->dispose (object);
}
static void
}
static GdkPixbuf *
-make_thumbnail_for_size (PdfDocument *pdf_document,
- gint page,
- int rotation,
- gint size)
+make_thumbnail_for_page (PdfDocument *pdf_document,
+ PopplerPage *poppler_page,
+ EvRenderContext *rc)
{
- PopplerPage *poppler_page;
GdkPixbuf *pixbuf;
int width, height;
- double scale;
- gdouble unscaled_width, unscaled_height;
-
- poppler_page = poppler_document_get_page (pdf_document->document, page);
- g_return_val_if_fail (poppler_page != NULL, NULL);
- pdf_document_thumbnails_get_dimensions (EV_DOCUMENT_THUMBNAILS (pdf_document), page,
- size, &width, &height);
- poppler_page_get_size (poppler_page, &unscaled_width, &unscaled_height);
- scale = width / unscaled_width;
-
- /* rotate */
- if (rotation == 90 || rotation == 270) {
- int temp;
- temp = width;
- width = height;
- height = temp;
- }
+ pdf_document_thumbnails_get_dimensions (EV_DOCUMENT_THUMBNAILS (pdf_document),
+ rc, &width, &height);
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
width, height);
ev_document_fc_mutex_lock ();
poppler_page_render_to_pixbuf (poppler_page, 0, 0,
width, height,
- scale, rotation, pixbuf);
+ rc->scale, rc->rotation, pixbuf);
ev_document_fc_mutex_unlock ();
-
-
- g_object_unref (poppler_page);
return pixbuf;
}
static GdkPixbuf *
pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails,
- gint page,
- gint rotation,
- gint size,
+ EvRenderContext *rc,
gboolean border)
{
PdfDocument *pdf_document;
pdf_document = PDF_DOCUMENT (document_thumbnails);
- poppler_page = poppler_document_get_page (pdf_document->document, page);
+ poppler_page = poppler_document_get_page (pdf_document->document, rc->page);
g_return_val_if_fail (poppler_page != NULL, NULL);
pixbuf = poppler_page_get_thumbnail (poppler_page);
-
- if (pixbuf == NULL) {
+ if (!pixbuf) {
/* There is no provided thumbnail. We need to make one. */
- pixbuf = make_thumbnail_for_size (pdf_document, page, rotation, size);
+ pixbuf = make_thumbnail_for_page (pdf_document, poppler_page, rc);
}
if (border) {
- border_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, rotation, pixbuf);
+ border_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, pixbuf);
g_object_unref (pixbuf);
pixbuf = border_pixbuf;
}
static void
pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails,
- gint page,
- gint size,
+ EvRenderContext *rc,
gint *width,
gint *height)
{
gint has_thumb;
pdf_document = PDF_DOCUMENT (document_thumbnails);
- poppler_page = poppler_document_get_page (pdf_document->document, page);
+ poppler_page = poppler_document_get_page (pdf_document->document, rc->page);
- g_return_if_fail (width != NULL);
- g_return_if_fail (height != NULL);
g_return_if_fail (poppler_page != NULL);
has_thumb = poppler_page_get_thumbnail_size (poppler_page, width, height);
double page_width, page_height;
poppler_page_get_size (poppler_page, &page_width, &page_height);
- *width = size;
- *height = (int) (size * page_height / page_width);
+
+ *width = (gint) MAX (page_width * rc->scale, 1);
+ *height = (gint) MAX (page_height * rc->scale, 1);
}
+
+ if (rc->rotation == 90 || rc->rotation == 270) {
+ gint temp;
+
+ temp = *width;
+ *width = *height;
+ *height = temp;
+ }
+
g_object_unref (poppler_page);
}
TRUE, 8,
width, height);
}
-
+
+#if POPPLER_VERSION <= 5
poppler_page_render_selection (POPPLER_PAGE (rc->data),
rc->scale, rc->rotation, *pixbuf,
(PopplerRectangle *)points,
(PopplerRectangle *)old_points,
text,
base);
+#else /* POPPLER_VERSION == 9 */
+ poppler_page_render_selection_to_pixbuf (POPPLER_PAGE (rc->data),
+ rc->scale, rc->rotation, *pixbuf,
+ (PopplerRectangle *)points,
+ (PopplerRectangle *)old_points,
+ POPPLER_SELECTION_NORMAL,
+ text,
+ base);
+#endif
}