[evince] libview: Get text attributes from backend and save them in page cache
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] libview: Get text attributes from backend and save them in page cache
- Date: Wed, 10 Jul 2013 15:58:04 +0000 (UTC)
commit 4592007f1c201ed1413845ffb56905495269f9d3
Author: Antia Puentes <apuentes igalia com>
Date: Wed Jul 10 17:47:26 2013 +0200
libview: Get text attributes from backend and save them in page cache
libview/ev-jobs.c | 4 ++++
libview/ev-jobs.h | 12 +++++++-----
libview/ev-page-cache.c | 37 +++++++++++++++++++++++++++++++++++++
libview/ev-page-cache.h | 2 ++
libview/ev-view.c | 1 +
5 files changed, 51 insertions(+), 5 deletions(-)
---
diff --git a/libview/ev-jobs.c b/libview/ev-jobs.c
index 2bf7a3c..e000e62 100644
--- a/libview/ev-jobs.c
+++ b/libview/ev-jobs.c
@@ -747,6 +747,10 @@ ev_job_page_data_run (EvJob *job)
ev_page,
&(job_pd->text_layout),
&(job_pd->text_layout_length));
+ if ((job_pd->flags & EV_PAGE_DATA_INCLUDE_TEXT_ATTRS) && EV_IS_DOCUMENT_TEXT (job->document))
+ job_pd ->text_attrs =
+ ev_document_text_get_text_attrs (EV_DOCUMENT_TEXT (job->document),
+ ev_page);
if ((job_pd->flags & EV_PAGE_DATA_INCLUDE_TEXT_LOG_ATTRS) && job_pd->text) {
job_pd->text_log_attrs_length = g_utf8_strlen (job_pd->text, -1);
job_pd->text_log_attrs = g_new0 (PangoLogAttr, job_pd->text_log_attrs_length + 1);
diff --git a/libview/ev-jobs.h b/libview/ev-jobs.h
index a436100..c71eb22 100644
--- a/libview/ev-jobs.h
+++ b/libview/ev-jobs.h
@@ -266,11 +266,12 @@ typedef enum {
EV_PAGE_DATA_INCLUDE_TEXT = 1 << 1,
EV_PAGE_DATA_INCLUDE_TEXT_MAPPING = 1 << 2,
EV_PAGE_DATA_INCLUDE_TEXT_LAYOUT = 1 << 3,
- EV_PAGE_DATA_INCLUDE_TEXT_LOG_ATTRS = 1 << 4,
- EV_PAGE_DATA_INCLUDE_IMAGES = 1 << 5,
- EV_PAGE_DATA_INCLUDE_FORMS = 1 << 6,
- EV_PAGE_DATA_INCLUDE_ANNOTS = 1 << 7,
- EV_PAGE_DATA_INCLUDE_ALL = (1 << 8) - 1
+ EV_PAGE_DATA_INCLUDE_TEXT_ATTRS = 1 << 4,
+ EV_PAGE_DATA_INCLUDE_TEXT_LOG_ATTRS = 1 << 5,
+ EV_PAGE_DATA_INCLUDE_IMAGES = 1 << 6,
+ EV_PAGE_DATA_INCLUDE_FORMS = 1 << 7,
+ EV_PAGE_DATA_INCLUDE_ANNOTS = 1 << 8,
+ EV_PAGE_DATA_INCLUDE_ALL = (1 << 9) - 1
} EvJobPageDataFlags;
struct _EvJobPageData
@@ -288,6 +289,7 @@ struct _EvJobPageData
gchar *text;
EvRectangle *text_layout;
guint text_layout_length;
+ PangoAttrList *text_attrs;
PangoLogAttr *text_log_attrs;
gulong text_log_attrs_length;
};
diff --git a/libview/ev-page-cache.c b/libview/ev-page-cache.c
index 020db3a..8e3271d 100644
--- a/libview/ev-page-cache.c
+++ b/libview/ev-page-cache.c
@@ -45,6 +45,7 @@ typedef struct _EvPageCacheData {
EvRectangle *text_layout;
guint text_layout_length;
gchar *text;
+ PangoAttrList *text_attrs;
PangoLogAttr *text_log_attrs;
gulong text_log_attrs_length;
} EvPageCacheData;
@@ -127,6 +128,11 @@ ev_page_cache_data_free (EvPageCacheData *data)
data->text = NULL;
}
+ if (data->text_attrs) {
+ pango_attr_list_unref (data->text_attrs);
+ data->text_attrs = NULL;
+ }
+
if (data->text_log_attrs) {
g_free (data->text_log_attrs);
data->text_log_attrs = NULL;
@@ -235,6 +241,12 @@ ev_page_cache_get_flags_for_data (EvPageCache *cache,
flags | EV_PAGE_DATA_INCLUDE_TEXT_LAYOUT;
}
+ if (cache->flags & EV_PAGE_DATA_INCLUDE_TEXT_ATTRS) {
+ flags = (data->text_attrs) ?
+ flags & ~EV_PAGE_DATA_INCLUDE_TEXT_ATTRS :
+ flags | EV_PAGE_DATA_INCLUDE_TEXT_ATTRS;
+ }
+
if (cache->flags & EV_PAGE_DATA_INCLUDE_TEXT_LOG_ATTRS) {
flags = (data->text_log_attrs) ?
flags & ~EV_PAGE_DATA_INCLUDE_TEXT_LOG_ATTRS :
@@ -285,10 +297,13 @@ job_page_data_finished_cb (EvJob *job,
}
if (job_data->flags & EV_PAGE_DATA_INCLUDE_TEXT)
data->text = job_data->text;
+ if (job_data->flags & EV_PAGE_DATA_INCLUDE_TEXT_ATTRS)
+ data->text_attrs = job_data->text_attrs;
if (job_data->flags & EV_PAGE_DATA_INCLUDE_TEXT_LOG_ATTRS) {
data->text_log_attrs = job_data->text_log_attrs;
data->text_log_attrs_length = job_data->text_log_attrs_length;
}
+
data->done = TRUE;
data->dirty = FALSE;
@@ -564,6 +579,28 @@ ev_page_cache_get_text_layout (EvPageCache *cache,
return FALSE;
}
+PangoAttrList *
+ev_page_cache_get_text_attrs (EvPageCache *cache,
+ gint page)
+{
+ EvPageCacheData *data;
+
+ g_return_val_if_fail (EV_IS_PAGE_CACHE (cache), NULL);
+ g_return_val_if_fail (page >= 0 && page < cache->n_pages, NULL);
+
+ if (!(cache->flags & EV_PAGE_DATA_INCLUDE_TEXT_ATTRS))
+ return NULL;
+
+ data = &cache->page_list[page];
+ if (data->done)
+ return data->text_attrs;
+
+ if (data->job)
+ return EV_JOB_PAGE_DATA(data->job)->text_attrs;
+
+ return data->text_attrs;
+}
+
gboolean
ev_page_cache_get_text_log_attrs (EvPageCache *cache,
gint page,
diff --git a/libview/ev-page-cache.h b/libview/ev-page-cache.h
index 5166e63..15ba1b0 100644
--- a/libview/ev-page-cache.h
+++ b/libview/ev-page-cache.h
@@ -65,6 +65,8 @@ gboolean ev_page_cache_get_text_layout (EvPageCache *cach
gint page,
EvRectangle **areas,
guint *n_areas);
+PangoAttrList *ev_page_cache_get_text_attrs (EvPageCache *cache,
+ gint page);
gboolean ev_page_cache_get_text_log_attrs (EvPageCache *cache,
gint page,
PangoLogAttr **log_attrs,
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 655a018..60381f6 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -6227,6 +6227,7 @@ setup_caches (EvView *view)
ev_page_cache_get_flags (view->page_cache) |
EV_PAGE_DATA_INCLUDE_TEXT_LAYOUT |
EV_PAGE_DATA_INCLUDE_TEXT |
+ EV_PAGE_DATA_INCLUDE_TEXT_ATTRS |
EV_PAGE_DATA_INCLUDE_TEXT_LOG_ATTRS);
inverted_colors = ev_document_model_get_inverted_colors (view->model);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]