From: Nickolay V. Shmyrev Date: Wed, 1 Feb 2006 19:13:53 +0000 (+0000) Subject: Place even pages to the left if document has less then two pages. Fix for X-Git-Tag: EVINCE_0_5_1~44 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=e2137316b9264832a019b3f26411d10cb46a9598;p=evince.git Place even pages to the left if document has less then two pages. Fix for * 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. --- diff --git a/ChangeLog b/ChangeLog index c287236d..4fca3f74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-02-01 Nickolay V. Shmyrev + + * 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 * thumbnailer/evince-thumbnailer-comics.schemas.in: diff --git a/shell/ev-page-cache.c b/shell/ev-page-cache.c index 389bafca..3dd8c9a7 100644 --- a/shell/ev-page-cache.c +++ b/shell/ev-page-cache.c @@ -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) diff --git a/shell/ev-page-cache.h b/shell/ev-page-cache.h index 2886ccec..0ad20e84 100644 --- a/shell/ev-page-cache.h +++ b/shell/ev-page-cache.h @@ -23,8 +23,6 @@ #include #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__ */ diff --git a/shell/ev-view.c b/shell/ev-view.c index bf441533..dae30b9c 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -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;