]> www.fi.muni.cz Git - evince.git/commitdiff
Yay! find works now... Now to find bugs...
authorMarco Pesenti Gritti <marco@gnome.org>
Sun, 30 Jan 2005 13:40:03 +0000 (13:40 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Sun, 30 Jan 2005 13:40:03 +0000 (13:40 +0000)
2005-01-30  Marco Pesenti Gritti  <marco@gnome.org>

        * pdf/xpdf/pdf-document.cc:
        * shell/ev-view.c: (draw_rubberband), (highlight_find_results),
        (expose_bin_window), (find_changed_cb):

        Yay! find works now... Now to find bugs...

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

index 673d9e1f33735a08a0d8c2ff13fb81a1999df372..ec08c50c16a08686d9947d353e0bfbf580d7c80e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2005-01-30  Marco Pesenti Gritti  <marco@gnome.org>
+
+       * pdf/xpdf/pdf-document.cc:
+       * shell/ev-view.c: (draw_rubberband), (highlight_find_results),
+       (expose_bin_window), (find_changed_cb):
+
+       Yay! find works now... Now to find bugs...
+
 2005-01-30  Marco Pesenti Gritti  <marco@gnome.org>
 
        * backend/ev-document-find.c: (ev_document_find_base_init),
index 01ae7398bb5e7e972ebcafee36f3321f115c35d3..48c01d887f19528478b36a11a09f87d8da345beb 100644 (file)
@@ -109,12 +109,11 @@ ev_document_find_get_result (EvDocumentFind *document_find,
        return iface->get_result (document_find, n_result, rectangle);
 }
 
-void
-ev_document_find_get_progress (EvDocumentFind *document_find,
-                              double          percent_complete)
+double
+ev_document_find_get_progress (EvDocumentFind *document_find)
 {
        EvDocumentFindIface *iface = EV_DOCUMENT_FIND_GET_IFACE (document_find);
-       iface->get_progress (document_find, percent_complete);
+       return iface->get_progress (document_find);
 }
 
 void
index ebce196bfd936f01aeb931963ca353d0af1f66c3..3f556671250136b69805ee3a295035da8dbe2f0d 100644 (file)
@@ -54,8 +54,7 @@ struct _EvDocumentFindIface
        gboolean (* get_result)       (EvDocumentFind *document_find,
                                       int             n_result,
                                       GdkRectangle   *rectangle); 
-       void     (* get_progress)     (EvDocumentFind *document_find,
-                                      double          percent_complete);
+       double   (* get_progress)     (EvDocumentFind *document_find);
 
         /* Signals */
 
@@ -74,8 +73,7 @@ int       ev_document_find_get_n_results    (EvDocumentFind *document_find);
 gboolean  ev_document_find_get_result      (EvDocumentFind *document_find,
                                             int             n_result,
                                             GdkRectangle   *rectangle); 
-void     ev_document_find_get_progress     (EvDocumentFind *document_find,
-                                            double          percent_complete);
+double   ev_document_find_get_progress     (EvDocumentFind *document_find);
 void      ev_document_find_changed          (EvDocumentFind *document_find,
                                             int             page);
 
index 5a7304c6162afe6d5b73fea8b138a40cb822dcc7..b913be852a9fec45a6c80fbf32fab1520d5a5fa2 100644 (file)
@@ -399,6 +399,24 @@ pdf_document_render (EvDocument  *document,
                                           draw.width, draw.height);
 }
 
+double
+pdf_document_find_get_progress (EvDocumentFind *document_find)
+{
+       PdfDocumentSearch *search = PDF_DOCUMENT (document_find)->search;
+       int n_pages, pages_done;
+       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;
+       } else if (search->search_page == search->start_page) {
+               pages_done = n_pages;
+       } else {
+               pages_done = n_pages - search->start_page + search->search_page;
+       }
+
+       return pages_done / (double) n_pages;
+}
+
 int
 pdf_document_find_page_has_results (EvDocumentFind *document_find,
                                    int             page)
