[evince] a11y: ensure text cached when you request an EvPageAccessible



commit b5fc924aeb9bca1543449558bb5aa64002813f32
Author: Alejandro Piñeiro <apinheiro igalia com>
Date:   Fri Apr 11 17:08:17 2014 +0200

    a11y: ensure text cached when you request an EvPageAccessible
    
    https://bugzilla.gnome.org/show_bug.cgi?id=724965

 libview/ev-page-cache.c      |   10 ++++++++++
 libview/ev-page-cache.h      |    2 ++
 libview/ev-view-accessible.c |   10 ++++++++++
 3 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/libview/ev-page-cache.c b/libview/ev-page-cache.c
index 13475e0..eda5579 100644
--- a/libview/ev-page-cache.c
+++ b/libview/ev-page-cache.c
@@ -654,3 +654,13 @@ ev_page_cache_get_text_log_attrs (EvPageCache   *cache,
 
         return FALSE;
 }
+
+void
+ev_page_cache_ensure_page (EvPageCache *cache,
+                           gint         page)
+{
+        g_return_if_fail (EV_IS_PAGE_CACHE (cache));
+        g_return_if_fail (page >= 0 && page < cache->n_pages);
+
+        ev_page_cache_schedule_job_if_needed (cache, page);
+}
diff --git a/libview/ev-page-cache.h b/libview/ev-page-cache.h
index 7dc445a..550ac28 100644
--- a/libview/ev-page-cache.h
+++ b/libview/ev-page-cache.h
@@ -74,6 +74,8 @@ gboolean           ev_page_cache_get_text_log_attrs     (EvPageCache       *cach
                                                          gint               page,
                                                          PangoLogAttr     **log_attrs,
                                                          gulong            *n_attrs);
+void               ev_page_cache_ensure_page            (EvPageCache       *cache,
+                                                         gint               page);
 G_END_DECLS
 
 #endif /* EV_PAGE_CACHE_H */
diff --git a/libview/ev-view-accessible.c b/libview/ev-view-accessible.c
index 6b4c8b9..185e335 100644
--- a/libview/ev-view-accessible.c
+++ b/libview/ev-view-accessible.c
@@ -138,11 +138,21 @@ ev_view_accessible_ref_child (AtkObject *obj,
                              gint       i)
 {
        EvViewAccessible *self;
+       EvView *view;
 
        g_return_val_if_fail (EV_IS_VIEW_ACCESSIBLE (obj), NULL);
        self = EV_VIEW_ACCESSIBLE (obj);
        g_return_val_if_fail (i >= 0 || i < ev_view_accessible_get_n_pages (self), NULL);
 
+       view = EV_VIEW (gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)));
+       if (view == NULL)
+               return NULL;
+
+       /* If a given page is requested, we assume that the text would
+        * be requested soon, so we need to be sure that is cached.*/
+       if (view->page_cache)
+               ev_page_cache_ensure_page (view->page_cache, i);
+
        return g_object_ref (g_ptr_array_index (self->priv->children, i));
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]