+2005-07-29 Marco Pesenti Gritti <mpg@redhat.com>
+
+ * 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 <mpg@redhat.com>
* shell/ev-page-cache.c: (build_height_to_page),
GdkPixbuf *
ev_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
gint page,
- EvOrientation orientation,
+ int rotation,
gint size,
gboolean border)
{
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
/* Methods */
GdkPixbuf * (* get_thumbnail) (EvDocumentThumbnails *document,
gint page,
- EvOrientation orientation,
+ gint rotation,
gint size,
gboolean border);
void (* get_dimensions) (EvDocumentThumbnails *document,
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,
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)
{
int page);
GdkPixbuf * (* render_pixbuf) (EvDocument *document,
EvRenderContext *rc);
- EvOrientation (* get_orientation) (EvDocument *document);
EvDocumentInfo * (* get_info) (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);
EvRenderContext *
-ev_render_context_new (EvOrientation orientation,
+ev_render_context_new (int rotation,
gint page,
gdouble scale)
{
rc = (EvRenderContext *) g_object_new (EV_TYPE_RENDER_CONTEXT, NULL);
- rc->orientation = orientation;
+ rc->rotation = rotation;
rc->page = page;
rc->scale = scale;
}
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
#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;
struct _EvRenderContext
{
GObject parent;
- EvOrientation orientation;
+ int rotation;
gint page;
gdouble scale;
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);
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,
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
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);
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)
{
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
static GdkPixbuf *
make_thumbnail_for_size (PdfDocument *pdf_document,
gint page,
- EvOrientation orientation,
+ int rotation,
gint size,
gboolean border)
{
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,
static GdkPixbuf *
pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails,
gint page,
- EvOrientation orientation,
+ gint rotation,
gint size,
gboolean border)
{
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);
}
} 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);
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);
}
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);
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);
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;
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)
{
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
EvJob *
ev_job_thumbnail_new (EvDocument *document,
gint page,
- EvOrientation orientation,
+ int rotation,
gint requested_width)
{
EvJobThumbnail *job;
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);
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;
EvJob parent;
gint page;
- EvOrientation orientation;
+ gint rotation;
gint requested_width;
GdkPixbuf *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);
double* height_to_page;
double* dual_height_to_page;
- EvOrientation orientation;
+ int rotation;
EvPageCacheInfo *size_cache;
EvDocumentInfo *page_info;
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);
}
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;
/* 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;
void
ev_page_cache_get_size (EvPageCache *page_cache,
gint page,
- EvOrientation orientation,
+ gint rotation,
gfloat scale,
gint *width,
gint *height)
*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)
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;
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;
void
ev_page_cache_get_height_to_page (EvPageCache *page_cache,
gint page,
- EvOrientation orientation,
+ gint rotation,
gfloat scale,
gint *height,
gint *dual_height)
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);
}
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);
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);
CacheJobInfo *job_info,
EvPageCache *page_cache,
gint page,
- EvOrientation orientation,
+ gint rotation,
gfloat scale,
EvJobPriority priority)
{
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 &&
/* 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 */
static void
ev_pixbuf_cache_add_jobs_if_needed (EvPixbufCache *pixbuf_cache,
- EvOrientation orientation,
+ gint rotation,
gfloat scale)
{
EvPageCache *page_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);
}
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);
}
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;
/* 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 *
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) ||
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 ();
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,
#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);
-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),
int find_result;
int spacing;
- EvOrientation orientation;
+ int rotation;
double scale;
gboolean continuous;
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);
}
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);
}
/* 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);
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) {
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)
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);
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);
/* 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) {
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);
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 */
}
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));
}
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
ev_page_cache_get_size (view->page_cache,
view->current_page,
- view->orientation,
+ view->rotation,
1.0,
&doc_width,
&doc_height);
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);
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);
/* 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);
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)
ev_page_cache_get_size (view->page_cache,
view->current_page,
- view->orientation,
+ view->rotation,
1.0,
&doc_width,
&doc_height);
GdkPoint *point;
ev_page_cache_get_size (view->page_cache, i,
- view->orientation,
+ view->rotation,
1.0, &width, &height);
selection = g_new0 (EvViewSelection, 1);
EvViewSelection *selection;
ev_page_cache_get_size (view->page_cache,
- view->orientation,
+ view->rotation,
i, 1.0, &width, &height);
selection = g_new0 (EvViewSelection, 1);
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)
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;
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)
{
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));