@@ -427,15 +445,16 @@ pdf_document_find_get_result (EvDocumentFind *document_find,
                              int             n_result,
                              GdkRectangle   *rectangle)
 {
-       PdfDocumentSearch *search = PDF_DOCUMENT (document_find)->search;
+       PdfDocument *pdf_document = PDF_DOCUMENT (document_find);
+       PdfDocumentSearch *search = pdf_document->search;
        GdkRectangle r;
 
        if (search != NULL) {
                r = g_array_index (search->current_page_results,
                                   GdkRectangle, n_result);
 
-               rectangle->x = r.x;
-               rectangle->y = r.y;
+               rectangle->x = r.x + pdf_document->page_x_offset;
+               rectangle->y = r.y + pdf_document->page_y_offset;
                rectangle->width = r.width;
                rectangle->height = r.height;
 
@@ -498,7 +517,7 @@ pdf_document_search_idle_callback (void *data)
 {
         PdfDocumentSearch *search = (PdfDocumentSearch*) data;
         PdfDocument *pdf_document = search->document;
-        int n_pages;
+        int n_pages, changed_page;
         double xMin, yMin, xMax, yMax;
 
         /* Note that PDF page count is 1 through n_pages INCLUSIVE
@@ -533,11 +552,7 @@ pdf_document_search_idle_callback (void *data)
                search->other_page_flags[search->search_page] = 0;
        }
 
-        if (search->search_page != search->start_page) {
-               ev_document_find_changed (EV_DOCUMENT_FIND (pdf_document),
-                                         search->search_page);
-               return TRUE;
-       }
+       changed_page = search->start_page;
 
         search->search_page += 1;
         if (search->search_page > n_pages) {
@@ -545,6 +560,12 @@ pdf_document_search_idle_callback (void *data)
                 search->search_page = 1;
         }
 
+        if (search->search_page != search->start_page) {
+               ev_document_find_changed (EV_DOCUMENT_FIND (pdf_document),
+                                         changed_page);
+               return TRUE;
+       }
+
 end_search:
         /* We're done. */
         search->idle = 0; /* will return FALSE to remove */
index 4e5db8b18b11ec5b4808e8c581c7abafb503fa1c..a38726cf50888181d7d582cb181c8c68fa8cfe2f 100644 (file)
@@ -328,7 +328,7 @@ ev_gdk_color_to_rgb (const GdkColor *color)
 
 static void
 draw_rubberband (GtkWidget *widget, GdkWindow *window,
-                const GdkRectangle *rect, gboolean dark)
+                const GdkRectangle *rect, guchar alpha)
 {
        GdkGC *gc;
        GdkPixbuf *pixbuf;
@@ -336,8 +336,7 @@ draw_rubberband (GtkWidget *widget, GdkWindow *window,
        guint fill_color;
 
        fill_color_gdk = gdk_color_copy (&GTK_WIDGET (widget)->style->base[GTK_STATE_SELECTED]);
-       fill_color = ev_gdk_color_to_rgb (fill_color_gdk) << 8 |
-                    (dark ? 0x90 : 0x40);
+       fill_color = ev_gdk_color_to_rgb (fill_color_gdk) << 8 | alpha;
 
        pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
                                 rect->width, rect->height);
@@ -373,12 +372,12 @@ highlight_find_results (EvView *view)
 
        for (i = 0; i < results; i++) {
                GdkRectangle rectangle;
-               gboolean current;
+               guchar alpha;
 
-               current = (i == view->find_result);
+               alpha = (i == view->find_result) ? 0x90 : 0x20;
                ev_document_find_get_result (find, i, &rectangle);
                draw_rubberband (GTK_WIDGET (view), view->bin_window,
-                                &rectangle, current);
+                                &rectangle, alpha);
         }
 }
 
@@ -416,7 +415,7 @@ expose_bin_window (GtkWidget      *widget,
 
        if (view->has_selection) {
                draw_rubberband (widget, view->bin_window,
-                                &view->selection, FALSE);
+                                &view->selection, 0x40);
        }
 }
 
@@ -909,26 +908,36 @@ ev_view_init (EvView *view)
        view->cursor = EV_VIEW_CURSOR_NORMAL;
 }
 
-static char *
-ev_view_get_find_status_message (EvView *view)
+static void
+update_find_status_message (EvView *view)
 {
-/*
-       if (view->find_results->len == 0) {
-               if (view->find_percent_complete >= (1.0 - 1e-10)) {
-                       return g_strdup (_("Not found"));
+       char *message;
+
+       if (ev_document_get_page (view->document) == view->find_page) {
+               int results;
+
+               results = ev_document_find_get_n_results
+                               (EV_DOCUMENT_FIND (view->document));
+
+               message = g_strdup_printf (_("%d found on this page"),
+                                          results);
+       } else {
+               double percent;
+               
+               percent = ev_document_find_get_progress
+                               (EV_DOCUMENT_FIND (view->document));
+
+               if (percent >= (1.0 - 1e-10)) {
+                       message = g_strdup (_("Not found"));
                } else {
-                       return g_strdup_printf (_("%3d%% remaining to search"),
-                                               (int) ((1.0 - view->find_percent_complete) * 100));
+                       message = g_strdup_printf (_("%3d%% remaining to search"),
+                                                  (int) ((1.0 - percent) * 100));
                }
-       } else if (view->results_on_this_page == 0) {
-               g_assert (view->next_page_with_result != 0);
-               return g_strdup_printf (_("Found on page %d"),
-                                       view->next_page_with_result);
-       } else {
-               return g_strdup_printf (_("%d found on this page"),
-                                       view->results_on_this_page);
+               
        }
-*/
+
+       ev_view_set_find_status (view, message);
+       g_free (message);
 }
 
 static void
@@ -960,6 +969,7 @@ set_document_page (EvView *view, int page)
 
                view->find_page = page;
                view->find_result = 0;
+               update_find_status_message (view);
        }
 }
 
@@ -1041,8 +1051,7 @@ find_changed_cb (EvDocument *document, int page, EvView *view)
 {
        jump_to_find_page (view);
        jump_to_find_result (view);
-
-       g_print ("Update for page %d\n", page);
+       update_find_status_message (view);
 
        if (ev_document_get_page (document) == page) {
                gtk_widget_queue_draw (GTK_WIDGET (view));