From 2a08b88d7fc1397335cc85812b8f2bd4d53125d9 Mon Sep 17 00:00:00 2001 From: Nickolay V. Shmyrev Date: Sun, 31 Jul 2005 10:07:24 +0000 Subject: Update backends to make them build with new rotation system --- diff --git a/ChangeLog b/ChangeLog index 0acd1d1..7a64383 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,21 @@ 2005-07-31 Nickolay V. Shmyrev + * djvu/djvu-document.c: (djvu_document_get_page_size), + (djvu_document_render_pixbuf), (djvu_document_document_iface_init), + (djvu_document_thumbnails_get_thumbnail): + * dvi/dvi-document.c: (dvi_document_get_page_size), + (dvi_document_render_pixbuf), (dvi_document_document_iface_init), + (dvi_document_thumbnails_get_dimensions), + (dvi_document_thumbnails_get_thumbnail): + * pixbuf/pixbuf-document.c: (pixbuf_document_get_page_size), + (pixbuf_document_render_pixbuf), + (pixbuf_document_document_iface_init), + (pixbuf_document_thumbnails_get_thumbnail): + + Update backends to make them build with new rotation system. + +2005-07-31 Nickolay V. Shmyrev + * help/C/figures/evince_start_window.png: Update documentation image from Luca Ferretti diff --git a/djvu/djvu-document.c b/djvu/djvu-document.c index 25cdb07..1945249 100644 --- a/djvu/djvu-document.c +++ b/djvu/djvu-document.c @@ -44,8 +44,6 @@ struct _DjvuDocument ddjvu_context_t *d_context; ddjvu_document_t *d_document; ddjvu_format_t *d_format; - - EvOrientation orientation; }; typedef struct _DjvuDocumentClass DjvuDocumentClass; @@ -111,23 +109,6 @@ 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, @@ -144,32 +125,8 @@ djvu_document_get_page_size (EvDocument *document, ddjvu_message_pop (djvu_document->d_context); } - 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); - } + *width = info.width * SCALE_FACTOR; + *height = info.height * SCALE_FACTOR; } static GdkPixbuf * @@ -209,8 +166,7 @@ djvu_document_render_pixbuf (EvDocument *document, gdk_pixbuf_get_rowstride (pixbuf), (gchar *)gdk_pixbuf_get_pixels (pixbuf)); - - rotated_pixbuf = rotate_pixbuf (document, pixbuf); + rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, rc->rotation); g_object_unref (pixbuf); return rotated_pixbuf; @@ -264,8 +220,6 @@ 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 @@ -291,11 +245,12 @@ djvu_document_thumbnails_get_dimensions (EvDocumentThumbnails *document, static GdkPixbuf * djvu_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, gint page, + gint rotation, gint width, gboolean border) { DjvuDocument *djvu_document = DJVU_DOCUMENT (document); - GdkPixbuf *pixbuf; + GdkPixbuf *pixbuf, *rotated_pixbuf; gint thumb_width, thumb_height; guchar *pixels; @@ -324,8 +279,11 @@ djvu_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, djvu_document->d_format, gdk_pixbuf_get_rowstride (pixbuf), (gchar *)pixels); + + rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, rotation); + g_object_unref (pixbuf); - return pixbuf; + return rotated_pixbuf; } static void diff --git a/dvi/dvi-document.c b/dvi/dvi-document.c index 0aff86a..05bc5b6 100644 --- a/dvi/dvi-document.c +++ b/dvi/dvi-document.c @@ -54,8 +54,6 @@ struct _DviDocument double base_width; double base_height; - - EvOrientation orientation; }; typedef struct _DviDocumentClass DviDocumentClass; @@ -136,24 +134,6 @@ 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, @@ -162,37 +142,13 @@ dvi_document_get_page_size (EvDocument *document, { 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) { @@ -235,8 +191,8 @@ dvi_document_render_pixbuf (EvDocument *document, g_mutex_unlock (dvi_context_mutex); - rotated_pixbuf = rotate_pixbuf (document, pixbuf); - g_object_unref (pixbuf); + rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, rc->rotation); + g_object_unref (pixbuf); return rotated_pixbuf; } @@ -293,16 +249,14 @@ 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 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; @@ -317,12 +271,14 @@ dvi_document_thumbnails_get_dimensions (EvDocumentThumbnails *document, 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; @@ -365,7 +321,10 @@ dvi_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, } - return pixbuf; + rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, rotation); + g_object_unref (pixbuf); + + return rotated_pixbuf; } static void diff --git a/pixbuf/pixbuf-document.c b/pixbuf/pixbuf-document.c index d4a8c9a..5147293 100644 --- a/pixbuf/pixbuf-document.c +++ b/pixbuf/pixbuf-document.c @@ -30,7 +30,6 @@ struct _PixbufDocument GObject parent_instance; GdkPixbuf *pixbuf; - EvOrientation orientation; }; typedef struct _PixbufDocumentClass PixbufDocumentClass; @@ -85,41 +84,6 @@ pixbuf_document_get_n_pages (EvDocument *document) return 1; } -static EvOrientation -pixbuf_document_get_orientation (EvDocument *document) -{ - PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document); - - return pixbuf_document->orientation; -} - -static void -pixbuf_document_set_orientation (EvDocument *document, - EvOrientation orientation) -{ - PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document); - - pixbuf_document->orientation = orientation; -} - -static GdkPixbuf * -rotate_pixbuf (EvDocument *document, GdkPixbuf *pixbuf) -{ - PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document); - - switch (pixbuf_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 void pixbuf_document_get_page_size (EvDocument *document, int page, @@ -128,14 +92,8 @@ pixbuf_document_get_page_size (EvDocument *document, { PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document); - if (pixbuf_document->orientation == EV_ORIENTATION_PORTRAIT || - pixbuf_document->orientation == EV_ORIENTATION_UPSIDEDOWN) { - *width = gdk_pixbuf_get_width (pixbuf_document->pixbuf); - *height = gdk_pixbuf_get_height (pixbuf_document->pixbuf); - } else { - *width = gdk_pixbuf_get_height (pixbuf_document->pixbuf); - *height = gdk_pixbuf_get_width (pixbuf_document->pixbuf); - } + *width = gdk_pixbuf_get_width (pixbuf_document->pixbuf); + *height = gdk_pixbuf_get_height (pixbuf_document->pixbuf); } static GdkPixbuf* @@ -150,8 +108,8 @@ pixbuf_document_render_pixbuf (EvDocument *document, gdk_pixbuf_get_height (pixbuf_document->pixbuf) * rc->scale, GDK_INTERP_BILINEAR); - rotated_pixbuf = rotate_pixbuf (document, scaled_pixbuf); - g_object_unref (scaled_pixbuf); + rotated_pixbuf = gdk_pixbuf_rotate_simple (scaled_pixbuf, rc->rotation); + g_object_unref (scaled_pixbuf); return rotated_pixbuf; } @@ -201,18 +159,17 @@ pixbuf_document_document_iface_init (EvDocumentIface *iface) iface->get_page_size = pixbuf_document_get_page_size; iface->render_pixbuf = pixbuf_document_render_pixbuf; iface->get_info = pixbuf_document_get_info; - iface->get_orientation = pixbuf_document_get_orientation; - iface->set_orientation = pixbuf_document_set_orientation; } static GdkPixbuf * pixbuf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, gint page, + gint rotation, gint size, gboolean border) { PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document); - GdkPixbuf *pixbuf; + GdkPixbuf *pixbuf, *rotated_pixbuf; gdouble scale_factor; gint height; @@ -222,8 +179,11 @@ pixbuf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, pixbuf = gdk_pixbuf_scale_simple (pixbuf_document->pixbuf, size, height, GDK_INTERP_BILINEAR); - - return pixbuf; + + rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, rotation); + g_object_unref (pixbuf); + + return rotated_pixbuf; } static void -- cgit v0.9.1