]> www.fi.muni.cz Git - evince.git/commitdiff
Add EvPage so that we can hold a reference to the backend page. Form
authorCarlos Garcia Campos <carlosgc@gnome.org>
Mon, 14 Apr 2008 17:07:39 +0000 (17:07 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Mon, 14 Apr 2008 17:07:39 +0000 (17:07 +0000)
2008-04-14  Carlos Garcia Campos  <carlosgc@gnome.org>

* libdocument/Makefile.am:
* libdocument/ev-page.[ch]:
* libdocument/ev-render-context.[ch]: (ev_render_context_dispose),
(ev_render_context_new), (ev_render_context_set_page):
* libdocument/ev-form-field.[ch]: (ev_form_field_init),
(ev_form_field_finalize), (ev_form_field_class_init):
* libdocument/ev-document-forms.[ch]:
(ev_document_forms_get_form_fields):
* libdocument/ev-document.[ch]: (ev_document_get_page),
(ev_document_get_page_size), (ev_document_get_page_label):
* shell/ev-jobs.[ch]: (ev_job_thumbnail_dispose),
(ev_job_render_run), (ev_job_thumbnail_new),
(ev_job_thumbnail_run), (ev_job_print_run):
* shell/ev-page-cache.c: (ev_page_cache_new):
* shell/ev-pixbuf-cache.c: (job_page_ready_cb), (job_finished_cb),
(check_job_size_and_unref), (add_job):
* shell/ev-sidebar-thumbnails.c: (add_range):
* shell/ev-view.c: (ev_view_form_field_get_region),
(ev_view_form_field_button_create_widget),
(ev_view_form_field_text_save), (ev_view_form_field_choice_save),
(ev_view_handle_form_field), (ev_view_size_allocate),
(get_selected_text):
* shell/ev-window.c: (ev_window_refresh_window_thumbnail):
* backend/pdf/ev-poppler.cc: (pdf_document_get_page_size),
(pdf_document_get_page), (pdf_document_get_page_label),
(pdf_document_render), (pdf_document_get_info),
(pdf_document_document_iface_init),
(pdf_document_thumbnails_get_thumbnail),
(pdf_document_thumbnails_get_dimensions),
(pdf_document_file_exporter_do_page),
(pdf_selection_render_selection),
(pdf_selection_get_selected_text),
(pdf_selection_get_selection_region),
(pdf_selection_get_selection_map),
(pdf_document_forms_get_form_fields),
(pdf_document_forms_form_field_text_get_text),
(pdf_document_forms_form_field_text_set_text),
(pdf_document_forms_form_field_button_set_state),
(pdf_document_forms_form_field_button_get_state),
(pdf_document_forms_form_field_choice_get_item),
(pdf_document_forms_form_field_choice_get_n_items),
(pdf_document_forms_form_field_choice_is_item_selected),
(pdf_document_forms_form_field_choice_select_item),
(pdf_document_forms_form_field_choice_toggle_item),
(pdf_document_forms_form_field_choice_unselect_all),
(pdf_document_forms_form_field_choice_set_text),
(pdf_document_forms_form_field_choice_get_text):
* backend/ps/ev-spectre.c: (ps_document_get_page),
(ps_document_get_page_size), (ps_document_get_page_label),
(ps_document_render), (ps_document_document_iface_init),
(ps_document_file_exporter_do_page):
* backend/tiff/tiff-document.c: (tiff_document_get_page_size),
(tiff_document_render), (tiff_document_render_pixbuf),
(tiff_document_file_exporter_do_page):
* backend/pixbuf/pixbuf-document.c:
(pixbuf_document_get_page_size):
* backend/comics/comics-document.c:
(comics_document_get_page_size), (comics_document_render_pixbuf):
* backend/djvu/djvu-document.c: (djvu_document_get_page_size),
(djvu_document_render), (djvu_selection_get_selected_text),
(djvu_document_thumbnails_get_thumbnail),
(djvu_document_file_exporter_do_page),
(djvu_document_find_get_result):
* backend/dvi/dvi-document.c: (dvi_document_get_page_size),
(dvi_document_render), (dvi_document_thumbnails_get_dimensions),
(dvi_document_thumbnails_get_thumbnail),
(dvi_document_file_exporter_do_page):
* backend/impress/impress-document.c:
(impress_document_get_page_size),
(impress_document_render_pixbuf):
* thumbnailer/evince-thumbnailer.c: (evince_thumbnail_pngenc_get):

Add EvPage so that we can hold a reference to the backend
page. Form fields keep now a reference to the poppler page
improving performance since we don't have to create/destroy the
poppler field for every form operation. This will be needed for
annotations too.

svn path=/trunk/; revision=3004

28 files changed:
ChangeLog
backend/comics/comics-document.c
backend/djvu/djvu-document.c
backend/dvi/dvi-document.c
backend/impress/impress-document.c
backend/pdf/ev-poppler.cc
backend/pixbuf/pixbuf-document.c
backend/ps/ev-spectre.c
backend/tiff/tiff-document.c
libdocument/Makefile.am
libdocument/ev-document-forms.c
libdocument/ev-document-forms.h
libdocument/ev-document.c
libdocument/ev-document.h
libdocument/ev-form-field.c
libdocument/ev-form-field.h
libdocument/ev-page.c [new file with mode: 0644]
libdocument/ev-page.h [new file with mode: 0644]
libdocument/ev-render-context.c
libdocument/ev-render-context.h
shell/ev-jobs.c
shell/ev-jobs.h
shell/ev-page-cache.c
shell/ev-pixbuf-cache.c
shell/ev-sidebar-thumbnails.c
shell/ev-view.c
shell/ev-window.c
thumbnailer/evince-thumbnailer.c

index 4345e53caa42c3d496e9e65d5dedd2db9cee997e..79c0003dfc637abc1b34f47a57182d32ce5a2f0c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,83 @@
+2008-04-14  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * libdocument/Makefile.am:
+       * libdocument/ev-page.[ch]:
+       * libdocument/ev-render-context.[ch]: (ev_render_context_dispose),
+       (ev_render_context_new), (ev_render_context_set_page):
+       * libdocument/ev-form-field.[ch]: (ev_form_field_init),
+       (ev_form_field_finalize), (ev_form_field_class_init):
+       * libdocument/ev-document-forms.[ch]:
+       (ev_document_forms_get_form_fields):
+       * libdocument/ev-document.[ch]: (ev_document_get_page),
+       (ev_document_get_page_size), (ev_document_get_page_label):
+       * shell/ev-jobs.[ch]: (ev_job_thumbnail_dispose),
+       (ev_job_render_run), (ev_job_thumbnail_new),
+       (ev_job_thumbnail_run), (ev_job_print_run):
+       * shell/ev-page-cache.c: (ev_page_cache_new):
+       * shell/ev-pixbuf-cache.c: (job_page_ready_cb), (job_finished_cb),
+       (check_job_size_and_unref), (add_job):
+       * shell/ev-sidebar-thumbnails.c: (add_range):
+       * shell/ev-view.c: (ev_view_form_field_get_region),
+       (ev_view_form_field_button_create_widget),
+       (ev_view_form_field_text_save), (ev_view_form_field_choice_save),
+       (ev_view_handle_form_field), (ev_view_size_allocate),
+       (get_selected_text):
+       * shell/ev-window.c: (ev_window_refresh_window_thumbnail):
+       * backend/pdf/ev-poppler.cc: (pdf_document_get_page_size),
+       (pdf_document_get_page), (pdf_document_get_page_label),
+       (pdf_document_render), (pdf_document_get_info),
+       (pdf_document_document_iface_init),
+       (pdf_document_thumbnails_get_thumbnail),
+       (pdf_document_thumbnails_get_dimensions),
+       (pdf_document_file_exporter_do_page),
+       (pdf_selection_render_selection),
+       (pdf_selection_get_selected_text),
+       (pdf_selection_get_selection_region),
+       (pdf_selection_get_selection_map),
+       (pdf_document_forms_get_form_fields),
+       (pdf_document_forms_form_field_text_get_text),
+       (pdf_document_forms_form_field_text_set_text),
+       (pdf_document_forms_form_field_button_set_state),
+       (pdf_document_forms_form_field_button_get_state),
+       (pdf_document_forms_form_field_choice_get_item),
+       (pdf_document_forms_form_field_choice_get_n_items),
+       (pdf_document_forms_form_field_choice_is_item_selected),
+       (pdf_document_forms_form_field_choice_select_item),
+       (pdf_document_forms_form_field_choice_toggle_item),
+       (pdf_document_forms_form_field_choice_unselect_all),
+       (pdf_document_forms_form_field_choice_set_text),
+       (pdf_document_forms_form_field_choice_get_text):
+       * backend/ps/ev-spectre.c: (ps_document_get_page),
+       (ps_document_get_page_size), (ps_document_get_page_label),
+       (ps_document_render), (ps_document_document_iface_init),
+       (ps_document_file_exporter_do_page):
+       * backend/tiff/tiff-document.c: (tiff_document_get_page_size),
+       (tiff_document_render), (tiff_document_render_pixbuf),
+       (tiff_document_file_exporter_do_page):
+       * backend/pixbuf/pixbuf-document.c:
+       (pixbuf_document_get_page_size):
+       * backend/comics/comics-document.c:
+       (comics_document_get_page_size), (comics_document_render_pixbuf):
+       * backend/djvu/djvu-document.c: (djvu_document_get_page_size),
+       (djvu_document_render), (djvu_selection_get_selected_text),
+       (djvu_document_thumbnails_get_thumbnail),
+       (djvu_document_file_exporter_do_page),
+       (djvu_document_find_get_result):
+       * backend/dvi/dvi-document.c: (dvi_document_get_page_size),
+       (dvi_document_render), (dvi_document_thumbnails_get_dimensions),
+       (dvi_document_thumbnails_get_thumbnail),
+       (dvi_document_file_exporter_do_page):
+       * backend/impress/impress-document.c:
+       (impress_document_get_page_size),
+       (impress_document_render_pixbuf):
+       * thumbnailer/evince-thumbnailer.c: (evince_thumbnail_pngenc_get):
+
+       Add EvPage so that we can hold a reference to the backend
+       page. Form fields keep now a reference to the poppler page
+       improving performance since we don't have to create/destroy the
+       poppler field for every form operation. This will be needed for
+       annotations too.
+       
 2008-04-12  Carlos Garcia Campos  <carlosgc@gnome.org>
 
        * data/evince-ui.xml:
index 127943d135353b51558b51be5510a3e3e72a5a58..2d8404e064fc6ad8fbeb4b0e12f7a3ca173ecf9f 100644 (file)
@@ -221,7 +221,7 @@ comics_document_get_n_pages (EvDocument *document)
 
 static void
 comics_document_get_page_size (EvDocument *document,
-                              int         page,
+                              EvPage     *page,
                               double     *width,
                               double     *height)
 {
@@ -232,7 +232,7 @@ comics_document_get_page_size (EvDocument *document,
        gint outpipe = -1;
        GPid child_pid = -1;
 
-       argv = extract_argv (document, page);
+       argv = extract_argv (document, page->index);
        success = g_spawn_async_with_pipes (NULL, argv, NULL,
                                            G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL,
                                            NULL, NULL,
@@ -290,7 +290,7 @@ comics_document_render_pixbuf (EvDocument      *document,
        gint outpipe = -1;
        GPid child_pid = -1;
 
-       argv = extract_argv (document, rc->page);
+       argv = extract_argv (document, rc->page->index);
        success = g_spawn_async_with_pipes (NULL, argv, NULL,
                                            G_SPAWN_SEARCH_PATH
                                            | G_SPAWN_STDERR_TO_DEV_NULL,
index f4caa7f0f36bdc8c594a0dfa5b3c4883468420da..392a7dc2514642467a84cbe097f54c832a33fbdc 100644 (file)
@@ -195,17 +195,14 @@ djvu_document_get_n_pages (EvDocument  *document)
 }
 
 static void
-djvu_document_get_page_size (EvDocument   *document,
-                            int           page,
-                            double       *width,
-                            double       *height)
+document_get_page_size (DjvuDocument *djvu_document,
+                       gint          page,
+                       double       *width,
+                       double       *height)
 {
-       DjvuDocument *djvu_document = DJVU_DOCUMENT (document);
-        ddjvu_pageinfo_t info;
+       ddjvu_pageinfo_t info;
        ddjvu_status_t r;
        
-       g_return_if_fail (djvu_document->d_document);
-
        while ((r = ddjvu_document_get_pageinfo(djvu_document->d_document, page, &info)) < DDJVU_JOB_OK)
                djvu_handle_events(djvu_document, TRUE);
        
@@ -216,6 +213,20 @@ djvu_document_get_page_size (EvDocument   *document,
         *height = info.height * SCALE_FACTOR;
 }
 
+static void
+djvu_document_get_page_size (EvDocument   *document,
+                            EvPage       *page,
+                            double       *width,
+                            double       *height)
+{
+       DjvuDocument *djvu_document = DJVU_DOCUMENT (document);
+
+       g_return_if_fail (djvu_document->d_document);
+
+       document_get_page_size (djvu_document, page->index,
+                               width, height);
+}
+
 static cairo_surface_t *
 djvu_document_render (EvDocument      *document, 
                      EvRenderContext *rc)
@@ -231,7 +242,7 @@ djvu_document_render (EvDocument      *document,
        double page_width, page_height, tmp;
        static const cairo_user_data_key_t key;
 
-       d_page = ddjvu_page_create_by_pageno (djvu_document->d_document, rc->page);
+       d_page = ddjvu_page_create_by_pageno (djvu_document->d_document, rc->page->index);
        
        while (!ddjvu_page_decoding_done (d_page))
                djvu_handle_events(djvu_document, TRUE);
@@ -364,7 +375,7 @@ djvu_selection_get_selected_text (EvSelection     *selection,
        rectangle.x2 = points->x2 / SCALE_FACTOR;
        rectangle.y2 = (height - points->y1) / SCALE_FACTOR;
                
-       text = djvu_text_copy (djvu_document, rc->page, &rectangle);
+       text = djvu_text_copy (djvu_document, rc->page->index, &rectangle);
       
        if (text == NULL)
                text = g_strdup ("");
@@ -423,10 +434,10 @@ djvu_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
        gdk_pixbuf_fill (pixbuf, 0xffffffff);
        pixels = gdk_pixbuf_get_pixels (pixbuf);
        
-       while (ddjvu_thumbnail_status (djvu_document->d_document, rc->page, 1) < DDJVU_JOB_OK)
+       while (ddjvu_thumbnail_status (djvu_document->d_document, rc->page->index, 1) < DDJVU_JOB_OK)
                djvu_handle_events(djvu_document, TRUE);
                    
-       ddjvu_thumbnail_render (djvu_document->d_document, rc->page, 
+       ddjvu_thumbnail_render (djvu_document->d_document, rc->page->index
                                &thumb_width, &thumb_height,
                                djvu_document->thumbs_format,
                                gdk_pixbuf_get_rowstride (pixbuf), 
@@ -472,7 +483,7 @@ djvu_document_file_exporter_do_page (EvFileExporter  *exporter,
 {
        DjvuDocument *djvu_document = DJVU_DOCUMENT (exporter);
        
-       g_string_append_printf (djvu_document->opts, "%d,", (rc->page) + 1); 
+       g_string_append_printf (djvu_document->opts, "%d,", (rc->page->index) + 1); 
 }
 
 static void
@@ -587,8 +598,7 @@ djvu_document_find_get_result (EvDocumentFind *document_find,
        if (r == NULL)
                return FALSE;
 
-       djvu_document_get_page_size (EV_DOCUMENT (djvu_document), 
-               page, &width, &height);
+       document_get_page_size (djvu_document, page, &width, &height);
        rectangle->x1 = r->x1 * SCALE_FACTOR;
        rectangle->y1 = height - r->y2 * SCALE_FACTOR;
        rectangle->x2 = r->x2 * SCALE_FACTOR;
index c8295232a3aaaa5b8481b6d4ba120bce58f2e1d6..876d577092b026153984732fb65f25a0e6094108 100644 (file)
@@ -67,10 +67,6 @@ typedef struct _DviDocumentClass DviDocumentClass;
 static void dvi_document_document_iface_init            (EvDocumentIface           *iface);
 static void dvi_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface);
 static void dvi_document_file_exporter_iface_init      (EvFileExporterIface       *iface);
-static void dvi_document_get_page_size                         (EvDocument                *document,
-                                                        int                        page,
-                                                        double                    *width,
-                                                        double                    *height);
 static void dvi_document_do_color_special               (DviContext                *dvi,
                                                         const char                *prefix,
                                                         const char                *arg);
@@ -150,7 +146,7 @@ dvi_document_get_n_pages (EvDocument *document)
 
 static void
 dvi_document_get_page_size (EvDocument *document,
-                           int         page,
+                           EvPage     *page,
                            double     *width,
                            double     *height)
 {
@@ -177,7 +173,7 @@ dvi_document_render (EvDocument      *document,
         */
        g_mutex_lock (dvi_context_mutex);
        
-       mdvi_setpage (dvi_document->context, rc->page);
+       mdvi_setpage (dvi_document->context, rc->page->index);
        
        mdvi_set_shrink (dvi_document->context, 
                         (int)((dvi_document->params->hshrink - 1) / rc->scale) + 1,
@@ -274,8 +270,8 @@ dvi_document_document_iface_init (EvDocumentIface *iface)
 static void
 dvi_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
                                        EvRenderContext      *rc, 
-                                       gint                  *width,
-                                       gint                  *height)
+                                       gint                 *width,
+                                       gint                 *height)
 {      
        DviDocument *dvi_document = DVI_DOCUMENT (document);
        gdouble page_width = dvi_document->base_width;
@@ -307,7 +303,7 @@ dvi_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
 
        g_mutex_lock (dvi_context_mutex);
        
-       mdvi_setpage (dvi_document->context, rc->page);
+       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,
@@ -377,7 +373,7 @@ dvi_document_file_exporter_do_page (EvFileExporter  *exporter,
 {
        DviDocument *dvi_document = DVI_DOCUMENT(exporter);
 
-       g_string_append_printf (dvi_document->exporter_opts, "%d,", (rc->page) + 1);
+       g_string_append_printf (dvi_document->exporter_opts, "%d,", (rc->page->index) + 1);
 }
 
 static void
index 8ceabd43d967419d6d1155e6f6a812a4e1891b28..2e3c39bedbc9e9d5b917b88e1e6fdc062b440a57 100644 (file)
@@ -334,9 +334,9 @@ impress_document_get_n_pages (EvDocument  *document)
 
 static void
 impress_document_get_page_size (EvDocument   *document,
-                            int           page,
-                            double       *width,
-                            double       *height)
+                               EvPage       *page,
+                               double       *width,
+                               double       *height)
 {
   ImpressDocument *impress_document = IMPRESS_DOCUMENT (document);
 
@@ -383,7 +383,7 @@ impress_document_render_pixbuf (EvDocument      *document,
   g_return_val_if_fail (IMPRESS_IS_DOCUMENT (document), NULL);
   g_return_val_if_fail (impress_document->imp != NULL, NULL);
   
-  impress_document->pagenum = rc->page;
+  impress_document->pagenum = rc->page->index;
 
   g_mutex_lock (impress_document->mutex);
   impress_document->cond = g_cond_new ();
index 01c9a698f8cf96ace3c47f4f66ae12815e8f7ccc..2b6d41597bc4a11fe2c2a4513956c9634d06ed91 100644 (file)
@@ -148,19 +148,6 @@ EV_BACKEND_REGISTER_WITH_CODE (PdfDocument, pdf_document,
                                                                 pdf_document_page_transition_iface_init);
                         });
 
-static void
-set_rc_data (PdfDocument     *pdf_document,
-            EvRenderContext *rc)
-{
-       if (rc->data == NULL) {
-               rc->data = poppler_document_get_page (pdf_document->document,
-                                                     rc->page);
-               rc->destroy = g_object_unref;
-       } else {
-               g_assert (rc->page == poppler_page_get_index (POPPLER_PAGE (rc->data)));
-       }
-}
-
 static void
 pdf_document_search_free (PdfDocumentSearch   *search)
 {
@@ -296,35 +283,45 @@ pdf_document_get_n_pages (EvDocument *document)
        return poppler_document_get_n_pages (PDF_DOCUMENT (document)->document);
 }
 
-static void
-pdf_document_get_page_size (EvDocument   *document,
-                           int           page,
-                           double       *width,
-                           double       *height)
+static EvPage *
+pdf_document_get_page (EvDocument *document,
+                      gint        index)
 {
        PdfDocument *pdf_document = PDF_DOCUMENT (document);
        PopplerPage *poppler_page;
+       EvPage      *page;
 
-       poppler_page = poppler_document_get_page (pdf_document->document, page);
-       poppler_page_get_size (poppler_page, width, height);
+       poppler_page = poppler_document_get_page (pdf_document->document, index);
+       page = ev_page_new (index);
+       page->backend_page = (EvBackendPage)g_object_ref (poppler_page);
+       page->backend_destroy_func = (EvBackendPageDestroyFunc)g_object_unref;
        g_object_unref (poppler_page);
+
+       return page;
+}
+
+static void
+pdf_document_get_page_size (EvDocument *document,
+                           EvPage     *page,
+                           double     *width,
+                           double     *height)
+{
+       g_return_if_fail (POPPLER_IS_PAGE (page->backend_page));
+       
+       poppler_page_get_size (POPPLER_PAGE (page->backend_page), width, height);
 }
 
 static char *
 pdf_document_get_page_label (EvDocument *document,
-                            int         page)
+                            EvPage     *page)
 {
-       PopplerPage *poppler_page;
        char *label = NULL;
 
-       poppler_page = poppler_document_get_page (PDF_DOCUMENT (document)->document,
-                                                 page);
+       g_return_val_if_fail (POPPLER_IS_PAGE (page->backend_page), NULL);
 
-       g_object_get (G_OBJECT (poppler_page),
+       g_object_get (G_OBJECT (page->backend_page),
                      "label", &label,
                      NULL);
-       g_object_unref (poppler_page);
-
        return label;
 }
 
@@ -504,14 +501,13 @@ pdf_document_render (EvDocument      *document,
                     EvRenderContext *rc)
 {
        PdfDocument *pdf_document;
+       PopplerPage *poppler_page;
        double width_points, height_points;
        gint width, height;
 
-       pdf_document = PDF_DOCUMENT (document);
-
-       set_rc_data (pdf_document, rc);
+       poppler_page = POPPLER_PAGE (rc->page->backend_page);
 
-       poppler_page_get_size (POPPLER_PAGE (rc->data),
+       poppler_page_get_size (poppler_page,
                               &width_points, &height_points);
        
        if (rc->rotation == 90 || rc->rotation == 270) {
@@ -522,7 +518,7 @@ pdf_document_render (EvDocument      *document,
                height = (int) ((height_points * rc->scale) + 0.5);
        }
        
-       return pdf_page_render (POPPLER_PAGE (rc->data),
+       return pdf_page_render (poppler_page,
                                width, height, rc);
 }
 
@@ -555,6 +551,7 @@ pdf_document_get_info (EvDocument *document)
        PopplerPageMode mode;
        PopplerViewerPreferences view_prefs;
        PopplerPermissions permissions;
+       EvPage *page;
 
        info = g_new0 (EvDocumentInfo, 1);
 
@@ -593,9 +590,11 @@ pdf_document_get_info (EvDocument *document)
                      "linearized", &(info->linearized),
                      NULL);
 
-       pdf_document_get_page_size(document, 0,
+       page = ev_document_get_page (document, 0);
+       ev_document_get_page_size (document, page,
                                   &(info->paper_width),
                                   &(info->paper_height));
+       g_object_unref (page);
 
        // Convert to mm.
        info->paper_width = info->paper_width / 72.0f * 25.4f;
@@ -698,6 +697,7 @@ pdf_document_document_iface_init (EvDocumentIface *iface)
        iface->save = pdf_document_save;
        iface->load = pdf_document_load;
        iface->get_n_pages = pdf_document_get_n_pages;
+       iface->get_page = pdf_document_get_page;
        iface->get_page_size = pdf_document_get_page_size;
        iface->get_page_label = pdf_document_get_page_label;
        iface->has_attachments = pdf_document_has_attachments;
@@ -1281,15 +1281,12 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails
                                       EvRenderContext      *rc, 
                                       gboolean              border)
 {
-       PdfDocument *pdf_document;
+       PdfDocument *pdf_document = PDF_DOCUMENT (document_thumbnails);
        PopplerPage *poppler_page;
        GdkPixbuf *pixbuf = NULL;
        GdkPixbuf *border_pixbuf;
 
-       pdf_document = PDF_DOCUMENT (document_thumbnails);
-
-       poppler_page = poppler_document_get_page (pdf_document->document, rc->page);
-       g_return_val_if_fail (poppler_page != NULL, NULL);
+       poppler_page = POPPLER_PAGE (rc->page->backend_page);
 
 #ifdef POPPLER_WITH_GDK
        pixbuf = poppler_page_get_thumbnail_pixbuf (poppler_page);
@@ -1303,7 +1300,6 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails
        }
 #endif /* POPPLER_WITH_GDK */
 
-               
        if (pixbuf) {
                /* Rotate provided thumbnail if needed */
                GdkPixbuf *rotated_pixbuf;
@@ -1323,8 +1319,6 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails
                pixbuf = border_pixbuf;
        }               
 
-       g_object_unref (poppler_page);
-       
        return pixbuf;
 }
 
@@ -1334,14 +1328,10 @@ pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnail
                                        gint                 *width,
                                        gint                 *height)
 {
-       PdfDocument *pdf_document;
        PopplerPage *poppler_page;
        gint has_thumb;
        
-       pdf_document = PDF_DOCUMENT (document_thumbnails);
-       poppler_page = poppler_document_get_page (pdf_document->document, rc->page);
-
-       g_return_if_fail (poppler_page != NULL);
+       poppler_page = POPPLER_PAGE (rc->page->backend_page);
 
        has_thumb = poppler_page_get_thumbnail_size (poppler_page, width, height);
 
@@ -1361,8 +1351,6 @@ pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnail
                *width = *height;
                *height = temp;
        }
-       
-       g_object_unref (poppler_page);
 }
 
 static void
@@ -1709,7 +1697,7 @@ pdf_document_file_exporter_do_page (EvFileExporter  *exporter,
 
        g_return_if_fail (pdf_document->print_ctx != NULL);
 
-       poppler_page = poppler_document_get_page (pdf_document->document, rc->page);
+       poppler_page = POPPLER_PAGE (rc->page->backend_page);
        
 #ifdef HAVE_CAIRO_PRINT
        x = (ctx->pages_printed % ctx->pages_per_sheet) % ctx->pages_x;
@@ -1795,8 +1783,6 @@ pdf_document_file_exporter_do_page (EvFileExporter  *exporter,
        if (ctx->format == EV_FILE_FORMAT_PS)
                poppler_page_render_to_ps (poppler_page, ctx->ps_file);
 #endif /* HAVE_CAIRO_PRINT */
-       
-       g_object_unref (poppler_page);
 }
 
 static void
@@ -1867,14 +1853,13 @@ pdf_selection_render_selection (EvSelection      *selection,
                                GdkColor         *text,
                                GdkColor         *base)
 {
-       PdfDocument *pdf_document;
+       PopplerPage *poppler_page;
        double width_points, height_points;
        gint width, height;
 
-       pdf_document = PDF_DOCUMENT (selection);
-       set_rc_data (pdf_document, rc);
+       poppler_page = POPPLER_PAGE (rc->page->backend_page);
 
-       poppler_page_get_size (POPPLER_PAGE (rc->data),
+       poppler_page_get_size (poppler_page,
                               &width_points, &height_points);
        width = (int) ((width_points * rc->scale) + 0.5);
        height = (int) ((height_points * rc->scale) + 0.5);
@@ -1903,7 +1888,7 @@ pdf_selection_render_selection (EvSelection      *selection,
        memset (cairo_image_surface_get_data (*surface), 0x00,
                cairo_image_surface_get_height (*surface) *
                cairo_image_surface_get_stride (*surface));
-       poppler_page_render_selection (POPPLER_PAGE (rc->data),
+       poppler_page_render_selection (poppler_page,
                                       cr,
                                       (PopplerRectangle *)points,
                                       (PopplerRectangle *)old_points,
@@ -1918,7 +1903,7 @@ pdf_selection_render_selection (EvSelection      *selection,
                                 TRUE, 8,
                                 width, height);
 
-       poppler_page_render_selection_to_pixbuf (POPPLER_PAGE (rc->data),
+       poppler_page_render_selection_to_pixbuf (poppler_page,
                                                 rc->scale, rc->rotation, pixbuf,
                                                 (PopplerRectangle *)points,
                                                 (PopplerRectangle *)old_points,
@@ -1938,14 +1923,12 @@ pdf_selection_get_selected_text (EvSelection     *selection,
                                 EvSelectionStyle style,
                                 EvRectangle     *points)
 {
-       PdfDocument *pdf_document = PDF_DOCUMENT (selection);
        PopplerPage *poppler_page;
        PopplerRectangle r;
        double height;
        char *retval;
        
-       poppler_page = poppler_document_get_page (pdf_document->document, rc->page);
-       g_return_val_if_fail (poppler_page != NULL, NULL);
+       poppler_page = POPPLER_PAGE (rc->page->backend_page);
 
        poppler_page_get_size (poppler_page, NULL, &height);
        r.x1 = points->x1;
@@ -1957,8 +1940,6 @@ pdf_selection_get_selected_text (EvSelection     *selection,
                                        (PopplerSelectionStyle)style,
                                        &r);
 
-       g_object_unref (poppler_page);
-
        return retval;
 }
 
@@ -1994,15 +1975,13 @@ pdf_selection_get_selection_region (EvSelection     *selection,
                                    EvSelectionStyle style,
                                    EvRectangle     *points)
 {
-       PdfDocument *pdf_document;
+       PopplerPage *poppler_page;
        GdkRegion   *retval;
-       GList *region;
+       GList       *region;
 
-       pdf_document = PDF_DOCUMENT (selection);
-
-       set_rc_data (pdf_document, rc);
+       poppler_page = POPPLER_PAGE (rc->page->backend_page);
        
-       region = poppler_page_get_selection_region (POPPLER_PAGE (rc->data),
+       region = poppler_page_get_selection_region (poppler_page,
                                                    rc->scale,
                                                    (PopplerSelectionStyle)style,
                                                    (PopplerRectangle *) points);
@@ -2016,15 +1995,12 @@ static GdkRegion *
 pdf_selection_get_selection_map (EvSelection     *selection,
                                 EvRenderContext *rc)
 {
-       PdfDocument *pdf_document;
        PopplerPage *poppler_page;
        PopplerRectangle points;
        GList *region;
        GdkRegion *retval;
 
-       pdf_document = PDF_DOCUMENT (selection);
-       poppler_page = poppler_document_get_page (pdf_document->document,
-                                                 rc->page);
+       poppler_page = POPPLER_PAGE (rc->page->backend_page);
 
        points.x1 = 0.0;
        points.y1 = 0.0;
@@ -2035,7 +2011,6 @@ pdf_selection_get_selection_map (EvSelection     *selection,
                                                    &points);
        retval = create_gdk_region_from_poppler_region (region);
        g_list_free (region);
-       g_object_unref (poppler_page);
 
        return retval;
 }
@@ -2239,17 +2214,17 @@ ev_form_field_from_poppler_field (PopplerFormField *poppler_field)
 
 static GList *
 pdf_document_forms_get_form_fields (EvDocumentForms *document, 
-                                   gint             page)
+                                   EvPage          *page)
 {
-       PdfDocument *pdf_document;
        PopplerPage *poppler_page;
        GList *retval = NULL;
        GList *fields;
        GList *list;
        double height;
 
-       pdf_document = PDF_DOCUMENT (document);
-       poppler_page = poppler_document_get_page (pdf_document->document, page);
+       g_return_val_if_fail (POPPLER_IS_PAGE (page->backend_page), NULL);
+       
+       poppler_page = POPPLER_PAGE (page->backend_page);
        fields = poppler_page_get_form_field_mapping (poppler_page);
        poppler_page_get_size (poppler_page, NULL, &height);
 
@@ -2270,13 +2245,17 @@ pdf_document_forms_get_form_fields (EvDocumentForms *document,
                field_mapping->y1 = height - mapping->area.y2;
                field_mapping->y2 = height - mapping->area.y1;
                field_mapping->field = ev_field;
-               field_mapping->field->page = page;
+               field_mapping->field->page = EV_PAGE (g_object_ref (page));
+
+               g_object_set_data_full (G_OBJECT (ev_field),
+                                       "poppler-field",
+                                       g_object_ref (mapping->field),
+                                       (GDestroyNotify) g_object_unref);
                
                retval = g_list_prepend (retval, field_mapping);
        }
        
        poppler_page_free_form_field_mapping (fields);
-       g_object_unref (poppler_page);
 
        return g_list_reverse (retval);
 }
@@ -2286,16 +2265,14 @@ pdf_document_forms_form_field_text_get_text (EvDocumentForms *document,
                                             EvFormField     *field)
        
 {
-       PdfDocument *pdf_document = PDF_DOCUMENT (document);
        PopplerFormField *poppler_field;
        gchar *text;
 
-       poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+       poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
        if (!poppler_field)
                return NULL;
        
        text = poppler_form_field_text_get_text (poppler_field);
-       g_object_unref (poppler_field);
 
        return text;
 }
@@ -2305,14 +2282,12 @@ pdf_document_forms_form_field_text_set_text (EvDocumentForms *document,
                                             EvFormField     *field,
                                             const gchar     *text)
 {
-       PdfDocument *pdf_document = PDF_DOCUMENT (document);
        PopplerFormField *poppler_field;
 
-       poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+       poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
        if (!poppler_field)
                return;
        poppler_form_field_text_set_text (poppler_field, text);
-       g_object_unref (poppler_field);
 }
 
 static void
@@ -2320,31 +2295,27 @@ pdf_document_forms_form_field_button_set_state (EvDocumentForms *document,
                                                EvFormField     *field,
                                                gboolean         state)
 {
-       PdfDocument *pdf_document = PDF_DOCUMENT (document);
        PopplerFormField *poppler_field;
 
-       poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+       poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
        if (!poppler_field)
                return;
        
        poppler_form_field_button_set_state (poppler_field, state);
-       g_object_unref (poppler_field);
 }
 
 static gboolean
 pdf_document_forms_form_field_button_get_state (EvDocumentForms *document, 
                                                EvFormField     *field)
 {
-       PdfDocument *pdf_document = PDF_DOCUMENT (document);
        PopplerFormField *poppler_field;
        gboolean state;
 
-       poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+       poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
        if (!poppler_field)
                return FALSE;
 
        state = poppler_form_field_button_get_state (poppler_field);
-       g_object_unref (poppler_field);
 
        return state;
 }
@@ -2354,16 +2325,14 @@ pdf_document_forms_form_field_choice_get_item (EvDocumentForms *document,
                                               EvFormField     *field,
                                               gint             index)
 {
-       PdfDocument *pdf_document = PDF_DOCUMENT (document);
        PopplerFormField *poppler_field;
        gchar *text;
 
-       poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+       poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
        if (!poppler_field)
                return NULL;
 
        text = poppler_form_field_choice_get_item (poppler_field, index);
-       g_object_unref (poppler_field);
 
        return text;
 }
@@ -2372,16 +2341,14 @@ static int
 pdf_document_forms_form_field_choice_get_n_items (EvDocumentForms *document, 
                                                  EvFormField     *field)
 {
-       PdfDocument *pdf_document = PDF_DOCUMENT (document);
        PopplerFormField *poppler_field;
        gint n_items;
 
-       poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+       poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
        if (!poppler_field)
                return -1;
        
        n_items = poppler_form_field_choice_get_n_items (poppler_field);
-       g_object_unref (poppler_field);
 
        return n_items;
 }
@@ -2391,16 +2358,14 @@ pdf_document_forms_form_field_choice_is_item_selected (EvDocumentForms *document
                                                       EvFormField     *field,
                                                       gint             index)
 {
-       PdfDocument *pdf_document = PDF_DOCUMENT (document);
        PopplerFormField *poppler_field;
        gboolean selected;
 
-       poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+       poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
        if (!poppler_field)
                return FALSE;
 
        selected = poppler_form_field_choice_is_item_selected (poppler_field, index);
-       g_object_unref (poppler_field);
 
        return selected;
 }
@@ -2410,15 +2375,13 @@ pdf_document_forms_form_field_choice_select_item (EvDocumentForms *document,
                                                  EvFormField     *field,
                                                  gint             index)
 {
-       PdfDocument *pdf_document = PDF_DOCUMENT (document);
        PopplerFormField *poppler_field;
 
-       poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+       poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
        if (!poppler_field)
                return;
 
        poppler_form_field_choice_select_item (poppler_field, index);
-       g_object_unref (poppler_field);
 }
 
 static void
@@ -2426,30 +2389,26 @@ pdf_document_forms_form_field_choice_toggle_item (EvDocumentForms *document,
                                                  EvFormField     *field,
                                                  gint             index)
 {
-       PdfDocument *pdf_document = PDF_DOCUMENT (document);
        PopplerFormField *poppler_field;
 
-       poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+       poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
        if (!poppler_field)
                return;
 
        poppler_form_field_choice_toggle_item (poppler_field, index);
-       g_object_unref (poppler_field);
 }
 
 static void
 pdf_document_forms_form_field_choice_unselect_all (EvDocumentForms *document, 
                                                   EvFormField     *field)
 {
-       PdfDocument *pdf_document = PDF_DOCUMENT (document);
        PopplerFormField *poppler_field;
 
-       poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+       poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
        if (!poppler_field)
                return;
        
        poppler_form_field_choice_unselect_all (poppler_field);
-       g_object_unref (poppler_field);
 }
 
 static void
@@ -2457,31 +2416,27 @@ pdf_document_forms_form_field_choice_set_text (EvDocumentForms *document,
                                               EvFormField     *field,
                                               const gchar     *text)
 {
-       PdfDocument *pdf_document = PDF_DOCUMENT (document);
        PopplerFormField *poppler_field;
 
-       poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+       poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
        if (!poppler_field)
                return;
        
        poppler_form_field_choice_set_text (poppler_field, text);
-       g_object_unref (poppler_field);
 }
 
 static gchar *
 pdf_document_forms_form_field_choice_get_text (EvDocumentForms *document,
                                               EvFormField     *field)
 {
-       PdfDocument *pdf_document = PDF_DOCUMENT (document);
        PopplerFormField *poppler_field;
        gchar *text;
 
-       poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+       poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
        if (!poppler_field)
                return NULL;
 
        text = poppler_form_field_choice_get_text (poppler_field);
-       g_object_unref (poppler_field);
 
        return text;
 }
index ed7034bed287aa2f7a410bc3974eaf76f4999d3f..bebc25b6444fe62fc8314bbfa13ad02cc03e2a76 100644 (file)
@@ -95,7 +95,7 @@ pixbuf_document_get_n_pages (EvDocument  *document)
 
 static void
 pixbuf_document_get_page_size (EvDocument   *document,
-                              int           page,
+                              EvPage       *page,
                               double       *width,
                               double       *height)
 {
index 6fe58692e1630f03d9e7047aca10c11fe6588c9b..54b595700551c39219ee7de47b2cf1ff1d4c5a21 100644 (file)
@@ -164,6 +164,22 @@ ps_document_get_n_pages (EvDocument *document)
        return spectre_document_get_n_pages (ps->doc);
 }
 
+static EvPage *
+ps_document_get_page (EvDocument *document,
+                     gint        index)
+{
+       PSDocument  *ps = PS_DOCUMENT (document);
+       SpectrePage *ps_page;
+       EvPage      *page;
+
+       ps_page = spectre_document_get_page (ps->doc, index);
+       page = ev_page_new (index);
+       page->backend_page = (EvBackendPage)ps_page;
+       page->backend_destroy_func = (EvBackendPageDestroyFunc)spectre_page_free;
+
+       return page;
+}
+
 static gint
 get_page_rotation (SpectrePage *page)
 {
@@ -184,17 +200,17 @@ get_page_rotation (SpectrePage *page)
 
 static void
 ps_document_get_page_size (EvDocument *document,
-                          int         page,
+                          EvPage     *page,
                           double     *width,
                           double     *height)
 {
-       PSDocument  *ps = PS_DOCUMENT (document);
        SpectrePage *ps_page;
        gdouble      page_width, page_height;
        gint         pwidth, pheight;
        gint         rotate;
 
-       ps_page = spectre_document_get_page (ps->doc, page);
+       ps_page = (SpectrePage *)page->backend_page;
+
        spectre_page_get_size (ps_page, &pwidth, &pheight);
 
        rotate = get_page_rotation (ps_page);
@@ -206,8 +222,6 @@ ps_document_get_page_size (EvDocument *document,
                page_height = pheight;
        }
 
-       spectre_page_free (ps_page);
-       
        if (width) {
                *width = page_width;
        }
@@ -219,17 +233,9 @@ ps_document_get_page_size (EvDocument *document,
 
 static char *
 ps_document_get_page_label (EvDocument *document,
-                           int         page)
+                           EvPage     *page)
 {
-       PSDocument  *ps = PS_DOCUMENT (document);
-       SpectrePage *ps_page;
-       gchar       *label;
-
-       ps_page = spectre_document_get_page (ps->doc, page);
-       label = g_strdup (spectre_page_get_label (ps_page));
-       spectre_page_free (ps_page);
-       
-       return label;
+       return g_strdup (spectre_page_get_label ((SpectrePage *)page->backend_page));
 }
 
 static EvDocumentInfo *
@@ -268,7 +274,6 @@ static cairo_surface_t *
 ps_document_render (EvDocument      *document,
                    EvRenderContext *rc)
 {
-       PSDocument           *ps = PS_DOCUMENT (document);
        SpectrePage          *ps_page;
        SpectreRenderContext *src;
        gint                  width_points;
@@ -281,7 +286,8 @@ ps_document_render (EvDocument      *document,
        cairo_surface_t      *surface;
        static const cairo_user_data_key_t key;
 
-       ps_page = spectre_document_get_page (ps->doc, rc->page);
+       ps_page = (SpectrePage *)rc->page->backend_page;
+       
        spectre_page_get_size (ps_page, &width_points, &height_points);
 
        width = (gint) ((width_points * rc->scale) + 0.5);
@@ -297,20 +303,16 @@ ps_document_render (EvDocument      *document,
        spectre_render_context_free (src);
 
        if (!data) {
-               spectre_page_free (ps_page);
                return NULL;
        }
 
        if (spectre_page_status (ps_page)) {
                g_warning (spectre_status_to_string (spectre_page_status (ps_page)));
                g_free (data);
-               spectre_page_free (ps_page);
                
                return NULL;
        }
 
-       spectre_page_free (ps_page);
-
        if (rotation == 90 || rotation == 270) {
                swidth = height;
                sheight = width;
@@ -334,6 +336,7 @@ ps_document_document_iface_init (EvDocumentIface *iface)
        iface->load = ps_document_load;
        iface->save = ps_document_save;
        iface->get_n_pages = ps_document_get_n_pages;
+       iface->get_page = ps_document_get_page;
        iface->get_page_size = ps_document_get_page_size;
        iface->get_page_label = ps_document_get_page_label;
        iface->get_info = ps_document_get_info;
@@ -433,7 +436,7 @@ ps_document_file_exporter_do_page (EvFileExporter  *exporter,
 {
        PSDocument *ps = PS_DOCUMENT (exporter);
 
-       spectre_exporter_do_page (ps->exporter, rc->page);
+       spectre_exporter_do_page (ps->exporter, rc->page->index);
 }
 
 static void
index 146e45539e78b3eec6c65749844c6e54b5d592a7..fc8f4aaad3af684f151739111c2291516c37e2d1 100644 (file)
@@ -176,10 +176,10 @@ tiff_document_get_resolution (TiffDocument *tiff_document,
 }
 
 static void
-tiff_document_get_page_size (EvDocument   *document,
-                            int           page,
-                            double       *width,
-                            double       *height)
+tiff_document_get_page_size (EvDocument *document,
+                            EvPage     *page,
+                            double     *width,
+                            double     *height)
 {
        guint32 w, h;
        gfloat x_res, y_res;
@@ -189,7 +189,7 @@ tiff_document_get_page_size (EvDocument   *document,
        g_return_if_fail (tiff_document->tiff != NULL);
        
        push_handlers ();
-       if (TIFFSetDirectory (tiff_document->tiff, page) != 1) {
+       if (TIFFSetDirectory (tiff_document->tiff, page->index) != 1) {
                pop_handlers ();
                return;
        }
@@ -223,7 +223,7 @@ tiff_document_render (EvDocument      *document,
        g_return_val_if_fail (tiff_document->tiff != NULL, NULL);
   
        push_handlers ();
-       if (TIFFSetDirectory (tiff_document->tiff, rc->page) != 1) {
+       if (TIFFSetDirectory (tiff_document->tiff, rc->page->index) != 1) {
                pop_handlers ();
                return NULL;
        }
@@ -317,7 +317,7 @@ tiff_document_render_pixbuf (EvDocument      *document,
        GdkPixbuf *rotated_pixbuf;
        
        push_handlers ();
-       if (TIFFSetDirectory (tiff_document->tiff, rc->page) != 1) {
+       if (TIFFSetDirectory (tiff_document->tiff, rc->page->index) != 1) {
                pop_handlers ();
                return NULL;
        }
@@ -482,7 +482,7 @@ tiff_document_file_exporter_do_page (EvFileExporter *exporter, EvRenderContext *
 
        if (document->ps_export_ctx == NULL)
                return;
-       if (TIFFSetDirectory (document->tiff, rc->page) != 1)
+       if (TIFFSetDirectory (document->tiff, rc->page->index) != 1)
                return;
        tiff2ps_process_page (document->ps_export_ctx, document->tiff,
                              0, 0, 0, 0, 0);
index a00eeaec6c7545ef0fa078771e61b5318c2992b3..577c1c5266c0bbb123ec5b92aaaeb2a923cdb777 100644 (file)
@@ -38,6 +38,7 @@ INST_H_FILES =                                        \
        ev-link-action.h                        \
        ev-link-dest.h                          \
        ev-link.h                               \
+       ev-page.h                               \
        ev-render-context.h                     \
        ev-selection.h                          \
        ev-transition-effect.h
@@ -68,6 +69,7 @@ libevbackend_la_SOURCES=                      \
        ev-file-exporter.c                      \
        ev-file-helpers.c                       \
        ev-module.c                             \
+       ev-page.c                               \
        ev-render-context.c                     \
        ev-selection.c                          \
        ev-transition-effect.c                  \
index db90bb886380b9600135a1d3e9dc0d9ab9123d55..d5d9c7094361834862a515ee5d20d81dcb96be65 100644 (file)
@@ -43,7 +43,7 @@ ev_document_forms_get_type (void)
 
 GList *
 ev_document_forms_get_form_fields (EvDocumentForms *document_forms,
-                                  gint             page)
+                                  EvPage          *page)
 {
        EvDocumentFormsIface *iface = EV_DOCUMENT_FORMS_GET_IFACE (document_forms);
 
index a1b192da7990630622567a071ccf123c91e8f43b..1337a5ed665ace24d8555a271d146437c629968c 100644 (file)
@@ -44,7 +44,7 @@ struct _EvDocumentFormsIface
 
        /* Methods  */
        GList   *(* get_form_fields)                    (EvDocumentForms   *document_forms,
-                                                        gint               page);
+                                                        EvPage            *page);
        gchar   *(* form_field_text_get_text)           (EvDocumentForms   *document_forms,
                                                         EvFormField       *field);
        void     (* form_field_text_set_text)           (EvDocumentForms   *document_forms,
@@ -80,7 +80,7 @@ struct _EvDocumentFormsIface
 
 GType    ev_document_forms_get_type                            (void) G_GNUC_CONST;
 GList   *ev_document_forms_get_form_fields                     (EvDocumentForms   *document_forms,
-                                                               gint               page);
+                                                               EvPage            *page);
 
 gchar  *ev_document_forms_form_field_text_get_text            (EvDocumentForms   *document_forms, 
                                                                EvFormField       *field);
index 2c6db95a0a552b8acec54f285bfdec0e9be91b3e..5e582d0aae3c9cfa8a3f5b10df4a73c5f7e2c604 100644 (file)
@@ -150,11 +150,26 @@ ev_document_get_n_pages (EvDocument  *document)
        return retval;
 }
 
+EvPage *
+ev_document_get_page (EvDocument *document,
+                     gint        index)
+{
+       EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+       EvPage *retval;
+
+       if (iface->get_page)
+               retval = iface->get_page (document, index);
+       else
+               retval = ev_page_new (index);
+
+       return retval;
+}
+
 void
-ev_document_get_page_size   (EvDocument   *document,
-                            int           page,
-                            double       *width,
-                            double       *height)
+ev_document_get_page_size (EvDocument *document,
+                          EvPage     *page,
+                          double     *width,
+                          double     *height)
 {
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
 
@@ -163,8 +178,8 @@ ev_document_get_page_size   (EvDocument   *document,
 }
 
 char *
-ev_document_get_page_label(EvDocument    *document,
-                          int             page)
+ev_document_get_page_label (EvDocument *document,
+                           EvPage     *page)
 {
        EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
 
@@ -239,7 +254,6 @@ ev_document_info_free (EvDocumentInfo *info)
        g_free (info->linearized);
        g_free (info->security);
        
-
        g_free (info);
 }
 
index bc040d14fa93913d8004d31576405c2b7e1f396e..cfcccdbec72be67bbbc090aabf8e4ba8ac1c4358 100644 (file)
@@ -28,6 +28,7 @@
 #include <cairo.h>
 
 #include "ev-document-info.h"
+#include "ev-page.h"
 #include "ev-render-context.h"
 
 G_BEGIN_DECLS
@@ -78,12 +79,14 @@ struct _EvDocumentIface
                                                const char      *uri,
                                                GError         **error);
         int               (* get_n_pages)     (EvDocument      *document);
+       EvPage          * (* get_page)        (EvDocument      *document,
+                                              gint             index);
         void              (* get_page_size)   (EvDocument      *document,
-                                               int              page,
+                                               EvPage          *page,
                                                double          *width,
                                                double          *height);
         char            * (* get_page_label)  (EvDocument      *document,
-                                               int              page);
+                                               EvPage          *page);
         gboolean          (* has_attachments) (EvDocument      *document);
         GList           * (* get_attachments) (EvDocument      *document);
         cairo_surface_t * (* render)          (EvDocument      *document,
@@ -112,12 +115,14 @@ gboolean         ev_document_save             (EvDocument      *document,
                                                const char      *uri,
                                                GError         **error);
 int              ev_document_get_n_pages      (EvDocument      *document);
+EvPage          *ev_document_get_page         (EvDocument      *document,
+                                              gint             index);
 void             ev_document_get_page_size    (EvDocument      *document,
-                                               int              page,
+                                               EvPage          *page,
                                                double          *width,
                                                double          *height);
 char            *ev_document_get_page_label   (EvDocument      *document,
-                                               int              page);
+                                               EvPage          *page);
 gboolean         ev_document_has_attachments  (EvDocument      *document);
 GList           *ev_document_get_attachments  (EvDocument      *document);
 cairo_surface_t *ev_document_render           (EvDocument      *document,
index cfa25f82c84cb98e02b42e9ebdb4294fd8407b03..130b6c0888e2c0a28b63812dedd32cd158a68f8d 100644 (file)
@@ -42,14 +42,28 @@ G_DEFINE_TYPE (EvFormFieldSignature, ev_form_field_signature, EV_TYPE_FORM_FIELD
 static void
 ev_form_field_init (EvFormField *field)
 {
-       field->page = -1;
+       field->page = NULL;
        field->changed = FALSE;
        field->is_read_only = FALSE;
 }
 
+static void
+ev_form_field_finalize (GObject *object)
+{
+       EvFormField *field = EV_FORM_FIELD (object);
+
+       g_object_unref (field->page);
+       field->page = NULL;
+
+       (* G_OBJECT_CLASS (ev_form_field_parent_class)->finalize) (object);
+}
+
 static void
 ev_form_field_class_init (EvFormFieldClass *klass)
 {
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       object_class->finalize = ev_form_field_finalize;
 }
 
 static void
index 0b09af94febcb7409b0e06113b12812338f2518f..027bee60e579e3b16e704b365f935c133b5f8b4c 100644 (file)
@@ -105,7 +105,7 @@ struct _EvFormField
        gboolean is_read_only;
        gdouble  font_size;
 
-       gint     page;
+       EvPage  *page;
        gboolean changed;
 };
 
diff --git a/libdocument/ev-page.c b/libdocument/ev-page.c
new file mode 100644 (file)
index 0000000..c37e38f
--- /dev/null
@@ -0,0 +1,62 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ *  Copyright (C) 2008 Carlos Garcia Campos <carlosgc@gnome.org>
+ *
+ * Evince 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 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include "ev-page.h"
+
+G_DEFINE_TYPE (EvPage, ev_page, G_TYPE_OBJECT)
+
+static void
+ev_page_init (EvPage *page)
+{
+}
+
+static void
+ev_page_finalize (GObject *object)
+{
+       EvPage *page = EV_PAGE (object);
+       
+       if (page->backend_destroy_func) {
+               page->backend_destroy_func (page->backend_page);
+               page->backend_destroy_func = NULL;
+       }
+       page->backend_page = NULL;
+
+       (* G_OBJECT_CLASS (ev_page_parent_class)->finalize) (object);
+}
+
+static void
+ev_page_class_init (EvPageClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       object_class->finalize = ev_page_finalize;
+}
+
+EvPage *
+ev_page_new (gint index)
+{
+       EvPage *page;
+
+       page = EV_PAGE (g_object_new (EV_TYPE_PAGE, NULL));
+       page->index = index;
+
+       return page;
+}
diff --git a/libdocument/ev-page.h b/libdocument/ev-page.h
new file mode 100644 (file)
index 0000000..801b3e1
--- /dev/null
@@ -0,0 +1,59 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ *  Copyright (C) 2008 Carlos Garcia Campos <carlosgc@gnome.org>
+ *
+ * Evince 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 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef EV_PAGE_H
+#define EV_PAGE_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define EV_TYPE_PAGE              (ev_page_get_type())
+#define EV_PAGE(object)           (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_PAGE, EvPage))
+#define EV_PAGE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_PAGE, EvPageClass))
+#define EV_IS_PAGE(object)        (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_PAGE))
+#define EV_IS_PAGE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_PAGE))
+#define EV_PAGE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_PAGE, EvPageClass))
+
+typedef struct _EvPage        EvPage;
+typedef struct _EvPageClass   EvPageClass;
+
+typedef gpointer       EvBackendPage;
+typedef GDestroyNotify EvBackendPageDestroyFunc;
+
+struct _EvPage {
+       GObject base_instance;
+       
+       gint index;
+
+       EvBackendPage            backend_page;
+       EvBackendPageDestroyFunc backend_destroy_func;
+};
+
+struct _EvPageClass {
+       GObjectClass base_class;
+};
+
+GType   ev_page_get_type (void) G_GNUC_CONST;
+
+EvPage *ev_page_new      (gint index);
+
+G_END_DECLS
+
+#endif /* EV_PAGE_H */
index 5595651036dd8b1578e281f9ae84aa9bd7baf628..4574066188d0f217ef47c72eb0209a1f7fb2c22d 100644 (file)
@@ -35,9 +35,9 @@ ev_render_context_dispose (GObject *object)
 
        rc = (EvRenderContext *) object;
 
-       if (rc->destroy) {
-               (*rc->destroy) (rc->data);
-               rc->destroy = NULL;
+       if (rc->page) {
+               g_object_unref (rc->page);
+               rc->page = NULL;
        }
 
        (* G_OBJECT_CLASS (ev_render_context_parent_class)->dispose) (object);
@@ -53,18 +53,17 @@ ev_render_context_class_init (EvRenderContextClass *class)
        oclass->dispose = ev_render_context_dispose;
 }
 
-
 EvRenderContext *
-ev_render_context_new (int           rotation,
-                      gint          page,
-                      gdouble       scale)
+ev_render_context_new (EvPage *page,
+                      gint    rotation,
+                      gdouble scale)
 {
        EvRenderContext *rc;
 
        rc = (EvRenderContext *) g_object_new (EV_TYPE_RENDER_CONTEXT, NULL);
 
+       rc->page = page ? g_object_ref (page) : NULL;
        rc->rotation = rotation;
-       rc->page = page;
        rc->scale = scale;
 
        return rc;
@@ -72,11 +71,14 @@ ev_render_context_new (int           rotation,
 
 void
 ev_render_context_set_page (EvRenderContext *rc,
-                           gint             page)
+                           EvPage          *page)
 {
        g_return_if_fail (rc != NULL);
+       g_return_if_fail (EV_IS_PAGE (page));
 
-       rc->page = page;
+       if (rc->page)
+               g_object_unref (rc->page);
+       rc->page = g_object_ref (page);
 }
 
 void
index 636f02fd9e6185660a47d30b081ef649bac6dc6f..eb324e880f0b465c8e2999246a788cfacf3017ba 100644 (file)
 
 #include <glib-object.h>
 
+#include "ev-page.h"
+
 G_BEGIN_DECLS
 
 typedef struct _EvRenderContext EvRenderContext;
 typedef struct _EvRenderContextClass EvRenderContextClass;
 
 #define EV_TYPE_RENDER_CONTEXT         (ev_render_context_get_type())
-#define EV_RENDER_CONTEXT(context)     ((EvRenderContext *) (context))
-#define EV_RENDER_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_RENDER_CONTEXT, EvRenderContext))
+#define EV_RENDER_CONTEXT(context)     (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_RENDER_CONTEXT, EvRenderContext)
+#define EV_RENDER_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_RENDER_CONTEXT, EvRenderContextClass))
 #define EV_IS_RENDER_CONTEXT(object)   (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_RENDER_CONTEXT))
 
 struct _EvRenderContextClass
@@ -40,23 +42,21 @@ struct _EvRenderContextClass
 struct _EvRenderContext
 {
        GObject parent;
-       int rotation;
-       gint page;
+       
+       EvPage *page;
+       gint    rotation;
        gdouble scale;
-
-       gpointer data;
-       GDestroyNotify destroy;
 };
 
 
 GType            ev_render_context_get_type        (void) G_GNUC_CONST;
-EvRenderContext *ev_render_context_new             (int              rotation,
-                                                   gint             page,
+EvRenderContext *ev_render_context_new             (EvPage          *page,
+                                                   gint             rotation,
                                                    gdouble          scale);
 void             ev_render_context_set_page        (EvRenderContext *rc,
-                                                   gint             page);
+                                                   EvPage          *page);
 void             ev_render_context_set_rotation    (EvRenderContext *rc,
-                                                   int              rotation);
+                                                   gint             rotation);
 void             ev_render_context_set_scale       (EvRenderContext *rc,
                                                    gdouble          scale);
 
index f6328af64565edae5125b9f84a24ff33ebc3c248..7a642a2dd1ee86ffb580fe59ec977fe92e864489 100644 (file)
@@ -184,11 +184,6 @@ ev_job_thumbnail_dispose (GObject *object)
                job->thumbnail = NULL;
        }
 
-       if (job->rc) {
-               g_object_unref (job->rc);
-               job->rc = NULL;
-       }
-
        (* G_OBJECT_CLASS (ev_job_thumbnail_parent_class)->dispose) (object);
 }
 
@@ -362,7 +357,7 @@ ev_job_render_run (EvJobRender *job)
 
        if (EV_JOB (job)->async) {
                EvAsyncRenderer *renderer = EV_ASYNC_RENDERER (EV_JOB (job)->document);
-               ev_async_renderer_render_pixbuf (renderer, job->rc->page, job->rc->scale,
+               ev_async_renderer_render_pixbuf (renderer, job->rc->page->index, job->rc->scale,
                                                 job->rc->rotation);
                g_signal_connect (EV_JOB (job)->document, "render_finished",
                                  G_CALLBACK (render_finished_cb), job);
@@ -396,15 +391,15 @@ ev_job_render_run (EvJobRender *job)
                if (job->include_links && EV_IS_DOCUMENT_LINKS (EV_JOB (job)->document))
                        job->link_mapping =
                                ev_document_links_get_links (EV_DOCUMENT_LINKS (EV_JOB (job)->document),
-                                                            job->rc->page);
+                                                            job->rc->page->index);
                if (job->include_forms && EV_IS_DOCUMENT_FORMS (EV_JOB (job)->document))
                        job->form_field_mapping =
-                               ev_document_forms_get_form_fields (EV_DOCUMENT_FORMS (EV_JOB(job)->document),
+                               ev_document_forms_get_form_fields (EV_DOCUMENT_FORMS (EV_JOB (job)->document),
                                                                   job->rc->page);
                if (job->include_images && EV_IS_DOCUMENT_IMAGES (EV_JOB (job)->document))
                        job->image_mapping =
                                ev_document_images_get_image_mapping (EV_DOCUMENT_IMAGES (EV_JOB (job)->document),
-                                                                     job->rc->page);
+                                                                     job->rc->page->index);
                EV_JOB (job)->finished = TRUE;
        }
 
@@ -412,15 +407,19 @@ ev_job_render_run (EvJobRender *job)
 }
 
 EvJob *
-ev_job_thumbnail_new (EvDocument      *document,
-                     EvRenderContext *rc)
+ev_job_thumbnail_new (EvDocument *document,
+                     gint        page,
+                     gint        rotation,
+                     gdouble     scale)
 {
        EvJobThumbnail *job;
 
        job = g_object_new (EV_TYPE_JOB_THUMBNAIL, NULL);
 
        EV_JOB (job)->document = g_object_ref (document);
-       job->rc = g_object_ref (rc);
+       job->page = page;
+       job->rotation = rotation;
+       job->scale = scale;
 
        return EV_JOB (job);
 }
@@ -428,16 +427,24 @@ ev_job_thumbnail_new (EvDocument      *document,
 void
 ev_job_thumbnail_run (EvJobThumbnail *job)
 {
+       EvRenderContext *rc;
+       EvPage          *page;
+       
        g_return_if_fail (EV_IS_JOB_THUMBNAIL (job));
 
        ev_document_doc_mutex_lock ();
 
+       page = ev_document_get_page (EV_JOB (job)->document, job->page);
+       rc = ev_render_context_new (page, job->rotation, job->scale);
+       g_object_unref (page);
+
        job->thumbnail =
                ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (EV_JOB (job)->document),
-                                                     job->rc, TRUE);
-       EV_JOB (job)->finished = TRUE;
-
+                                                     rc, TRUE);
+       g_object_unref (rc);
        ev_document_doc_mutex_unlock ();
+       
+       EV_JOB (job)->finished = TRUE;
 }
 
 static void ev_job_fonts_init (EvJobFonts *job) { /* Do Nothing */ }
@@ -917,7 +924,7 @@ ev_job_print_run (EvJobPrint *job)
        fc.duplex = FALSE;
        fc.pages_per_sheet = MAX (1, job->pages_per_sheet);
 
-       rc = ev_render_context_new (0, 0, 1.0);
+       rc = ev_render_context_new (NULL, 0, 1.0);
 
        ev_document_doc_mutex_lock ();
        ev_file_exporter_begin (EV_FILE_EXPORTER (document), &fc);
@@ -937,12 +944,17 @@ ev_job_print_run (EvJobPrint *job)
                                ev_file_exporter_begin_page (EV_FILE_EXPORTER (document));
                                
                                for (j = 0; j < job->pages_per_sheet; j++) {
+                                       EvPage *ev_page;
+                                       
                                        gint p = page + j;
 
                                        if (p < 0 || p >= n_pages)
                                                break;
+
+                                       ev_page = ev_document_get_page (document, page_list[p]);
+                                       ev_render_context_set_page (rc, ev_page);
+                                       g_object_unref (ev_page);
                                        
-                                       ev_render_context_set_page (rc, page_list[p]);
                                        ev_file_exporter_do_page (EV_FILE_EXPORTER (document), rc);
                                }
 
index c6d73a1a3614453856dce2a975318ae448a83443..16471544ab150941691c4b92e82245a93ad7145a 100644 (file)
@@ -163,7 +163,10 @@ struct _EvJobThumbnail
 {
        EvJob parent;
 
-       EvRenderContext *rc;
+       gint page;
+       gint rotation;
+       gdouble scale;
+       
        GdkPixbuf *thumbnail;
 };
 
@@ -265,7 +268,9 @@ void            ev_job_render_run         (EvJobRender     *thumbnail);
 /* EvJobThumbnail */
 GType           ev_job_thumbnail_get_type (void) G_GNUC_CONST;
 EvJob          *ev_job_thumbnail_new      (EvDocument      *document,
-                                          EvRenderContext *rc);
+                                          gint             page,
+                                          gint             rotation,
+                                          gdouble          scale);
 void            ev_job_thumbnail_run      (EvJobThumbnail  *thumbnail);
 
 /* EvJobFonts */
index a1b4d609019e1a1abe17b4fda3b71797eef1ce9a..8b8bedc971355c6479450818d729c8af0a2a6352 100644 (file)
@@ -2,6 +2,7 @@
 #include "ev-page-cache.h"
 #include "ev-job-queue.h"
 #include "ev-document-thumbnails.h"
+#include "ev-page.h"
 #include <stdlib.h>
 #include <string.h>
 
@@ -289,19 +290,22 @@ ev_page_cache_new (EvDocument *document)
        has_thumbs = EV_IS_DOCUMENT_THUMBNAILS (document);
        
        for (i = 0; i < page_cache->n_pages; i++) {
-               double page_width = 0;
-               double page_height = 0;
-               gint   thumb_width = 0;
-               gint   thumb_height = 0;
+               EvPage *page;
+               double  page_width = 0;
+               double  page_height = 0;
+               gint    thumb_width = 0;
+               gint    thumb_height = 0;
 
-               ev_document_get_page_size (document, i, &page_width, &page_height);
+               page = ev_document_get_page (document, i);
+               
+               ev_document_get_page_size (document, page, &page_width, &page_height);
 
-               page_cache->page_labels[i] = ev_document_get_page_label (document, i);
+               page_cache->page_labels[i] = ev_document_get_page_label (document, page);
                
                if (page_cache->page_labels[i] != NULL) {
                
-                       page_cache->max_label_chars = MAX(page_cache->max_label_chars, 
-                                                           g_utf8_strlen (page_cache->page_labels[i], 256));
+                       page_cache->max_label_chars = MAX (page_cache->max_label_chars, 
+                                                          g_utf8_strlen (page_cache->page_labels[i], 256));
                        if (!page_cache->has_labels) {
                                gchar *expected_label;
                        
@@ -347,13 +351,15 @@ ev_page_cache_new (EvDocument *document)
                        info->height = page_height;
                }
 
-               if (!has_thumbs)
+               if (!has_thumbs) {
+                       g_object_unref (page);
                        continue;
+               }
 
                if (!rc) {
-                       rc = ev_render_context_new (0, i, (gdouble)THUMBNAIL_WIDTH / page_width);
+                       rc = ev_render_context_new (page, 0, (gdouble)THUMBNAIL_WIDTH / page_width);
                } else {
-                       ev_render_context_set_page (rc, i);
+                       ev_render_context_set_page (rc, page);
                        ev_render_context_set_scale (rc, (gdouble)THUMBNAIL_WIDTH / page_width);
                }
 
@@ -393,6 +399,8 @@ ev_page_cache_new (EvDocument *document)
                        thumb_info->width = thumb_width;
                        thumb_info->height = thumb_height;
                }
+
+               g_object_unref (page);
        }
 
        if (rc) {
index 3403873cffeb97ff91bbac90302ab62490de13a2..4710dfee7ba1c0cfdf846cbc309f87c91d25139e 100644 (file)
@@ -250,13 +250,13 @@ job_page_ready_cb (EvJob         *job,
        EvJobRender *job_render = EV_JOB_RENDER (job);
 
        /* If the job is outside of our interest, we silently discard it */
-       if ((job_render->rc->page < (pixbuf_cache->start_page - pixbuf_cache->preload_cache_size)) ||
-           (job_render->rc->page > (pixbuf_cache->end_page + pixbuf_cache->preload_cache_size))) {
+       if ((job_render->rc->page->index < (pixbuf_cache->start_page - pixbuf_cache->preload_cache_size)) ||
+           (job_render->rc->page->index > (pixbuf_cache->end_page + pixbuf_cache->preload_cache_size))) {
                g_object_unref (job);
                return;
        }
 
-       job_info = find_job_cache (pixbuf_cache, job_render->rc->page);
+       job_info = find_job_cache (pixbuf_cache, job_render->rc->page->index);
 
        copy_job_page_and_selection_to_job_info (job_render, job_info, pixbuf_cache);
        g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
@@ -270,13 +270,13 @@ job_finished_cb (EvJob         *job,
        EvJobRender *job_render = EV_JOB_RENDER (job);
 
        /* If the job is outside of our interest, we silently discard it */
-       if ((job_render->rc->page < (pixbuf_cache->start_page - pixbuf_cache->preload_cache_size)) ||
-           (job_render->rc->page > (pixbuf_cache->end_page + pixbuf_cache->preload_cache_size))) {
+       if ((job_render->rc->page->index < (pixbuf_cache->start_page - pixbuf_cache->preload_cache_size)) ||
+           (job_render->rc->page->index > (pixbuf_cache->end_page + pixbuf_cache->preload_cache_size))) {
                g_object_unref (job);
                return;
        }
 
-       job_info = find_job_cache (pixbuf_cache, job_render->rc->page);
+       job_info = find_job_cache (pixbuf_cache, job_render->rc->page->index);
        copy_job_to_job_info (job_render, job_info, pixbuf_cache);
 }
 
@@ -298,7 +298,7 @@ check_job_size_and_unref (EvPixbufCache *pixbuf_cache,
                return;
 
        ev_page_cache_get_size (page_cache,
-                               EV_JOB_RENDER (job_info->job)->rc->page,
+                               EV_JOB_RENDER (job_info->job)->rc->page->index,
                                EV_JOB_RENDER (job_info->job)->rc->rotation,
                                scale,
                                &width, &height);
@@ -608,6 +608,7 @@ add_job (EvPixbufCache *pixbuf_cache,
         gfloat         scale,
         EvJobPriority  priority)
 {
+       EvPage  *ev_page;
        gboolean include_links = FALSE;
        gboolean include_text = FALSE;
        gboolean include_selection = FALSE;
@@ -617,14 +618,21 @@ add_job (EvPixbufCache *pixbuf_cache,
 
        job_info->page_ready = FALSE;
        
+       /* FIXME: we shouldn't lock here */
+       ev_document_doc_mutex_lock ();
+       ev_page = ev_document_get_page (pixbuf_cache->document, page);
+       ev_document_doc_mutex_unlock ();
+       
        if (job_info->rc == NULL) {
-               job_info->rc = ev_render_context_new (rotation, page, scale);
+               job_info->rc = ev_render_context_new (ev_page, rotation, scale);
        } else {
+               ev_render_context_set_page (job_info->rc, ev_page);
                ev_render_context_set_rotation (job_info->rc, rotation);
-               ev_render_context_set_page (job_info->rc, page);
                ev_render_context_set_scale (job_info->rc, scale);
        }
 
+       g_object_unref (ev_page);
+
        if (job_info->region)
                gdk_region_destroy (job_info->region);
        job_info->region = region ? gdk_region_copy (region) : NULL;
index 0d4ed3113fd7e3145da90cd5f44fd4b67970330a..25b1b838e0820f49eae06733aba20264b9a9bd55 100644 (file)
@@ -260,13 +260,10 @@ add_range (EvSidebarThumbnails *sidebar_thumbnails,
                                    -1);
 
                if (job == NULL && !thumbnail_set) {
-                       EvRenderContext *rc;
-
-                       rc = ev_render_context_new (priv->rotation, page,
+                       job = ev_job_thumbnail_new (priv->document,
+                                                   page, priv->rotation,
                                                    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),
index 1a76442a910fb19c53c59407d084f80f6596d372..f984396c861ea96a6f64d9c197dc14820dc07d0b 100644 (file)
@@ -1658,9 +1658,9 @@ ev_view_form_field_get_region (EvView      *view,
        GList       *forms_mapping;
 
        forms_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache,
-                                                               field->page);
+                                                               field->page->index);
        ev_form_field_mapping_get_area (forms_mapping, field, &field_area);
-       doc_rect_to_view_rect (view, field->page, &field_area, &view_area);
+       doc_rect_to_view_rect (view, field->page->index, &field_area, &view_area);
        view_area.x -= view->scroll_x;
        view_area.y -= view->scroll_y;
 
@@ -1711,7 +1711,7 @@ ev_view_form_field_button_create_widget (EvView      *view,
                         * we need to update also the region for the current selected item
                         */
                        forms_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache,
-                                                                               field->page);
+                                                                               field->page->index);
                        for (l = forms_mapping; l; l = g_list_next (l)) {
                                EvFormField *button = ((EvFormFieldMapping *)(l->data))->field;
                                GdkRegion   *button_region;
@@ -1739,7 +1739,7 @@ ev_view_form_field_button_create_widget (EvView      *view,
 
        ev_pixbuf_cache_reload_page (view->pixbuf_cache,
                                     field_region,
-                                    field->page,
+                                    field->page->index,
                                     view->rotation,
                                     view->scale);
        gdk_region_destroy (field_region);
@@ -1769,7 +1769,7 @@ ev_view_form_field_text_save (EvView    *view,
                field->changed = FALSE;
                ev_pixbuf_cache_reload_page (view->pixbuf_cache,
                                             field_region,
-                                            field->page,
+                                            field->page->index,
                                             view->rotation,
                                             view->scale);
                gdk_region_destroy (field_region);
@@ -1890,7 +1890,7 @@ ev_view_form_field_choice_save (EvView    *view,
                field->changed = FALSE;
                ev_pixbuf_cache_reload_page (view->pixbuf_cache,
                                             field_region,
-                                            field->page,
+                                            field->page->index,
                                             view->rotation,
                                             view->scale);
                gdk_region_destroy (field_region);
@@ -2107,10 +2107,10 @@ ev_view_handle_form_field (EvView      *view,
                                g_object_ref (field),
                                (GDestroyNotify)g_object_unref);
 
-       form_field_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache, field->page);
+       form_field_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache, field->page->index);
        ev_form_field_mapping_get_area (form_field_mapping, field, &field_area);
        
-       doc_rect_to_view_rect (view, field->page, &field_area, &view_area);
+       doc_rect_to_view_rect (view, field->page->index, &field_area, &view_area);
        view_area.x -= view->scroll_x;
        view_area.y -= view->scroll_y;
 
@@ -2310,10 +2310,10 @@ ev_view_size_allocate (GtkWidget      *widget,
                        continue;
 
                form_field_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache,
-                                                                            field->page);
+                                                                            field->page->index);
                ev_form_field_mapping_get_area (form_field_mapping, field, &field_area);
 
-               doc_rect_to_view_rect (view, field->page, &field_area, &view_area);
+               doc_rect_to_view_rect (view, field->page->index, &field_area, &view_area);
                view_area.x -= view->scroll_x;
                view_area.y -= view->scroll_y;
 
@@ -5716,15 +5716,19 @@ get_selected_text (EvView *view)
        EvRenderContext *rc;
 
        text = g_string_new (NULL);
-       rc = ev_render_context_new (view->rotation, 1, view->scale);
+       rc = ev_render_context_new (NULL, view->rotation, view->scale);
 
        ev_document_doc_mutex_lock ();
 
        for (l = view->selection_info.selections; l != NULL; l = l->next) {
                EvViewSelection *selection = (EvViewSelection *)l->data;
+               EvPage *page;
                gchar *tmp;
 
-               ev_render_context_set_page (rc, selection->page);
+               page = ev_document_get_page (view->document, selection->page);
+               ev_render_context_set_page (rc, page);
+               g_object_unref (page);
+               
                tmp = ev_selection_get_selected_text (EV_SELECTION (view->document),
                                                      rc, selection->style,
                                                      &(selection->rect));
@@ -5733,10 +5737,10 @@ get_selected_text (EvView *view)
                g_free (tmp);
        }
 
-       ev_document_doc_mutex_unlock ();
-
        g_object_unref (rc);
        
+       ev_document_doc_mutex_unlock ();
+       
        normalized_text = g_utf8_normalize (text->str, text->len, G_NORMALIZE_NFKC);
        g_string_free (text, TRUE);
        return normalized_text;
index ffac5d7387a8da8e34f32d0a098e9dd504c0af23..81c5b9ee76af13420027dbf7929c206136ce9daf 100644 (file)
@@ -1072,8 +1072,6 @@ ev_window_set_icon_from_thumbnail (EvJobThumbnail *job,
 static void
 ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation)
 {
-       
-       EvRenderContext *rc;
        gint page_width, page_height;
        gdouble scale;
        EvDocument *document = ev_window->priv->document;
@@ -1089,14 +1087,11 @@ ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation)
                                &page_width, &page_height);
        scale = (gdouble)128 / (gdouble)page_width;
        
-       rc = ev_render_context_new (rotation, 0, scale);
-       
-       ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, rc);
+       ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, 0, rotation, scale);
        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);
 }
 
 static gboolean
index 8960f18065ff9bad665ebaed9a6bcfd8e2c3b1dc..b3c8285ee3d83debba1e41578b18f0f4a7a21124 100644 (file)
@@ -65,13 +65,17 @@ evince_thumbnail_pngenc_get (EvDocument *document, const char *thumbnail, int si
        EvRenderContext *rc;
        double width, height;
        GdkPixbuf *pixbuf;
+       EvPage *page;
 
-       ev_document_get_page_size (document, 0, &width, &height);
+       page = ev_document_get_page (document, 0);
+       
+       ev_document_get_page_size (document, page, &width, &height);
 
-       rc = ev_render_context_new (0, 0, size / width);
+       rc = ev_render_context_new (page, 0, size / width);
        pixbuf = ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (document),
                                                       rc, FALSE);
        g_object_unref (rc);
+       g_object_unref (page);
        
        if (pixbuf != NULL) {
                const char *overlaid_icon_name = NULL;