Commit 1d615023 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos Committed by Carlos Garcia Campos

Use an EvRenderContext for rendering thumbnails instead of a suggested

2007-02-16  Carlos Garcia Campos  <carlosgc@gnome.org>
	* backend/dvi/dvi-document.c:
	(dvi_document_thumbnails_get_dimensions),
	(dvi_document_thumbnails_get_thumbnail):
	* backend/impress/impress-document.c:
	(impress_document_thumbnails_get_thumbnail),
	(impress_document_thumbnails_get_dimensions):
	* backend/ps/ps-document.c: (ps_document_thumbnails_get_thumbnail),
	(ps_document_thumbnails_get_dimensions):
	* backend/djvu/djvu-document.c:
	(djvu_document_thumbnails_get_dimensions),
	(djvu_document_thumbnails_get_thumbnail):
	* backend/tiff/tiff-document.c:
	(tiff_document_thumbnails_get_thumbnail),
	(tiff_document_thumbnails_get_dimensions):
	* backend/pdf/ev-poppler.cc: (make_thumbnail_for_page),
	(pdf_document_thumbnails_get_thumbnail),
	(pdf_document_thumbnails_get_dimensions):
	* backend/comics/comics-document.c:
	(comics_document_thumbnails_get_thumbnail),
	(comics_document_thumbnails_get_dimensions):
	* backend/pixbuf/pixbuf-document.c:
	(pixbuf_document_thumbnails_get_thumbnail),
	(pixbuf_document_thumbnails_get_dimensions):
	* libdocument/ev-document-thumbnails.[ch]:
	(ev_document_thumbnails_get_thumbnail),
	(ev_document_thumbnails_get_dimensions):
	* libdocument/ev-document-misc.[ch]:
	(ev_document_misc_get_thumbnail_frame):
	* shell/ev-jobs.[ch]: (ev_job_thumbnail_dispose),
	(ev_job_thumbnail_new), (ev_job_thumbnail_run):
	* shell/ev-sidebar-thumbnails.c: (get_scale_for_page), (add_range),
	(ev_sidebar_thumbnails_set_loading_icon), (refresh),
	(ev_sidebar_thumbnails_refresh):
	* shell/ev-window.c: (ev_window_setup_document):
	* thumbnailer/evince-thumbnailer.c: (evince_thumbnail_pngenc_get):
	Use an EvRenderContext for rendering thumbnails instead of a suggested
	width, so that different sized pages get sized proportionally.

