+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),
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);
}
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
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);
}
* 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"
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;
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,
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);
}
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);
}
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
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);
}
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) (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);
}
}
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;
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
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);
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);
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;
}
static void
ps_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails,
- gint page,
- gint size,
+ EvRenderContext *rc,
gint *width,
gint *height)
{
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
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
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;
+ 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;
}
static gboolean
tiff_document_save (EvDocument *document,
- const char *uri,
- GError **error)
+ const char *uri,
+ GError **error)
{
TiffDocument *tiff_document = TIFF_DOCUMENT (document);
static int
tiff_document_get_n_pages (EvDocument *document)
{
- TiffDocument *tiff_document = TIFF_DOCUMENT (document);
-
- g_return_val_if_fail (TIFF_IS_DOCUMENT (document), 0);
- g_return_val_if_fail (tiff_document->tiff != NULL, 0);
-
- if (tiff_document->n_pages == -1)
- {
- push_handlers ();
- tiff_document->n_pages = 0;
- do
- {
- tiff_document->n_pages ++;
+ TiffDocument *tiff_document = TIFF_DOCUMENT (document);
+
+ g_return_val_if_fail (TIFF_IS_DOCUMENT (document), 0);
+ g_return_val_if_fail (tiff_document->tiff != NULL, 0);
+
+ if (tiff_document->n_pages == -1) {
+ push_handlers ();
+ tiff_document->n_pages = 0;
+
+ do {
+ tiff_document->n_pages ++;
+ }
+ while (TIFFReadDirectory (tiff_document->tiff));
+ pop_handlers ();
}
- while (TIFFReadDirectory (tiff_document->tiff));
- pop_handlers ();
- }
- return tiff_document->n_pages;
+ return tiff_document->n_pages;
}
static void
double *width,
double *height)
{
- guint32 w, h;
- gfloat x_res, y_res;
- TiffDocument *tiff_document = TIFF_DOCUMENT (document);
-
- g_return_if_fail (TIFF_IS_DOCUMENT (document));
- g_return_if_fail (tiff_document->tiff != NULL);
-
- push_handlers ();
- if (TIFFSetDirectory (tiff_document->tiff, page) != 1)
- {
- pop_handlers ();
- return;
- }
-
- TIFFGetField (tiff_document->tiff, TIFFTAG_IMAGEWIDTH, &w);
- TIFFGetField (tiff_document->tiff, TIFFTAG_IMAGELENGTH, &h);
- TIFFGetField (tiff_document->tiff, TIFFTAG_XRESOLUTION, &x_res);
- TIFFGetField (tiff_document->tiff, TIFFTAG_YRESOLUTION, &y_res);
- h = h * (x_res / y_res);
-
- *width = w;
- *height = h;
-
- pop_handlers ();
+ guint32 w, h;
+ gfloat x_res, y_res;
+ TiffDocument *tiff_document = TIFF_DOCUMENT (document);
+
+ g_return_if_fail (TIFF_IS_DOCUMENT (document));
+ g_return_if_fail (tiff_document->tiff != NULL);
+
+ push_handlers ();
+ if (TIFFSetDirectory (tiff_document->tiff, page) != 1) {
+ pop_handlers ();
+ return;
+ }
+
+ TIFFGetField (tiff_document->tiff, TIFFTAG_IMAGEWIDTH, &w);
+ TIFFGetField (tiff_document->tiff, TIFFTAG_IMAGELENGTH, &h);
+ TIFFGetField (tiff_document->tiff, TIFFTAG_XRESOLUTION, &x_res);
+ TIFFGetField (tiff_document->tiff, TIFFTAG_YRESOLUTION, &y_res);
+ h = h * (x_res / y_res);
+
+ *width = w;
+ *height = h;
+
+ pop_handlers ();
}
static GdkPixbuf *
tiff_document_render_pixbuf (EvDocument *document,
EvRenderContext *rc)
{
- TiffDocument *tiff_document = TIFF_DOCUMENT (document);
- int width, height;
- float x_res, y_res;
- gint rowstride, bytes;
- guchar *pixels = NULL;
- GdkPixbuf *pixbuf;
- GdkPixbuf *scaled_pixbuf;
- GdkPixbuf *rotated_pixbuf;
-
- g_return_val_if_fail (TIFF_IS_DOCUMENT (document), 0);
- g_return_val_if_fail (tiff_document->tiff != NULL, 0);
-
- push_handlers ();
- if (TIFFSetDirectory (tiff_document->tiff, rc->page) != 1)
- {
- pop_handlers ();
- return NULL;
- }
-
- if (!TIFFGetField (tiff_document->tiff, TIFFTAG_IMAGEWIDTH, &width))
- {
- pop_handlers ();
- return NULL;
- }
-
- if (! TIFFGetField (tiff_document->tiff, TIFFTAG_IMAGELENGTH, &height))
- {
- pop_handlers ();
- return NULL;
- }
-
- if (!TIFFGetField (tiff_document->tiff, TIFFTAG_XRESOLUTION, &x_res))
- {
- pop_handlers ();
- return NULL;
- }
-
- if (! TIFFGetField (tiff_document->tiff, TIFFTAG_YRESOLUTION, &y_res))
- {
- pop_handlers ();
- return NULL;
- }
-
- pop_handlers ();
-
- /* Sanity check the doc */
- if (width <= 0 || height <= 0)
- return NULL;
-
- rowstride = width * 4;
- if (rowstride / 4 != width)
- /* overflow */
- return NULL;
-
- bytes = height * rowstride;
- if (bytes / rowstride != height)
- /* overflow */
- return NULL;
-
- pixels = g_try_malloc (bytes);
- if (!pixels)
- return NULL;
+ TiffDocument *tiff_document = TIFF_DOCUMENT (document);
+ int width, height;
+ float x_res, y_res;
+ gint rowstride, bytes;
+ guchar *pixels = NULL;
+ GdkPixbuf *pixbuf;
+ GdkPixbuf *scaled_pixbuf;
+ GdkPixbuf *rotated_pixbuf;
+
+ g_return_val_if_fail (TIFF_IS_DOCUMENT (document), NULL);
+ g_return_val_if_fail (tiff_document->tiff != NULL, NULL);
+
+ push_handlers ();
+ if (TIFFSetDirectory (tiff_document->tiff, rc->page) != 1) {
+ pop_handlers ();
+ return NULL;
+ }
- pixbuf = gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, TRUE, 8,
- width, height, rowstride,
- (GdkPixbufDestroyNotify) g_free, NULL);
+ if (!TIFFGetField (tiff_document->tiff, TIFFTAG_IMAGEWIDTH, &width)) {
+ pop_handlers ();
+ return NULL;
+ }
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
- TIFFReadRGBAImageOriented (tiff_document->tiff, width, height, (uint32 *)gdk_pixbuf_get_pixels (pixbuf), ORIENTATION_TOPLEFT, 1);
- pop_handlers ();
+ if (! TIFFGetField (tiff_document->tiff, TIFFTAG_IMAGELENGTH, &height)) {
+ pop_handlers ();
+ return NULL;
+ }
- scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
- width * rc->scale,
- height * rc->scale * (x_res/y_res),
- GDK_INTERP_BILINEAR);
- g_object_unref (pixbuf);
+ if (!TIFFGetField (tiff_document->tiff, TIFFTAG_XRESOLUTION, &x_res)) {
+ pop_handlers ();
+ return NULL;
+ }
- rotated_pixbuf = gdk_pixbuf_rotate_simple (scaled_pixbuf, 360 - rc->rotation);
- g_object_unref (scaled_pixbuf);
+ if (! TIFFGetField (tiff_document->tiff, TIFFTAG_YRESOLUTION, &y_res)) {
+ pop_handlers ();
+ return NULL;
+ }
- return rotated_pixbuf;
+ pop_handlers ();
+
+ /* Sanity check the doc */
+ if (width <= 0 || height <= 0)
+ return NULL;
+
+ rowstride = width * 4;
+ if (rowstride / 4 != width)
+ /* overflow */
+ return NULL;
+
+ bytes = height * rowstride;
+ if (bytes / rowstride != height)
+ /* overflow */
+ return NULL;
+
+ pixels = g_try_malloc (bytes);
+ if (!pixels)
+ return NULL;
+
+ pixbuf = gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, TRUE, 8,
+ width, height, rowstride,
+ (GdkPixbufDestroyNotify) g_free, NULL);
+
+ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
+ TIFFReadRGBAImageOriented (tiff_document->tiff, width, height, (uint32 *)gdk_pixbuf_get_pixels (pixbuf), ORIENTATION_TOPLEFT, 1);
+ pop_handlers ();
+
+ scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
+ width * rc->scale,
+ height * rc->scale * (x_res/y_res),
+ GDK_INTERP_BILINEAR);
+ g_object_unref (pixbuf);
+
+ rotated_pixbuf = gdk_pixbuf_rotate_simple (scaled_pixbuf, 360 - rc->rotation);
+ g_object_unref (scaled_pixbuf);
+
+ return rotated_pixbuf;
}
static void
static GdkPixbuf *
tiff_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
- gint page,
- gint rotation,
- gint size,
+ EvRenderContext *rc,
gboolean border)
{
- EvRenderContext *rc;
- GdkPixbuf *pixbuf;
- gdouble w, h;
-
- tiff_document_get_page_size (EV_DOCUMENT (document),
- page,
- &w, &h);
-
- rc = ev_render_context_new (rotation, page, size/w);
- pixbuf = tiff_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);
- g_object_unref (tmp_pixbuf);
- }
-
- return pixbuf;
+ GdkPixbuf *pixbuf;
+
+ pixbuf = tiff_document_render_pixbuf (EV_DOCUMENT (document), rc);
+
+ if (border) {
+ GdkPixbuf *tmp_pixbuf = pixbuf;
+
+ pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf);
+ g_object_unref (tmp_pixbuf);
+ }
+
+ return pixbuf;
}
static void
tiff_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
- gint page,
- gint suggested_width,
+ EvRenderContext *rc,
gint *width,
gint *height)
{
- gdouble page_ratio;
- gdouble w, h;
-
- tiff_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);
+ gdouble page_width, page_height;
+
+ tiff_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
tiff_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface)
{
- iface->get_thumbnail = tiff_document_thumbnails_get_thumbnail;
- iface->get_dimensions = tiff_document_thumbnails_get_dimensions;
+ iface->get_thumbnail = tiff_document_thumbnails_get_thumbnail;
+ iface->get_dimensions = tiff_document_thumbnails_get_dimensions;
}
/* postscript exporter implementation */
static void
tiff_document_init (TiffDocument *tiff_document)
{
- tiff_document->n_pages = -1;
+ tiff_document->n_pages = -1;
}
GdkPixbuf *
ev_document_misc_get_thumbnail_frame (int width,
int height,
- int rotation,
GdkPixbuf *source_pixbuf)
{
GdkPixbuf *retval;
int i;
int width_r, height_r;
- rotation = rotation % 360;
-
-
if (source_pixbuf)
g_return_val_if_fail (GDK_IS_PIXBUF (source_pixbuf), NULL);
width_r = gdk_pixbuf_get_width (source_pixbuf);
height_r = gdk_pixbuf_get_height (source_pixbuf);
} else {
- if (rotation == 0 || rotation == 180) {
- width_r = width;
- height_r = height;
- } else if (rotation == 90 || rotation == 270) {
- width_r = height;
- height_r = width;
- } else {
- g_assert_not_reached ();
- }
+ width_r = width;
+ height_r = height;
}
/* make sure no one is passing us garbage */
GdkPixbuf *ev_document_misc_get_thumbnail_frame (int width,
int height,
- int rotation,
GdkPixbuf *source_pixbuf);
void ev_document_misc_get_page_border_size (gint page_width,
gint page_height,
*
*/
-#include "config.h"
-
#include "ev-document-thumbnails.h"
GType
}
GdkPixbuf *
-ev_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
- gint page,
- int rotation,
- gint size,
- gboolean border)
+ev_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
+ EvRenderContext *rc,
+ gboolean border)
{
EvDocumentThumbnailsIface *iface;
g_return_val_if_fail (EV_IS_DOCUMENT_THUMBNAILS (document), NULL);
+ g_return_val_if_fail (EV_IS_RENDER_CONTEXT (rc), NULL);
iface = EV_DOCUMENT_THUMBNAILS_GET_IFACE (document);
- return iface->get_thumbnail (document, page, rotation, size, border);
+ return iface->get_thumbnail (document, rc, border);
}
void
ev_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
- gint page,
- gint suggested_width,
+ EvRenderContext *rc,
gint *width,
gint *height)
{
EvDocumentThumbnailsIface *iface;
g_return_if_fail (EV_IS_DOCUMENT_THUMBNAILS (document));
+ g_return_if_fail (EV_IS_RENDER_CONTEXT (rc));
g_return_if_fail (width != NULL);
g_return_if_fail (height != NULL);
iface = EV_DOCUMENT_THUMBNAILS_GET_IFACE (document);
- iface->get_dimensions (document, page, suggested_width, width, height);
+ iface->get_dimensions (document, rc, width, height);
}
G_BEGIN_DECLS
-#define EV_TYPE_DOCUMENT_THUMBNAILS (ev_document_thumbnails_get_type ())
-#define EV_DOCUMENT_THUMBNAILS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_DOCUMENT_THUMBNAILS, EvDocumentThumbnails))
-#define EV_DOCUMENT_THUMBNAILS_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT_THUMBNAILS, EvDocumentThumbnailsIface))
-#define EV_IS_DOCUMENT_THUMBNAILS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_DOCUMENT_THUMBNAILS))
-#define EV_IS_DOCUMENT_THUMBNAILS_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_DOCUMENT_THUMBNAILS))
+#define EV_TYPE_DOCUMENT_THUMBNAILS (ev_document_thumbnails_get_type ())
+#define EV_DOCUMENT_THUMBNAILS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_DOCUMENT_THUMBNAILS, EvDocumentThumbnails))
+#define EV_DOCUMENT_THUMBNAILS_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT_THUMBNAILS, EvDocumentThumbnailsIface))
+#define EV_IS_DOCUMENT_THUMBNAILS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_DOCUMENT_THUMBNAILS))
+#define EV_IS_DOCUMENT_THUMBNAILS_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_DOCUMENT_THUMBNAILS))
#define EV_DOCUMENT_THUMBNAILS_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_DOCUMENT_THUMBNAILS, EvDocumentThumbnailsIface))
-typedef struct _EvDocumentThumbnails EvDocumentThumbnails;
-typedef struct _EvDocumentThumbnailsIface EvDocumentThumbnailsIface;
+typedef struct _EvDocumentThumbnails EvDocumentThumbnails;
+typedef struct _EvDocumentThumbnailsIface EvDocumentThumbnailsIface;
-struct _EvDocumentThumbnailsIface
-{
+struct _EvDocumentThumbnailsIface {
GTypeInterface base_iface;
/* Methods */
GdkPixbuf * (* get_thumbnail) (EvDocumentThumbnails *document,
- gint page,
- gint rotation,
- gint size,
- gboolean border);
+ EvRenderContext *rc,
+ gboolean border);
void (* get_dimensions) (EvDocumentThumbnails *document,
- gint page,
- gint suggested_width,
- gint *width,
- gint *height);
+ EvRenderContext *rc,
+ gint *width,
+ gint *height);
};
-GType ev_document_thumbnails_get_type (void);
-
-/* FIXME: This is a little bit busted. We call get_thumbnail w/ a suggested
- * width, but we should call it with a scale so that different sized pages get
- * sized proportionally.
- */
+GType ev_document_thumbnails_get_type (void) G_GNUC_CONST;
GdkPixbuf *ev_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
- gint page,
- gint rotation,
- gint size,
+ EvRenderContext *rc,
gboolean border);
void ev_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
- gint page,
- gint size,
+ EvRenderContext *rc,
gint *width,
gint *height);
G_END_DECLS
-#endif
+#endif /* EV_DOCUMENT_THUMBNAILS_H */
job->thumbnail = NULL;
}
+ if (job->rc) {
+ g_object_unref (job->rc);
+ job->rc = NULL;
+ }
+
(* G_OBJECT_CLASS (ev_job_thumbnail_parent_class)->dispose) (object);
}
}
EvJob *
-ev_job_thumbnail_new (EvDocument *document,
- gint page,
- int rotation,
- gint requested_width)
+ev_job_thumbnail_new (EvDocument *document,
+ EvRenderContext *rc)
{
EvJobThumbnail *job;
job = g_object_new (EV_TYPE_JOB_THUMBNAIL, NULL);
EV_JOB (job)->document = g_object_ref (document);
- job->page = page;
- job->rotation = rotation;
- job->requested_width = requested_width;
+ job->rc = g_object_ref (rc);
return EV_JOB (job);
}
job->thumbnail =
ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (EV_JOB (job)->document),
- job->page,
- job->rotation,
- job->requested_width,
- TRUE);
+ job->rc, TRUE);
EV_JOB (job)->finished = TRUE;
ev_document_doc_mutex_unlock ();
{
EvJob parent;
- gint page;
- gint rotation;
- gint requested_width;
+ EvRenderContext *rc;
GdkPixbuf *thumbnail;
};
/* EvJobThumbnail */
GType ev_job_thumbnail_get_type (void) G_GNUC_CONST;
-EvJob *ev_job_thumbnail_new (EvDocument *document,
- gint page,
- int rotation,
- gint requested_width);
-void ev_job_thumbnail_run (EvJobThumbnail *thumbnail);
+EvJob *ev_job_thumbnail_new (EvDocument *document,
+ EvRenderContext *rc);
+void ev_job_thumbnail_run (EvJobThumbnail *thumbnail);
/* EvJobFonts */
GType ev_job_fonts_get_type (void) G_GNUC_CONST;
gtk_tree_path_free (path);
}
+static gdouble
+get_scale_for_page (EvSidebarThumbnails *sidebar_thumbnails,
+ gint page)
+{
+ EvSidebarThumbnailsPrivate *priv = sidebar_thumbnails->priv;
+ gint width, height;
+
+ ev_page_cache_get_size (priv->page_cache,
+ page, priv->rotation,
+ 1.0, &width, &height);
+
+ return (gdouble)THUMBNAIL_WIDTH / (gdouble)width;
+}
+
static void
add_range (EvSidebarThumbnails *sidebar_thumbnails,
gint start_page,
for (result = gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->list_store), &iter, path);
result && page <= end_page;
result = gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->list_store), &iter), page ++) {
- EvJobThumbnail *job;
+ EvJob *job;
gboolean thumbnail_set;
gtk_tree_model_get (GTK_TREE_MODEL (priv->list_store), &iter,
-1);
if (job == NULL && !thumbnail_set) {
- /* FIXME: Need rotation */
- job = (EvJobThumbnail *)ev_job_thumbnail_new (priv->document, page, priv->rotation, THUMBNAIL_WIDTH);
+ EvRenderContext *rc;
+
+ rc = ev_render_context_new (priv->rotation, page,
+ get_scale_for_page (sidebar_thumbnails, page));
+ job = ev_job_thumbnail_new (priv->document, rc);
ev_job_queue_add_job (EV_JOB (job), EV_JOB_PRIORITY_HIGH);
+ g_object_unref (rc);
+
g_object_set_data_full (G_OBJECT (job), "tree_iter",
gtk_tree_iter_copy (&iter),
(GDestroyNotify) gtk_tree_iter_free);
gtk_list_store_set (priv->list_store, &iter,
COLUMN_JOB, job,
-1);
+
/* The queue and the list own a ref to the job now */
g_object_unref (job);
} else if (job) {
g_object_unref (sidebar_thumbnails->priv->loading_icon);
if (sidebar_thumbnails->priv->document) {
+ EvRenderContext *rc;
+
+ rc = ev_render_context_new (sidebar_thumbnails->priv->rotation, 0,
+ get_scale_for_page (sidebar_thumbnails, 0));
+
/* We get the dimensions of the first doc so that we can make a blank
* icon. */
ev_document_doc_mutex_lock ();
ev_document_thumbnails_get_dimensions (EV_DOCUMENT_THUMBNAILS (sidebar_thumbnails->priv->document),
- 0, THUMBNAIL_WIDTH, &width, &height);
+ rc, &width, &height);
ev_document_doc_mutex_unlock ();
+
+ g_object_unref (rc);
+
sidebar_thumbnails->priv->loading_icon =
- ev_document_misc_get_thumbnail_frame (width, height, sidebar_thumbnails->priv->rotation, NULL);
+ ev_document_misc_get_thumbnail_frame (width, height, NULL);
} else {
sidebar_thumbnails->priv->loading_icon = NULL;
}
}
+static gboolean
+refresh (EvSidebarThumbnails *sidebar_thumbnails)
+{
+ adjustment_changed_cb (sidebar_thumbnails);
+ return FALSE;
+}
+
void
ev_sidebar_thumbnails_refresh (EvSidebarThumbnails *sidebar_thumbnails,
int rotation)
/* Trigger a redraw */
sidebar_thumbnails->priv->start_page = 0;
sidebar_thumbnails->priv->end_page = 0;
- adjustment_changed_cb (sidebar_thumbnails);
+ g_idle_add ((GSourceFunc)refresh, sidebar_thumbnails);
}
static void
document = ev_window->priv->document;
ev_window->priv->page_cache = ev_page_cache_get (ev_window->priv->document);
- g_signal_connect (ev_window->priv->page_cache, "page-changed", G_CALLBACK (page_changed_cb), ev_window);
- g_signal_connect (ev_window->priv->page_cache, "history-changed", G_CALLBACK (history_changed_cb), ev_window);
+ g_signal_connect (ev_window->priv->page_cache, "page-changed",
+ G_CALLBACK (page_changed_cb), ev_window);
+ g_signal_connect (ev_window->priv->page_cache, "history-changed",
+ G_CALLBACK (history_changed_cb), ev_window);
if (EV_IS_DOCUMENT_FIND (document)) {
g_signal_connect_object (G_OBJECT (document),
}
if (EV_IS_DOCUMENT_THUMBNAILS (document)) {
+ EvRenderContext *rc;
+ gint page_width, page_height;
+ gdouble scale;
+
ev_window_clear_thumbnail_job (ev_window);
- ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, 0, 0, 100);
+
+ ev_page_cache_get_size (ev_window->priv->page_cache,
+ 1, 0, 1.0,
+ &page_width, &page_height);
+ scale = (gdouble)128 / (gdouble)page_width;
+
+ rc = ev_render_context_new (0, 0, scale);
+ ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, rc);
g_signal_connect (ev_window->priv->thumbnail_job, "finished",
G_CALLBACK (ev_window_set_icon_from_thumbnail),
ev_window);
ev_job_queue_add_job (EV_JOB (ev_window->priv->thumbnail_job), EV_JOB_PRIORITY_LOW);
+ g_object_unref (rc);
}
ev_sidebar_set_document (sidebar, document);
evince_thumbnail_pngenc_get (const char *uri, const char *thumbnail, int size)
{
EvDocument *document = NULL;
+ EvRenderContext *rc;
+ double width, height;
GError *error = NULL;
GdkPixbuf *pixbuf;
return FALSE;
}
+ ev_document_get_page_size (document, 0, &width, &height);
+ rc = ev_render_context_new (0, 0, THUMBNAIL_SIZE / width);
+
pixbuf = ev_document_thumbnails_get_thumbnail
- (EV_DOCUMENT_THUMBNAILS (document), 0, 0, size, FALSE);
+ (EV_DOCUMENT_THUMBNAILS (document), rc, FALSE);
+
+ g_object_unref (rc);
if (pixbuf != NULL) {
const char *overlaid_icon_name = NULL;
1, 1,
GDK_INTERP_NEAREST, 100);
- gdk_pixbuf_unref (overlaid_pixbuf);
+ g_object_unref (overlaid_pixbuf);
}
}
if (gdk_pixbuf_save (pixbuf, thumbnail, "png", NULL, NULL)) {
- gdk_pixbuf_unref (pixbuf);
+ g_object_unref (pixbuf);
g_object_unref (document);
return TRUE;
} else {
- gdk_pixbuf_unref (pixbuf);
+ g_object_unref (pixbuf);
g_object_unref (document);
}
}