From 7dca53f0824e2e24079a000289120c55540272ed Mon Sep 17 00:00:00 2001 From: "Nickolay V. Shmyrev" Date: Sat, 29 Apr 2006 12:20:26 +0000 Subject: [PATCH] =?utf8?q?Fix=20for=20the=20bug=20#312573=20=E2=80=93=20Op?= =?utf8?q?timal=20selection=20of=20current=20page=20among?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * shell/ev-view.c: (view_update_range_and_current_page), (ev_view_scroll): Fix for the bug #312573 – Optimal selection of current page among visible pages. --- ChangeLog | 8 ++++++++ configure.ac | 2 +- shell/ev-view.c | 53 ++++++++++++++++++++++++++++--------------------- 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 51ca9ad0..6dbe4653 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-04-29 Nickolay V. Shmyrev <> + + * shell/ev-view.c: (view_update_range_and_current_page), + (ev_view_scroll): + + Fix for the bug #312573 – Optimal selection of current + page among visible pages. + 2006-04-29 Nickolay V. Shmyrev <> * configure.ac: diff --git a/configure.ac b/configure.ac index 04bc517b..e6708090 100644 --- a/configure.ac +++ b/configure.ac @@ -221,7 +221,7 @@ if test "x$enable_djvu" = "xyes"; then DJVULIBRE_REQUIRED=3.5.17 -PKG_CHECK_MODULES(DJVU, ddjvuapi >= 3.5.17, enable_djvu=yes, enable_djvu=no) +PKG_CHECK_MODULES(DJVU, ddjvuapi >= $DJVULIBRE_REQUIRED, enable_djvu=yes, enable_djvu=no) if test "x$enable_djvu" = "xyes"; then AC_DEFINE([ENABLE_DJVU], [1], [Enable djvu viewer support.]) diff --git a/shell/ev-view.c b/shell/ev-view.c index eb8f3292..9925d5ab 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -424,6 +424,7 @@ static void view_update_range_and_current_page (EvView *view) { gint current_page; + gint best_current_page = -1; if (view->pending_scroll != SCROLL_TO_KEEP_POSITION) return; @@ -436,6 +437,7 @@ view_update_range_and_current_page (EvView *view) GdkRectangle current_area, unused, page_area; GtkBorder border; gboolean found = FALSE; + gint area_max, area; int i; if (!(view->vadjustment && view->hadjustment)) @@ -451,44 +453,50 @@ view_update_range_and_current_page (EvView *view) get_page_extents (view, i, &page_area, &border); if (gdk_rectangle_intersect (¤t_area, &page_area, &unused)) { - if (! found) { + area = unused.width * unused.height; + + if (!found) { + area_max = area; view->start_page = i; found = TRUE; - + best_current_page = i; + } + if (area > area_max) { + best_current_page = (area == area_max) ? MIN (i, best_current_page) : i; + area_max = area; } + view->end_page = i; } else if (found) { break; } } - } else { - if (view->dual_page) { - if (view->current_page % 2 == ev_page_cache_get_dual_even_left (view->page_cache)) { - view->start_page = view->current_page; - if (view->current_page + 1 < ev_page_cache_get_n_pages (view->page_cache)) - view->end_page = view->start_page + 1; - else - view->end_page = view->start_page; - } else { - if (view->current_page < 1) - view->start_page = view->current_page; - else - view->start_page = view->current_page - 1; - view->end_page = view->current_page; - } - } else { + } else if (view->dual_page) { + if (view->current_page % 2 == ev_page_cache_get_dual_even_left (view->page_cache)) { view->start_page = view->current_page; + if (view->current_page + 1 < ev_page_cache_get_n_pages (view->page_cache)) + view->end_page = view->start_page + 1; + else + view->end_page = view->start_page; + } else { + if (view->current_page < 1) + view->start_page = view->current_page; + else + view->start_page = view->current_page - 1; view->end_page = view->current_page; } - + } else { + view->start_page = view->current_page; + view->end_page = view->current_page; } + best_current_page = MAX (best_current_page, view->start_page); current_page = ev_page_cache_get_current_page (view->page_cache); - if (current_page < view->start_page || current_page > view->end_page) { - view->current_page = view->start_page; - ev_page_cache_set_current_page (view->page_cache, view->start_page); + if (current_page != best_current_page) { + view->current_page = best_current_page; + ev_page_cache_set_current_page (view->page_cache, best_current_page); } ev_pixbuf_cache_set_page_range (view->pixbuf_cache, @@ -646,7 +654,6 @@ ev_view_scroll (EvView *view, adjustment->upper - adjustment->page_size); gtk_adjustment_set_value (adjustment, value); - } #define MARGIN 5 -- 2.43.5