]> www.fi.muni.cz Git - evince.git/commitdiff
Rework API a bit. Add a border flag and change sizing logic (now the size
authorMarco Pesenti Gritti <marco@gnome.org>
Mon, 7 Mar 2005 13:51:12 +0000 (13:51 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Mon, 7 Mar 2005 13:51:12 +0000 (13:51 +0000)
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.

ChangeLog
backend/ev-document-thumbnails.c
backend/ev-document-thumbnails.h
pdf/pdf-document.cc
pixbuf/pixbuf-document.c
shell/ev-sidebar-thumbnails.c
thumbnailer/evince-thumbnailer.c

index dc833ce88f3c31b083ff3bc316df60365c09712f..1052cf2b64380765a7603ed064815da464a932d6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+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):
index ce2f21874860df356af9b456edb7a03000cbc8ec..260d623864edd7bbaa481ea5c8e4190855bd7761 100644 (file)
@@ -47,14 +47,15 @@ ev_document_thumbnails_get_type (void)
 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
index 52ed6c57329ebe80e87155a0ccc8cf87272ce54f..76b0cc8cdea4e9c52c66edb11c9dcccdc23d5ea0 100644 (file)
@@ -42,7 +42,8 @@ struct _EvDocumentThumbnailsIface
         /* Methods  */
         GdkPixbuf *  (* get_thumbnail)  (EvDocumentThumbnails *document,
                                          gint                  page,
-                                         gint                  width);
+                                         gint                  size,
+                                        gboolean              border);
         void         (* get_dimensions) (EvDocumentThumbnails *document,
                                         gint                  page,
                                         gint                  suggested_width,
@@ -53,10 +54,11 @@ struct _EvDocumentThumbnailsIface
 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);
 
index a749d3683b61dfd94be9f3f5627fb07332cec618..2ed1f1719142bc1dd99f31de6d7048510230b7ce 100644 (file)
@@ -1240,7 +1240,8 @@ pdf_document_thumbnails_get_page_pixbuf (PdfDocument *pdf_document,
                                         gdouble      scale_factor,
                                         gint         page_num,
                                         gint         width,
-                                        gint         height)
+                                        gint         height,
+                                        gboolean     border)
 {
        SplashOutputDev *output;
        GdkPixbuf *pixbuf;
@@ -1256,9 +1257,17 @@ pdf_document_thumbnails_get_page_pixbuf (PdfDocument *pdf_document,
                                        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;
 
@@ -1268,7 +1277,7 @@ pdf_document_thumbnails_get_page_pixbuf (PdfDocument *pdf_document,
 static void
 pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails,
                                        gint                  page,
-                                       gint                  suggested_width,
+                                       gint                  size,
                                        gint                 *width,
                                        gint                 *height)
 {
@@ -1276,9 +1285,8 @@ pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnail
        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())) {
@@ -1289,16 +1297,26 @@ pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnail
                *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;
@@ -1306,17 +1324,11 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails
        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 (),
@@ -1342,15 +1354,18 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails
                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;
index ab93f19b2c97d047295bff183f56da16dfe78755..4195675ba755aa7e9fd5ad5f467a5f6acbfcfc36 100644 (file)
@@ -267,19 +267,20 @@ pixbuf_document_document_iface_init (EvDocumentIface *iface)
 
 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;
index de31e478a2304baa2dabdece72381a23d63188d7..b602bb26ae7dfa2beaabd47d1504b89a0fe96e47 100644 (file)
@@ -35,7 +35,8 @@
 #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
 
@@ -222,8 +223,9 @@ do_one_iteration (EvSidebarThumbnails *ev_sidebar_thumbnails)
                            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),
index 06fdec146bd62c0aeef20718aa28f84b20f12874..d7db2654a864122592fb232609d94b9ebef2329f 100644 (file)
@@ -28,7 +28,7 @@
 
 #include <string.h>
 
-#define THUMBNAIL_SIZE 100
+#define THUMBNAIL_SIZE 128
 
 static gboolean
 evince_thumbnail_pngenc_get (const char *uri, const char *thumbnail)
@@ -57,7 +57,7 @@ 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;