]> www.fi.muni.cz Git - evince.git/commitdiff
Require libgnomeprint >= 2.5.1. Thanks to Colin Slater
authorNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Fri, 1 Jul 2005 07:44:23 +0000 (07:44 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Fri, 1 Jul 2005 07:44:23 +0000 (07:44 +0000)
* 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

ChangeLog
configure.ac
djvu/djvu-document.c
dvi/dvi-document.c

index 09c3de7e8497bc0ce0b3fea2ed65fa3c88105662..0afe222c1a403a6553eca252d2008b3b3f0684a4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+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),
index 227b020659974e1c37ec273f23c0602a18417a7f..d49fe82cdd13e7a17dd6c2bd9e32b3128d6f7319 100644 (file)
@@ -39,7 +39,7 @@ PKG_CHECK_MODULES(LIBEVPRIVATE, gtk+-2.0 >= 2.4.0)
 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)
index d82a643f799d4e42a0aa4bbe431fb5a1c087c39d..25cdb075778153a4ba80cc177274a7c458599f0a 100644 (file)
@@ -44,6 +44,8 @@ struct _DjvuDocument
        ddjvu_context_t  *d_context;
        ddjvu_document_t *d_document;
        ddjvu_format_t   *d_format;
+       
+       EvOrientation    orientation;
 };
 
 typedef struct _DjvuDocumentClass DjvuDocumentClass;
@@ -109,6 +111,23 @@ djvu_document_get_n_pages (EvDocument  *document)
        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,
@@ -125,18 +144,41 @@ djvu_document_get_page_size (EvDocument   *document,
                    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;
@@ -144,15 +186,15 @@ djvu_document_render_pixbuf (EvDocument  *document,
        
        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);
 
@@ -168,7 +210,10 @@ djvu_document_render_pixbuf (EvDocument  *document,
                           (gchar *)gdk_pixbuf_get_pixels (pixbuf));
        
     
-       return pixbuf;
+       rotated_pixbuf = rotate_pixbuf (document, pixbuf);
+       g_object_unref (pixbuf);
+       
+       return rotated_pixbuf;
 }
 
 static void
@@ -219,6 +264,8 @@ djvu_document_document_iface_init (EvDocumentIface *iface)
        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
index d0307e3a2661226be08b50adc65ab56f3e47d5f8..0aff86a3afde24e7b779040444f8a207e94a20bc 100644 (file)
@@ -54,6 +54,8 @@ struct _DviDocument
        
        double base_width;
        double base_height;
+
+       EvOrientation orientation;
 };
 
 typedef struct _DviDocumentClass DviDocumentClass;
@@ -134,6 +136,24 @@ dvi_document_get_n_pages (EvDocument  *document)
     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,
@@ -141,20 +161,43 @@ dvi_document_get_page_size (EvDocument   *document,
                            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);
 
@@ -168,14 +211,14 @@ dvi_document_render_pixbuf (EvDocument  *document, int page, double scale)
         */
        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;
        
@@ -192,7 +235,10 @@ dvi_document_render_pixbuf (EvDocument  *document, int page, double scale)
 
        g_mutex_unlock (dvi_context_mutex);
 
-       return pixbuf;
+        rotated_pixbuf = rotate_pixbuf (document, pixbuf);
+        g_object_unref (pixbuf);
+
+       return rotated_pixbuf;
 }
 
 static void
@@ -247,6 +293,8 @@ dvi_document_document_iface_init (EvDocumentIface *iface)
        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