[evince] libview: Only try to move the focus to different page when the current page has a focused element



commit 0d5846e1e2e5c0373c171ac23838cd54b0750326
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 d3f8469..9a99954 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -7096,6 +7096,7 @@ ev_view_focus_next (EvView           *view,
 {
        EvMapping *focus_element;
        GList     *elements;
+       gboolean   had_focused_element;
 
        if (view->focused_element) {
                GList *l;
@@ -7104,9 +7105,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);
@@ -7121,6 +7124,13 @@ ev_view_focus_next (EvView           *view,
        ev_view_remove_all_form_fields (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]