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. --- (limited to 'shell') 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); -- cgit v0.9.1