summaryrefslogtreecommitdiff
path: root/libview/ev-view.c
diff options
context:
space:
mode:
authorCarlos Garcia Campos <[email protected]>2013-06-13 21:00:48 +0200
committerraveit65 <[email protected]>2017-09-06 18:25:34 +0200
commitb346e03c34b05f8607b7802f0f40b7f0b96e6916 (patch)
treef6249043412fb19d9165b9ecab96d47a4e9bf36a /libview/ev-view.c
parent387b00d43a02761833a43f5072b9599d8d237e80 (diff)
downloadatril-b346e03c34b05f8607b7802f0f40b7f0b96e6916.tar.bz2
atril-b346e03c34b05f8607b7802f0f40b7f0b96e6916.tar.xz
libview: Actually update the page when moving the care from a different page
I removed the line to set the current page after moving the caret cursor by mistake. Add it back and change cursor_go_to_next/previous_page to not update the page, but only update the cursor_page so that we have a single place where the page is updated after caret cursor moves. origin commit: https://git.gnome.org/browse/evince/commit/?h=gnome-3-10&id=bf85030
Diffstat (limited to 'libview/ev-view.c')
-rw-r--r--libview/ev-view.c65
1 files changed, 43 insertions, 22 deletions
diff --git a/libview/ev-view.c b/libview/ev-view.c
index d2c5a807..7184cab1 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -4843,7 +4843,7 @@ ev_view_forward_key_event_to_focused_child (EvView *view,
return handled;
}
-static gboolean
+static gint
go_to_next_page (EvView *view,
gint page)
{
@@ -4851,7 +4851,7 @@ go_to_next_page (EvView *view,
gboolean dual_page;
if (!view->document)
- return FALSE;
+ return -1;
n_pages = ev_document_get_n_pages (view->document);
@@ -4859,35 +4859,33 @@ go_to_next_page (EvView *view,
page += dual_page ? 2 : 1;
if (page < n_pages)
- ev_document_model_set_page (view->model, page);
- else if (dual_page && page == n_pages)
- ev_document_model_set_page (view->model, page - 1);
- else
- return FALSE;
+ return page;
- return TRUE;
+ if (dual_page && page == n_pages)
+ return page - 1;
+
+ return -1;
}
-static gboolean
+static gint
go_to_previous_page (EvView *view,
gint page)
{
gboolean dual_page;
if (!view->document)
- return FALSE;
+ return -1;
dual_page = is_dual_page (view, NULL);
page -= dual_page ? 2 : 1;
if (page >= 0)
- ev_document_model_set_page (view->model, page);
- else if (dual_page && page == -1)
- ev_document_model_set_page (view->model, 0);
- else
- return FALSE;
+ return page;
- return TRUE;
+ if (dual_page && page == -1)
+ return 0;
+
+ return -1;
}
static gboolean
@@ -4919,8 +4917,11 @@ cursor_go_to_page_end (EvView *view)
static gboolean
cursor_go_to_next_page (EvView *view)
{
- if (go_to_next_page (view, view->cursor_page)) {
- view->cursor_page = ev_document_model_get_page (view->model);
+ gint new_page;
+
+ new_page = go_to_next_page (view, view->cursor_page);
+ if (new_page != -1) {
+ view->cursor_page = new_page;
return cursor_go_to_page_start (view);
}
@@ -4930,8 +4931,11 @@ cursor_go_to_next_page (EvView *view)
static gboolean
cursor_go_to_previous_page (EvView *view)
{
- if (go_to_previous_page (view, view->cursor_page)) {
- view->cursor_page = ev_document_model_get_page (view->model);
+ gint new_page;
+
+ new_page = go_to_previous_page (view, view->cursor_page);
+ if (new_page != -1) {
+ view->cursor_page = new_page;
return cursor_go_to_page_end (view);
}
return FALSE;
@@ -5187,6 +5191,7 @@ caret_key_press_event (EvView *view,
if (!get_caret_cursor_rect_from_offset (view, view->cursor_offset, view->cursor_page, &view_rect))
return TRUE;
+ ev_document_model_set_page (view->model, view->cursor_page);
ensure_rectangle_is_visible (view, &view_rect);
gtk_widget_queue_draw (GTK_WIDGET (view));
}
@@ -7647,17 +7652,33 @@ ev_view_show_cursor (EvView *view)
gboolean
ev_view_next_page (EvView *view)
{
+ gint next_page;
+
g_return_val_if_fail (EV_IS_VIEW (view), FALSE);
- return go_to_next_page (view, view->current_page);
+ next_page = go_to_next_page (view, view->current_page);
+ if (next_page == -1)
+ return FALSE;
+
+ ev_document_model_set_page (view->model, next_page);
+
+ return TRUE;
}
gboolean
ev_view_previous_page (EvView *view)
{
+ gint prev_page;
+
g_return_val_if_fail (EV_IS_VIEW (view), FALSE);
- return go_to_previous_page (view, view->current_page);
+ prev_page = go_to_previous_page (view, view->current_page);
+ if (prev_page == -1)
+ return FALSE;
+
+ ev_document_model_set_page (view->model, prev_page);
+
+ return TRUE;
}
/**