]> www.fi.muni.cz Git - evince.git/commitdiff
Remove EvDocumentThumbnails interface
authorCarlos Garcia Campos <carlosgc@gnome.org>
Thu, 19 Aug 2010 13:41:25 +0000 (15:41 +0200)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Thu, 19 Aug 2010 13:41:25 +0000 (15:41 +0200)
The only method get_thumbnail() has been moved to EvDocument. Thumbnails
are always implemented by backends since it's usually just rendering the
page at a lower scale factor. EvDocument provides a default
implementation so that most of the backends don't even need to implement
it.

17 files changed:
backend/comics/comics-document.c
backend/djvu/djvu-document.c
backend/dvi/dvi-document.c
backend/pdf/ev-poppler.cc
backend/pixbuf/pixbuf-document.c
backend/ps/ev-spectre.c
backend/tiff/tiff-document.c
evince-document.h
libdocument/Makefile.am
libdocument/ev-document-thumbnails.c [deleted file]
libdocument/ev-document-thumbnails.h [deleted file]
libdocument/ev-document.c
libdocument/ev-document.h
libview/ev-jobs.c
shell/ev-sidebar-thumbnails.c
shell/ev-window.c
thumbnailer/evince-thumbnailer.c

index 9205b974c8c214adf5f119bb7cd6e8980c488a20..0481de864b586ce7e118820fddd422a4d0907c4d 100644 (file)
@@ -39,7 +39,6 @@
 
 #include "comics-document.h"
 #include "ev-document-misc.h"
-#include "ev-document-thumbnails.h"
 #include "ev-file-helpers.h"
 
 #ifdef G_OS_WIN32
@@ -123,8 +122,6 @@ static const ComicBookDecompressCommand command_usage_def[] = {
        {"%s -xOf"          , "%s -tf %s"      , NULL             , FALSE, NO_OFFSET}
 };
 
-static void       comics_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface);
-
 static GSList*    get_supported_image_extensions (void);
 static void       get_page_size_area_prepared_cb (GdkPixbufLoader *loader,
                                                  gpointer data);
@@ -136,11 +133,7 @@ static char**     extract_argv                   (EvDocument *document,
                                                  gint page);
 
 
