diff options
author | rootavish <[email protected]> | 2014-08-07 17:43:55 +0530 |
---|---|---|
committer | rootavish <[email protected]> | 2014-08-07 17:43:55 +0530 |
commit | ff0a79e545356046c7145bff0630a7cd50ad977c (patch) | |
tree | 69bcf2b5c333151297378f7da28a573b0d655f5f /libview | |
parent | 65dd892279c70b31509a5e478ae6f9aa44d9cd21 (diff) | |
download | atril-ff0a79e545356046c7145bff0630a7cd50ad977c.tar.bz2 atril-ff0a79e545356046c7145bff0630a7cd50ad977c.tar.xz |
Ability to search through epub documents
You can now search through the entire epub document. In the next commit I'm adding support for webkit2 with gtk3.
Diffstat (limited to 'libview')
-rw-r--r-- | libview/ev-web-view.c | 54 | ||||
-rw-r--r-- | libview/ev-web-view.h | 4 |
2 files changed, 31 insertions, 27 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); |