]> www.fi.muni.cz Git - evince.git/commitdiff
Do not change left, top and zoom values when they are null in PDF
authorCarlos Garcia Campos <carlosgc@gnome.org>
Fri, 14 Dec 2007 11:12:20 +0000 (11:12 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Fri, 14 Dec 2007 11:12:20 +0000 (11:12 +0000)
2007-12-14  Carlos Garcia Campos  <carlosgc@gnome.org>
* backend/pdf/ev-poppler.cc: (ev_link_dest_from_dest):
* libdocument/ev-link-dest.[ch]: (ev_link_dest_get_top),
(ev_link_dest_get_left), (ev_link_dest_get_zoom),
(ev_link_dest_get_property), (ev_link_dest_set_property),
(ev_link_dest_class_init), (ev_link_dest_new_xyz),
(ev_link_dest_new_fith), (ev_link_dest_new_fitv),
(ev_link_dest_new_fitr):
* shell/ev-view.c: (goto_fitr_dest), (goto_fitv_dest),
(goto_fith_dest), (goto_xyz_dest):
Do not change left, top and zoom values when they are null in PDF
destinations. Fixes bug #460658.

svn path=/trunk/; revision=2769

ChangeLog
backend/pdf/ev-poppler.cc
libdocument/ev-link-dest.c
libdocument/ev-link-dest.h
shell/ev-view.c

index a7c0b674cf776f9cedf54b01307ab7e676879b91..4b96411ecf40cecf2b8d501303fef9329a31517f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2007-12-14  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * backend/pdf/ev-poppler.cc: (ev_link_dest_from_dest):
+       * libdocument/ev-link-dest.[ch]: (ev_link_dest_get_top),
+       (ev_link_dest_get_left), (ev_link_dest_get_zoom),
+       (ev_link_dest_get_property), (ev_link_dest_set_property),
+       (ev_link_dest_class_init), (ev_link_dest_new_xyz),
+       (ev_link_dest_new_fith), (ev_link_dest_new_fitv),
+       (ev_link_dest_new_fitr):
+       * shell/ev-view.c: (goto_fitr_dest), (goto_fitv_dest),
+       (goto_fith_dest), (goto_xyz_dest):
+
+       Do not change left, top and zoom values when they are null in PDF
+       destinations. Fixes bug #460658.
+       
 2007-12-10  Christian Persch  <chpe@gnome.org>
 
        * shell/ev-view-accessible.c: (ev_view_accessible_finalize),
index c4baa99f9956fe5803517a94a58e84ad2d67730e..690c90810412c7ba592c242c53c448d2e3447c3d 100644 (file)
@@ -859,7 +859,10 @@ ev_link_dest_from_dest (PdfDocument *pdf_document,
                        ev_dest = ev_link_dest_new_xyz (dest->page_num - 1,
                                                        dest->left,
                                                        height - dest->top,
-                                                       dest->zoom);
+                                                       dest->zoom,
+                                                       dest->change_left,
+                                                       dest->change_top,
+                                                       dest->change_zoom);
                        g_object_unref (poppler_page);
                }
                        break;
@@ -874,13 +877,15 @@ ev_link_dest_from_dest (PdfDocument *pdf_document,
                                                                  MAX (0, dest->page_num - 1));
                        poppler_page_get_size (poppler_page, NULL, &height);
                        ev_dest = ev_link_dest_new_fith (dest->page_num - 1,
-                                                        height - dest->top);
+                                                        height - dest->top,
+                                                        dest->change_top);
                        g_object_unref (poppler_page);
                }
                        break;
                case POPPLER_DEST_FITV:
                        ev_dest = ev_link_dest_new_fitv (dest->page_num - 1,
-                                                        dest->left);
+                                                        dest->left,
+                                                        dest->change_left);
                        break;
                case POPPLER_DEST_FITR: {
                        PopplerPage *poppler_page;
index 09f840afb2079d1f98a3d4ddeb5d6b77e86cbfad..7d04649d08c64856df946d5ba8b0c0effeb4169e 100644 (file)
@@ -29,10 +29,17 @@ enum {
        PROP_BOTTOM,
        PROP_RIGHT,
        PROP_ZOOM,
+       PROP_CHANGE,
        PROP_NAMED,
        PROP_PAGE_LABEL
 };
 
+typedef enum {
+       EV_DEST_CHANGE_TOP    = 1 << 0,
+       EV_DEST_CHANGE_LEFT   = 1 << 1,
+       EV_DEST_CHANGE_ZOOM   = 1 << 2
+} EvDestChange;
+
 struct _EvLinkDest {
        GObject base_instance;
        
@@ -51,6 +58,7 @@ struct _EvLinkDestPrivate {
        double         bottom;
        double         right;
        double         zoom;
+       EvDestChange   change;
        gchar         *named;
        gchar         *page_label;
 };
@@ -102,18 +110,26 @@ ev_link_dest_get_page (EvLinkDest *self)
 }
 
 gdouble
-ev_link_dest_get_top (EvLinkDest *self)
+ev_link_dest_get_top (EvLinkDest *self,
+                     gboolean   *change_top)
 {
        g_return_val_if_fail (EV_IS_LINK_DEST (self), 0);
 
+       if (change_top)
+               *change_top = (self->priv->change & EV_DEST_CHANGE_TOP);
+       
        return self->priv->top;
 }
 
 gdouble
-ev_link_dest_get_left (EvLinkDest *self)
+ev_link_dest_get_left (EvLinkDest *self,
+                      gboolean   *change_left)
 {
        g_return_val_if_fail (EV_IS_LINK_DEST (self), 0);
 
+       if (change_left)
+               *change_left = (self->priv->change & EV_DEST_CHANGE_LEFT);
+
        return self->priv->left;
 }
 
@@ -134,10 +150,14 @@ ev_link_dest_get_right (EvLinkDest *self)
 }
 
 gdouble
