From 41229e9ef5135c93176acb6320f96abc7d624b0a Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Fri, 29 Jul 2005 16:02:28 +0000 Subject: Use rotation rather than orientation. It's easier and enough for our 2005-07-29 Marco Pesenti Gritti * backend/ev-document-thumbnails.c: (ev_document_thumbnails_get_thumbnail): * backend/ev-document-thumbnails.h: * backend/ev-document.c: * backend/ev-document.h: * backend/ev-render-context.c: (ev_render_context_new), (ev_render_context_set_rotation): * backend/ev-render-context.h: * pdf/ev-poppler.cc: * ps/ps-document.c: (ps_document_document_iface_init): * shell/ev-jobs.c: (ev_job_thumbnail_new), (ev_job_thumbnail_run): * shell/ev-jobs.h: * shell/ev-page-cache.c: (build_height_to_page), (ev_page_cache_new), (ev_page_cache_get_size), (ev_page_cache_get_max_width), (ev_page_cache_get_max_height), (ev_page_cache_get_height_to_page): * shell/ev-page-cache.h: * shell/ev-pixbuf-cache.c: (check_job_size_and_unref), (add_job_if_needed), (ev_pixbuf_cache_add_jobs_if_needed), (ev_pixbuf_cache_set_page_range), (new_selection_pixbuf_needed), (ev_pixbuf_cache_get_selection_pixbuf): * shell/ev-pixbuf-cache.h: * shell/ev-print-job.c: (idle_print_handler): * shell/ev-sidebar-thumbnails.c: (add_range): * shell/ev-view.c: (view_update_range_and_current_page), (get_page_y_offset), (get_page_extents), (ev_view_size_request_continuous_dual_page), (ev_view_size_request_continuous), (ev_view_size_request_dual_page), (ev_view_size_request_single_page), (draw_one_page), (ev_view_set_rotation), (ev_view_rotate_right), (ev_view_rotate_left), (ev_view_zoom_for_size_presentation), (ev_view_zoom_for_size_continuous_and_dual_page), (ev_view_zoom_for_size_continuous), (ev_view_zoom_for_size_dual_page), (ev_view_zoom_for_size_single_page), (compute_new_selection_text), (ev_view_select_all): * thumbnailer/evince-thumbnailer.c: (evince_thumbnail_pngenc_get): * tiff/tiff-document.c: (tiff_document_render_pixbuf), (tiff_document_document_iface_init), (tiff_document_thumbnails_get_thumbnail): Use rotation rather than orientation. It's easier and enough for our needs. --- diff --git a/ChangeLog b/ChangeLog index fde3949..0cca894 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,52 @@ 2005-07-29 Marco Pesenti Gritti + * backend/ev-document-thumbnails.c: + (ev_document_thumbnails_get_thumbnail): + * backend/ev-document-thumbnails.h: + * backend/ev-document.c: + * backend/ev-document.h: + * backend/ev-render-context.c: (ev_render_context_new), + (ev_render_context_set_rotation): + * backend/ev-render-context.h: + * pdf/ev-poppler.cc: + * ps/ps-document.c: (ps_document_document_iface_init): + * shell/ev-jobs.c: (ev_job_thumbnail_new), (ev_job_thumbnail_run): + * shell/ev-jobs.h: + * shell/ev-page-cache.c: (build_height_to_page), + (ev_page_cache_new), (ev_page_cache_get_size), + (ev_page_cache_get_max_width), (ev_page_cache_get_max_height), + (ev_page_cache_get_height_to_page): + * shell/ev-page-cache.h: + * shell/ev-pixbuf-cache.c: (check_job_size_and_unref), + (add_job_if_needed), (ev_pixbuf_cache_add_jobs_if_needed), + (ev_pixbuf_cache_set_page_range), (new_selection_pixbuf_needed), + (ev_pixbuf_cache_get_selection_pixbuf): + * shell/ev-pixbuf-cache.h: + * shell/ev-print-job.c: (idle_print_handler): + * shell/ev-sidebar-thumbnails.c: (add_range): + * shell/ev-view.c: (view_update_range_and_current_page), + (get_page_y_offset), (get_page_extents), + (ev_view_size_request_continuous_dual_page), + (ev_view_size_request_continuous), + (ev_view_size_request_dual_page), + (ev_view_size_request_single_page), (draw_one_page), + (ev_view_set_rotation), (ev_view_rotate_right), + (ev_view_rotate_left), (ev_view_zoom_for_size_presentation), + (ev_view_zoom_for_size_continuous_and_dual_page), + (ev_view_zoom_for_size_continuous), + (ev_view_zoom_for_size_dual_page), + (ev_view_zoom_for_size_single_page), (compute_new_selection_text), + (ev_view_select_all): + * thumbnailer/evince-thumbnailer.c: (evince_thumbnail_pngenc_get): + * tiff/tiff-document.c: (tiff_document_render_pixbuf), + (tiff_document_document_iface_init), + (tiff_document_thumbnails_get_thumbnail): + + Use rotation rather than orientation. It's easier and enough + for our needs. + +2005-07-29 Marco Pesenti Gritti + * shell/ev-page-cache.c: (build_height_to_page), (ev_page_cache_new), (ev_page_cache_get_size), (ev_page_cache_get_max_width), (ev_page_cache_get_max_height), diff --git a/backend/ev-document-thumbnails.c b/backend/ev-document-thumbnails.c index 9bf1695..f537afd 100644 --- a/backend/ev-document-thumbnails.c +++ b/backend/ev-document-thumbnails.c @@ -47,7 +47,7 @@ ev_document_thumbnails_get_type (void) GdkPixbuf * ev_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, gint page, - EvOrientation orientation, + int rotation, gint size, gboolean border) { @@ -57,7 +57,7 @@ ev_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, iface = EV_DOCUMENT_THUMBNAILS_GET_IFACE (document); - return iface->get_thumbnail (document, page, orientation, size, border); + return iface->get_thumbnail (document, page, rotation, size, border); } void diff --git a/backend/ev-document-thumbnails.h b/backend/ev-document-thumbnails.h index ea77629..6e15a32 100644 --- a/backend/ev-document-thumbnails.h +++ b/backend/ev-document-thumbnails.h @@ -44,7 +44,7 @@ struct _EvDocumentThumbnailsIface /* Methods */ GdkPixbuf * (* get_thumbnail) (EvDocumentThumbnails *document, gint page, - EvOrientation orientation, + gint rotation, gint size, gboolean border); void (* get_dimensions) (EvDocumentThumbnails *document, @@ -63,7 +63,7 @@ GType ev_document_thumbnails_get_type (void); GdkPixbuf *ev_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, gint page, - EvOrientation orientation, + gint rotation, gint size, gboolean border); void ev_document_thumbnails_get_dimensions (EvDocumentThumbnails *document, diff --git a/backend/ev-document.c b/backend/ev-document.c index 2778f77..a800866 100644 --- a/backend/ev-document.c +++ b/backend/ev-document.c @@ -217,14 +217,6 @@ ev_document_render_pixbuf (EvDocument *document, return retval; } -EvOrientation -ev_document_get_orientation (EvDocument *document) -{ - EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); - - return iface->get_orientation (document); -} - void ev_document_info_free (EvDocumentInfo *info) { diff --git a/backend/ev-document.h b/backend/ev-document.h index b4668e7..2629a47 100644 --- a/backend/ev-document.h +++ b/backend/ev-document.h @@ -89,7 +89,6 @@ struct _EvDocumentIface int page); GdkPixbuf * (* render_pixbuf) (EvDocument *document, EvRenderContext *rc); - EvOrientation (* get_orientation) (EvDocument *document); EvDocumentInfo * (* get_info) (EvDocument *document); }; @@ -121,10 +120,6 @@ GList *ev_document_get_links (EvDocument *document, int page); GdkPixbuf *ev_document_render_pixbuf (EvDocument *document, EvRenderContext *rc); -EvOrientation ev_document_get_orientation (EvDocument *document); -void ev_document_set_orientation (EvDocument *document, - EvOrientation orientation); - gint ev_rect_cmp (EvRectangle *a, EvRectangle *b); diff --git a/backend/ev-render-context.c b/backend/ev-render-context.c index 2d09d44..a3969ad 100644 --- a/backend/ev-render-context.c +++ b/backend/ev-render-context.c @@ -35,7 +35,7 @@ ev_render_context_class_init (EvRenderContextClass *class) EvRenderContext * -ev_render_context_new (EvOrientation orientation, +ev_render_context_new (int rotation, gint page, gdouble scale) { @@ -43,7 +43,7 @@ ev_render_context_new (EvOrientation orientation, rc = (EvRenderContext *) g_object_new (EV_TYPE_RENDER_CONTEXT, NULL); - rc->orientation = orientation; + rc->rotation = rotation; rc->page = page; rc->scale = scale; @@ -60,12 +60,12 @@ ev_render_context_set_page (EvRenderContext *rc, } void -ev_render_context_set_orientation (EvRenderContext *rc, - EvOrientation orientation) +ev_render_context_set_rotation (EvRenderContext *rc, + int rotation) { g_return_if_fail (rc != NULL); - rc->orientation = orientation; + rc->rotation = rotation; } void diff --git a/backend/ev-render-context.h b/backend/ev-render-context.h index 7bd73d6..636f02f 100644 --- a/backend/ev-render-context.h +++ b/backend/ev-render-context.h @@ -32,15 +32,6 @@ typedef struct _EvRenderContextClass EvRenderContextClass; #define EV_RENDER_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_RENDER_CONTEXT, EvRenderContext)) #define EV_IS_RENDER_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_RENDER_CONTEXT)) -typedef enum -{ - EV_ORIENTATION_PORTRAIT, - EV_ORIENTATION_LANDSCAPE, - EV_ORIENTATION_UPSIDEDOWN, - EV_ORIENTATION_SEASCAPE -} EvOrientation; - - struct _EvRenderContextClass { GObjectClass klass; @@ -49,7 +40,7 @@ struct _EvRenderContextClass struct _EvRenderContext { GObject parent; - EvOrientation orientation; + int rotation; gint page; gdouble scale; @@ -59,13 +50,13 @@ struct _EvRenderContext GType ev_render_context_get_type (void) G_GNUC_CONST; -EvRenderContext *ev_render_context_new (EvOrientation orientation, +EvRenderContext *ev_render_context_new (int rotation, gint page, gdouble scale); void ev_render_context_set_page (EvRenderContext *rc, gint page); -void ev_render_context_set_orientation (EvRenderContext *rc, - EvOrientation orientation); +void ev_render_context_set_rotation (EvRenderContext *rc, + int rotation); void ev_render_context_set_scale (EvRenderContext *rc, gdouble scale); diff --git a/pdf/ev-poppler.cc b/pdf/ev-poppler.cc index 08b811b..07f1028 100644 --- a/pdf/ev-poppler.cc +++ b/pdf/ev-poppler.cc @@ -204,24 +204,6 @@ pdf_document_save (EvDocument *document, return retval; } -static PopplerOrientation -get_document_orientation (PdfDocument *pdf_document) -{ - PopplerOrientation orientation; - PopplerPage *page; - - /* Should prolly be smarter here and check more than first page */ - page = poppler_document_get_page (pdf_document->document, 0); - if (page) { - orientation = poppler_page_get_orientation (page); - } else { - orientation = POPPLER_ORIENTATION_PORTRAIT; - } - g_object_unref (page); - - return orientation; -} - static gboolean pdf_document_load (EvDocument *document, const char *uri, @@ -247,30 +229,28 @@ pdf_document_get_n_pages (EvDocument *document) return poppler_document_get_n_pages (PDF_DOCUMENT (document)->document); } -/* FIXME This should not be necessary, poppler should rember it */ static void -set_page_orientation (PdfDocument *pdf_document, PopplerPage *page, EvOrientation orientation) +set_page_orientation (PdfDocument *pdf_document, PopplerPage *page, int rotation) { - PopplerOrientation poppler_orientation; + PopplerOrientation orientation; + int r = rotation; - switch (orientation) { - case EV_ORIENTATION_PORTRAIT: - poppler_orientation = POPPLER_ORIENTATION_PORTRAIT; - break; - case EV_ORIENTATION_LANDSCAPE: - poppler_orientation = POPPLER_ORIENTATION_LANDSCAPE; - break; - case EV_ORIENTATION_UPSIDEDOWN: - poppler_orientation = POPPLER_ORIENTATION_UPSIDEDOWN; - break; - case EV_ORIENTATION_SEASCAPE: - poppler_orientation = POPPLER_ORIENTATION_SEASCAPE; - break; - default: - g_assert_not_reached (); + orientation = poppler_page_get_orientation (page); + + while (r > 0) { + if (orientation == POPPLER_ORIENTATION_PORTRAIT) { + orientation = POPPLER_ORIENTATION_LANDSCAPE; + } else if (orientation == POPPLER_ORIENTATION_LANDSCAPE) { + orientation = POPPLER_ORIENTATION_UPSIDEDOWN; + } else if (orientation == POPPLER_ORIENTATION_UPSIDEDOWN) { + orientation = POPPLER_ORIENTATION_SEASCAPE; + } else { + orientation = POPPLER_ORIENTATION_PORTRAIT; + } + r -= 90; } - poppler_page_set_orientation (page, poppler_orientation); + poppler_page_set_orientation (page, orientation); } static void @@ -358,7 +338,7 @@ pdf_document_render_pixbuf (EvDocument *document, pdf_document = PDF_DOCUMENT (document); poppler_page = poppler_document_get_page (pdf_document->document, rc->page); - set_page_orientation (pdf_document, poppler_page, rc->orientation); + set_page_orientation (pdf_document, poppler_page, rc->rotation); poppler_page_get_size (poppler_page, &width_points, &height_points); width = (int) ((width_points * rc->scale) + 0.5); @@ -568,32 +548,6 @@ pdf_document_get_text (EvDocument *document, int page, EvRectangle *rect) return text; } -static EvOrientation -pdf_document_get_orientation (EvDocument *document) -{ - EvOrientation result; - PdfDocument *pdf_document = PDF_DOCUMENT (document); - - switch (get_document_orientation (pdf_document)) { - case POPPLER_ORIENTATION_PORTRAIT: - result = EV_ORIENTATION_PORTRAIT; - break; - case POPPLER_ORIENTATION_LANDSCAPE: - result = EV_ORIENTATION_LANDSCAPE; - break; - case POPPLER_ORIENTATION_UPSIDEDOWN: - result = EV_ORIENTATION_UPSIDEDOWN; - break; - case POPPLER_ORIENTATION_SEASCAPE: - result = EV_ORIENTATION_SEASCAPE; - break; - default: - g_assert_not_reached (); - } - - return result; -} - static void pdf_document_document_iface_init (EvDocumentIface *iface) { @@ -607,7 +561,6 @@ pdf_document_document_iface_init (EvDocumentIface *iface) iface->get_text = pdf_document_get_text; iface->can_get_text = pdf_document_can_get_text; iface->get_info = pdf_document_get_info; - iface->get_orientation = pdf_document_get_orientation; }; static void @@ -843,7 +796,7 @@ pdf_document_document_links_iface_init (EvDocumentLinksIface *iface) static GdkPixbuf * make_thumbnail_for_size (PdfDocument *pdf_document, gint page, - EvOrientation orientation, + int rotation, gint size, gboolean border) { @@ -854,7 +807,7 @@ make_thumbnail_for_size (PdfDocument *pdf_document, gdouble unscaled_width, unscaled_height; poppler_page = poppler_document_get_page (pdf_document->document, page); - set_page_orientation (pdf_document, poppler_page, orientation); + set_page_orientation (pdf_document, poppler_page, rotation); g_return_val_if_fail (poppler_page != NULL, NULL); pdf_document_thumbnails_get_dimensions (EV_DOCUMENT_THUMBNAILS (pdf_document), page, @@ -890,7 +843,7 @@ make_thumbnail_for_size (PdfDocument *pdf_document, static GdkPixbuf * pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails, gint page, - EvOrientation orientation, + gint rotation, gint size, gboolean border) { @@ -901,7 +854,7 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails pdf_document = PDF_DOCUMENT (document_thumbnails); poppler_page = poppler_document_get_page (pdf_document->document, page); - set_page_orientation (pdf_document, poppler_page, orientation); + set_page_orientation (pdf_document, poppler_page, rotation); g_return_val_if_fail (poppler_page != NULL, NULL); pixbuf = poppler_page_get_thumbnail (poppler_page); @@ -917,7 +870,7 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails } } else { /* There is no provided thumbnail. We need to make one. */ - pixbuf = make_thumbnail_for_size (pdf_document, page, orientation, size, border); + pixbuf = make_thumbnail_for_size (pdf_document, page, rotation, size, border); } g_object_unref (poppler_page); @@ -1188,7 +1141,7 @@ pdf_document_ps_exporter_do_page (EvPSExporter *exporter, EvRenderContext *rc) g_return_if_fail (pdf_document->ps_file != NULL); poppler_page = poppler_document_get_page (pdf_document->document, rc->page); - set_page_orientation (pdf_document, poppler_page, rc->orientation); + set_page_orientation (pdf_document, poppler_page, rc->rotation); poppler_page_render_to_ps (poppler_page, pdf_document->ps_file); g_object_unref (poppler_page); } @@ -1226,7 +1179,7 @@ pdf_selection_render_selection (EvSelection *selection, pdf_document = PDF_DOCUMENT (selection); poppler_page = poppler_document_get_page (pdf_document->document, rc->page); - set_page_orientation (pdf_document, poppler_page, rc->orientation); + set_page_orientation (pdf_document, poppler_page, rc->rotation); poppler_page_get_size (poppler_page, &width_points, &height_points); width = (int) ((width_points * rc->scale) + 0.5); @@ -1259,7 +1212,7 @@ pdf_selection_get_selection_region (EvSelection *selection, pdf_document = PDF_DOCUMENT (selection); poppler_page = poppler_document_get_page (pdf_document->document, rc->page); - set_page_orientation (pdf_document, poppler_page, rc->orientation); + set_page_orientation (pdf_document, poppler_page, rc->rotation); retval = poppler_page_get_selection_region (poppler_page, rc->scale, (PopplerRectangle *) points); g_object_unref (poppler_page); @@ -1279,7 +1232,7 @@ pdf_selection_get_selection_map (EvSelection *selection, pdf_document = PDF_DOCUMENT (selection); poppler_page = poppler_document_get_page (pdf_document->document, rc->page); - set_page_orientation (pdf_document, poppler_page, rc->orientation); + set_page_orientation (pdf_document, poppler_page, rc->rotation); points.x1 = 0.0; points.y1 = 0.0; diff --git a/ps/ps-document.c b/ps/ps-document.c index 28c4374..cfd22d9 100644 --- a/ps/ps-document.c +++ b/ps/ps-document.c @@ -1240,35 +1240,6 @@ ps_document_get_info (EvDocument *document) return info; } -static EvOrientation -ps_document_get_orientation (EvDocument *document) -{ - EvOrientation orientation; - PSDocument *ps = PS_DOCUMENT (document); - - g_return_val_if_fail (ps != NULL, EV_ORIENTATION_PORTRAIT); - - switch (ps->orientation) { - case GTK_GS_ORIENTATION_PORTRAIT: - orientation = EV_ORIENTATION_PORTRAIT; - break; - case GTK_GS_ORIENTATION_LANDSCAPE: - orientation = EV_ORIENTATION_LANDSCAPE; - break; - case GTK_GS_ORIENTATION_UPSIDEDOWN: - orientation = EV_ORIENTATION_UPSIDEDOWN; - break; - case GTK_GS_ORIENTATION_SEASCAPE: - orientation = EV_ORIENTATION_SEASCAPE; - break; - default: - orientation = EV_ORIENTATION_PORTRAIT; - break; - } - - return orientation; -} - static void ps_document_document_iface_init (EvDocumentIface *iface) { @@ -1278,7 +1249,6 @@ ps_document_document_iface_init (EvDocumentIface *iface) iface->get_n_pages = ps_document_get_n_pages; iface->get_page_size = ps_document_get_page_size; iface->get_info = ps_document_get_info; - iface->get_orientation = ps_document_get_orientation; } static void diff --git a/shell/ev-jobs.c b/shell/ev-jobs.c index 677b39f..c250f0e 100644 --- a/shell/ev-jobs.c +++ b/shell/ev-jobs.c @@ -301,7 +301,7 @@ ev_job_render_run (EvJobRender *job) EvJob * ev_job_thumbnail_new (EvDocument *document, gint page, - EvOrientation orientation, + int rotation, gint requested_width) { EvJobThumbnail *job; @@ -310,7 +310,7 @@ ev_job_thumbnail_new (EvDocument *document, EV_JOB (job)->document = g_object_ref (document); job->page = page; - job->orientation = orientation; + job->rotation = rotation; job->requested_width = requested_width; return EV_JOB (job); @@ -326,7 +326,7 @@ ev_job_thumbnail_run (EvJobThumbnail *job) job->thumbnail = ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (EV_JOB (job)->document), job->page, - job->orientation, + job->rotation, job->requested_width, TRUE); EV_JOB (job)->finished = TRUE; diff --git a/shell/ev-jobs.h b/shell/ev-jobs.h index 070fd4d..d7f49c7 100644 --- a/shell/ev-jobs.h +++ b/shell/ev-jobs.h @@ -135,7 +135,7 @@ struct _EvJobThumbnail EvJob parent; gint page; - EvOrientation orientation; + gint rotation; gint requested_width; GdkPixbuf *thumbnail; }; @@ -193,7 +193,7 @@ void ev_job_render_run (EvJobRender *thumbnail); GType ev_job_thumbnail_get_type (void); EvJob *ev_job_thumbnail_new (EvDocument *document, gint page, - EvOrientation orientation, + int rotation, gint requested_width); void ev_job_thumbnail_run (EvJobThumbnail *thumbnail); diff --git a/shell/ev-page-cache.c b/shell/ev-page-cache.c index 1b0f8e4..d7aa03d 100644 --- a/shell/ev-page-cache.c +++ b/shell/ev-page-cache.c @@ -33,7 +33,7 @@ struct _EvPageCache double* height_to_page; double* dual_height_to_page; - EvOrientation orientation; + int rotation; EvPageCacheInfo *size_cache; EvDocumentInfo *page_info; @@ -111,8 +111,8 @@ build_height_to_page (EvPageCache *page_cache) double uniform_height, page_height, next_page_height; double saved_height; - swap = (page_cache->orientation == EV_ORIENTATION_LANDSCAPE || - page_cache->orientation == EV_ORIENTATION_SEASCAPE); + swap = (page_cache->rotation == 90 || + page_cache->rotation == 270); g_free (page_cache->height_to_page); g_free (page_cache->dual_height_to_page); @@ -130,7 +130,7 @@ build_height_to_page (EvPageCache *page_cache) } page_cache->height_to_page [i] = (i + 1) * uniform_height; } else { - if (swap) { + if (!swap) { page_height = page_cache->size_cache [i].height; } else { page_height = page_cache->size_cache [i].width; @@ -186,7 +186,6 @@ ev_page_cache_new (EvDocument *document) /* Assume all pages are the same size until proven otherwise */ page_cache->uniform = TRUE; page_cache->has_labels = FALSE; - page_cache->orientation = ev_document_get_orientation (document); page_cache->n_pages = ev_document_get_n_pages (document); page_cache->page_labels = g_new0 (char *, page_cache->n_pages); page_cache->max_width = 0; @@ -363,7 +362,7 @@ ev_page_cache_get_title (EvPageCache *page_cache) void ev_page_cache_get_size (EvPageCache *page_cache, gint page, - EvOrientation orientation, + gint rotation, gfloat scale, gint *width, gint *height) @@ -387,8 +386,7 @@ ev_page_cache_get_size (EvPageCache *page_cache, *height = info->height; } - if (orientation == EV_ORIENTATION_PORTRAIT || - orientation == EV_ORIENTATION_UPSIDEDOWN) { + if (rotation == 0 || rotation == 180) { if (width) *width = (int) ((*width) * scale + 0.5); if (height) @@ -403,15 +401,14 @@ ev_page_cache_get_size (EvPageCache *page_cache, void ev_page_cache_get_max_width (EvPageCache *page_cache, - EvOrientation orientation, + gint rotation, gfloat scale, gint *width) { g_return_if_fail (EV_IS_PAGE_CACHE (page_cache)); if (width) { - if (orientation == EV_ORIENTATION_PORTRAIT || - orientation == EV_ORIENTATION_UPSIDEDOWN) { + if (rotation == 0 || rotation == 180) { *width = page_cache->max_width * scale; } else { *width = page_cache->max_height * scale; @@ -421,15 +418,14 @@ ev_page_cache_get_max_width (EvPageCache *page_cache, void ev_page_cache_get_max_height (EvPageCache *page_cache, - EvOrientation orientation, + gint rotation, gfloat scale, gint *height) { g_return_if_fail (EV_IS_PAGE_CACHE (page_cache)); if (height) { - if (orientation == EV_ORIENTATION_PORTRAIT || - orientation == EV_ORIENTATION_UPSIDEDOWN) { + if (rotation == 0 || rotation == 180) { *height = page_cache->max_height * scale; } else { *height = page_cache->max_width * scale; @@ -440,7 +436,7 @@ ev_page_cache_get_max_height (EvPageCache *page_cache, void ev_page_cache_get_height_to_page (EvPageCache *page_cache, gint page, - EvOrientation orientation, + gint rotation, gfloat scale, gint *height, gint *dual_height) @@ -450,8 +446,8 @@ ev_page_cache_get_height_to_page (EvPageCache *page_cache, g_return_if_fail (EV_IS_PAGE_CACHE (page_cache)); - if (page_cache->orientation != orientation) { - page_cache->orientation = orientation; + if (page_cache->rotation != rotation) { + page_cache->rotation = rotation; build_height_to_page (page_cache); } diff --git a/shell/ev-page-cache.h b/shell/ev-page-cache.h index 3360d82..ae0c179 100644 --- a/shell/ev-page-cache.h +++ b/shell/ev-page-cache.h @@ -36,21 +36,21 @@ gint ev_page_cache_get_n_pages (EvPageCache *page_cache); const char *ev_page_cache_get_title (EvPageCache *page_cache); void ev_page_cache_get_size (EvPageCache *page_cache, gint page, - EvOrientation orientation, + gint rotation, gfloat scale, gint *width, gint *height); void ev_page_cache_get_max_width (EvPageCache *page_cache, - EvOrientation orientation, + gint rotation, gfloat scale, gint *width); void ev_page_cache_get_max_height (EvPageCache *page_cache, - EvOrientation orientation, + gint rotation, gfloat scale, gint *height); void ev_page_cache_get_height_to_page (EvPageCache *page_cache, gint page, - EvOrientation orientation, + gint rotation, gfloat scale, gint *height, gint *dual_height); diff --git a/shell/ev-pixbuf-cache.c b/shell/ev-pixbuf-cache.c index 00d71d4..7ada246 100644 --- a/shell/ev-pixbuf-cache.c +++ b/shell/ev-pixbuf-cache.c @@ -255,7 +255,7 @@ check_job_size_and_unref (CacheJobInfo *job_info, ev_page_cache_get_size (page_cache, EV_JOB_RENDER (job_info->job)->rc->page, - EV_JOB_RENDER (job_info->job)->rc->orientation, + EV_JOB_RENDER (job_info->job)->rc->rotation, scale, &width, &height); @@ -479,7 +479,7 @@ add_job_if_needed (EvPixbufCache *pixbuf_cache, CacheJobInfo *job_info, EvPageCache *page_cache, gint page, - EvOrientation orientation, + gint rotation, gfloat scale, EvJobPriority priority) { @@ -491,7 +491,7 @@ add_job_if_needed (EvPixbufCache *pixbuf_cache, if (job_info->job) return; - ev_page_cache_get_size (page_cache, page, orientation, + ev_page_cache_get_size (page_cache, page, rotation, scale, &width, &height); if (job_info->pixbuf && @@ -501,11 +501,11 @@ add_job_if_needed (EvPixbufCache *pixbuf_cache, /* make a new job now */ if (job_info->rc == NULL) { - job_info->rc = ev_render_context_new (orientation, page, scale); + job_info->rc = ev_render_context_new (rotation, page, scale); } else { ev_render_context_set_page (job_info->rc, page); ev_render_context_set_scale (job_info->rc, scale); - ev_render_context_set_orientation (job_info->rc, orientation); + ev_render_context_set_rotation (job_info->rc, rotation); } /* Figure out what else we need for this job */ @@ -531,7 +531,7 @@ add_job_if_needed (EvPixbufCache *pixbuf_cache, static void ev_pixbuf_cache_add_jobs_if_needed (EvPixbufCache *pixbuf_cache, - EvOrientation orientation, + gint rotation, gfloat scale) { EvPageCache *page_cache; @@ -546,7 +546,7 @@ ev_pixbuf_cache_add_jobs_if_needed (EvPixbufCache *pixbuf_cache, page = pixbuf_cache->start_page + i; add_job_if_needed (pixbuf_cache, job_info, - page_cache, page, orientation, scale, + page_cache, page, rotation, scale, EV_JOB_PRIORITY_HIGH); } @@ -555,7 +555,7 @@ ev_pixbuf_cache_add_jobs_if_needed (EvPixbufCache *pixbuf_cache, page = pixbuf_cache->start_page - pixbuf_cache->preload_cache_size + i; add_job_if_needed (pixbuf_cache, job_info, - page_cache, page, orientation, scale, + page_cache, page, rotation, scale, EV_JOB_PRIORITY_LOW); } @@ -564,18 +564,18 @@ ev_pixbuf_cache_add_jobs_if_needed (EvPixbufCache *pixbuf_cache, page = pixbuf_cache->end_page + 1 + i; add_job_if_needed (pixbuf_cache, job_info, - page_cache, page, orientation, scale, + page_cache, page, rotation, scale, EV_JOB_PRIORITY_LOW); } } void -ev_pixbuf_cache_set_page_range (EvPixbufCache *pixbuf_cache, - gint start_page, - gint end_page, - EvOrientation orientation, - gfloat scale, +ev_pixbuf_cache_set_page_range (EvPixbufCache *pixbuf_cache, + gint start_page, + gint end_page, + gint rotation, + gfloat scale, GList *selection_list) { EvPageCache *page_cache; @@ -601,7 +601,7 @@ ev_pixbuf_cache_set_page_range (EvPixbufCache *pixbuf_cache, /* Finally, we add the new jobs for all the sizes that don't have a * pixbuf */ - ev_pixbuf_cache_add_jobs_if_needed (pixbuf_cache, orientation, scale); + ev_pixbuf_cache_add_jobs_if_needed (pixbuf_cache, rotation, scale); } GdkPixbuf * @@ -654,7 +654,7 @@ new_selection_pixbuf_needed (EvPixbufCache *pixbuf_cache, if (job_info->selection) { page_cache = ev_page_cache_get (pixbuf_cache->document); - ev_page_cache_get_size (page_cache, page, job_info->rc->orientation, + ev_page_cache_get_size (page_cache, page, job_info->rc->rotation, scale, &width, &height); if (width != gdk_pixbuf_get_width (job_info->selection) || @@ -737,9 +737,7 @@ ev_pixbuf_cache_get_selection_pixbuf (EvPixbufCache *pixbuf_cache, if (ev_rect_cmp (&(job_info->new_points), &(job_info->selection_points))) { EvRenderContext *rc; - rc = ev_render_context_new (EV_ORIENTATION_PORTRAIT, - page, - scale); + rc = ev_render_context_new (0, page, scale); /* we need to get a new selection pixbuf */ ev_document_doc_mutex_lock (); diff --git a/shell/ev-pixbuf-cache.h b/shell/ev-pixbuf-cache.h index 7af7243..0021f62 100644 --- a/shell/ev-pixbuf-cache.h +++ b/shell/ev-pixbuf-cache.h @@ -52,7 +52,7 @@ EvPixbufCache *ev_pixbuf_cache_new (EvDocument *document); void ev_pixbuf_cache_set_page_range (EvPixbufCache *pixbuf_cache, gint start_page, gint end_page, - EvOrientation orientation, + gint rotation, gfloat scale, GList *selection_list); GdkPixbuf *ev_pixbuf_cache_get_pixbuf (EvPixbufCache *pixbuf_cache, diff --git a/shell/ev-print-job.c b/shell/ev-print-job.c index b9aded8..955e4ba 100644 --- a/shell/ev-print-job.c +++ b/shell/ev-print-job.c @@ -273,8 +273,7 @@ idle_print_handler (EvPrintJob *job) #if 0 g_printerr ("Printing page %d\n", job->next_page); #endif - rc = ev_render_context_new (EV_ORIENTATION_PORTRAIT, - job->next_page, 1.0); + rc = ev_render_context_new (0, job->next_page, 1.0); ev_document_doc_mutex_lock (); ev_ps_exporter_do_page (EV_PS_EXPORTER (job->document), rc); diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c index f992d87..46dc9ce 100644 --- a/shell/ev-sidebar-thumbnails.c +++ b/shell/ev-sidebar-thumbnails.c @@ -229,8 +229,7 @@ add_range (EvSidebarThumbnails *sidebar_thumbnails, -1); if (job == NULL && !thumbnail_set) { - job = (EvJobThumbnail *)ev_job_thumbnail_new (priv->document, page, THUMBNAIL_WIDTH, - EV_ORIENTATION_PORTRAIT); + job = (EvJobThumbnail *)ev_job_thumbnail_new (priv->document, page, THUMBNAIL_WIDTH, 0); ev_job_queue_add_job (EV_JOB (job), EV_JOB_PRIORITY_HIGH); g_object_set_data_full (G_OBJECT (job), "tree_iter", gtk_tree_iter_copy (&iter), diff --git a/shell/ev-view.c b/shell/ev-view.c index 0953999..e4524eb 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -149,7 +149,7 @@ struct _EvView { int find_result; int spacing; - EvOrientation orientation; + int rotation; double scale; gboolean continuous; @@ -532,7 +532,7 @@ view_update_range_and_current_page (EvView *view) ev_pixbuf_cache_set_page_range (view->pixbuf_cache, view->start_page, view->end_page, - view->orientation, + view->rotation, view->scale, view->selection_info.selections); } @@ -757,17 +757,17 @@ get_page_y_offset (EvView *view, int page, double zoom, int *y_offset) g_return_if_fail (y_offset != NULL); - ev_page_cache_get_max_width (view->page_cache, view->orientation, zoom, &max_width); + ev_page_cache_get_max_width (view->page_cache, view->rotation, zoom, &max_width); compute_border (view, max_width, max_width, &border); if (view->dual_page) { ev_page_cache_get_height_to_page (view->page_cache, page, - view->orientation, zoom, NULL, &offset); + view->rotation, zoom, NULL, &offset); offset += (page / 2 + 1) * view->spacing + (page / 2) * (border.top + border.bottom); } else { ev_page_cache_get_height_to_page (view->page_cache, page, - view->orientation, zoom, &offset, NULL); + view->rotation, zoom, &offset, NULL); offset += (page + 1) * view->spacing + page * (border.top + border.bottom); } @@ -788,7 +788,7 @@ get_page_extents (EvView *view, /* Get the size of the page */ ev_page_cache_get_size (view->page_cache, page, - view->orientation, + view->rotation, view->scale, &width, &height); compute_border (view, width, height, border); @@ -803,7 +803,7 @@ get_page_extents (EvView *view, gint x, y; ev_page_cache_get_max_width (view->page_cache, view->scale, - view->orientation, &max_width); + view->rotation, &max_width); max_width = max_width + border->left + border->right; /* Get the location of the bounding box */ if (view->dual_page) { @@ -835,7 +835,7 @@ get_page_extents (EvView *view, if (other_page < ev_page_cache_get_n_pages (view->page_cache)) { ev_page_cache_get_size (view->page_cache, other_page, - view->orientation, + view->rotation, view->scale, &width_2, &height_2); if (width_2 > width) @@ -1067,7 +1067,7 @@ ev_view_size_request_continuous_dual_page (EvView *view, gint n_pages; GtkBorder border; - ev_page_cache_get_max_width (view->page_cache, view->orientation, + ev_page_cache_get_max_width (view->page_cache, view->rotation, view->scale, &max_width); compute_border (view, max_width, max_width, &border); @@ -1095,7 +1095,7 @@ ev_view_size_request_continuous (EvView *view, GtkBorder border; - ev_page_cache_get_max_width (view->page_cache, view->orientation, + ev_page_cache_get_max_width (view->page_cache, view->rotation, view->scale, &max_width); n_pages = ev_page_cache_get_n_pages (view->page_cache); compute_border (view, max_width, max_width, &border); @@ -1123,14 +1123,14 @@ ev_view_size_request_dual_page (EvView *view, /* Find the largest of the two. */ ev_page_cache_get_size (view->page_cache, view->current_page, - view->orientation, + view->rotation, view->scale, &width, &height); if (view->current_page + 1 < ev_page_cache_get_n_pages (view->page_cache)) { gint width_2, height_2; ev_page_cache_get_size (view->page_cache, view->current_page + 1, - view->orientation, + view->rotation, view->scale, &width_2, &height_2); if (width_2 > width) { @@ -1162,7 +1162,7 @@ ev_view_size_request_single_page (EvView *view, ev_page_cache_get_size (view->page_cache, view->current_page, - view->orientation, + view->rotation, view->scale, &width, &height); compute_border (view, width, height, &border); @@ -1615,7 +1615,7 @@ draw_one_page (EvView *view, selection = find_selection_for_page (view, page); ev_page_cache_get_size (view->page_cache, - page, view->orientation, + page, view->rotation, view->scale, &width, &height); /* Render the document itself */ @@ -2299,10 +2299,9 @@ ev_view_zoom_out (EvView *view) } static void -ev_view_set_orientation (EvView *view, - EvOrientation orientation) +ev_view_set_rotation (EvView *view, int rotation) { - view->orientation = orientation; + view->rotation = rotation; gtk_widget_queue_resize (GTK_WIDGET (view)); } @@ -2310,37 +2309,13 @@ ev_view_set_orientation (EvView *view, void ev_view_rotate_right (EvView *view) { - EvOrientation orientation; - - if (view->orientation == EV_ORIENTATION_PORTRAIT) { - orientation = EV_ORIENTATION_LANDSCAPE; - } else if (view->orientation == EV_ORIENTATION_LANDSCAPE) { - orientation = EV_ORIENTATION_UPSIDEDOWN; - } else if (view->orientation == EV_ORIENTATION_UPSIDEDOWN) { - orientation = EV_ORIENTATION_SEASCAPE; - } else { - orientation = EV_ORIENTATION_PORTRAIT; - } - - ev_view_set_orientation (view, orientation); + ev_view_set_rotation (view, view->rotation + 90); } void ev_view_rotate_left (EvView *view) { - EvOrientation orientation; - - if (view->orientation == EV_ORIENTATION_PORTRAIT) { - orientation = EV_ORIENTATION_SEASCAPE; - } else if (view->orientation == EV_ORIENTATION_SEASCAPE) { - orientation = EV_ORIENTATION_UPSIDEDOWN; - } else if (view->orientation == EV_ORIENTATION_UPSIDEDOWN) { - orientation = EV_ORIENTATION_LANDSCAPE; - } else { - orientation = EV_ORIENTATION_PORTRAIT; - } - - ev_view_set_orientation (view, orientation); + ev_view_set_rotation (view, view->rotation - 90); } static double @@ -2393,7 +2368,7 @@ ev_view_zoom_for_size_presentation (EvView *view, ev_page_cache_get_size (view->page_cache, view->current_page, - view->orientation, + view->rotation, 1.0, &doc_width, &doc_height); @@ -2413,11 +2388,11 @@ ev_view_zoom_for_size_continuous_and_dual_page (EvView *view, gdouble scale; ev_page_cache_get_max_width (view->page_cache, - view->orientation, + view->rotation, 1.0, &doc_width); ev_page_cache_get_max_height (view->page_cache, - view->orientation, + view->rotation, 1.0, &doc_height); compute_border (view, doc_width, doc_height, &border); @@ -2451,11 +2426,11 @@ ev_view_zoom_for_size_continuous (EvView *view, gdouble scale; ev_page_cache_get_max_width (view->page_cache, - view->orientation, + view->rotation, 1.0, &doc_width); ev_page_cache_get_max_height (view->page_cache, - view->orientation, + view->rotation, 1.0, &doc_height); compute_border (view, doc_width, doc_height, &border); @@ -2493,7 +2468,7 @@ ev_view_zoom_for_size_dual_page (EvView *view, /* Find the largest of the two. */ ev_page_cache_get_size (view->page_cache, view->current_page, - view->orientation, + view->rotation, 1.0, &doc_width, &doc_height); @@ -2501,7 +2476,7 @@ ev_view_zoom_for_size_dual_page (EvView *view, gint width_2, height_2; ev_page_cache_get_size (view->page_cache, other_page, - view->orientation, + view->rotation, 1.0, &width_2, &height_2); if (width_2 > doc_width) @@ -2538,7 +2513,7 @@ ev_view_zoom_for_size_single_page (EvView *view, ev_page_cache_get_size (view->page_cache, view->current_page, - view->orientation, + view->rotation, 1.0, &doc_width, &doc_height); @@ -2883,7 +2858,7 @@ compute_new_selection_text (EvView *view, GdkPoint *point; ev_page_cache_get_size (view->page_cache, i, - view->orientation, + view->rotation, 1.0, &width, &height); selection = g_new0 (EvViewSelection, 1); @@ -2981,7 +2956,7 @@ ev_view_select_all (EvView *view) EvViewSelection *selection; ev_page_cache_get_size (view->page_cache, - view->orientation, + view->rotation, i, 1.0, &width, &height); selection = g_new0 (EvViewSelection, 1); diff --git a/tiff/tiff-document.c b/tiff/tiff-document.c index aba8851..d30ab18 100644 --- a/tiff/tiff-document.c +++ b/tiff/tiff-document.c @@ -176,30 +176,6 @@ tiff_document_get_page_size (EvDocument *document, pop_handlers (); } -static EvOrientation -tiff_document_get_orientation (EvDocument *document) -{ - return EV_ORIENTATION_PORTRAIT; -} - -static GdkPixbuf * -rotate_pixbuf (EvDocument *document, EvOrientation orientation, GdkPixbuf *pixbuf) -{ - TiffDocument *tiff_document = TIFF_DOCUMENT (document); - - switch (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 * tiff_document_render_pixbuf (EvDocument *document, EvRenderContext *rc) @@ -281,7 +257,7 @@ tiff_document_render_pixbuf (EvDocument *document, GDK_INTERP_BILINEAR); g_object_unref (pixbuf); - rotated_pixbuf = rotate_pixbuf (document, rc->orientation, scaled_pixbuf); + rotated_pixbuf = gdk_pixbuf_rotate_simple (scaled_pixbuf, rc->rotation); g_object_unref (scaled_pixbuf); return rotated_pixbuf; @@ -332,13 +308,12 @@ tiff_document_document_iface_init (EvDocumentIface *iface) iface->get_page_size = tiff_document_get_page_size; iface->render_pixbuf = tiff_document_render_pixbuf; iface->get_info = tiff_document_get_info; - iface->get_orientation = tiff_document_get_orientation; } static GdkPixbuf * tiff_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, gint page, - EvOrientation orientation, + gint rotation, gint size, gboolean border) { @@ -350,7 +325,7 @@ tiff_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, page, &w, &h); - rc = ev_render_context_new (EV_ORIENTATION_PORTRAIT, page, size/w); + rc = ev_render_context_new (rotation, page, size/w); pixbuf = tiff_document_render_pixbuf (EV_DOCUMENT (document), rc); g_object_unref (G_OBJECT (rc)); -- cgit v0.9.1