[evince/gnome-3-8] center target box for /FitR jumping



commit fac1d12646b53e11f0c8f6960387ab11e975cdd6
Author: Simon Budig <simon budig de>
Date:   Sun Mar 10 01:45:49 2013 +0100

    center target box for /FitR jumping
    
    https://bugzilla.gnome.org/show_bug.cgi?id=695524

 libview/ev-view.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 5b755b3..e656db5 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -1624,7 +1624,7 @@ static void
 goto_fitr_dest (EvView *view, EvLinkDest *dest)
 {
        EvPoint doc_point;
-       gdouble zoom, left, top;
+       gdouble zoom, left, top, doc_width, doc_height;
        gboolean change_left, change_top;
        GtkAllocation allocation;
 
@@ -1633,14 +1633,21 @@ goto_fitr_dest (EvView *view, EvLinkDest *dest)
        left = ev_link_dest_get_left (dest, &change_left);
        top = ev_link_dest_get_top (dest, &change_top);
 
-       zoom = zoom_for_size_fit_page (ev_link_dest_get_right (dest) - left,
-                                      ev_link_dest_get_bottom (dest) - top,
+       doc_width = ev_link_dest_get_right (dest) - left;
+       doc_height = ev_link_dest_get_bottom (dest) - top;
+
+       zoom = zoom_for_size_fit_page (doc_width,
+                                      doc_height,
                                       allocation.width,
                                       allocation.height);
 
        ev_document_model_set_sizing_mode (view->model, EV_SIZING_FREE);
        ev_document_model_set_scale (view->model, zoom);
 
+       /* center the target box within the view */
+       left -= (allocation.width / zoom - doc_width) / 2;
+       top -= (allocation.height / zoom - doc_height) / 2;
+
        doc_point.x = change_left ? left : 0;
        doc_point.y = change_top ? top : 0;
        view->pending_point = doc_point;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]