From 30668ba1c42ab4facb9794e7706bec3ace58725f Mon Sep 17 00:00:00 2001 From: Wouter Bolsterlee Date: Thu, 20 Apr 2006 15:35:24 +0000 Subject: [PATCH] Add support for "Find Previous" as dictated by the GNOME HIG. A menu item 2006-04-20 Wouter Bolsterlee * 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. --- ChangeLog | 12 ++++++++++++ data/evince-ui.xml | 1 + shell/ev-view.c | 17 +++++++++++++++++ shell/ev-view.h | 3 ++- shell/ev-window.c | 12 ++++++++++++ 5 files changed, 44 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8ad2d012..74be37a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-04-20 Wouter Bolsterlee + + * 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. + 2006-04-09 Wouter Bolsterlee * configure.ac: Award myself the "useless use of cat" award. diff --git a/data/evince-ui.xml b/data/evince-ui.xml index bfd42121..213a276c 100644 --- a/data/evince-ui.xml +++ b/data/evince-ui.xml @@ -19,6 +19,7 @@ + diff --git a/shell/ev-view.c b/shell/ev-view.c index f903e20a..eb8f3292 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 dc00ff36..3ad40166 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 905fd51b..cce9d765 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)); @@ -1446,6 +1448,14 @@ ev_window_cmd_edit_find_next (GtkAction *action, EvWindow *ev_window) ev_view_find_next (EV_VIEW (ev_window->priv->view)); } +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) { @@ -2848,6 +2858,8 @@ static const GtkActionEntry entries[] = { G_CALLBACK (ev_window_cmd_edit_find) }, { "EditFindNext", NULL, N_("Find Ne_xt"), "G", NULL, G_CALLBACK (ev_window_cmd_edit_find_next) }, + { "EditFindPrevious", NULL, N_("Find Pre_vious"), "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, -- 2.43.5