From 1cb865554fcb40760784a30c7700b6a751567762 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Fri, 4 Feb 2005 12:18:26 +0000 Subject: [PATCH] Fix several bugs with find 2005-02-04 Marco Pesenti Gritti * 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 | 10 ++++++++++ backend/ev-document-find.c | 1 - backend/ev-document-find.h | 1 - pdf/xpdf/pdf-document.cc | 18 +++++++++++++----- shell/ev-view.c | 20 +++++++++++++------- shell/ev-window.c | 1 + 6 files changed, 37 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49411dd6..c32c7a8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-02-04 Marco Pesenti Gritti + + * 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 * shell/ev-sidebar-thumbnails.c diff --git a/backend/ev-document-find.c b/backend/ev-document-find.c index 48c01d88..5c1fbe44 100644 --- a/backend/ev-document-find.c +++ b/backend/ev-document-find.c @@ -121,4 +121,3 @@ ev_document_find_changed (EvDocumentFind *document_find, int page) { g_signal_emit_by_name (document_find, "find_changed", page); } - diff --git a/backend/ev-document-find.h b/backend/ev-document-find.h index 3f556671..49c3672b 100644 --- a/backend/ev-document-find.h +++ b/backend/ev-document-find.h @@ -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. diff --git a/pdf/xpdf/pdf-document.cc b/pdf/xpdf/pdf-document.cc index 18552225..255c5abd 100644 --- a/pdf/xpdf/pdf-document.cc +++ b/pdf/xpdf/pdf-document.cc @@ -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; } diff --git a/shell/ev-view.c b/shell/ev-view.c index a5fc7ce6..6d071a9d 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -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), diff --git a/shell/ev-window.c b/shell/ev-window.c index 01c4f8a3..368919ad 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -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)); } } } -- 2.43.5