From e9ffd7b5401b32979ea83bc56da4592e80f8ce3e Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Thu, 16 Jun 2005 16:40:40 +0000 Subject: Add a get_orientation api. Improve set_orientation. 2005-06-16 Marco Pesenti Gritti * backend/ev-document.c: (ev_document_get_orientation): * backend/ev-document.h: * pdf/ev-poppler.cc: * ps/ps-document.c: (ps_document_get_orientation), (ps_document_set_orientation), (ps_document_document_iface_init): Add a get_orientation api. Improve set_orientation. * data/evince-ui.xml: * shell/ev-view.c: (ev_view_set_orientation), (ev_view_rotate_right), (ev_view_rotate_left): * shell/ev-view.h: * shell/ev-window.c: (ev_window_cmd_edit_rotate_left), (ev_window_cmd_edit_rotate_right): Better ui for changing document orientation --- (limited to 'pdf') diff --git a/pdf/ev-poppler.cc b/pdf/ev-poppler.cc index 1f1e4e5..0f9a356 100644 --- a/pdf/ev-poppler.cc +++ b/pdf/ev-poppler.cc @@ -128,6 +128,7 @@ static void pdf_document_init (PdfDocument *pdf_document) { pdf_document->password = NULL; + pdf_document->orientation = POPPLER_ORIENTATION_PORTRAIT; } static void @@ -175,6 +176,24 @@ pdf_document_save (EvDocument *document, return retval; } +static PopplerOrientation +get_document_orientation (PdfDocument *pdf_document) +{ +#ifdef POPPLER_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) { + return poppler_page_get_orientation (page); + } else { + return POPPLER_ORIENTATION_PORTRAIT; + } +#else + return POPPLER_ORIENTATION_PORTRAIT; +#endif +} + static gboolean pdf_document_load (EvDocument *document, const char *uri, @@ -191,6 +210,8 @@ pdf_document_load (EvDocument *document, return FALSE; } + pdf_document->orientation = get_document_orientation (pdf_document); + return TRUE; } @@ -488,6 +509,30 @@ pdf_document_get_text (EvDocument *document, int page, EvRectangle *rect) return poppler_page_get_text (poppler_page, &r); } +static EvOrientation +pdf_document_get_orientation (EvDocument *document) +{ + EvOrientation result; + PdfDocument *pdf_document = PDF_DOCUMENT (document); + + switch (pdf_document->orientation) { + 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; + } + + return result; +} + static void pdf_document_set_orientation (EvDocument *document, EvOrientation orientation) { @@ -495,9 +540,6 @@ pdf_document_set_orientation (EvDocument *document, EvOrientation orientation) PopplerOrientation poppler_orientation; switch (orientation) { - case EV_ORIENTATION_DOCUMENT: - poppler_orientation = POPPLER_ORIENTATION_DOCUMENT; - break; case EV_ORIENTATION_PORTRAIT: poppler_orientation = POPPLER_ORIENTATION_PORTRAIT; break; @@ -529,6 +571,7 @@ pdf_document_document_iface_init (EvDocumentIface *iface) iface->can_get_text = pdf_document_can_get_text; iface->get_info = pdf_document_get_info; iface->set_orientation = pdf_document_set_orientation; + iface->get_orientation = pdf_document_get_orientation; }; static void -- cgit v0.9.1