Commit dfed06b8 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos

[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.
parent fe09db35
......@@ -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)
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment