From dfed06b88fae63bbd0460e43df977c0d33ef1045 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Tue, 20 Jul 2010 14:34:18 +0200 Subject: [PATCH] [libview] Add ev_page_cache_mark_dirty() 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 | 23 ++++++++++++++++++++--- libview/ev-page-cache.h | 2 ++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/libview/ev-page-cache.c b/libview/ev-page-cache.c index cdec16ca..c3c57041 100644 --- a/libview/ev-page-cache.c +++ b/libview/ev-page-cache.c @@ -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) diff --git a/libview/ev-page-cache.h b/libview/ev-page-cache.h index 4c2effb7..1c2e5cdf 100644 --- a/libview/ev-page-cache.h +++ b/libview/ev-page-cache.h @@ -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, -- 2.43.5