+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),
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;
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;
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;
double bottom;
double right;
double zoom;
+ EvDestChange change;
gchar *named;
gchar *page_label;
};
}
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;
}
}
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;
}
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;
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;
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",
}
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));
}
}
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));
}
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,
"bottom", bottom,
"right", right,
"top", top,
+ "change", change,
NULL));
}
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);
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,
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));
{
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,
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));
{
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);
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));
{
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));