-EV_BACKEND_REGISTER_WITH_CODE (ComicsDocument, comics_document,
-       {
-               EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS,
-                                               comics_document_document_thumbnails_iface_init);
-       } );
+EV_BACKEND_REGISTER (ComicsDocument, comics_document)
 
 /**
  * comics_regex_quote:
@@ -851,31 +844,6 @@ get_supported_image_extensions()
        return extensions;
 }
 
-static GdkPixbuf *
-comics_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
-                                         EvRenderContext      *rc,
-                                         gboolean              border)
-{
-       GdkPixbuf *thumbnail;
-
-       thumbnail = comics_document_render_pixbuf (EV_DOCUMENT (document), rc);
-
-       if (border) {
-             GdkPixbuf *tmp_pixbuf = thumbnail;
-             
-             thumbnail = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf);
-             g_object_unref (tmp_pixbuf);
-       }
-
-       return thumbnail;
-}
-
-static void
-comics_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface)
-{
-       iface->get_thumbnail = comics_document_thumbnails_get_thumbnail;
-}
-
 static char**
 extract_argv (EvDocument *document, gint page)
 {
index ae4fb01a6c0723f3566a6eb8348a8bfe6f75f98a..3349f4037bae2f54e756711054b6ba526d476f05 100644 (file)
@@ -24,7 +24,6 @@
 #include "djvu-text-page.h"
 #include "djvu-links.h"
 #include "djvu-document-private.h"
-#include "ev-document-thumbnails.h"
 #include "ev-file-exporter.h"
 #include "ev-document-misc.h"
 #include "ev-document-find.h"
@@ -51,7 +50,6 @@ struct _DjvuDocumentClass
 
 typedef struct _DjvuDocumentClass DjvuDocumentClass;
 
-static void djvu_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface);
 static void djvu_document_file_exporter_iface_init (EvFileExporterInterface *iface);
 static void djvu_document_find_iface_init (EvDocumentFindInterface *iface);
 static void djvu_document_document_links_iface_init  (EvDocumentLinksInterface *iface);
@@ -59,7 +57,6 @@ static void djvu_selection_iface_init (EvSelectionInterface *iface);
 
 EV_BACKEND_REGISTER_WITH_CODE (DjvuDocument, djvu_document,
     {
-      EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS, djvu_document_document_thumbnails_iface_init);
       EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_FILE_EXPORTER, djvu_document_file_exporter_iface_init);
       EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_FIND, djvu_document_find_iface_init);
       EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_LINKS, djvu_document_document_links_iface_init);
@@ -380,6 +377,44 @@ djvu_document_render (EvDocument      *document,
        return surface;
 }
 
+static GdkPixbuf *
+djvu_document_get_thumbnail (EvDocument      *document,
+                            EvRenderContext *rc)
+{
+       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);
+       
+       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, rc->page->index, 1) < DDJVU_JOB_OK)
+               djvu_handle_events(djvu_document, TRUE, NULL);
+                   
+       ddjvu_thumbnail_render (djvu_document->d_document, rc->page->index, 
+                               &thumb_width, &thumb_height,
+                               djvu_document->thumbs_format,
+                               gdk_pixbuf_get_rowstride (pixbuf), 
+                               (gchar *)pixels);
+
+       rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rc->rotation);
+       g_object_unref (pixbuf);
+
+       return rotated_pixbuf;
+}
+
 static void
 djvu_document_finalize (GObject *object)
 {
@@ -415,6 +450,7 @@ djvu_document_class_init (DjvuDocumentClass *klass)
        ev_document_class->get_n_pages = djvu_document_get_n_pages;
        ev_document_class->get_page_size = djvu_document_get_page_size;
        ev_document_class->render = djvu_document_render;
+       ev_document_class->get_thumbnail = djvu_document_get_thumbnail;
 }
 
 static gchar *
@@ -473,58 +509,6 @@ djvu_selection_iface_init (EvSelectionInterface *iface)
        iface->get_selected_text = djvu_selection_get_selected_text;
 }
 
-static GdkPixbuf *
-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);
-       
-       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, rc->page->index, 1) < DDJVU_JOB_OK)
-               djvu_handle_events(djvu_document, TRUE, NULL);
-                   
-       ddjvu_thumbnail_render (djvu_document->d_document, rc->page->index, 
-                               &thumb_width, &thumb_height,
-                               djvu_document->thumbs_format,
-                               gdk_pixbuf_get_rowstride (pixbuf), 
-                               (gchar *)pixels);
-
-       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, tmp_pixbuf);
-             g_object_unref (tmp_pixbuf);
-       }
-       
-       return rotated_pixbuf;
-}
-
-static void
-djvu_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface)
-{
-       iface->get_thumbnail = djvu_document_thumbnails_get_thumbnail;
-}
-
 /* EvFileExporterIface */
 static void
 djvu_document_file_exporter_begin (EvFileExporter        *exporter,
index 84870365a6741d192d29b90d1d4fd0434bba87dc..89d3189d59c303da27a5561212950b55b898308e 100644 (file)
@@ -21,7 +21,6 @@
 
 #include "dvi-document.h"
 #include "texmfcnf.h"
-#include "ev-document-thumbnails.h"
 #include "ev-document-misc.h"
 #include "ev-file-exporter.h"
 #include "ev-file-helpers.h"
@@ -74,15 +73,13 @@ struct _DviDocument
 
 typedef struct _DviDocumentClass DviDocumentClass;
 
-static void dvi_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface);
-static void dvi_document_file_exporter_iface_init      (EvFileExporterInterface       *iface);
-static void dvi_document_do_color_special               (DviContext                    *dvi,
-                                                        const char                    *prefix,
-                                                        const char                    *arg);
+static void dvi_document_file_exporter_iface_init (EvFileExporterInterface       *iface);
+static void dvi_document_do_color_special         (DviContext                    *dvi,
+                                                  const char                    *prefix,
+                                                  const char                    *arg);
 
 EV_BACKEND_REGISTER_WITH_CODE (DviDocument, dvi_document,
      {
-      EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS, dvi_document_document_thumbnails_iface_init);
       EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_FILE_EXPORTER, dvi_document_file_exporter_iface_init);
      });
 
@@ -267,69 +264,6 @@ dvi_document_class_init (DviDocumentClass *klass)
        ev_document_class->support_synctex = dvi_document_support_synctex;
 }
 
