#include "pixbuf-device.h"
#include <gtk/gtk.h>
+#include <glib/gi18n.h>
GMutex *dvi_context_mutex = NULL;
filename = g_filename_from_uri (uri, NULL, error);
- if (!filename)
- return FALSE;
+ if (!filename) {
+ g_set_error (error,
+ EV_DOCUMENT_ERROR,
+ EV_DOCUMENT_ERROR_INVALID,
+ _("File not available"));
+ return FALSE;
+ }
if (dvi_document->context)
mdvi_destroy_context (dvi_document->context);
dvi_document->context = mdvi_init_context(dvi_document->params, dvi_document->spec, filename);
+ if (!dvi_document->context) {
+ g_set_error (error,
+ EV_DOCUMENT_ERROR,
+ EV_DOCUMENT_ERROR_INVALID,
+ _("DVI document has incorrect format"));
+ return FALSE;
+ }
+
mdvi_pixbuf_device_init (&dvi_document->context->device);
dvi_document->base_width = dvi_document->context->dvi_page_w * dvi_document->context->params.conv
- + 2 * unit2pix(dvi_document->params->dpi, MDVI_VMARGIN) / dvi_document->params->hshrink;
+ + 2 * unit2pix(dvi_document->params->dpi, MDVI_HMARGIN) / dvi_document->params->hshrink;
dvi_document->base_height = dvi_document->context->dvi_page_h * dvi_document->context->params.vconv
- + 2 * unit2pix(dvi_document->params->dpi, MDVI_VMARGIN) / dvi_document->params->vshrink;
+ + 2 * unit2pix(dvi_document->params->vdpi, MDVI_VMARGIN) / dvi_document->params->vshrink;
dvi_context_mutex = g_mutex_new ();
double *height)
{
DviDocument * dvi_document = DVI_DOCUMENT (document);
-
- if (width != NULL)
- *width = dvi_document->base_width;
- if (height != NULL)
- *height = dvi_document->base_height;
-
+ *width = dvi_document->base_width;
+ *height = dvi_document->base_height;;
+
return;
}
static GdkPixbuf *
-dvi_document_render_pixbuf (EvDocument *document, int page, double scale)
+dvi_document_render_pixbuf (EvDocument *document,
+ EvRenderContext *rc)
{
GdkPixbuf *pixbuf;
+ GdkPixbuf *rotated_pixbuf;
DviDocument *dvi_document = DVI_DOCUMENT(document);
*/
g_mutex_lock (dvi_context_mutex);
- mdvi_setpage(dvi_document->context, page);
+ mdvi_setpage(dvi_document->context, rc->page);
mdvi_set_shrink (dvi_document->context,
- (int)((dvi_document->params->hshrink - 1) / scale) + 1,
- (int)((dvi_document->params->vshrink - 1) / scale) + 1);
+ (int)((dvi_document->params->hshrink - 1) / rc->scale) + 1,
+ (int)((dvi_document->params->vshrink - 1) / rc->scale) + 1);
- required_width = dvi_document->base_width * scale;
- required_height = dvi_document->base_height * scale;
+ required_width = dvi_document->base_width * rc->scale;
+ required_height = dvi_document->base_height * rc->scale;
proposed_width = dvi_document->context->dvi_page_w * dvi_document->context->params.conv;
proposed_height = dvi_document->context->dvi_page_h * dvi_document->context->params.vconv;
g_mutex_unlock (dvi_context_mutex);
- return pixbuf;
+ rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, rc->rotation);
+ g_object_unref (pixbuf);
+
+ return rotated_pixbuf;
}
static void
G_OBJECT_CLASS (dvi_document_parent_class)->finalize (object);
}
-static void
-dvi_document_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (prop_id)
- {
- case PROP_TITLE:
- /* read only */
- break;
- }
-}
-
-static void
-dvi_document_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (prop_id)
- {
- case PROP_TITLE:
- g_value_set_string (value, NULL);
- break;
- }
-}
static void
dvi_document_class_init (DviDocumentClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = dvi_document_finalize;
- gobject_class->get_property = dvi_document_get_property;
- gobject_class->set_property = dvi_document_set_property;
-
- g_object_class_override_property (gobject_class, PROP_TITLE, "title");
}
static gboolean
return FALSE;
}
+static EvDocumentInfo *
+dvi_document_get_info (EvDocument *document)
+{
+ EvDocumentInfo *info;
+
+ info = g_new0 (EvDocumentInfo, 1);
+
+ return info;
+}
+
static void
dvi_document_document_iface_init (EvDocumentIface *iface)
{
iface->get_n_pages = dvi_document_get_n_pages;
iface->get_page_size = dvi_document_get_page_size;
iface->render_pixbuf = dvi_document_render_pixbuf;
+ iface->get_info = dvi_document_get_info;
}
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;
mdvi_set_shrink (dvi_document->context,
(int)dvi_document->base_width * dvi_document->params->hshrink / thumb_width,
- (int)dvi_document->base_width * dvi_document->params->vshrink / thumb_height);
+ (int)dvi_document->base_height * dvi_document->params->vshrink / thumb_height);
proposed_width = dvi_document->context->dvi_page_w * dvi_document->context->params.conv;
proposed_height = dvi_document->context->dvi_page_h * dvi_document->context->params.vconv;
}
- return pixbuf;
+ rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, rotation);
+ g_object_unref (pixbuf);
+
+ return rotated_pixbuf;
}
static void
dvi_document->params->hdrift = 0;
dvi_document->params->vdrift = 0;
dvi_document->params->hshrink = MDVI_SHRINK_FROM_DPI(dvi_document->params->dpi);
- dvi_document->params->vshrink = MDVI_SHRINK_FROM_DPI(dvi_document->params->dpi);
+ dvi_document->params->vshrink = MDVI_SHRINK_FROM_DPI(dvi_document->params->vdpi);
dvi_document->params->orientation = MDVI_ORIENT_TBLR;
dvi_document->spec = NULL;