+2005-07-01 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
+
+ * configure.ac:
+
+ Require libgnomeprint >= 2.5.1. Thanks to Colin Slater
+ <kiltedaco@gmail.com>
+
+ * djvu/djvu-document.c: (djvu_document_get_orientation),
+ (djvu_document_set_orientation), (djvu_document_get_page_size),
+ (rotate_pixbuf), (djvu_document_render_pixbuf),
+ (djvu_document_document_iface_init):
+ * dvi/dvi-document.c: (dvi_document_get_orientation),
+ (dvi_document_set_orientation), (dvi_document_get_page_size),
+ (rotate_pixbuf), (dvi_document_render_pixbuf),
+ (dvi_document_document_iface_init):
+
+ Dvi and djvu backends are ported to new API
+
Fri Jul 1 00:10:15 2005 Jonathan Blandford <jrb@redhat.com>
* backend/ev-selection.c: (ev_selection_get_selection_region),
PKG_CHECK_MODULES(TOOLBAR_EDITOR, gtk+-2.0 >= 2.4.0 libgnomeui-2.0 >= 2.4.0)
PKG_CHECK_MODULES(RECENT_FILES, gtk+-2.0 >= 2.4.0 libgnomeui-2.0 >= 2.4.0)
PKG_CHECK_MODULES(ZOOM_CONTROL, gtk+-2.0 >= 2.4.0)
-PKG_CHECK_MODULES(SHELL, gtk+-2.0 >= 2.6.0 libgnomeui-2.0 gnome-vfs-2.0 libgnomeprint-2.2 libgnomeprintui-2.2 libglade-2.0 gconf-2.0 poppler-glib >= $POPPLER_REQUIRED)
+PKG_CHECK_MODULES(SHELL, gtk+-2.0 >= 2.6.0 libgnomeui-2.0 gnome-vfs-2.0 libgnomeprint-2.2 >= 2.5.1 libgnomeprintui-2.2 libglade-2.0 gconf-2.0 poppler-glib >= $POPPLER_REQUIRED)
PKG_CHECK_MODULES(THUMBNAILER, gtk+-2.0 >= 2.6.0 gnome-vfs-2.0 poppler-glib >= $POPPLER_REQUIRED)
PKG_CHECK_MODULES(DVI, gtk+-2.0 >= 2.6.0)
PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.6.0)
ddjvu_context_t *d_context;
ddjvu_document_t *d_document;
ddjvu_format_t *d_format;
+
+ EvOrientation orientation;
};
typedef struct _DjvuDocumentClass DjvuDocumentClass;
return ddjvu_document_get_pagenum (djvu_document->d_document);
}
+static EvOrientation
+djvu_document_get_orientation (EvDocument *document)
+{
+ DjvuDocument *djvu_document = DJVU_DOCUMENT (document);
+
+ return djvu_document->orientation;
+}
+
+static void
+djvu_document_set_orientation (EvDocument *document,
+ EvOrientation orientation)
+{
+ DjvuDocument *djvu_document = DJVU_DOCUMENT (document);
+
+ djvu_document->orientation = orientation;
+}
+
static void
djvu_document_get_page_size (EvDocument *document,
int page,
ddjvu_message_pop (djvu_document->d_context);
}
- if (width)
- *width = info.width * SCALE_FACTOR;
- if (height)
- *height = info.height * SCALE_FACTOR;
+ if (djvu_document->orientation == EV_ORIENTATION_PORTRAIT ||
+ djvu_document->orientation == EV_ORIENTATION_UPSIDEDOWN) {
+ *width = info.width * SCALE_FACTOR;
+ *height = info.height * SCALE_FACTOR;
+ } else {
+ *width = info.height * SCALE_FACTOR;
+ *height = info.width * SCALE_FACTOR;
+ }
+}
+
+static GdkPixbuf *
+rotate_pixbuf (EvDocument *document, GdkPixbuf *pixbuf)
+{
+ DjvuDocument *djvu_document = DJVU_DOCUMENT (document);
+
+ switch (djvu_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 *
djvu_document_render_pixbuf (EvDocument *document,
- int page, gdouble scale)
+ EvRenderContext *rc)
{
DjvuDocument *djvu_document = DJVU_DOCUMENT (document);
GdkPixbuf *pixbuf;
+ GdkPixbuf *rotated_pixbuf;
ddjvu_rect_t rrect;
ddjvu_rect_t prect;
double page_width, page_height;
- d_page = ddjvu_page_create_by_pageno (djvu_document->d_document, page);
+ d_page = ddjvu_page_create_by_pageno (djvu_document->d_document, rc->page);
while (!ddjvu_page_decoding_done (d_page)) {
ddjvu_message_wait (djvu_document->d_context);
ddjvu_message_pop (djvu_document->d_context);
}
- page_width = ddjvu_page_get_width (d_page) * scale * SCALE_FACTOR;
- page_height = ddjvu_page_get_height (d_page) * scale * SCALE_FACTOR;
+ page_width = ddjvu_page_get_width (d_page) * rc->scale * SCALE_FACTOR;
+ page_height = ddjvu_page_get_height (d_page) * rc->scale * SCALE_FACTOR;
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, page_width, page_height);
(gchar *)gdk_pixbuf_get_pixels (pixbuf));
- return pixbuf;
+ rotated_pixbuf = rotate_pixbuf (document, pixbuf);
+ g_object_unref (pixbuf);
+
+ return rotated_pixbuf;
}
static void
iface->get_page_size = djvu_document_get_page_size;
iface->render_pixbuf = djvu_document_render_pixbuf;
iface->get_info = djvu_document_get_info;
+ iface->set_orientation = djvu_document_set_orientation;
+ iface->get_orientation = djvu_document_get_orientation;
}
static void
double base_width;
double base_height;
+
+ EvOrientation orientation;
};
typedef struct _DviDocumentClass DviDocumentClass;
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,
double *height)
{
DviDocument * dvi_document = DVI_DOCUMENT (document);
-
- if (width != NULL)
- *width = dvi_document->base_width;
- if (height != NULL)
- *height = dvi_document->base_height;
-
+ 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;
+ }
+
return;
}
static GdkPixbuf *
-dvi_document_render_pixbuf (EvDocument *document, int page, double scale)
+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)
{
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 = rotate_pixbuf (document, pixbuf);
+ g_object_unref (pixbuf);
+
+ return rotated_pixbuf;
}
static void
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