-static GdkPixbuf *
-dvi_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
-                                      EvRenderContext      *rc,   
-                                      gboolean              border)
-{
-       DviDocument *dvi_document = DVI_DOCUMENT (document);
-       GdkPixbuf *pixbuf;
-       GdkPixbuf *rotated_pixbuf;
-       cairo_surface_t *surface;
-       gint thumb_width, thumb_height;
-       gint proposed_width, proposed_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, rc->page->index);
-
-       mdvi_set_shrink (dvi_document->context, 
-                         (int)dvi_document->base_width * dvi_document->params->hshrink / thumb_width,
-                         (int)dvi_document->base_height * dvi_document->params->vshrink / thumb_height);
-
-       proposed_width = dvi_document->context->dvi_page_w * dvi_document->context->params.conv;
-       proposed_height = dvi_document->context->dvi_page_h * dvi_document->context->params.vconv;
-                         
-       if (border) {
-               mdvi_cairo_device_set_margins (&dvi_document->context->device, 
-                                              MAX (thumb_width - proposed_width, 0) / 2,
-                                              MAX (thumb_height - proposed_height, 0) / 2);    
-       } else {
-               mdvi_cairo_device_set_margins (&dvi_document->context->device, 
-                                              MAX (thumb_width - proposed_width - 2, 0) / 2,
-                                              MAX (thumb_height - proposed_height - 2, 0) / 2);        
-       }
-
-       mdvi_cairo_device_set_scale (&dvi_document->context->device, rc->scale);
-        mdvi_cairo_device_render (dvi_document->context);
-       surface = mdvi_cairo_device_get_surface (&dvi_document->context->device);
-       g_mutex_unlock (dvi_context_mutex);
-
-       pixbuf = ev_document_misc_pixbuf_from_surface (surface);
-       cairo_surface_destroy (surface);
-
-       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, tmp_pixbuf);
-               g_object_unref (tmp_pixbuf);
-       }
-
-       return rotated_pixbuf;
-}
-
-static void
-dvi_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface)
-{
-       iface->get_thumbnail = dvi_document_thumbnails_get_thumbnail;
-}
-
 /* EvFileExporterIface */
 static void
 dvi_document_file_exporter_begin (EvFileExporter        *exporter,
index dc253c70d142b80d7202c70e8cc86f96d78f7c79..bf1fed5ada84166b8d8b534a7a91c37809fd7ac7 100644 (file)
@@ -43,7 +43,6 @@
 #include "ev-document-images.h"
 #include "ev-document-fonts.h"
 #include "ev-document-security.h"
-#include "ev-document-thumbnails.h"
 #include "ev-document-transition.h"
 #include "ev-document-forms.h"
 #include "ev-document-layers.h"
@@ -115,7 +114,6 @@ struct _PdfDocument
 };
 
 static void pdf_document_security_iface_init             (EvDocumentSecurityInterface    *iface);
-static void pdf_document_document_thumbnails_iface_init  (EvDocumentThumbnailsInterface  *iface);
 static void pdf_document_document_links_iface_init       (EvDocumentLinksInterface       *iface);
 static void pdf_document_document_images_iface_init      (EvDocumentImagesInterface      *iface);
 static void pdf_document_document_forms_iface_init       (EvDocumentFormsInterface       *iface);
@@ -145,8 +143,6 @@ EV_BACKEND_REGISTER_WITH_CODE (PdfDocument, pdf_document,
                         {
                                 EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_SECURITY,
                                                                 pdf_document_security_iface_init);
-                                EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS,
-                                                                pdf_document_document_thumbnails_iface_init);
                                 EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_LINKS,
                                                                 pdf_document_document_links_iface_init);
                                 EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_IMAGES,
@@ -403,6 +399,102 @@ pdf_document_render (EvDocument      *document,
                                width, height, rc);
 }
 
+static GdkPixbuf *
+make_thumbnail_for_page (PopplerPage     *poppler_page,
+                        EvRenderContext *rc,
+                        gint             width,
+                        gint             height)
+{
+       GdkPixbuf *pixbuf;
+
+#ifdef POPPLER_WITH_GDK
+       pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
+                                width, height);
+       gdk_pixbuf_fill (pixbuf, 0xffffffff);
+
+       ev_document_fc_mutex_lock ();
+       poppler_page_render_to_pixbuf (poppler_page, 0, 0,
+                                      width, height,
+                                      rc->scale, rc->rotation, pixbuf);
+       ev_document_fc_mutex_unlock ();
+#else
+       cairo_surface_t *surface;
+
+       ev_document_fc_mutex_lock ();
+       surface = pdf_page_render (poppler_page, width, height, rc);
+       ev_document_fc_mutex_unlock ();
+       
+       pixbuf = ev_document_misc_pixbuf_from_surface (surface);
+       cairo_surface_destroy (surface);
+#endif /* POPPLER_WITH_GDK */
+
+       return pixbuf;
+}
+
+static GdkPixbuf *
+pdf_document_get_thumbnail (EvDocument      *document,
+                           EvRenderContext *rc)
+{
+       PdfDocument *pdf_document = PDF_DOCUMENT (document);
+       PopplerPage *poppler_page;
+       GdkPixbuf *pixbuf = NULL;
+       GdkPixbuf *border_pixbuf;
+       double page_width, page_height;
+       gint width, height;
+
+       poppler_page = POPPLER_PAGE (rc->page->backend_page);
+
+       poppler_page_get_size (poppler_page,
+                              &page_width, &page_height);
+
+       width = MAX ((gint)(page_width * rc->scale + 0.5), 1);
+       height = MAX ((gint)(page_height * rc->scale + 0.5), 1);
+
+       if (rc->rotation == 90 || rc->rotation == 270) {
+               gint  temp;
+
+               temp = width;
+               width = height;
+               height = temp;
+       }
+
+#ifdef POPPLER_WITH_GDK
+       pixbuf = poppler_page_get_thumbnail_pixbuf (poppler_page);
+#else
+       cairo_surface_t *surface;
+       
+       surface = poppler_page_get_thumbnail (poppler_page);
+       if (surface) {
+               pixbuf = ev_document_misc_pixbuf_from_surface (surface);
+               cairo_surface_destroy (surface);
+       }
+#endif /* POPPLER_WITH_GDK */
+
+       if (pixbuf != NULL) {
+               int thumb_width = (rc->rotation == 90 || rc->rotation == 270) ?
+                       gdk_pixbuf_get_height (pixbuf) :
+                       gdk_pixbuf_get_width (pixbuf);
+
+               if (thumb_width == width) {
+                       GdkPixbuf *rotated_pixbuf;
+
+                       rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf,
+                                                                  (GdkPixbufRotation) (360 - rc->rotation));
+                       g_object_unref (pixbuf);
+                       pixbuf = rotated_pixbuf;
+               } else {
+                       /* The provided thumbnail has a different size */
+                       g_object_unref (pixbuf);
+                       pixbuf = make_thumbnail_for_page (poppler_page, rc, width, height);
+               }
+       } else {
+               /* There is no provided thumbnail. We need to make one. */
+               pixbuf = make_thumbnail_for_page (poppler_page, rc, width, height);
+       }
+
+       return pixbuf;
+}
+
 /* reference:
 http://www.pdfa.org/lib/exe/fetch.php?id=pdfa%3Aen%3Atechdoc&cache=cache&media=pdfa:techdoc:tn0001_pdfa-1_and_namespaces_2008-03-18.pdf */
 static char *
