+2005-09-24 Marco Pesenti Gritti <mpg@redhat.com>
+
+ * backend/ev-link.c: (ev_link_type_get_type), (ev_link_get_bottom),
+ (ev_link_get_right), (ev_link_get_property),
+ (ev_link_set_property), (ev_link_class_init),
+ (ev_link_new_page_fitv), (ev_link_new_page_fitr):
+ * backend/ev-link.h:
+ * pdf/ev-poppler.cc:
+ * shell/ev-view.c: (goto_fitr_link), (ev_view_goto_link):
+
+ Implement fitr links
+
2005-09-24 Marco Pesenti Gritti <mpg@redhat.com>
* shell/ev-view.c: (ev_view_get_width), (ev_view_get_height),
PROP_URI,
PROP_LEFT,
PROP_TOP,
+ PROP_BOTTOM,
+ PROP_RIGHT,
PROP_ZOOM
};
int page;
double top;
double left;
+ double bottom;
+ double right;
double zoom;
};
{ EV_LINK_TYPE_PAGE_FIT, "EV_LINK_TYPE_PAGE_FIT", "page-fit" },
{ EV_LINK_TYPE_PAGE_FITH, "EV_LINK_TYPE_PAGE_FITH", "page-fith" },
{ EV_LINK_TYPE_PAGE_FITV, "EV_LINK_TYPE_PAGE_FITV", "page-fitv" },
+ { EV_LINK_TYPE_PAGE_FITR, "EV_LINK_TYPE_PAGE_FITR", "page-fitr" },
{ EV_LINK_TYPE_EXTERNAL_URI, "EV_LINK_TYPE_EXTERNAL_URI", "external" },
{ 0, NULL, NULL }
};
return self->priv->left;
}
+double
+ev_link_get_bottom (EvLink *self)
+{
+ g_return_val_if_fail (EV_IS_LINK (self), 0);
+
+ return self->priv->bottom;
+}
+
+double
+ev_link_get_right (EvLink *self)
+{
+ g_return_val_if_fail (EV_IS_LINK (self), 0);
+
+ return self->priv->right;
+}
+
double
ev_link_get_zoom (EvLink *self)
{
case PROP_LEFT:
g_value_set_double (value, self->priv->left);
break;
+ case PROP_BOTTOM:
+ g_value_set_double (value, self->priv->bottom);
+ break;
+ case PROP_RIGHT:
+ g_value_set_double (value, self->priv->left);
+ break;
case PROP_ZOOM:
g_value_set_double (value, self->priv->zoom);
break;
case PROP_LEFT:
link->priv->left = g_value_get_double (value);
break;
+ case PROP_BOTTOM:
+ link->priv->bottom = g_value_get_double (value);
+ break;
+ case PROP_RIGHT:
+ link->priv->right = g_value_get_double (value);
+ break;
case PROP_ZOOM:
link->priv->zoom = g_value_get_double (value);
break;
0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_BOTTOM,
+ g_param_spec_double ("bottom",
+ "Bottom coordinate",
+ "The bottom coordinate",
+ -G_MAXDOUBLE,
+ G_MAXDOUBLE,
+ 0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (g_object_class,
+ PROP_RIGHT,
+ g_param_spec_double ("right",
+ "Right coordinate",
+ "The right coordinate",
+ -G_MAXDOUBLE,
+ G_MAXDOUBLE,
+ 0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
g_object_class_install_property (g_object_class,
PROP_ZOOM,
g_param_spec_double ("zoom",
NULL));
}
+EvLink *
+ev_link_new_page_fitr (const char *title,
+ int page,
+ double left,
+ double bottom,
+ double right,
+ double top)
+{
+ return EV_LINK (g_object_new (EV_TYPE_LINK,
+ "title", title,
+ "page", page,
+ "type", EV_LINK_TYPE_PAGE_FITR,
+ "left", left,
+ "bottom", bottom,
+ "right", right,
+ "top", top,
+ NULL));
+}
+
EvLink *
ev_link_new_external (const char *title, const char *uri)
{
EV_LINK_TYPE_PAGE_FIT,
EV_LINK_TYPE_PAGE_FITH,
EV_LINK_TYPE_PAGE_FITV,
+ EV_LINK_TYPE_PAGE_FITR,
EV_LINK_TYPE_EXTERNAL_URI,
/* We'll probably fill this in more as we support the other types of
* links */
EvLink *ev_link_new_page_fitv (const char *title,
int page,
double left);
+EvLink *ev_link_new_page_fitr (const char *title,
+ int page,
+ double left,
+ double bottom,
+ double right,
+ double top);
EvLink *ev_link_new_page_fit (const char *title,
int page);
EvLink *ev_link_new_external (const char *title,
int ev_link_get_page (EvLink *link);
double ev_link_get_top (EvLink *link);
double ev_link_get_left (EvLink *link);
+double ev_link_get_bottom (EvLink *link);
+double ev_link_get_right (EvLink *link);
double ev_link_get_zoom (EvLink *link);
/* Link Mapping stuff */
action->goto_dest.dest->left);
break;
case POPPLER_DEST_FITR:
- unimplemented_dest = "POPPLER_DEST_FITR";
+ link = ev_link_new_page_fitr (action->any.title,
+ action->goto_dest.dest->page_num - 1,
+ action->goto_dest.dest->left,
+ action->goto_dest.dest->bottom,
+ action->goto_dest.dest->right,
+ action->goto_dest.dest->top);
break;
case POPPLER_DEST_FITB:
unimplemented_dest = "POPPLER_DEST_FITB";
return NULL;
}
+static void
+goto_fitr_link (EvView *view, EvLink *link)
+{
+ GdkPoint view_point;
+ EvPoint doc_point;
+ int doc_width, doc_height, page;
+ double zoom;
+
+ page = ev_link_get_page (link);
+ ev_page_cache_get_size (view->page_cache, page, 0, 1.0, &doc_width, &doc_height);
+
+ doc_point.x = ev_link_get_left (link);
+ doc_point.y = ev_link_get_top (link);
+ doc_point_to_view_point (view, page, &doc_point, &view_point);
+
+ zoom = zoom_for_size_best_fit (ev_link_get_right (link) - ev_link_get_left (link),
+ ev_link_get_top (link) - ev_link_get_bottom (link),
+ 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);
+ ev_page_cache_set_current_page (view->page_cache, page);
+ gtk_adjustment_set_value (view->hadjustment, view_point.x);
+}
+
static void
goto_fitv_link (EvView *view, EvLink *link)
{
case EV_LINK_TYPE_PAGE_FITV:
goto_fitv_link (view, link);
break;
+ case EV_LINK_TYPE_PAGE_FITR:
+ goto_fitr_link (view, link);
+ break;
case EV_LINK_TYPE_PAGE_XYZ:
goto_xyz_link (view, link);
break;