]> www.fi.muni.cz Git - evince.git/commitdiff
[libview] Get annotations when rendering pages
authorCarlos Garcia Campos <carlosgc@gnome.org>
Tue, 12 May 2009 09:32:22 +0000 (11:32 +0200)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Tue, 12 May 2009 09:32:22 +0000 (11:32 +0200)
libview/ev-jobs.c
libview/ev-jobs.h
libview/ev-pixbuf-cache.c
libview/ev-pixbuf-cache.h

index d2f08ef15bd56086550bef95b293311bc0e4ed27..b5b4282d5b35e9d525b888cc71cea8fa949865aa 100644 (file)
@@ -33,6 +33,7 @@
 #include "ev-document-security.h"
 #include "ev-document-find.h"
 #include "ev-document-layers.h"
+#include "ev-document-annotations.h"
 #include "ev-debug.h"
 
 #include <errno.h>
@@ -558,6 +559,10 @@ ev_job_render_run (EvJob *job)
                job_render->image_mapping =
                        ev_document_images_get_image_mapping (EV_DOCUMENT_IMAGES (job->document),
                                                              job_render->page);
+       if ((job_render->flags & EV_RENDER_INCLUDE_ANNOTS) && EV_IS_DOCUMENT_ANNOTATIONS (job->document))
+               job_render->annots_mapping =
+                       ev_document_annotations_get_annotations (EV_DOCUMENT_ANNOTATIONS (job->document),
+                                                                job_render->ev_page);
        g_object_unref (rc);
        ev_document_doc_mutex_unlock ();
        
index fc577c1ed807fad243f7d1dc65a88cd7e410ed2d..17f1b3c53308450f4fa8938da779a40203b76184 100644 (file)
@@ -187,7 +187,8 @@ typedef enum {
        EV_RENDER_INCLUDE_SELECTION = 1 << 2,
        EV_RENDER_INCLUDE_IMAGES    = 1 << 3,
        EV_RENDER_INCLUDE_FORMS     = 1 << 4,
-       EV_RENDER_INCLUDE_ALL       = (1 << 5) - 1
+       EV_RENDER_INCLUDE_ANNOTS    = 1 << 5,
+       EV_RENDER_INCLUDE_ALL       = (1 << 6) - 1
 } EvRenderFlags;
 
 struct _EvJobRender
@@ -208,6 +209,7 @@ struct _EvJobRender
        GdkRegion *text_mapping;
        GList *image_mapping;
        GList *form_field_mapping;
+       GList *annots_mapping;
 
        cairo_surface_t *selection;
        GdkRegion *selection_region;
index d7d89f70d9d3f5b6f9dce47dd6f2b35532934072..b81b7d1900417eb3b85f11106ca25356c9b570b2 100644 (file)
@@ -5,8 +5,10 @@
 #include "ev-document-images.h"
 #include "ev-document-forms.h"
 #include "ev-document-links.h"
+#include "ev-document-annotations.h"
 #include "ev-image.h"
 #include "ev-form-field.h"
+#include "ev-annotation.h"
 
 typedef struct _CacheJobInfo
 {
@@ -22,6 +24,7 @@ typedef struct _CacheJobInfo
        GList *link_mapping;
        GList *image_mapping;
        GList *form_field_mapping;
+       GList *annots_mapping;
        GdkRegion *text_mapping;
        
        /* Selection data. 
@@ -188,6 +191,10 @@ dispose_cache_job_info (CacheJobInfo *job_info,
                ev_form_field_mapping_free (job_info->form_field_mapping);
                job_info->form_field_mapping = NULL;
        }
+       if (job_info->annots_mapping) {
+               ev_annotation_mapping_free (job_info->annots_mapping);
+               job_info->annots_mapping = NULL;
+       }
        if (job_info->text_mapping) {
                gdk_region_destroy (job_info->text_mapping);
                job_info->text_mapping = NULL;
@@ -373,6 +380,7 @@ move_one_job (CacheJobInfo  *job_info,
        job_info->link_mapping = NULL;
        job_info->image_mapping = NULL;
        job_info->form_field_mapping = NULL;
+       job_info->annots_mapping = NULL;
 
        if (new_priority != priority && target_page->job) {
                ev_job_scheduler_update_job (target_page->job, new_priority);
@@ -527,6 +535,12 @@ copy_job_to_job_info (EvJobRender   *job_render,
                job_info->form_field_mapping = job_render->form_field_mapping;
        }
 
+       if (job_render->flags & EV_RENDER_INCLUDE_ANNOTS) {
+               if (job_info->annots_mapping)
+                       ev_annotation_mapping_free (job_info->annots_mapping);
+               job_info->annots_mapping = job_render->annots_mapping;
+       }
+
        if (job_render->flags & EV_RENDER_INCLUDE_TEXT) {
                if (job_info->text_mapping)
                        gdk_region_destroy (job_info->text_mapping);
@@ -633,6 +647,8 @@ add_job (EvPixbufCache *pixbuf_cache,
                flags |= EV_RENDER_INCLUDE_IMAGES;
        if (job_info->form_field_mapping == NULL)
                flags |= EV_RENDER_INCLUDE_FORMS;
+       if (job_info->annots_mapping == NULL)
+               flags |= EV_RENDER_INCLUDE_ANNOTS;
        if (job_info->text_mapping == NULL)
                flags |= EV_RENDER_INCLUDE_TEXT;
 
@@ -849,6 +865,28 @@ ev_pixbuf_cache_get_form_field_mapping (EvPixbufCache *pixbuf_cache,
        return job_info->form_field_mapping;
 }
 
+GList *
+ev_pixbuf_cache_get_annots_mapping (EvPixbufCache *pixbuf_cache,
+                                   gint           page)
+{
+       CacheJobInfo *job_info;
+
+       if (!EV_IS_DOCUMENT_ANNOTATIONS (pixbuf_cache->document))
+               return NULL;
+
+       job_info = find_job_cache (pixbuf_cache, page);
+       if (job_info == NULL)
+               return NULL;
+
+       /* We don't need to wait for the idle to handle the callback */
+       if (job_info->job &&
+          EV_JOB (job_info->job)->finished) {
+               copy_job_to_job_info (EV_JOB_RENDER (job_info->job), job_info, pixbuf_cache);
+       }
+
+       return job_info->annots_mapping;
+}
+
 static gboolean
 new_selection_surface_needed (EvPixbufCache *pixbuf_cache,
                              CacheJobInfo  *job_info,
index a22634e6d5151a2cd349f3dc62d8d808d81ba0ed..4ab0fce062326fa7f295989fc0dd0f0de89e0420 100644 (file)
@@ -72,6 +72,8 @@ GdkRegion     *ev_pixbuf_cache_get_text_mapping     (EvPixbufCache *pixbuf_cache
                                                     gint           page);
 GList        *ev_pixbuf_cache_get_form_field_mapping (EvPixbufCache *pixbuf_cache,
                                                       gint         page);
+GList         *ev_pixbuf_cache_get_annots_mapping   (EvPixbufCache *pixbuf_cache,
+                                                    gint           page);
 void           ev_pixbuf_cache_clear                (EvPixbufCache *pixbuf_cache);
 void           ev_pixbuf_cache_style_changed        (EvPixbufCache *pixbuf_cache);
 void           ev_pixbuf_cache_reload_page         (EvPixbufCache *pixbuf_cache,