svn path=/trunk/; revision=2332
parent 76f05590
2007-02-16 Carlos Garcia Campos <carlosgc@gnome.org>
* backend/dvi/dvi-document.c:
(dvi_document_thumbnails_get_dimensions),
(dvi_document_thumbnails_get_thumbnail):
* backend/impress/impress-document.c:
(impress_document_thumbnails_get_thumbnail),
(impress_document_thumbnails_get_dimensions):
* backend/ps/ps-document.c: (ps_document_thumbnails_get_thumbnail),
(ps_document_thumbnails_get_dimensions):
* backend/djvu/djvu-document.c:
(djvu_document_thumbnails_get_dimensions),
(djvu_document_thumbnails_get_thumbnail):
* backend/tiff/tiff-document.c:
(tiff_document_thumbnails_get_thumbnail),
(tiff_document_thumbnails_get_dimensions):
* backend/pdf/ev-poppler.cc: (make_thumbnail_for_page),
(pdf_document_thumbnails_get_thumbnail),
(pdf_document_thumbnails_get_dimensions):
* backend/comics/comics-document.c:
(comics_document_thumbnails_get_thumbnail),
(comics_document_thumbnails_get_dimensions):
* backend/pixbuf/pixbuf-document.c:
(pixbuf_document_thumbnails_get_thumbnail),
(pixbuf_document_thumbnails_get_dimensions):
* libdocument/ev-document-thumbnails.[ch]:
(ev_document_thumbnails_get_thumbnail),
(ev_document_thumbnails_get_dimensions):
* libdocument/ev-document-misc.[ch]:
(ev_document_misc_get_thumbnail_frame):
* shell/ev-jobs.[ch]: (ev_job_thumbnail_dispose),
(ev_job_thumbnail_new), (ev_job_thumbnail_run):
* shell/ev-sidebar-thumbnails.c: (get_scale_for_page), (add_range),
(ev_sidebar_thumbnails_set_loading_icon), (refresh),
(ev_sidebar_thumbnails_refresh):
* shell/ev-window.c: (ev_window_setup_document):
* thumbnailer/evince-thumbnailer.c: (evince_thumbnail_pngenc_get):
Use an EvRenderContext for rendering thumbnails instead of a suggested
width, so that different sized pages get sized proportionally.
2007-02-15 Carlos Garcia Campos <carlosgc@gnome.org>
* shell/ev-view.c: (ev_view_button_press_event),
......
......@@ -409,52 +409,19 @@ get_supported_image_extensions()
return extensions;
}
static void
comics_document_thumbnails_get_geometry (EvDocumentThumbnails *document,
gint page,
gint suggested_width,
gint *width,
gint *height,
gdouble *scale_factor)
{
gdouble orig_width, orig_height, scale;
comics_document_get_page_size (EV_DOCUMENT (document), page,
&orig_width, &orig_height);
scale = suggested_width / orig_width;
if (width)
*width = suggested_width;
if (height)
*height = orig_height * scale;
if (scale_factor)
*scale_factor = scale;
}
static GdkPixbuf *
comics_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
gint page,
gint rotation,
gint size,
gboolean border)
EvRenderContext *rc,
gboolean border)
{
GdkPixbuf *thumbnail, *framed;
gint thumb_width, thumb_height;
gdouble scale;
EvRenderContext *rc;
GdkPixbuf *thumbnail;
comics_document_thumbnails_get_geometry (document, page, size,
&thumb_width, &thumb_height,
&scale);
rc = ev_render_context_new (rotation, page, scale);
thumbnail = comics_document_render_pixbuf (EV_DOCUMENT (document),
rc);
g_object_unref (G_OBJECT (rc));
thumbnail = comics_document_render_pixbuf (EV_DOCUMENT (document), rc);
if (border) {
GdkPixbuf *tmp_pixbuf = thumbnail;
thumbnail = ev_document_misc_get_thumbnail_frame (-1, -1, 0, tmp_pixbuf);
thumbnail = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf);
g_object_unref (tmp_pixbuf);
}
......@@ -463,14 +430,22 @@ comics_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
static void
comics_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
gint page,
gint suggested_width,
gint *width,
gint *height)
EvRenderContext *rc,
gint *width,
gint *height)
{
comics_document_thumbnails_get_geometry (document, page,
suggested_width,
width, height, NULL);
gdouble page_width, page_height;
comics_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
......
......@@ -326,61 +326,65 @@ djvu_document_document_iface_init (EvDocumentIface *iface)
static void
djvu_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
gint page,
gint suggested_width,
gint *width,
gint *height)
EvRenderContext *rc,
gint *width,
gint *height)
{
DjvuDocument *djvu_document = DJVU_DOCUMENT (document);
gdouble p_width, p_height;
gdouble page_ratio;
gdouble page_width, page_height;
djvu_document_get_page_size (EV_DOCUMENT(djvu_document), page, &p_width, &p_height);
djvu_document_get_page_size (EV_DOCUMENT(djvu_document), rc->page,
&page_width, &page_height);
page_ratio = p_height / p_width;
*width = suggested_width;
*height = (gint) (suggested_width * page_ratio);
return;
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 GdkPixbuf *
djvu_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
gint page,
gint rotation,
gint width,
gboolean border)
djvu_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
EvRenderContext *rc,
gboolean border)
{
DjvuDocument *djvu_document = DJVU_DOCUMENT (document);
GdkPixbuf *pixbuf, *rotated_pixbuf;
gdouble page_width, page_height;
gint thumb_width, thumb_height;
guchar *pixels;
g_return_val_if_fail (djvu_document->d_document, NULL);
djvu_document_get_page_size (EV_DOCUMENT(djvu_document), rc->page,
&page_width, &page_height);
djvu_document_thumbnails_get_dimensions (document, page, width, &thumb_width, &thumb_height);
thumb_width = (gint) (page_width * rc->scale);
thumb_height = (gint) (page_height * rc->scale);
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
thumb_width, thumb_height);
gdk_pixbuf_fill (pixbuf, 0xffffffff);
pixels = gdk_pixbuf_get_pixels (pixbuf);
while (ddjvu_thumbnail_status (djvu_document->d_document, page, 1) < DDJVU_JOB_OK)
while (ddjvu_thumbnail_status (djvu_document->d_document, rc->page, 1) < DDJVU_JOB_OK)
djvu_handle_events(djvu_document, TRUE);
ddjvu_thumbnail_render (djvu_document->d_document, page,
ddjvu_thumbnail_render (djvu_document->d_document, rc->page,
&thumb_width, &thumb_height,
djvu_document->d_format,
gdk_pixbuf_get_rowstride (pixbuf),
(gchar *)pixels);
rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rotation);
rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rc->rotation);
g_object_unref (pixbuf);
if (border) {
GdkPixbuf *tmp_pixbuf = rotated_pixbuf;
rotated_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, 0, tmp_pixbuf);
rotated_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf);
g_object_unref (tmp_pixbuf);
}
......
......@@ -17,8 +17,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include "dvi-document.h"
#include "ev-document-thumbnails.h"
#include "ev-document-misc.h"
......@@ -267,27 +265,27 @@ dvi_document_document_iface_init (EvDocumentIface *iface)
static void
dvi_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
gint page,
gint suggested_width,
EvRenderContext *rc,
gint *width,
gint *height)
{
DviDocument *dvi_document = DVI_DOCUMENT (document);
gdouble page_ratio;
page_ratio = dvi_document->base_height / dvi_document->base_width;
*width = suggested_width;
*height = (gint) (suggested_width * page_ratio);
DviDocument *dvi_document = DVI_DOCUMENT (document);
gdouble page_width = dvi_document->base_width;
gdouble page_height = dvi_document->base_height;
return;
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 GdkPixbuf *
dvi_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
gint page,
gint rotation,
gint width,
gboolean border)
dvi_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
EvRenderContext *rc,
gboolean border)
{
DviDocument *dvi_document = DVI_DOCUMENT (document);
GdkPixbuf *pixbuf;
......@@ -296,11 +294,12 @@ dvi_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
gint thumb_width, thumb_height;
gint proposed_width, proposed_height;
dvi_document_thumbnails_get_dimensions (document, page, width, &thumb_width, &thumb_height);
thumb_width = (gint) (dvi_document->base_width * rc->scale);
thumb_height = (gint) (dvi_document->base_height * rc->scale);
g_mutex_lock (dvi_context_mutex);
mdvi_setpage(dvi_document->context, page);
mdvi_setpage (dvi_document->context, rc->page);
mdvi_set_shrink (dvi_document->context,
(int)dvi_document->base_width * dvi_document->params->hshrink / thumb_width,
......@@ -325,12 +324,13 @@ dvi_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
g_mutex_unlock (dvi_context_mutex);
rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rotation);
rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rc->rotation);
g_object_unref (pixbuf);
if (border) {
GdkPixbuf *tmp_pixbuf = rotated_pixbuf;
rotated_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, 0, tmp_pixbuf);
rotated_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf);
g_object_unref (tmp_pixbuf);
}
......
......@@ -467,27 +467,19 @@ impress_document_document_iface_init (EvDocumentIface *iface)
static GdkPixbuf *
impress_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
gint page,
gint rotation,
gint size,
gboolean border)
EvRenderContext *rc,
gboolean border)
{
GdkPixbuf *pixbuf = NULL;
gdouble w, h;
EvRenderContext *rc;
impress_document_get_page_size (EV_DOCUMENT (document),
page,
&w, &h);
rc = ev_render_context_new (rotation, page, size/w);
pixbuf = impress_document_render_pixbuf (EV_DOCUMENT (document), rc);
g_object_unref (G_OBJECT (rc));
if (border)
{
GdkPixbuf *tmp_pixbuf = pixbuf;
pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, 0, tmp_pixbuf);
pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf);
g_object_unref (tmp_pixbuf);
}
......@@ -496,21 +488,26 @@ impress_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
static void
impress_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
gint page,
gint suggested_width,
gint *width,
gint *height)
EvRenderContext *rc,
gint *width,
gint *height)
{
gdouble page_ratio;
gdouble w, h;
gdouble page_width, page_height;
impress_document_get_page_size (EV_DOCUMENT (document),
page,
&w, &h);
g_return_if_fail (w > 0);
page_ratio = h/w;
*width = suggested_width;
*height = (gint) (suggested_width * page_ratio);
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
......
......@@ -92,8 +92,7 @@ static void pdf_document_file_exporter_iface_init (EvFileExporterIface
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);
......@@ -1174,32 +1173,15 @@ pdf_document_document_images_iface_init (EvDocumentImagesIface *iface)
}
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);
......@@ -1208,20 +1190,15 @@ make_thumbnail_for_size (PdfDocument *pdf_document,
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;
......@@ -1231,18 +1208,17 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails
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;
}
......@@ -1254,8 +1230,7 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails
static void
pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails,
gint page,
gint size,
EvRenderContext *rc,
gint *width,
gint *height)
{
......@@ -1264,10 +1239,8 @@ pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnail
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);
......@@ -1276,9 +1249,19 @@ pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnail
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) (page_width * rc->scale);
*height = (gint) (page_height * rc->scale);
}
if (rc->rotation == 90 || rc->rotation == 270) {
gint temp;
temp = *width;
*width = *height;
*height = temp;
}
g_object_unref (poppler_page);
}
......
......@@ -168,25 +168,22 @@ pixbuf_document_document_iface_init (EvDocumentIface *iface)
}
static GdkPixbuf *
pixbuf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
gint page,
gint rotation,
gint size,
gboolean border)
pixbuf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
EvRenderContext *rc,
gboolean border)
{
PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document);
GdkPixbuf *pixbuf, *rotated_pixbuf;
gdouble scale_factor;
gint height;
gint width, height;
scale_factor = (gdouble)size / gdk_pixbuf_get_width (pixbuf_document->pixbuf);
height = gdk_pixbuf_get_height (pixbuf_document->pixbuf) * scale_factor;
width = (gint) (gdk_pixbuf_get_width (pixbuf_document->pixbuf) * rc->scale);
height = (gint) (gdk_pixbuf_get_height (pixbuf_document->pixbuf) * rc->scale);
pixbuf = gdk_pixbuf_scale_simple (pixbuf_document->pixbuf, size, height,
pixbuf = gdk_pixbuf_scale_simple (pixbuf_document->pixbuf,
width, height,
GDK_INTERP_BILINEAR);
rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rotation);
rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rc->rotation);
g_object_unref (pixbuf);
return rotated_pixbuf;
......@@ -194,18 +191,21 @@ pixbuf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
static void
pixbuf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
gint page,
gint suggested_width,
gint *width,
gint *height)
EvRenderContext *rc,
gint *width,
gint *height)
{
PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document);
gdouble page_ratio;
page_ratio = ((double)gdk_pixbuf_get_height (pixbuf_document->pixbuf)) /
gdk_pixbuf_get_width (pixbuf_document->pixbuf);
*width = suggested_width;
*height = (gint) (suggested_width * page_ratio);
gint p_width = gdk_pixbuf_get_width (pixbuf_document->pixbuf);
gint p_height = gdk_pixbuf_get_height (pixbuf_document->pixbuf);
if (rc->rotation == 90 || rc->rotation == 270) {
*width = (gint) (p_height * rc->scale);
*height = (gint) (p_width * rc->scale);
} else {
*width = (gint) (p_width * rc->scale);
*height = (gint) (p_height * rc->scale);
}
}
static void
......
......@@ -516,15 +516,11 @@ ps_document_render_thumbnail (PSDocument *ps_document)
static GdkPixbuf *
ps_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails,
gint page,
gint rotation,
gint size,
EvRenderContext *rc,
gboolean border)
{
PSDocument *ps_document;
GdkPixbuf *pixbuf = NULL;
gdouble page_width, page_height;
gdouble scale;
ps_document = PS_DOCUMENT (document_thumbnails);
......@@ -543,19 +539,9 @@ ps_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails,
ps_document->thumbs_mutex = g_mutex_new ();
ps_document->thumbs_cond = g_cond_new ();
ps_document_get_page_size (EV_DOCUMENT (ps_document), page,
&page_width, &page_height);
scale = size / page_width;
rotation = (rotation + ps_document_get_page_rotation (ps_document, page)) % 360;
if (!ps_document->thumbs_rc) {
ps_document->thumbs_rc = ev_render_context_new (rotation, page, scale);
} else {
ev_render_context_set_page (ps_document->thumbs_rc, page);
ev_render_context_set_scale (ps_document->thumbs_rc, scale);
ev_render_context_set_rotation (ps_document->thumbs_rc, rotation);
}
if (ps_document->thumbs_rc)
g_object_unref (ps_document->thumbs_rc);
ps_document->thumbs_rc = g_object_ref (rc);
ev_document_doc_mutex_unlock ();
g_mutex_lock (ps_document->thumbs_mutex);
......@@ -572,7 +558,7 @@ ps_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails,
if (border) {
GdkPixbuf *border_pixbuf;
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;
}
......@@ -582,8 +568,7 @@ ps_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails,
static void
ps_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails,
gint page,
gint size,
EvRenderContext *rc,
gint *width,
gint *height)
{
......@@ -593,10 +578,16 @@ ps_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails
ps_document = PS_DOCUMENT (document_thumbnails);
ps_document_get_page_size (EV_DOCUMENT (ps_document),
page,
rc->page,
&page_width, &page_height);
*width = size;
*height = (int) (size * page_height / page_width);
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
......
......@@ -67,15 +67,15 @@ static TIFFErrorHandler orig_warning_handler = NULL;
static void
push_handlers (void)
{
orig_error_handler = TIFFSetErrorHandler (NULL);
orig_warning_handler = TIFFSetWarningHandler (NULL);
orig_error_handler = TIFFSetErrorHandler (NULL);
orig_warning_handler = TIFFSetWarningHandler (NULL);
}
static void
pop_handlers (void)
{
TIFFSetErrorHandler (orig_error_handler);
TIFFSetWarningHandler (orig_warning_handler);
TIFFSetErrorHandler (orig_error_handler);
TIFFSetWarningHandler (orig_warning_handler);
}
static gboolean
......@@ -83,44 +83,44 @@ tiff_document_load (EvDocument *document,
const char *uri,
GError **error)
{
TiffDocument *tiff_document = TIFF_DOCUMENT (document);
gchar *filename;
TIFF *tiff;
push_handlers ();
filename = g_filename_from_uri (uri, NULL, error);
if (!filename)
{
pop_handlers ();
return FALSE;
}
tiff = TIFFOpen (filename, "r");
if (tiff)
{
guint32 w, h;
/* FIXME: unused data? why bother here */
TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &w);
TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &h);
}
if (!tiff)
{
pop_handlers ();
return FALSE;
}
tiff_document->tiff = tiff;
g_free (tiff_document->uri);
g_free (filename);
tiff_document->uri = g_strdup (uri);
pop_handlers ();
return TRUE;
TiffDocument *tiff_document = TIFF_DOCUMENT (document);
gchar *filename;