-ev_link_dest_get_zoom (EvLinkDest *self)
+ev_link_dest_get_zoom (EvLinkDest *self,
+                      gboolean   *change_zoom)
 {
        g_return_val_if_fail (EV_IS_LINK_DEST (self), 0);
 
+       if (change_zoom)
+               *change_zoom = (self->priv->change & EV_DEST_CHANGE_ZOOM);
+
        return self->priv->zoom;
 }
 
@@ -189,6 +209,9 @@ ev_link_dest_get_property (GObject    *object,
                case PROP_ZOOM:
                        g_value_set_double (value, self->priv->zoom);
                        break;
+               case PROP_CHANGE:
+                       g_value_set_uint (value, self->priv->change);
+                       break;
                case PROP_NAMED:
                        g_value_set_string (value, self->priv->named);
                        break;
@@ -233,6 +256,9 @@ ev_link_dest_set_property (GObject      *object,
                case PROP_ZOOM:
                        self->priv->zoom = g_value_get_double (value);
                        break;
+               case PROP_CHANGE:
+                       self->priv->change = g_value_get_uint (value);
+                       break;
                case PROP_NAMED:
                        self->priv->named = g_value_dup_string (value);
                        break;
@@ -358,6 +384,16 @@ ev_link_dest_class_init (EvLinkDestClass *ev_link_dest_class)
                                                              0,
                                                              G_PARAM_READWRITE |
                                                              G_PARAM_CONSTRUCT_ONLY));
+       g_object_class_install_property (g_object_class,
+                                        PROP_CHANGE,
+                                        g_param_spec_uint ("change",
+                                                           "Change",
+                                                           "Wether top, left, and zoom should be changed",
+                                                           0,
+                                                           G_MAXUINT,
+                                                           0,
+                                                           G_PARAM_READWRITE |
+                                                           G_PARAM_CONSTRUCT_ONLY));
        g_object_class_install_property (g_object_class,
                                         PROP_NAMED,
                                         g_param_spec_string ("named",
@@ -386,17 +422,30 @@ ev_link_dest_new_page (gint page)
 }
 
 EvLinkDest *
-ev_link_dest_new_xyz (gint    page,
-                     gdouble left,
-                     gdouble top,
-                     gdouble zoom)
+ev_link_dest_new_xyz (gint     page,
+                     gdouble  left,
+                     gdouble  top,
+                     gdouble  zoom,
+                     gboolean change_left,
+                     gboolean change_top,
+                     gboolean change_zoom)
 {
+       EvDestChange change = 0;
+
+       if (change_left)
+               change |= EV_DEST_CHANGE_LEFT;
+       if (change_top)
+               change |= EV_DEST_CHANGE_TOP;
+       if (change_zoom)
+               change |= EV_DEST_CHANGE_ZOOM;
+       
        return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
                                           "page", page,
                                           "type", EV_LINK_DEST_TYPE_XYZ,
                                           "left", left,
                                           "top", top,
                                           "zoom", zoom,
+                                          "change", change,
                                           NULL));
 }
 
@@ -410,24 +459,38 @@ ev_link_dest_new_fit (gint page)
 }
 
 EvLinkDest *
-ev_link_dest_new_fith (gint    page,
-                      gdouble top)
+ev_link_dest_new_fith (gint     page,
+                      gdouble  top,
+                      gboolean change_top)
 {
+       EvDestChange change = 0;
+
+       if (change_top)
+               change |= EV_DEST_CHANGE_TOP;
+       
        return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
                                           "page", page,
                                           "type", EV_LINK_DEST_TYPE_FITH,
                                           "top", top,
+                                          "change", change,
                                           NULL));
 }
 
 EvLinkDest *
