]> www.fi.muni.cz Git - evince.git/commitdiff
Place even pages to the left if document has less then two pages. Fix for
authorNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Wed, 1 Feb 2006 19:13:53 +0000 (19:13 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Wed, 1 Feb 2006 19:13:53 +0000 (19:13 +0000)
* shell/ev-page-cache.c: (build_height_to_page),
(ev_page_cache_new), (ev_page_cache_get_max_label_chars),
(ev_page_cache_get_dual_even_left):
* shell/ev-page-cache.h:
* shell/ev-view.c: (view_update_range_and_current_page),
(get_page_y_offset), (get_page_extents):

Place even pages to the left if document has less then
two pages. Fix for the bug #328856.

ChangeLog
shell/ev-page-cache.c
shell/ev-page-cache.h
shell/ev-view.c

index c287236db25e47db1200485988508ba5973dcad0..4fca3f74b3bbc2ba3d757c1403e2f6ff246e98ee 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-02-01  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
+
+       * shell/ev-page-cache.c: (build_height_to_page),
+       (ev_page_cache_new), (ev_page_cache_get_max_label_chars),
+       (ev_page_cache_get_dual_even_left):
+       * shell/ev-page-cache.h:
+       * shell/ev-view.c: (view_update_range_and_current_page),
+       (get_page_y_offset), (get_page_extents):
+       
+       Place even pages to the left if document has less then
+       two pages. Fix for the bug #328856.
+
 2006-01-31  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
 
        * thumbnailer/evince-thumbnailer-comics.schemas.in:
index 389bafca8bd03012e66ed1e38bbb490d99871a75..3dd8c9a7f1c1c9c29174d0f0079f452a35938b89 100644 (file)
@@ -23,6 +23,7 @@ struct _EvPageCache
        gint max_label_chars;
        gboolean has_labels;
        gboolean uniform;
+       gboolean dual_even_left;
        
        double uniform_width;
        double uniform_height;
@@ -140,7 +141,7 @@ build_height_to_page (EvPageCache *page_cache)
                }
        }
 
