summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libview/ev-web-view.c54
-rw-r--r--libview/ev-web-view.h4
-rw-r--r--shell/ev-window.c8
3 files changed, 36 insertions, 30 deletions
diff --git a/libview/ev-web-view.c b/libview/ev-web-view.c
index 0756b0f0..e6bef75a 100644
--- a/libview/ev-web-view.c
+++ b/libview/ev-web-view.c
@@ -436,10 +436,12 @@ jump_to_find_result_on_page(EvWebView *webview,EvWebViewFindDirection direction)
webview->search->case_sensitive,
forward,
wrap);
+
+ webview->search->search_jump = FALSE;
}
static void
-jump_to_find_result(EvWebView *webview,
+jump_to_find_results(EvWebView *webview,
GParamSpec *pspec,
gpointer data)
{
@@ -496,8 +498,7 @@ ev_web_view_find_get_n_results (EvWebView *webview, gint page)
*
* Jumps to the first page that has occurences of searched word.
* Uses a direction where to look and a shift from current page.
- *
- */
+**/
static void
jump_to_find_page (EvWebView *webview, EvWebViewFindDirection direction, gint shift)
{
@@ -507,20 +508,22 @@ jump_to_find_page (EvWebView *webview, EvWebViewFindDirection direction, gint sh
for (i = 0; i < n_pages; i++) {
int page;
-
+
if (direction == EV_WEB_VIEW_FIND_NEXT)
page = webview->current_page + i;
else
page = webview->current_page - i;
page += shift;
-
+
if (page >= n_pages) {
page = page - n_pages;
} else if (page < 0)
page = page + n_pages;
- if (page == webview->current_page)
+ if (page == webview->current_page && ev_web_view_find_get_n_results(webview,page) > 0) {
jump_to_find_result_on_page(webview,EV_WEB_VIEW_FIND_NEXT);
+ break;
+ }
if (ev_web_view_find_get_n_results (webview, page) > 0) {
webkit_web_view_unmark_text_matches (WEBKIT_WEB_VIEW(webview));
@@ -537,11 +540,9 @@ ev_web_view_find_changed (EvWebView *webview, guint *results, gchar *text,gboole
webview->search->results = results;
webview->search->search_string = g_strdup(text);
webview->search->case_sensitive = case_sensitive;
-
+ webview->search->on_result = 0;
if (webview->search->search_jump == TRUE) {
jump_to_find_page (webview, EV_WEB_VIEW_FIND_NEXT, 0);
- } else {
- jump_to_find_result_on_page(webview,EV_WEB_VIEW_FIND_NEXT);
}
}
@@ -576,20 +577,9 @@ ev_web_view_find_previous (EvWebView *webview)
}
void
-ev_web_view_find_search_changed (EvWebView *webview,gboolean visible)
+ev_web_view_find_search_changed (EvWebView *webview)
{
/* search string has changed, focus on new search result */
- if (visible) {
- g_signal_connect(webview,
- "notify::load-status",
- G_CALLBACK(jump_to_find_result),
- NULL);
- }
- else {
- g_signal_handlers_disconnect_by_func(webview,
- jump_to_find_result,
- NULL);
- }
webkit_web_view_unmark_text_matches(WEBKIT_WEB_VIEW(webview));
webview->search->search_jump = TRUE;
@@ -609,14 +599,27 @@ ev_web_view_find_set_highlight_search (EvWebView *webview, gboolean value)
void
ev_web_view_find_cancel (EvWebView *webview)
{
- g_signal_handlers_disconnect_by_func(webview,
- jump_to_find_result,
- NULL);
-
webkit_web_view_unmark_text_matches(WEBKIT_WEB_VIEW(webview));
ev_web_view_find_set_highlight_search(webview,FALSE);
}
+
+void
+ev_web_view_set_handler(EvWebView *webview,gboolean visible)
+{
+ if (visible) {
+ g_signal_connect(webview,
+ "notify::load-status",
+ G_CALLBACK(jump_to_find_results),
+ NULL);
+ }
+ else {
+ g_signal_handlers_disconnect_by_func(webview,
+ jump_to_find_results,
+ NULL);
+ }
+}
+
/* Selection */
gboolean
ev_web_view_get_has_selection(EvWebView *webview)
@@ -642,6 +645,7 @@ ev_web_view_copy(EvWebView *webview)
}
+/*Zoom control*/
gboolean
ev_web_view_zoom_in(EvWebView *webview)
{
diff --git a/libview/ev-web-view.h b/libview/ev-web-view.h
index 751e7381..661ed9d0 100644
--- a/libview/ev-web-view.h
+++ b/libview/ev-web-view.h
@@ -69,10 +69,10 @@ void ev_web_view_find_changed (EvWebView *webview,
gchar *text,
gboolean case_sensitive);
-void ev_web_view_find_search_changed (EvWebView *webview,gboolean visible);
+void ev_web_view_find_search_changed (EvWebView *webview);
void ev_web_view_find_cancel (EvWebView *webview);
void ev_web_view_find_set_highlight_search (EvWebView *webview,gboolean visible);
-
+void ev_web_view_set_handler (EvWebView *webview,gboolean visible);
/* Selection */
gboolean ev_web_view_get_has_selection (EvWebView *webview);
void ev_web_view_select_all (EvWebView *webview);
diff --git a/shell/ev-window.c b/shell/ev-window.c
index d765a2d8..aab14229 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -5073,7 +5073,8 @@ ev_window_find_job_updated_cb (EvJobFind *job,
{
ev_window_update_actions (ev_window);
if (ev_window->priv->document->iswebdocument == TRUE ) {
- ev_web_view_find_changed(EV_WEB_VIEW(ev_window->priv->webview), job->results,job->text, job->case_sensitive);
+ ev_web_view_find_changed(EV_WEB_VIEW(ev_window->priv->webview),
+ job->results,job->text, job->case_sensitive);
}
else {
ev_view_find_changed (EV_VIEW (ev_window->priv->view),
@@ -5154,7 +5155,7 @@ find_bar_search_changed_cb (EggFindBar *find_bar,
search_string = egg_find_bar_get_search_string (find_bar);
if (ev_window->priv->document->iswebdocument) {
- ev_web_view_find_search_changed(EV_WEB_VIEW(ev_window->priv->webview),TRUE);
+ ev_web_view_find_search_changed(EV_WEB_VIEW(ev_window->priv->webview));
} else {
ev_view_find_search_changed (EV_VIEW (ev_window->priv->view));
}
@@ -5201,7 +5202,8 @@ find_bar_visibility_changed_cb (EggFindBar *find_bar,
}
else {
ev_web_view_find_set_highlight_search(EV_WEB_VIEW(ev_window->priv->webview),visible);
- ev_web_view_find_search_changed(EV_WEB_VIEW(ev_window->priv->webview),visible);
+ ev_web_view_find_search_changed(EV_WEB_VIEW(ev_window->priv->webview));
+ ev_web_view_set_handler(EV_WEB_VIEW(ev_window->priv->webview),visible);
}
ev_window_update_actions (ev_window);