[evince/gnome-3-16] libview: Only try to move the focus to different page when the current page has a focused element



commit 557a93e9cf5bc16c0e6eed1607e3b2cc7001997d
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Thu Jun 4 12:04:01 2015 +0200

    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 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 3fc4584..84f1d49 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -6825,6 +6825,7 @@ ev_view_focus_next (EvView           *view,
 {
        EvMapping *focus_element;
        GList     *elements;
+       gboolean   had_focused_element;
 
        if (view->focused_element) {
                GList *l;
@@ -6833,9 +6834,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);
@@ -6850,6 +6853,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)) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]