-       if (DUAL_EVEN_LEFT && !page_cache->uniform) {
+       if (page_cache->dual_even_left && !page_cache->uniform) {
                if (!swap) {
                        saved_height = page_cache->size_cache [0].height;
                } else {
@@ -149,16 +150,16 @@ build_height_to_page (EvPageCache *page_cache)
        } else {
                saved_height = 0;
        }
-       for (i = DUAL_EVEN_LEFT; i < page_cache->n_pages + 2; i += 2) {
+       for (i = page_cache->dual_even_left; i < page_cache->n_pages + 2; i += 2) {
                if (page_cache->uniform) {
                        if (!swap) {
                                uniform_height = page_cache->uniform_height;
                        } else {
                                uniform_height = page_cache->uniform_width;
                        }
-                       page_cache->dual_height_to_page [i] = ((i + DUAL_EVEN_LEFT) / 2) * uniform_height;
+                       page_cache->dual_height_to_page [i] = ((i + page_cache->dual_even_left) / 2) * uniform_height;
                        if (i + 1 < page_cache->n_pages + 2)
-                               page_cache->dual_height_to_page [i + 1] = ((i + DUAL_EVEN_LEFT) / 2) * uniform_height;
+                               page_cache->dual_height_to_page [i + 1] = ((i + page_cache->dual_even_left) / 2) * uniform_height;
                } else {
                        if (i + 1 < page_cache->n_pages) {
                                if (!swap) {
@@ -206,6 +207,7 @@ ev_page_cache_new (EvDocument *document)
        page_cache->uniform = TRUE;
        page_cache->has_labels = FALSE;
        page_cache->n_pages = ev_document_get_n_pages (document);
+       page_cache->dual_even_left = (page_cache->n_pages > 2);
        page_cache->page_labels = g_new0 (char *, page_cache->n_pages);
        page_cache->max_width = 0;
        page_cache->max_height = 0;
@@ -469,6 +471,14 @@ ev_page_cache_get_max_label_chars (EvPageCache *page_cache)
        return page_cache->max_label_chars;
 }
 
+gboolean
+ev_page_cache_get_dual_even_left (EvPageCache *page_cache)
+{
+       g_return_val_if_fail (EV_IS_PAGE_CACHE (page_cache), 0);
+       
+       return page_cache->dual_even_left;
+}
+
 gchar *
 ev_page_cache_get_page_label (EvPageCache *page_cache,
                              gint         page)
index 2886ccec0693dd780195e96445f8568234592adb..0ad20e84aadcb0a6184f3875deb9612987984f74 100644 (file)
@@ -23,8 +23,6 @@
 #include <gtk/gtkwidget.h>
 #include "ev-document.h"
 
-#define DUAL_EVEN_LEFT 1
-
 G_BEGIN_DECLS
 #define EV_TYPE_PAGE_CACHE            (ev_page_cache_get_type ())
 #define EV_PAGE_CACHE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), EV_TYPE_PAGE_CACHE, EvPageCache))
@@ -62,6 +60,8 @@ char          *ev_page_cache_get_page_label      (EvPageCache   *page_cache,
 gboolean       ev_page_cache_has_nonnumeric_page_labels (EvPageCache *page_cache);
 const EvDocumentInfo *ev_page_cache_get_info            (EvPageCache *page_cache);
 
+gboolean       ev_page_cache_get_dual_even_left  (EvPageCache *page_cache);
+
 /* Navigation */
 gint           ev_page_cache_get_current_page    (EvPageCache *page_cache);
 void           ev_page_cache_set_current_page    (EvPageCache *page_cache,
@@ -71,6 +71,7 @@ gboolean       ev_page_cache_set_page_label      (EvPageCache *page_cache,
 
 EvPageCache   *ev_page_cache_get                (EvDocument *document);
 
+
 G_END_DECLS
 
 #endif /* __EV_PAGE_CACHE_H__ */
index bf441533ff45c2df43ebd075fa58d9779b266404..dae30b9c38a51d7c2bf3e97fc6b3a4ab2fe72b1c 100644 (file)
@@ -462,7 +462,7 @@ view_update_range_and_current_page (EvView *view)
 
        } else {
                if (view->dual_page) {
-                       if (view->current_page % 2 == DUAL_EVEN_LEFT) {
+                       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;
@@ -731,7 +731,7 @@ get_page_y_offset (EvView *view, int page, double zoom, int *y_offset)
        if (view->dual_page) {
                ev_page_cache_get_height_to_page (view->page_cache, page,
                                                  view->rotation, zoom, NULL, &offset);
-               offset += ((page + DUAL_EVEN_LEFT) / 2 + 1) * view->spacing + ((page + DUAL_EVEN_LEFT) / 2 ) * (border.top + border.bottom);
+               offset += ((page + ev_page_cache_get_dual_even_left (view->page_cache)) / 2 + 1) * view->spacing + ((page + ev_page_cache_get_dual_even_left (view->page_cache)) / 2 ) * (border.top + border.bottom);
        } else {
                ev_page_cache_get_height_to_page (view->page_cache, page,
                                                  view->rotation, zoom, &offset, NULL);
@@ -774,9 +774,9 @@ get_page_extents (EvView       *view,
                max_width = max_width + border->left + border->right;
                /* Get the location of the bounding box */
                if (view->dual_page) {
-                       x = view->spacing + ((page % 2 == DUAL_EVEN_LEFT) ? 0 : 1) * (max_width + view->spacing);
+                       x = view->spacing + ((page % 2 == ev_page_cache_get_dual_even_left (view->page_cache)) ? 0 : 1) * (max_width + view->spacing);
                        x = x + MAX (0, widget->allocation.width - (max_width * 2 + view->spacing * 3)) / 2;
-                       if (page % 2 == DUAL_EVEN_LEFT)
+                       if (page % 2 == ev_page_cache_get_dual_even_left (view->page_cache))
                                x = x + (max_width - width - border->left - border->right);
                } else {
                        x = view->spacing;
@@ -796,7 +796,7 @@ get_page_extents (EvView       *view,
                        GtkBorder overall_border;
                        gint other_page;
 
-                       other_page = (page % 2 == DUAL_EVEN_LEFT) ? page + 1: page - 1;
+                       other_page = (page % 2 == ev_page_cache_get_dual_even_left (view->page_cache)) ? page + 1: page - 1;
 
                        /* First, we get the bounding box of the two pages */
                        if (other_page < ev_page_cache_get_n_pages (view->page_cache)
@@ -818,7 +818,7 @@ get_page_extents (EvView       *view,
                        y = view->spacing;
 
                        /* Adjust for being the left or right page */
-                       if (page % 2 == DUAL_EVEN_LEFT)
+                       if (page % 2 == ev_page_cache_get_dual_even_left (view->page_cache))
                                x = x + max_width - width;
                        else
                                x = x + (max_width + overall_border.left + overall_border.right) + view->spacing;