@@ -825,6 +917,7 @@ pdf_document_class_init (PdfDocumentClass *klass)
        ev_document_class->get_page_size = pdf_document_get_page_size;
        ev_document_class->get_page_label = pdf_document_get_page_label;
        ev_document_class->render = pdf_document_render;
+       ev_document_class->get_thumbnail = pdf_document_get_thumbnail;
        ev_document_class->get_info = pdf_document_get_info;
        ev_document_class->get_backend_info = pdf_document_get_backend_info;
        ev_document_class->support_synctex = pdf_document_support_synctex;
@@ -1381,116 +1474,6 @@ pdf_document_document_images_iface_init (EvDocumentImagesInterface *iface)
        iface->get_image = pdf_document_images_get_image;
 }
 
-static GdkPixbuf *
-make_thumbnail_for_page (PopplerPage     *poppler_page,
-                        EvRenderContext *rc,
-                        gint             width,
-                        gint             height)
-{
-       GdkPixbuf *pixbuf;
-
-#ifdef POPPLER_WITH_GDK
-       pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
-                                width, height);
-       gdk_pixbuf_fill (pixbuf, 0xffffffff);
-
-       ev_document_fc_mutex_lock ();
-       poppler_page_render_to_pixbuf (poppler_page, 0, 0,
-                                      width, height,
-                                      rc->scale, rc->rotation, pixbuf);
-       ev_document_fc_mutex_unlock ();
-#else
-       cairo_surface_t *surface;
-
-       ev_document_fc_mutex_lock ();
-       surface = pdf_page_render (poppler_page, width, height, rc);
-       ev_document_fc_mutex_unlock ();
-       
-       pixbuf = ev_document_misc_pixbuf_from_surface (surface);
-       cairo_surface_destroy (surface);
-#endif /* POPPLER_WITH_GDK */
-
-       return pixbuf;
-}
-
-static GdkPixbuf *
-pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails,
-                                      EvRenderContext      *rc, 
-                                      gboolean              border)
-{
-       PdfDocument *pdf_document = PDF_DOCUMENT (document_thumbnails);
-       PopplerPage *poppler_page;
-       GdkPixbuf *pixbuf = NULL;
-       GdkPixbuf *border_pixbuf;
-       double page_width, page_height;
-       gint width, height;
-
-       poppler_page = POPPLER_PAGE (rc->page->backend_page);
-
-       poppler_page_get_size (poppler_page,
-                              &page_width, &page_height);
-
-       width = MAX ((gint)(page_width * rc->scale + 0.5), 1);
-       height = MAX ((gint)(page_height * rc->scale + 0.5), 1);
-
-       if (rc->rotation == 90 || rc->rotation == 270) {
-               gint  temp;
-
-               temp = width;
-               width = height;
-               height = temp;
-       }
-
-#ifdef POPPLER_WITH_GDK
-       pixbuf = poppler_page_get_thumbnail_pixbuf (poppler_page);
-#else
-       cairo_surface_t *surface;
-       
-       surface = poppler_page_get_thumbnail (poppler_page);
-       if (surface) {
-               pixbuf = ev_document_misc_pixbuf_from_surface (surface);
-               cairo_surface_destroy (surface);
-       }
-#endif /* POPPLER_WITH_GDK */
-
-       if (pixbuf != NULL) {
-               int thumb_width = (rc->rotation == 90 || rc->rotation == 270) ?
-                       gdk_pixbuf_get_height (pixbuf) :
-                       gdk_pixbuf_get_width (pixbuf);
-
-               if (thumb_width == width) {
-                       GdkPixbuf *rotated_pixbuf;
-
-                       rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf,
-                                                                  (GdkPixbufRotation) (360 - rc->rotation));
-                       g_object_unref (pixbuf);
-                       pixbuf = rotated_pixbuf;
-               } else {
-                       /* The provided thumbnail has a different size */
-                       g_object_unref (pixbuf);
-                       pixbuf = make_thumbnail_for_page (poppler_page, rc, width, height);
-               }
-       } else {
-               /* There is no provided thumbnail. We need to make one. */
-               pixbuf = make_thumbnail_for_page (poppler_page, rc, width, height);
-       }
-
-        if (border && pixbuf) {
-               border_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, pixbuf);
-               g_object_unref (pixbuf);
-               pixbuf = border_pixbuf;
-       }               
-
-       return pixbuf;
-}
-
-static void
-pdf_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface)
-{
-       iface->get_thumbnail = pdf_document_thumbnails_get_thumbnail;
-}
-
-
 static GList *
 pdf_document_find_find_text (EvDocumentFind *document_find,
                             EvPage         *page,
index 978970ddbf6ee3f0116575e2d8be55c69b1b1d6c..ae7b4376cb27c116da0d8558bd6ddac1981a7667 100644 (file)
@@ -21,7 +21,6 @@
 #include <glib/gi18n-lib.h>
 
 #include "pixbuf-document.h"
-#include "ev-document-thumbnails.h"
 #include "ev-document-misc.h"
 #include "ev-file-helpers.h"
 
@@ -41,13 +40,7 @@ struct _PixbufDocument
 
 typedef struct _PixbufDocumentClass PixbufDocumentClass;
 
-static void pixbuf_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface);
-
-EV_BACKEND_REGISTER_WITH_CODE (PixbufDocument, pixbuf_document,
-                   {
-                        EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS,
-                                                        pixbuf_document_document_thumbnails_iface_init)                                   
-                  });
+EV_BACKEND_REGISTER (PixbufDocument, pixbuf_document)
 
 static gboolean
 pixbuf_document_load (EvDocument  *document,
@@ -127,6 +120,27 @@ pixbuf_document_render (EvDocument      *document,
        return surface;
 }
 
+static GdkPixbuf *
+pixbuf_document_get_thumbnail (EvDocument      *document,
+                              EvRenderContext *rc)
+{
+       PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document);
+       GdkPixbuf *pixbuf, *rotated_pixbuf;
+       gint width, height;
+       
+       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,
+                                         width, height,
+                                         GDK_INTERP_BILINEAR);
+
+       rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rc->rotation);
+        g_object_unref (pixbuf);
+
+        return rotated_pixbuf;
+}
+
 static void
 pixbuf_document_finalize (GObject *object)
 {
@@ -151,37 +165,9 @@ pixbuf_document_class_init (PixbufDocumentClass *klass)
        ev_document_class->get_n_pages = pixbuf_document_get_n_pages;
        ev_document_class->get_page_size = pixbuf_document_get_page_size;
        ev_document_class->render = pixbuf_document_render;
+       ev_document_class->get_thumbnail = pixbuf_document_get_thumbnail;
 }
 
