diff options
author | Wouter Bolsterlee <uws+gnome@xs4all.nl> | 2006-04-20 15:35:24 (GMT) |
---|---|---|
committer | Wouter Bolsterlee <wbolster@src.gnome.org> | 2006-04-20 15:35:24 (GMT) |
commit | 30668ba1c42ab4facb9794e7706bec3ace58725f (patch) | |
tree | af26ae3a24154abcf6b2da9ec1d30223bf5e2db0 /shell | |
parent | afd118ec954f98602ccc896af0f6200598284016 (diff) |
Add support for "Find Previous" as dictated by the GNOME HIG. A menu item
2006-04-20 Wouter Bolsterlee <uws+gnome@xs4all.nl>
* data/evince-ui.xml:
* shell/ev-view.c: (ev_view_can_find_previous):
* shell/ev-view.h:
* shell/ev-window.c: (ev_window_update_actions),
(ev_window_cmd_edit_find_previous):
Add support for "Find Previous" as dictated by the GNOME HIG. A
menu item is added and some glue code to make it all work is added
to various files.
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ev-view.c | 17 | ||||
-rw-r--r-- | shell/ev-view.h | 3 | ||||
-rw-r--r-- | shell/ev-window.c | 12 |
3 files changed, 31 insertions, 1 deletions
diff --git a/shell/ev-view.c b/shell/ev-view.c index f903e20..eb8f329 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -3430,6 +3430,23 @@ ev_view_find_next (EvView *view) } } +gboolean +ev_view_can_find_previous (EvView *view) +{ + if (EV_IS_DOCUMENT_FIND (view->document)) { + EvDocumentFind *find = EV_DOCUMENT_FIND (view->document); + int i, n_pages; + + n_pages = ev_page_cache_get_n_pages (view->page_cache); + for (i = n_pages - 1; i >= 0; i--) { + if (ev_document_find_get_n_results (find, i) > 0) { + return TRUE; + } + } + } + + return FALSE; +} void ev_view_find_previous (EvView *view) { diff --git a/shell/ev-view.h b/shell/ev-view.h index dc00ff3..3ad4016 100644 --- a/shell/ev-view.h +++ b/shell/ev-view.h @@ -119,8 +119,9 @@ void ev_view_set_rotation (EvView *view, int ev_view_get_rotation (EvView *view); /* Find */ -gboolean ev_view_can_find_next (EvView *view); +gboolean ev_view_can_find_next (EvView *view); void ev_view_find_next (EvView *view); +gboolean ev_view_can_find_previous (EvView *view); void ev_view_find_previous (EvView *view); void ev_view_search_changed (EvView *view); diff --git a/shell/ev-window.c b/shell/ev-window.c index 905fd51..cce9d76 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -335,6 +335,8 @@ ev_window_update_actions (EvWindow *ev_window) ev_window_set_action_sensitive (ev_window, "EditCopy", has_pages && ev_view_get_has_selection (view)); ev_window_set_action_sensitive (ev_window, "EditFindNext", ev_view_can_find_next (view)); + ev_window_set_action_sensitive (ev_window, "EditFindPrevious", + ev_view_can_find_previous (view)); ev_window_set_action_sensitive (ev_window, "ViewZoomIn", has_pages && ev_view_can_zoom_in (view)); @@ -1447,6 +1449,14 @@ ev_window_cmd_edit_find_next (GtkAction *action, EvWindow *ev_window) } static void +ev_window_cmd_edit_find_previous (GtkAction *action, EvWindow *ev_window) +{ + g_return_if_fail (EV_IS_WINDOW (ev_window)); + + ev_view_find_previous (EV_VIEW (ev_window->priv->view)); +} + +static void ev_window_cmd_edit_copy (GtkAction *action, EvWindow *ev_window) { g_return_if_fail (EV_IS_WINDOW (ev_window)); @@ -2848,6 +2858,8 @@ static const GtkActionEntry entries[] = { G_CALLBACK (ev_window_cmd_edit_find) }, { "EditFindNext", NULL, N_("Find Ne_xt"), "<control>G", NULL, G_CALLBACK (ev_window_cmd_edit_find_next) }, + { "EditFindPrevious", NULL, N_("Find Pre_vious"), "<shift><control>G", NULL, + G_CALLBACK (ev_window_cmd_edit_find_previous) }, { "EditToolbar", NULL, N_("T_oolbar"), NULL, NULL, G_CALLBACK (ev_window_cmd_edit_toolbar) }, { "EditRotateLeft", NULL, N_("Rotate _Left"), NULL, NULL, |