]> www.fi.muni.cz Git - evince.git/commitdiff
Fix for the bug #312573 – Optimal selection of current page among
authorNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Sat, 29 Apr 2006 12:20:26 +0000 (12:20 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Sat, 29 Apr 2006 12:20:26 +0000 (12:20 +0000)
* 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
configure.ac
shell/ev-view.c

index 51ca9ad0349bc4d999d1edc8e63da11e26037e79..6dbe465366a6a832be4970f3b68ca525863aff44 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-04-29  Nickolay V. Shmyrev  <<nshmyrev@yandex.ru>>
+
+       * 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  <<nshmyrev@yandex.ru>>
 
        * configure.ac:
index 04bc517b2b2423be38e91337cc7a876cd57dac9a..e670809097efc96f62e5c7bd087f1de765cac811 100644 (file)
@@ -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.])
index eb8f3292455d8e56dfa2552c918481c0d26bbaa2..9925d5abc072fb1dbc12bddb41c83c4f717d48ce 100644 (file)
@@ -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 (&current_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