-static GdkPixbuf *
-pixbuf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
-                                         EvRenderContext      *rc,
-                                         gboolean              border)
-{
-       PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document);
-       GdkPixbuf *pixbuf, *rotated_pixbuf;
-       gint width, height;
-       
-       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,
-                                         width, height,
-                                         GDK_INTERP_BILINEAR);
-
-       rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rc->rotation);
-        g_object_unref (pixbuf);
-
-        return rotated_pixbuf;
-}
-
-static void
-pixbuf_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface)
-{
-       iface->get_thumbnail = pixbuf_document_thumbnails_get_thumbnail;
-}
-
-
 static void
 pixbuf_document_init (PixbufDocument *pixbuf_document)
 {
index 256d9bef24ac456ea1ff3636a0aefcc910ae0c8a..23957cd6c2f83652a00e32a7e2cc94c0bf66af33 100644 (file)
@@ -27,7 +27,6 @@
 #include "ev-spectre.h"
 
 #include "ev-file-exporter.h"
-#include "ev-document-thumbnails.h"
 #include "ev-document-misc.h"
 
 struct _PSDocument {
@@ -42,12 +41,9 @@ struct _PSDocumentClass {
 };
 
 static void ps_document_file_exporter_iface_init       (EvFileExporterInterface       *iface);
-static void ps_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface);
 
 EV_BACKEND_REGISTER_WITH_CODE (PSDocument, ps_document,
                          {
-                                EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS,
-                                                                ps_document_document_thumbnails_iface_init);
                                 EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_FILE_EXPORTER,
                                                                 ps_document_file_exporter_iface_init);
                         });
@@ -348,42 +344,6 @@ ps_document_class_init (PSDocumentClass *klass)
        ev_document_class->render = ps_document_render;
 }
 
