From 0d5846e1e2e5c0373c171ac23838cd54b0750326 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Thu, 4 Jun 2015 12:04:01 +0200 Subject: [PATCH] libview: Only try to move the focus to different page when the current page has a focused element This prevents the view from jumping to the first/last page when there are not focusable elements. https://bugzilla.gnome.org/show_bug.cgi?id=741979 --- libview/ev-view.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libview/ev-view.c b/libview/ev-view.c index a9159cd..6098fc0 100644 --- a/libview/ev-view.c +++ b/libview/ev-view.c @@ -6814,6 +6814,7 @@ ev_view_focus_next (EvView *view, { EvMapping *focus_element; GList *elements; + gboolean had_focused_element; if (view->focused_element) { GList *l; @@ -6822,9 +6823,11 @@ ev_view_focus_next (EvView *view, l = g_list_find (elements, view->focused_element); l = g_list_next (l); focus_element = l ? l->data : NULL; + had_focused_element = TRUE; } else { elements = ev_view_get_sorted_mapping_list (view, direction, view->current_page); focus_element = elements ? elements->data : NULL; + had_focused_element = FALSE; } g_list_free (elements); @@ -6839,6 +6842,13 @@ ev_view_focus_next (EvView *view, ev_view_remove_all (view); _ev_view_set_focused_element (view, NULL, -1); + /* Only try to move the focus to next/previous pages when the current page had + * a focused element. This prevents the view from jumping to the first/last page + * when there are not focusable elements. + */ + if (!had_focused_element) + return FALSE; + /* FIXME: this doesn't work if the next/previous page doesn't have form fields */ if (direction == GTK_DIR_TAB_FORWARD) { if (ev_view_next_page (view)) { -- 2.5.0