]> www.fi.muni.cz Git - evince.git/commitdiff
Fix several bugs with find
authorMarco Pesenti Gritti <marco@gnome.org>
Fri, 4 Feb 2005 12:18:26 +0000 (12:18 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Fri, 4 Feb 2005 12:18:26 +0000 (12:18 +0000)
2005-02-04  Marco Pesenti Gritti  <marco@gnome.org>

        * backend/ev-document-find.c: (ev_document_find_changed):
        * backend/ev-document-find.h:
        * pdf/xpdf/pdf-document.cc:
        * shell/ev-view.c: (jump_to_find_result), (ev_view_set_document):
        * shell/ev-window.c: (find_bar_search_changed_cb):

        Fix several bugs with find

ChangeLog
backend/ev-document-find.c
backend/ev-document-find.h
pdf/xpdf/pdf-document.cc
shell/ev-view.c
shell/ev-window.c

index 49411dd64c5ad7c6d5c9295d59101c3577166f32..c32c7a8b9c667b54ab99169a151074db02ba766b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2005-02-04  Marco Pesenti Gritti  <marco@gnome.org>
+
+       * backend/ev-document-find.c: (ev_document_find_changed):
+       * backend/ev-document-find.h:
+       * pdf/xpdf/pdf-document.cc:
+       * shell/ev-view.c: (jump_to_find_result), (ev_view_set_document):
+       * shell/ev-window.c: (find_bar_search_changed_cb):
+
+       Fix several bugs with find
+
 2005-02-04  Martin Kretzschmar  <martink@gnome.org>
 
        * shell/ev-sidebar-thumbnails.c
index 48c01d887f19528478b36a11a09f87d8da345beb..5c1fbe4460ba0d46b9e2818768a7f41554f26206 100644 (file)
@@ -121,4 +121,3 @@ ev_document_find_changed (EvDocumentFind  *document_find, int page)
 {
        g_signal_emit_by_name (document_find, "find_changed", page);
 }
-                                   
index 3f556671250136b69805ee3a295035da8dbe2f0d..49c3672b0cf66a1748faa22a357b77924982ea5c 100644 (file)
@@ -77,7 +77,6 @@ double          ev_document_find_get_progress     (EvDocumentFind *document_find);
 void      ev_document_find_changed          (EvDocumentFind *document_find,
                                             int             page);
 
-
 /* How this interface works:
  *
  * begin() begins a new search, canceling any previous search.
index 1855222562df660d3f88a4fe77f4f9bdf4482865..255c5abd17f1fa6c50cc94c35211c9826c5f71b1 100644 (file)
@@ -413,12 +413,18 @@ pdf_document_render (EvDocument  *document,
 double
 pdf_document_find_get_progress (EvDocumentFind *document_find)
 {
-       PdfDocumentSearch *search = PDF_DOCUMENT (document_find)->search;
+       PdfDocumentSearch *search;
        int n_pages, pages_done;
+
+       search = PDF_DOCUMENT (document_find)->search;
+
+       if (search == NULL) {
+               return 0;
+       }
+
        n_pages = ev_document_get_n_pages (EV_DOCUMENT (document_find));
        if (search->search_page > search->start_page) {
-               pages_done = search->search_page - search->start_page;
+               pages_done = search->search_page - search->start_page + 1;
        } else if (search->search_page == search->start_page) {
                pages_done = n_pages;
        } else {
@@ -460,7 +466,8 @@ pdf_document_find_get_result (EvDocumentFind *document_find,
        PdfDocumentSearch *search = pdf_document->search;
        GdkRectangle r;
 
-       if (search != NULL) {
+       if (search != NULL &&
+           n_result < search->current_page_results->len) {
                r = g_array_index (search->current_page_results,
                                   GdkRectangle, n_result);
 
@@ -655,7 +662,7 @@ pdf_document_find_begin (EvDocumentFind   *document,
 }
 
 static void
-pdf_document_find_cancel (EvDocumentFind   *document)
+pdf_document_find_cancel (EvDocumentFind *document)
 {
         PdfDocument *pdf_document = PDF_DOCUMENT (document);
 
@@ -1136,6 +1143,7 @@ pdf_document_find_iface_init (EvDocumentFindIface *iface)
        iface->get_n_results = pdf_document_find_get_n_results;
        iface->get_result = pdf_document_find_get_result;
        iface->page_has_results = pdf_document_find_page_has_results;
+       iface->get_progress = pdf_document_find_get_progress;
         iface->cancel = pdf_document_find_cancel;
 }
 
index a5fc7ce636a351d9f9bd6420cd724be0e706ddf2..6d071a9d71e9e928d6628c2096add49de8033710 100644 (file)
@@ -1018,11 +1018,17 @@ ensure_rectangle_is_visible (EvView *view, GdkRectangle *rect)
 static void
 jump_to_find_result (EvView *view)
 {
+       EvDocumentFind *find = EV_DOCUMENT_FIND (view->document);
        GdkRectangle rect;
+       int n_results;
+
+       n_results = ev_document_find_get_n_results (find);
 
-       ev_document_find_get_result (EV_DOCUMENT_FIND (view->document),
-                                    view->find_result, &rect);
-       ensure_rectangle_is_visible (view, &rect);
+       if (n_results > view->find_result) {
+               ev_document_find_get_result
+                       (find, view->find_result, &rect);
+               ensure_rectangle_is_visible (view, &rect);
+       }
 }
 
 static void
@@ -1090,9 +1096,8 @@ ev_view_set_document (EvView     *view,
 
        if (document != view->document) {
                if (view->document) {
-                        g_signal_handlers_disconnect_by_func (view->document,
-                                                              find_changed_cb,
-                                                              view);
+                        g_signal_handlers_disconnect_by_func
+                               (view->document, find_changed_cb, view);
                        g_object_unref (view->document);
                 }
 
@@ -1102,11 +1107,12 @@ ev_view_set_document (EvView     *view,
 
                if (view->document) {
                        g_object_ref (view->document);
-                       if (EV_IS_DOCUMENT_FIND (view->document))
+                       if (EV_IS_DOCUMENT_FIND (view->document)) {
                                g_signal_connect (view->document,
                                                  "find_changed",
                                                  G_CALLBACK (find_changed_cb),
                                                  view);
+                       }
                        g_signal_connect (view->document,
                                          "changed",
                                          G_CALLBACK (document_changed_callback),
index 01c4f8a3ea9557876816afc0a6d0c6b9fe6a34ba..368919ad9ccc84a7b8c824aabbf157f24641af82 100644 (file)
@@ -1384,6 +1384,7 @@ find_bar_search_changed_cb (EggFindBar *find_bar,
                        ev_document_find_cancel (EV_DOCUMENT_FIND (ev_window->priv->document));
                        egg_find_bar_set_status_text (EGG_FIND_BAR (ev_window->priv->find_bar),
                                                      NULL);
+                       gtk_widget_queue_draw (GTK_WIDGET (ev_window->priv->view));
                }
        }
 }