-/* EvDocumentThumbnailsIface */
-static GdkPixbuf *
-ps_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails,
-                                     EvRenderContext      *rc, 
-                                     gboolean              border)
-{
-       PSDocument      *ps = PS_DOCUMENT (document_thumbnails);
-       cairo_surface_t *surface;
-       GdkPixbuf       *pixbuf = NULL;
-
-       surface = ps_document_render (EV_DOCUMENT (ps), rc);
-       if (!surface) {
-               g_warning ("Error rendering thumbnail");
-               return NULL;
-       }
-               
-       pixbuf = ev_document_misc_pixbuf_from_surface (surface);
-       cairo_surface_destroy (surface);
-
-       if (border) {
-               GdkPixbuf *border_pixbuf;
-               
-               border_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, pixbuf);
-               g_object_unref (pixbuf);
-               pixbuf = border_pixbuf;
-       }
-
-       return pixbuf;
-}
-
-static void
-ps_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface)
-{
-       iface->get_thumbnail = ps_document_thumbnails_get_thumbnail;
-}
-       
 /* EvFileExporterIface */
 static void
 ps_document_file_exporter_begin (EvFileExporter        *exporter,
index 80aec9b240442d49d252edc7285821c098ea4789..1be2aecebfec467f99334b09236031d8bd97ff50 100644 (file)
@@ -31,7 +31,6 @@
 #include "tiff2ps.h"
 #include "tiff-document.h"
 #include "ev-document-misc.h"
-#include "ev-document-thumbnails.h"
 #include "ev-file-exporter.h"
 #include "ev-file-helpers.h"
 
@@ -53,13 +52,10 @@ struct _TiffDocument
 
 typedef struct _TiffDocumentClass TiffDocumentClass;
 
-static void tiff_document_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface);
 static void tiff_document_document_file_exporter_iface_init (EvFileExporterInterface *iface);
 
 EV_BACKEND_REGISTER_WITH_CODE (TiffDocument, tiff_document,
                         {
-                          EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS,
-                                                          tiff_document_document_thumbnails_iface_init);
                           EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_FILE_EXPORTER,
                                                           tiff_document_document_file_exporter_iface_init);
                         });
@@ -312,7 +308,7 @@ tiff_document_render (EvDocument      *document,
 }
 
 static GdkPixbuf *
