[evince] ev-find-sidebar: Show all results in sidebar for multicolumn documents



commit 641dc96ed11ee7e046d315f036f13ccb3b0d8abb
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Sun Jun 30 09:55:44 2013 +0200

    ev-find-sidebar: Show all results in sidebar for multicolumn documents
    
    Search results are sorted in physical order while text layout is in
    reading order, so when a match is not found after the offset of previous
    one, continue iterating the text layout from the beginning. Add a
    warning when we fail to find the offset for a match because it should
    never happen.

 shell/ev-find-sidebar.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/shell/ev-find-sidebar.c b/shell/ev-find-sidebar.c
index 1d03b94..b6fe0f8 100644
--- a/shell/ev-find-sidebar.c
+++ b/shell/ev-find-sidebar.c
@@ -347,14 +347,18 @@ get_match_offset (EvRectangle *areas,
         x = match->x1;
         y = (match->y1 + match->y2) / 2;
 
-        for (i = offset; i < n_areas; i++) {
+        i = offset;
+
+        do {
                 EvRectangle *area = areas + i;
 
                 if (x >= area->x1 && x < area->x2 &&
                     y >= area->y1 && y <= area->y2) {
                         return i;
                 }
-        }
+
+                i = (i + 1) % n_areas;
+        } while (i != offset);
 
         return -1;
 }
@@ -416,8 +420,11 @@ process_matches_idle (EvFindSidebar *sidebar)
                         GtkTreeIter  iter;
 
                         offset = get_match_offset (areas, n_areas, match, offset);
-                        if (offset == -1)
+                        if (offset == -1) {
+                                g_warning ("No offset found for match \"%s\" at page %d after processing %d 
results\n",
+                                           priv->job->text, current_page, result);
                                 break;
+                        }
 
                         if (current_page >= priv->job->start_page) {
                                 gtk_list_store_append (GTK_LIST_STORE (model), &iter);


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