]> www.fi.muni.cz Git - evince.git/commitdiff
[libview] Add ev_page_cache_mark_dirty()
authorCarlos Garcia Campos <carlosgc@gnome.org>
Tue, 20 Jul 2010 12:34:18 +0000 (14:34 +0200)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Tue, 20 Jul 2010 15:06:31 +0000 (17:06 +0200)
Annotations might be added at runtime, in that case we need to mark
cache as dirty to force a new job to get annotations.

libview/ev-page-cache.c
libview/ev-page-cache.h

index cdec16ca3a3fca05983371d5d54837fad75ea67f..c3c570417285e9303a294872c6f6ce4b25274770 100644 (file)
@@ -34,6 +34,7 @@
 typedef struct _EvPageCacheData {
        EvJob             *job;
        gboolean           done : 1;
+       gboolean           dirty : 1;
        EvJobPageDataFlags flags;
 
        EvMappingList     *link_mapping;
@@ -179,10 +180,10 @@ ev_page_cache_get_flags_for_data (EvPageCache     *cache,
 {
        EvJobPageDataFlags flags = EV_PAGE_DATA_INCLUDE_NONE;
 
-       if (data->flags == cache->flags)
+       if (data->flags == cache->flags && !data->dirty)
                return cache->flags;
 
-       /* Flags changed */
+       /* Flags changed or data is dirty */
        if (cache->flags & EV_PAGE_DATA_INCLUDE_LINKS) {
                flags = (data->link_mapping) ?
                        flags & ~EV_PAGE_DATA_INCLUDE_LINKS :
@@ -270,6 +271,7 @@ job_page_data_finished_cb (EvJob       *job,
        if (job_data->flags & EV_PAGE_DATA_INCLUDE_TEXT)
                data->text = job_data->text;
        data->done = TRUE;
+       data->dirty = FALSE;
 
        g_object_unref (data->job);
        data->job = NULL;
@@ -300,7 +302,7 @@ ev_page_cache_set_page_range (EvPageCache *cache,
                EvPageCacheData   *data = &cache->page_list[i];
                EvJobPageDataFlags flags;
 
-               if (data->flags == cache->flags && (data->done || data->job))
+               if (data->flags == cache->flags && !data->dirty && (data->done || data->job))
                        continue;
 
                if (data->job)
@@ -339,6 +341,21 @@ ev_page_cache_set_flags (EvPageCache       *cache,
        ev_page_cache_set_page_range (cache, cache->start_page, cache->end_page);
 }
 
+void
+ev_page_cache_mark_dirty (EvPageCache *cache,
+                         gint         page)
+{
+       EvPageCacheData *data;
+
+       g_return_if_fail (EV_IS_PAGE_CACHE (cache));
+
+       data = &cache->page_list[page];
+       data->dirty = TRUE;
+
+       /* Update the current range */
+       ev_page_cache_set_page_range (cache, cache->start_page, cache->end_page);
+}
+
 EvMappingList *
 ev_page_cache_get_link_mapping (EvPageCache *cache,
                                gint         page)
index 4c2effb7587a53e3d02302174b31dba57cd27d1e..1c2e5cdf2035f35ea80f8b68462acbd582fdd27a 100644 (file)
@@ -47,6 +47,8 @@ void               ev_page_cache_set_page_range         (EvPageCache       *cach
 EvJobPageDataFlags ev_page_cache_get_flags              (EvPageCache       *cache);
 void               ev_page_cache_set_flags              (EvPageCache       *cache,
                                                         EvJobPageDataFlags flags);
+void               ev_page_cache_mark_dirty             (EvPageCache       *cache,
+                                                        gint               page);
 EvMappingList     *ev_page_cache_get_link_mapping       (EvPageCache       *cache,
                                                         gint               page);
 EvMappingList     *ev_page_cache_get_image_mapping      (EvPageCache       *cache,