Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/ev-view.c68
-rw-r--r--shell/ev-window.c12
2 files changed, 76 insertions, 4 deletions
diff --git a/shell/ev-view.c b/shell/ev-view.c
index 7aaa59a..a928ed3 100644
--- a/shell/ev-view.c
+++ b/shell/ev-view.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
/* this file is part of evince, a gnome document viewer
*
* Copyright (C) 2004 Red Hat, Inc
@@ -38,6 +39,8 @@ struct _EvView {
GtkAdjustment *hadjustment;
GtkAdjustment *vadjustment;
+
+ GArray *find_results;
};
struct _EvViewClass {
@@ -135,6 +138,9 @@ ev_view_finalize (GObject *object)
ev_view_set_scroll_adjustments (view, NULL, NULL);
+ g_array_free (view->find_results, TRUE);
+ view->find_results = NULL;
+
G_OBJECT_CLASS (ev_view_parent_class)->finalize (object);
}
@@ -285,11 +291,35 @@ expose_bin_window (GtkWidget *widget,
GdkEventExpose *event)
{
EvView *view = EV_VIEW (widget);
+ int i;
+ const EvFindResult *results;
if (view->document)
ev_document_render (view->document,
event->area.x, event->area.y,
event->area.width, event->area.height);
+
+ results = (EvFindResult*) view->find_results->data;
+ i = 0;
+ while (i < view->find_results->len) {
+#if 0
+ g_printerr ("highlighting result %d at %d,%d %dx%d\n",
+ i,
+ results[i].highlight_area.x,
+ results[i].highlight_area.y,
+ results[i].highlight_area.width,
+ results[i].highlight_area.height);
+#endif
+ // if (results[i].page_num == current_page) FIXME
+ gdk_draw_rectangle (view->bin_window,
+ widget->style->base_gc[GTK_STATE_SELECTED],
+ FALSE,
+ results[i].highlight_area.x,
+ results[i].highlight_area.y,
+ results[i].highlight_area.width,
+ results[i].highlight_area.height);
+ ++i;
+ }
}
static gboolean
@@ -304,7 +334,6 @@ ev_view_expose_event (GtkWidget *widget,
return GTK_WIDGET_CLASS (ev_view_parent_class)->expose_event (widget, event);
return FALSE;
-
}
static gboolean
@@ -430,6 +459,29 @@ ev_view_init (EvView *view)
static const GdkColor white = { 0, 0xffff, 0xffff, 0xffff };
gtk_widget_modify_bg (GTK_WIDGET (view), GTK_STATE_NORMAL, &white);
+
+ view->find_results = g_array_new (FALSE,
+ FALSE,
+ sizeof (EvFindResult));
+}
+
+
+static void
+found_results_callback (EvDocument *document,
+ const EvFindResult *results,
+ int n_results,
+ double percent_complete,
+ void *data)
+{
+ EvView *view = EV_VIEW (data);
+
+ g_array_set_size (view->find_results, 0);
+
+ if (n_results > 0)
+ g_array_append_vals (view->find_results,
+ results, n_results);
+
+ gtk_widget_queue_draw (GTK_WIDGET (view));
}
/*** Public API ***/
@@ -449,13 +501,23 @@ ev_view_set_document (EvView *view,
if (document != view->document) {
int old_page = ev_view_get_page (view);
- if (view->document)
+ if (view->document) {
g_object_unref (view->document);
+ g_signal_handlers_disconnect_by_func (view->document,
+ found_results_callback,
+ view);
+ g_array_set_size (view->find_results, 0);
+ }
view->document = document;
- if (view->document)
+ if (view->document) {
g_object_ref (view->document);
+ g_signal_connect (view->document,
+ "found",
+ G_CALLBACK (found_results_callback),
+ view);
+ }
if (GTK_WIDGET_REALIZED (view))
ev_document_set_target (view->document, view->bin_window);
diff --git a/shell/ev-window.c b/shell/ev-window.c
index ec21ae9..df7bf25 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -593,8 +593,18 @@ find_bar_search_changed_cb (EggFindBar *find_bar,
visible = GTK_WIDGET_VISIBLE (find_bar);
search_string = egg_find_bar_get_search_string (find_bar);
- /* FIXME */
+#if 0
g_printerr ("search for '%s'\n", search_string ? search_string : "(nil)");
+#endif
+
+ /* We don't require begin/end find calls to be matched up, it's really
+ * start_find and cancel_any_find_that_may_not_be_finished
+ */
+ if (visible && search_string) {
+ ev_document_begin_find (ev_window->priv->document, search_string, case_sensitive);
+ } else {
+ ev_document_end_find (ev_window->priv->document);
+ }
}
static void