+2005-03-07 Marco Pesenti Gritti <marco@gnome.org>
+
+ * backend/ev-document-thumbnails.c:
+ (ev_document_thumbnails_get_thumbnail):
+ * backend/ev-document-thumbnails.h:
+
+ Rework API a bit. Add a border flag and
+ change sizing logic (now the size we specify
+ applies to the bigger dimension).
+
+ * pdf/pdf-document.cc:
+ * pixbuf/pixbuf-document.c:
+ (pixbuf_document_thumbnails_get_thumbnail):
+ * shell/ev-sidebar-thumbnails.c: (do_one_iteration):
+ * thumbnailer/evince-thumbnailer.c: (evince_thumbnail_pngenc_get):
+
+ Adapt to the new API and do not draw a border for nautilus
+ thumbnailer.
+
2005-03-03 Fernando Herrera <fherrera@onirica.com>
* thumbnailer/evince-thumbnailer.c: (evince_thumbnail_pngenc_get):
GdkPixbuf *
ev_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
gint page,
- gint suggested_width)
+ gint size,
+ gboolean border)
{
EvDocumentThumbnailsIface *iface;
g_return_val_if_fail (EV_IS_DOCUMENT_THUMBNAILS (document), NULL);
iface = EV_DOCUMENT_THUMBNAILS_GET_IFACE (document);
- return iface->get_thumbnail (document, page, suggested_width);
+ return iface->get_thumbnail (document, page, size, border);
}
void
/* Methods */
GdkPixbuf * (* get_thumbnail) (EvDocumentThumbnails *document,
gint page,
- gint width);
+ gint size,
+ gboolean border);
void (* get_dimensions) (EvDocumentThumbnails *document,
gint page,
gint suggested_width,
GType ev_document_thumbnails_get_type (void);
GdkPixbuf *ev_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
gint page,
- gint suggested_width);
+ gint size,
+ gboolean border);
void ev_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
gint page,
- gint suggested_width,
+ gint size,
gint *width,
gint *height);
gdouble scale_factor,
gint page_num,
gint width,
- gint height)
+ gint height,
+ gboolean border)
{
SplashOutputDev *output;
GdkPixbuf *pixbuf;
72*scale_factor,
0, gTrue, gFalse);
- pixbuf = ev_document_misc_get_thumbnail_frame (output->getBitmap()->getWidth(),
- output->getBitmap()->getHeight(),
- NULL);
+ width = output->getBitmap()->getWidth();
+ height = output->getBitmap()->getHeight();
+
+ if (border) {
+ pixbuf = ev_document_misc_get_thumbnail_frame (width, height, NULL);
+ } else {
+ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
+ width + 4, height + 4);
+ gdk_pixbuf_fill (pixbuf, 0xffffffff);
+ }
+
bitmap_to_pixbuf (output->getBitmap(), pixbuf, 1, 1);
delete output;
static void
pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails,
gint page,
- gint suggested_width,
+ gint size,
gint *width,
gint *height)
{
Page *the_page;
Object the_thumb;
Thumb *thumb = NULL;
- gdouble page_ratio;
- the_page = pdf_document->doc->getCatalog ()->getPage (page);
+ the_page = pdf_document->doc->getCatalog ()->getPage (page + 1);
the_page->getThumb (&the_thumb);
if (!(the_thumb.isNull () || the_thumb.isNone())) {
*width = thumb->getWidth ();
*height = thumb->getHeight ();
} else {
- page_ratio = the_page->getHeight () / the_page->getWidth ();
- *width = suggested_width;
- *height = (gint) (suggested_width * page_ratio);
+ double page_width, page_height;
+
+ page_width = the_page->getWidth ();
+ page_height = the_page->getHeight ();
+
+ if (page_width > page_height) {
+ *width = size;
+ *height = (int) (size * page_height / page_width);
+ } else {
+ *width = (int) (size * page_width / page_height);
+ *height = size;
+ }
}
}
static GdkPixbuf *
pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails,
gint page,
- gint width)
+ gint size,
+ gboolean border)
{
PdfDocument *pdf_document = PDF_DOCUMENT (document_thumbnails);
GdkPixbuf *thumbnail;
Object the_thumb;
Thumb *thumb = NULL;
gboolean have_ethumbs = FALSE;
- gdouble page_ratio;
- gint dest_height;
/* getPage seems to want page + 1 for some reason; */
the_page = pdf_document->doc->getCatalog ()->getPage (page + 1);
the_page->getThumb(&the_thumb);
- page_ratio = the_page->getHeight () / the_page->getWidth ();
- dest_height = (gint) (width * page_ratio);
-
-
if (!(the_thumb.isNull () || the_thumb.isNone())) {
/* Build the thumbnail object */
thumb = new Thumb(pdf_document->doc->getXRef (),
thumbnail = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf);
g_object_unref (tmp_pixbuf);
} else {
- gdouble scale_factor;
-
- scale_factor = (gdouble)width / the_page->getWidth ();
-
+ int width, height;
+ double scale_factor;
+
+ pdf_document_thumbnails_get_dimensions (document_thumbnails, page, size,
+ &width, &height);
+ scale_factor = width / the_page->getWidth ();
thumbnail = pdf_document_thumbnails_get_page_pixbuf (pdf_document,
scale_factor,
page,
width,
- dest_height);
+ height,
+ border);
}
return thumbnail;
static GdkPixbuf *
pixbuf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
- gint page,
- gint width)
+ gint page,
+ gint size,
+ gboolean border)
{
PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document);
GdkPixbuf *pixbuf;
gdouble scale_factor;
gint height;
- scale_factor = (gdouble)width / gdk_pixbuf_get_width (pixbuf_document->pixbuf);
+ scale_factor = (gdouble)size / gdk_pixbuf_get_width (pixbuf_document->pixbuf);
height = gdk_pixbuf_get_height (pixbuf_document->pixbuf) * scale_factor;
- pixbuf = gdk_pixbuf_scale_simple (pixbuf_document->pixbuf, width, height,
+ pixbuf = gdk_pixbuf_scale_simple (pixbuf_document->pixbuf, size, height,
GDK_INTERP_BILINEAR);
return pixbuf;
#include "ev-window.h"
#include "ev-utils.h"
-#define THUMBNAIL_WIDTH 75
+#define THUMBNAIL_WIDTH 100
+
/* Amount of time we devote to each iteration of the idle, in microseconds */
#define IDLE_WORK_LENGTH 5000
COLUMN_THUMBNAIL_SET, &thumbnail_set,
-1);
if (!thumbnail_set) {
- pixbuf = ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (priv->document),
- priv->current_page, THUMBNAIL_WIDTH);
+ pixbuf = ev_document_thumbnails_get_thumbnail
+ (EV_DOCUMENT_THUMBNAILS (priv->document),
+ priv->current_page, THUMBNAIL_WIDTH, TRUE);
gtk_list_store_set (priv->list_store,
&(priv->current_page_iter),
#include <string.h>
-#define THUMBNAIL_SIZE 100
+#define THUMBNAIL_SIZE 128
static gboolean
evince_thumbnail_pngenc_get (const char *uri, const char *thumbnail)
}
pixbuf = ev_document_thumbnails_get_thumbnail
- (EV_DOCUMENT_THUMBNAILS (document), 0, THUMBNAIL_SIZE);
+ (EV_DOCUMENT_THUMBNAILS (document), 0, THUMBNAIL_SIZE, FALSE);
if (pixbuf != NULL) {
GdkPixbuf *pdflogo;