-tiff_document_render_pixbuf (EvDocument      *document,
+tiff_document_get_thumbnail (EvDocument      *document,
                             EvRenderContext *rc)
 {
        TiffDocument *tiff_document = TIFF_DOCUMENT (document);
@@ -424,34 +420,10 @@ tiff_document_class_init (TiffDocumentClass *klass)
        ev_document_class->get_n_pages = tiff_document_get_n_pages;
        ev_document_class->get_page_size = tiff_document_get_page_size;
        ev_document_class->render = tiff_document_render;
+       ev_document_class->get_thumbnail = tiff_document_get_thumbnail;
        ev_document_class->get_page_label = tiff_document_get_page_label;
 }
 
-static GdkPixbuf *
-tiff_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
-                                       EvRenderContext      *rc, 
-                                       gboolean              border)
-{
-       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_document_thumbnails_iface_init (EvDocumentThumbnailsInterface *iface)
-{
-       iface->get_thumbnail = tiff_document_thumbnails_get_thumbnail;
-}
-
 /* postscript exporter implementation */
 static void
 tiff_document_file_exporter_begin (EvFileExporter        *exporter,
index 3e38c25b6ef53d055dee67e27932bad3f1452860..1db675b9aae268d49f3e9a3655a871a3cbaa59cc 100644 (file)
@@ -38,7 +38,6 @@
 #include <libdocument/ev-document-links.h>
 #include <libdocument/ev-document-misc.h>
 #include <libdocument/ev-document-security.h>
-#include <libdocument/ev-document-thumbnails.h>
 #include <libdocument/ev-document-transition.h>
 #include <libdocument/ev-document-type-builtins.h>
 #include <libdocument/ev-file-exporter.h>
index e8bad83b4ae4f63b3d5fde7ca4921cadbe792eeb..7ca7fc8c8ee0357c66a369550684166bfa260254 100644 (file)
@@ -23,7 +23,6 @@ INST_H_SRC_FILES =                            \
        ev-document-misc.h                      \
        ev-document-print.h                     \
        ev-document-security.h                  \
-       ev-document-thumbnails.h                \
        ev-document-transition.h                \
        ev-document-text.h                      \
        ev-file-exporter.h                      \
@@ -64,7 +63,6 @@ libevdocument3_la_SOURCES=                    \
        ev-document-annotations.c               \
        ev-document-attachments.c               \
        ev-document-factory.c                   \
-       ev-document-thumbnails.c                \
        ev-document-fonts.c                     \
        ev-document-layers.c                    \
        ev-document-links.c                     \
diff --git a/libdocument/ev-document-thumbnails.c b/libdocument/ev-document-thumbnails.c
deleted file mode 100644 (file)
index 9ff10f8..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
-/*
- *  Copyright (C) 2004 Anders Carlsson <andersca@gnome.org>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
- *  any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include <config.h>
-#include "ev-document-thumbnails.h"
-#include "ev-document.h"
-
-G_DEFINE_INTERFACE (EvDocumentThumbnails, ev_document_thumbnails, 0)
-
-static void
-ev_document_thumbnails_default_init (EvDocumentThumbnailsInterface *klass)
-{
-}
-
-GdkPixbuf *
-ev_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
-                                     EvRenderContext      *rc,
-                                     gboolean              border)
-{
-       EvDocumentThumbnailsInterface *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, rc, border);
-}
-
diff --git a/libdocument/ev-document-thumbnails.h b/libdocument/ev-document-thumbnails.h
deleted file mode 100644 (file)
index b2779fc..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
-/*
- *  Copyright (C) 2004 Anders Carlsson
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
- *  any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#if !defined (__EV_EVINCE_DOCUMENT_H_INSIDE__) && !defined (EVINCE_COMPILATION)
-#error "Only <evince-document.h> can be included directly."
-#endif
-
-#ifndef EV_DOCUMENT_THUMBNAILS_H
-#define EV_DOCUMENT_THUMBNAILS_H
-
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
-#include "ev-render-context.h"
-
-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, EvDocumentThumbnailsInterface))
-#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, EvDocumentThumbnailsInterface))
-
-typedef struct _EvDocumentThumbnails          EvDocumentThumbnails;
-typedef struct _EvDocumentThumbnailsInterface EvDocumentThumbnailsInterface;
-
-struct _EvDocumentThumbnailsInterface {
-        GTypeInterface base_iface;
-
-        /* Methods  */
-        GdkPixbuf *  (* get_thumbnail)  (EvDocumentThumbnails *document,
-                                         EvRenderContext      *rc, 
-                                         gboolean              border);
-};
-
-GType      ev_document_thumbnails_get_type       (void) G_GNUC_CONST;
-
-GdkPixbuf *ev_document_thumbnails_get_thumbnail  (EvDocumentThumbnails *document,
-                                                  EvRenderContext      *rc, 
-                                                  gboolean              border);
-
-G_END_DECLS
-
-#endif /* EV_DOCUMENT_THUMBNAILS_H */
index 70349dcb7f67c43d2aa71467a1ad3359999b54e9..d7ee2c1d2d472501cc32448ecc7c28837c603353 100644 (file)
@@ -25,6 +25,7 @@
 #include <string.h>
 
 #include "ev-document.h"
+#include "ev-document-misc.h"
 #include "synctex_parser.h"
 
 #define EV_DOCUMENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EV_TYPE_DOCUMENT, EvDocumentPrivate))
@@ -581,6 +582,32 @@ ev_document_render (EvDocument      *document,
        return klass->render (document, rc);
 }
 
+static GdkPixbuf *
+_ev_document_get_thumbnail (EvDocument      *document,
+                           EvRenderContext *rc)
+{
+       cairo_surface_t *surface;
+       GdkPixbuf       *pixbuf;
+
+       surface = ev_document_render (document, rc);
+       pixbuf = ev_document_misc_pixbuf_from_surface (surface);
+       cairo_surface_destroy (surface);
+
+       return pixbuf;
+}
+
+GdkPixbuf *
+ev_document_get_thumbnail (EvDocument      *document,
+                          EvRenderContext *rc)
+{
+       EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
+
+       if (klass->get_thumbnail)
+               return klass->get_thumbnail (document, rc);
+
+       return _ev_document_get_thumbnail (document, rc);
+}
+
 const gchar *
 ev_document_get_uri (EvDocument *document)
 {
index 63d2a8ec7e71c561240de009f7c9db6bdd67aa4f..d28289254df20796c7709d9aed0a6e3b42469e22 100644 (file)
@@ -109,6 +109,8 @@ struct _EvDocumentClass
                                                EvPage          *page);
         cairo_surface_t * (* render)          (EvDocument      *document,
                                                EvRenderContext *rc);
+       GdkPixbuf       * (* get_thumbnail)   (EvDocument      *document,
+                                              EvRenderContext *rc);
         EvDocumentInfo  * (* get_info)        (EvDocument      *document);
         gboolean          (* get_backend_info)(EvDocument      *document,
                                                EvDocumentBackendInfo *info);
@@ -150,6 +152,8 @@ gchar           *ev_document_get_page_label       (EvDocument      *document,
                                                   gint             page_index);
 cairo_surface_t *ev_document_render               (EvDocument      *document,
                                                   EvRenderContext *rc);
+GdkPixbuf       *ev_document_get_thumbnail        (EvDocument      *document,
+                                                  EvRenderContext *rc);
 const gchar     *ev_document_get_uri              (EvDocument      *document);
 const gchar     *ev_document_get_title            (EvDocument      *document);
 gboolean         ev_document_is_page_size_uniform (EvDocument      *document);
index e1522757a293537aec23fd4315fbd8391d8c91dd..3e33886f7f4a761f029544dffe26abd88a803eeb 100644 (file)
@@ -21,7 +21,6 @@
 #include <config.h>
 
 #include "ev-jobs.h"
-#include "ev-document-thumbnails.h"
 #include "ev-document-links.h"
 #include "ev-document-images.h"
 #include "ev-document-forms.h"
@@ -765,6 +764,7 @@ ev_job_thumbnail_run (EvJob *job)
 {
        EvJobThumbnail  *job_thumb = EV_JOB_THUMBNAIL (job);
        EvRenderContext *rc;
+       GdkPixbuf       *pixbuf;
        EvPage          *page;
 
        ev_debug_message (DEBUG_JOBS, "%d (%p)", job_thumb->page, job);
@@ -776,11 +776,13 @@ ev_job_thumbnail_run (EvJob *job)
        rc = ev_render_context_new (page, job_thumb->rotation, job_thumb->scale);
        g_object_unref (page);
 
-       job_thumb->thumbnail = ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (job->document),
-                                                                    rc, TRUE);
+       pixbuf = ev_document_get_thumbnail (job->document, rc);
        g_object_unref (rc);
        ev_document_doc_mutex_unlock ();
 
+       job_thumb->thumbnail = ev_document_misc_get_thumbnail_frame (-1, -1, pixbuf);
+       g_object_unref (pixbuf);
+
        ev_job_succeeded (job);
        
        return FALSE;
index ef0e3a91a126c14ddf6eb8acbd80eb52999dad41..4854e930bab3bec1f5f5c3bf0f444dfec86631ad 100644 (file)
@@ -32,7 +32,6 @@
 #include <gtk/gtk.h>
 
 #include "ev-document-misc.h"
-#include "ev-document-thumbnails.h"
 #include "ev-job-scheduler.h"
 #include "ev-sidebar-page.h"
 #include "ev-sidebar-thumbnails.h"
@@ -822,8 +821,7 @@ ev_sidebar_thumbnails_document_changed_cb (EvDocumentModel     *model,
        EvDocument *document = ev_document_model_get_document (model);
        EvSidebarThumbnailsPrivate *priv = sidebar_thumbnails->priv;
 
-       if (!EV_IS_DOCUMENT_THUMBNAILS (document) ||
-           ev_document_get_n_pages (document) <= 0 ||
+       if (ev_document_get_n_pages (document) <= 0 ||
            !ev_document_check_dimensions (document)) {
                return;
        }
@@ -931,7 +929,7 @@ static gboolean
 ev_sidebar_thumbnails_support_document (EvSidebarPage   *sidebar_page,
                                        EvDocument *document)
 {
-       return (EV_IS_DOCUMENT_THUMBNAILS (document));
+       return TRUE;
 }
 
 static const gchar*
index f1d3bd905cb534b88a12eb8a5efb257b456885be..89d18d997863c792ca245cf7ebd2140f681f0b63 100644 (file)
@@ -56,7 +56,6 @@
 #include "ev-document-fonts.h"
 #include "ev-document-images.h"
 #include "ev-document-links.h"
-#include "ev-document-thumbnails.h"
 #include "ev-document-annotations.h"
 #include "ev-document-type-builtins.h"
 #include "ev-document-misc.h"
@@ -1310,8 +1309,7 @@ ev_window_refresh_window_thumbnail (EvWindow *ev_window)
        gint rotation;
        EvDocument *document = ev_window->priv->document;
 
-       if (!EV_IS_DOCUMENT_THUMBNAILS (document) ||
-           ev_document_get_n_pages (document) <= 0 ||
+       if (ev_document_get_n_pages (document) <= 0 ||
            !ev_document_check_dimensions (document)) {
                return;
        }
index 31da3d3cae1800852b9ac29d14665b396fba1591..94d6b77ea334d3b676aa9ba4f2f840ea819d6ecd 100644 (file)
@@ -137,8 +137,7 @@ evince_thumbnail_pngenc_get (EvDocument *document, const char *thumbnail, int si
        ev_document_get_page_size (document, 0, &width, &height);
 
        rc = ev_render_context_new (page, 0, size / width);
-       pixbuf = ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (document),
-                                                      rc, FALSE);
+       pixbuf = ev_document_get_thumbnail (document, rc);
        g_object_unref (rc);
        g_object_unref (page);
        
@@ -270,12 +269,6 @@ main (int argc, char *argv[])
                return -2;
        }
 
-       if (!EV_IS_DOCUMENT_THUMBNAILS (document)) {
-               g_object_unref (document);
-               ev_shutdown ();
-               return -2;
-       }
-
        if (EV_IS_ASYNC_RENDERER (document)) {
                struct AsyncData data;