-ev_link_dest_new_fitv (gint    page,
-                      gdouble left)
+ev_link_dest_new_fitv (gint     page,
+                      gdouble  left,
+                      gboolean change_left)
 {
+       EvDestChange change = 0;
+
+       if (change_left)
+               change |= EV_DEST_CHANGE_LEFT;
+
        return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
                                           "page", page,
                                           "type", EV_LINK_DEST_TYPE_FITV,
                                           "left", left,
+                                          "change", change,
                                           NULL));
 }
 
@@ -438,6 +501,8 @@ ev_link_dest_new_fitr (gint    page,
                       gdouble right,
                       gdouble top)
 {
+       EvDestChange change = EV_DEST_CHANGE_TOP | EV_DEST_CHANGE_LEFT;
+       
        return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST,
                                           "page", page,
                                           "type", EV_LINK_DEST_TYPE_FITR,
@@ -445,6 +510,7 @@ ev_link_dest_new_fitr (gint    page,
                                           "bottom", bottom,
                                           "right", right,
                                           "top", top,
+                                          "change", change,
                                           NULL));
 }
 
index a0c96f5818eba3004f0559f0f439bc6a763756bd..a7ee05951b87fbbf703563f5783666e55bed684d 100644 (file)
@@ -55,11 +55,14 @@ GType           ev_link_dest_get_type       (void) G_GNUC_CONST;
 
 EvLinkDestType  ev_link_dest_get_dest_type  (EvLinkDest  *self);
 gint            ev_link_dest_get_page       (EvLinkDest  *self);
-gdouble         ev_link_dest_get_top        (EvLinkDest  *self);
-gdouble         ev_link_dest_get_left       (EvLinkDest  *self);
+gdouble         ev_link_dest_get_top        (EvLinkDest  *self,
+                                            gboolean    *change_top);
+gdouble         ev_link_dest_get_left       (EvLinkDest  *self,
+                                            gboolean    *change_left);
 gdouble         ev_link_dest_get_bottom     (EvLinkDest  *self);
 gdouble         ev_link_dest_get_right      (EvLinkDest  *self);
-gdouble         ev_link_dest_get_zoom       (EvLinkDest  *self);
+gdouble         ev_link_dest_get_zoom       (EvLinkDest  *self,
+                                            gboolean    *change_zoom);
 const gchar    *ev_link_dest_get_named_dest (EvLinkDest  *self);
 const gchar    *ev_link_dest_get_page_label (EvLinkDest  *self);
 
