double base_width;
double base_height;
-
- EvOrientation orientation;
+
+ gchar *uri;
};
typedef struct _DviDocumentClass DviDocumentClass;
return FALSE;
}
+ g_mutex_lock (dvi_context_mutex);
if (dvi_document->context)
mdvi_destroy_context (dvi_document->context);
dvi_document->context = mdvi_init_context(dvi_document->params, dvi_document->spec, filename);
+ g_mutex_unlock (dvi_context_mutex);
if (!dvi_document->context) {
g_set_error (error,
dvi_document->base_height = dvi_document->context->dvi_page_h * dvi_document->context->params.vconv
+ 2 * unit2pix(dvi_document->params->vdpi, MDVI_VMARGIN) / dvi_document->params->vshrink;
- dvi_context_mutex = g_mutex_new ();
-
+ g_free (dvi_document->uri);
+ dvi_document->uri = g_strdup (uri);
return TRUE;
}
const char *uri,
GError **error)
{
- g_warning ("dvi_document_save not implemented"); /* FIXME */
- return TRUE;
+ DviDocument *dvi_document = DVI_DOCUMENT (document);
+
+ return ev_xfer_uri_simple (dvi_document->uri, uri, error);
}
static int
return dvi_document->context->npages;
}
-static EvOrientation
-dvi_document_get_orientation (EvDocument *document)
-{
- DviDocument *dvi_document = DVI_DOCUMENT (document);
-
- return dvi_document->orientation;
-}
-
-static void
-dvi_document_set_orientation (EvDocument *document,
- EvOrientation orientation)
-{
- DviDocument *dvi_document = DVI_DOCUMENT (document);
-
- dvi_document->orientation = orientation;
-}
-
-
static void
dvi_document_get_page_size (EvDocument *document,
int page,
{
DviDocument * dvi_document = DVI_DOCUMENT (document);
- if (dvi_document->orientation == EV_ORIENTATION_PORTRAIT ||
- dvi_document->orientation == EV_ORIENTATION_UPSIDEDOWN) {
- *width = dvi_document->base_width;
- *height = dvi_document->base_height;;
- } else {
- *width = dvi_document->base_height;
- *height = dvi_document->base_width;
- }
+ *width = dvi_document->base_width;
+ *height = dvi_document->base_height;;
return;
}
-static GdkPixbuf *
-rotate_pixbuf (EvDocument *document, GdkPixbuf *pixbuf)
-{
- DviDocument *dvi_document = DVI_DOCUMENT (document);
-
- switch (dvi_document->orientation)
- {
- case EV_ORIENTATION_LANDSCAPE:
- return gdk_pixbuf_rotate_simple (pixbuf, 90);
- case EV_ORIENTATION_UPSIDEDOWN:
- return gdk_pixbuf_rotate_simple (pixbuf, 180);
- case EV_ORIENTATION_SEASCAPE:
- return gdk_pixbuf_rotate_simple (pixbuf, 270);
- default:
- return g_object_ref (pixbuf);
- }
-}
-
static GdkPixbuf *
dvi_document_render_pixbuf (EvDocument *document,
EvRenderContext *rc)
g_mutex_unlock (dvi_context_mutex);
- rotated_pixbuf = rotate_pixbuf (document, pixbuf);
- g_object_unref (pixbuf);
+ rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rc->rotation);
+ g_object_unref (pixbuf);
return rotated_pixbuf;
}
dvi_document_finalize (GObject *object)
{
DviDocument *dvi_document = DVI_DOCUMENT(object);
-
+
+ g_mutex_lock (dvi_context_mutex);
if (dvi_document->context)
{
mdvi_pixbuf_device_free (&dvi_document->context->device);
mdvi_destroy_context (dvi_document->context);
}
+ g_mutex_unlock (dvi_context_mutex);
if (dvi_document->params)
g_free (dvi_document->params);
+
+ g_free (dvi_document->uri);
G_OBJECT_CLASS (dvi_document_parent_class)->finalize (object);
}
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = dvi_document_finalize;
+
+ mdvi_init_kpathsea("evince", MDVI_MFMODE, MDVI_FALLBACK_FONT, MDVI_DPI);
+ mdvi_register_fonts ();
+
+ dvi_context_mutex = g_mutex_new ();
}
static gboolean
iface->get_page_size = dvi_document_get_page_size;
iface->render_pixbuf = dvi_document_render_pixbuf;
iface->get_info = dvi_document_get_info;
- iface->get_orientation = dvi_document_get_orientation;
- iface->set_orientation = dvi_document_set_orientation;
}
static void
dvi_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
- gint page,
- gint suggested_width,
- gint *width,
- gint *height)
+ gint page,
+ gint suggested_width,
+ gint *width,
+ gint *height)
{
DviDocument *dvi_document = DVI_DOCUMENT (document);
gdouble page_ratio;
static GdkPixbuf *
dvi_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
gint page,
+ gint rotation,
gint width,
gboolean border)
{
DviDocument *dvi_document = DVI_DOCUMENT (document);
GdkPixbuf *pixbuf;
GdkPixbuf *border_pixbuf;
+ GdkPixbuf *rotated_pixbuf;
gint thumb_width, thumb_height;
gint proposed_width, proposed_height;
pixbuf = mdvi_pixbuf_device_get_pixbuf (&dvi_document->context->device);
g_mutex_unlock (dvi_context_mutex);
-
- if (border) {
- border_pixbuf = ev_document_misc_get_thumbnail_frame (thumb_width, thumb_height, NULL);
- gdk_pixbuf_copy_area (pixbuf, 0, 0,
- thumb_width - 2, thumb_height - 2,
- border_pixbuf, 2, 2);
- g_object_unref (pixbuf);
- pixbuf = border_pixbuf;
- }
+ rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rotation);
+ g_object_unref (pixbuf);
- return pixbuf;
+ if (border) {
+ GdkPixbuf *tmp_pixbuf = rotated_pixbuf;
+ rotated_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, 0, tmp_pixbuf);
+ g_object_unref (tmp_pixbuf);
+ }
+
+ return rotated_pixbuf;
}
static void
dvi_document->params->bg = 0xffffffff;
dvi_document->params->fg = 0xff000000;
-
- mdvi_init_kpathsea("evince", MDVI_MFMODE, MDVI_FALLBACK_FONT, MDVI_DPI);
-
- mdvi_register_fonts ();
}
static void