+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
{
g_signal_emit_by_name (document_find, "find_changed", page);
}
-
void ev_document_find_changed (EvDocumentFind *document_find,
int page);
-
/* How this interface works:
*
* begin() begins a new search, canceling any previous search.
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 {
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);
}
static void
-pdf_document_find_cancel (EvDocumentFind *document)
+pdf_document_find_cancel (EvDocumentFind *document)
{
PdfDocument *pdf_document = PDF_DOCUMENT (document);
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;
}
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
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);
}
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),
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));
}
}
}