@@ -67,12 +70,17 @@ EvLinkDest     *ev_link_dest_new_page       (gint         page);
 EvLinkDest     *ev_link_dest_new_xyz        (gint         page,
                                             gdouble      left,
                                             gdouble      top,
-                                            gdouble      zoom);
+                                            gdouble      zoom,
+                                            gboolean     change_left,
+                                            gboolean     change_top,
+                                            gboolean     change_zoom);
 EvLinkDest     *ev_link_dest_new_fit        (gint         page);
 EvLinkDest     *ev_link_dest_new_fith       (gint         page,
-                                            gdouble      top);
+                                            gdouble      top,
+                                            gboolean     change_top);
 EvLinkDest     *ev_link_dest_new_fitv       (gint         page,
-                                            gdouble      left);
+                                            gdouble      left,
+                                            gboolean     change_left);
 EvLinkDest     *ev_link_dest_new_fitr       (gint         page,
                                             gdouble      left,
                                             gdouble      bottom,
index b1ec0569c0deafc133db1e5c1672fd85589cffa8..a6007c911897f83665166ce0f5c98cc3b1b9f70f 100644 (file)
@@ -1154,21 +1154,26 @@ static void
 goto_fitr_dest (EvView *view, EvLinkDest *dest)
 {
        EvPoint doc_point;
-       double zoom;
+       gdouble zoom, left, top;
+       gboolean change_left, change_top;
+
+       left = ev_link_dest_get_left (dest, &change_left);
+       top = ev_link_dest_get_top (dest, &change_top);
 
-       zoom = zoom_for_size_best_fit (ev_link_dest_get_right (dest) - ev_link_dest_get_left (dest),
-                                      ev_link_dest_get_bottom (dest) - ev_link_dest_get_top (dest),
+       zoom = zoom_for_size_best_fit (ev_link_dest_get_right (dest) - left,
+                                      ev_link_dest_get_bottom (dest) - top,
                                       ev_view_get_width (view),
                                       ev_view_get_height (view), 0, 0);
 
        ev_view_set_sizing_mode (view, EV_SIZING_FREE);
        ev_view_set_zoom (view, zoom, FALSE);
 
-       doc_point.x = ev_link_dest_get_left (dest);
-       doc_point.y = ev_link_dest_get_top (dest);
+       doc_point.x = change_left ? left : 0;
+       doc_point.y = change_top ? top : 0;
        
        view->current_page = ev_link_dest_get_page (dest);
-       view->pending_point = doc_point;
+       if (change_left || change_top)
+               view->pending_point = doc_point;
        view->pending_scroll = SCROLL_TO_PAGE_POSITION;
 
        gtk_widget_queue_resize (GTK_WIDGET (view));
@@ -1179,12 +1184,14 @@ goto_fitv_dest (EvView *view, EvLinkDest *dest)
 {
        EvPoint doc_point;
        int doc_width, doc_height, page;
-       double zoom;
+       double zoom, left;
+       gboolean change_left;
 
        page = ev_link_dest_get_page (dest);
        ev_page_cache_get_size (view->page_cache, page, 0, 1.0, &doc_width, &doc_height);
 
-       doc_point.x = ev_link_dest_get_left (dest);
+       left = ev_link_dest_get_left (dest, &change_left);
+       doc_point.x = change_left ? left : 0;
        doc_point.y = 0;
 
        zoom = zoom_for_size_fit_height (doc_width - doc_point.x , doc_height,
@@ -1195,7 +1202,8 @@ goto_fitv_dest (EvView *view, EvLinkDest *dest)
        ev_view_set_zoom (view, zoom, FALSE);
 
        view->current_page = page;
-       view->pending_point = doc_point;
+       if (change_left)
+               view->pending_point = doc_point;
        view->pending_scroll = SCROLL_TO_PAGE_POSITION;
 
        gtk_widget_queue_resize (GTK_WIDGET (view));
@@ -1206,15 +1214,18 @@ goto_fith_dest (EvView *view, EvLinkDest *dest)
 {
        EvPoint doc_point;
        int doc_width, doc_height, page;
-       double zoom;
+       gdouble zoom, top;
+       gboolean change_top;
 
        page = ev_link_dest_get_page (dest);
        ev_page_cache_get_size (view->page_cache, page, 0, 1.0, &doc_width, &doc_height);
 
+       top = ev_link_dest_get_top (dest, &change_top);
+
        doc_point.x = 0;
-       doc_point.y = ev_link_dest_get_top (dest);
+       doc_point.y = change_top ? top : 0;
 
-       zoom = zoom_for_size_fit_width (doc_width, ev_link_dest_get_top (dest),
+       zoom = zoom_for_size_fit_width (doc_width, top,
                                        ev_view_get_width (view),
                                        ev_view_get_height (view), 0);
 
@@ -1222,7 +1233,8 @@ goto_fith_dest (EvView *view, EvLinkDest *dest)
        ev_view_set_zoom (view, zoom, FALSE);
 
        view->current_page = page;
-       view->pending_point = doc_point;
+       if (change_top)
+               view->pending_point = doc_point;
        view->pending_scroll = SCROLL_TO_PAGE_POSITION;
 
        gtk_widget_queue_resize (GTK_WIDGET (view));
@@ -1255,21 +1267,26 @@ goto_xyz_dest (EvView *view, EvLinkDest *dest)
 {
        EvPoint doc_point;
        gint page;
-       double zoom;
+       gdouble zoom, left, top;
+       gboolean change_zoom, change_left, change_top; 
 
-       zoom = ev_link_dest_get_zoom (dest);
+       zoom = ev_link_dest_get_zoom (dest, &change_zoom);
        page = ev_link_dest_get_page (dest);
 
-       if (zoom > 1) {
+       if (change_zoom && zoom > 1) {
                ev_view_set_sizing_mode (view, EV_SIZING_FREE);
                ev_view_set_zoom (view, zoom, FALSE);
        }
 
-       doc_point.x = ev_link_dest_get_left (dest);
-       doc_point.y = ev_link_dest_get_top (dest);
+       left = ev_link_dest_get_left (dest, &change_left);
+       top = ev_link_dest_get_top (dest, &change_top);
+
+       doc_point.x = change_left ? left : 0;
+       doc_point.y = change_top ? top : 0;
 
        view->current_page = page;
-       view->pending_point = doc_point;
+       if (change_left || change_top)
+               view->pending_point = doc_point;
        view->pending_scroll = SCROLL_TO_PAGE_POSITION;
 
        gtk_widget_queue_resize (GTK_WIDGET (view));