From 25998f832079decd8cbb2092b3cfb41d9fb75a3b Mon Sep 17 00:00:00 2001 From: Abdo Roig-Maranges Date: Sun, 20 Oct 2013 17:05:15 +0200 Subject: [PATCH] make the document object aware of page layout Now the document object knows about pages_per_row, first_page_column and page_padding, so we will be able to compute sizes and positions of the document view without querying the GTK widgets. --- document.c | 40 ++++++++++++++++++++++++++++++++++++++++ document.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/document.c b/document.c index aa55a5e..7fd104d 100644 --- a/document.c +++ b/document.c @@ -52,6 +52,9 @@ struct zathura_document_s { int page_offset; /**< Page offset */ double cell_width; /**< width of a page cell in the document (not ransformed by scale and rotation) */ double cell_height; /**< height of a page cell in the document (not ransformed by scale and rotation) */ + unsigned int pages_per_row; /**< number of pages in a row */ + unsigned int first_page_column; /**< column of the first page */ + unsigned int page_padding; /**< padding between pages */ /** * Document pages @@ -424,6 +427,43 @@ zathura_document_get_cell_size(zathura_document_t* document, } +void +zathura_document_set_page_layout(zathura_document_t* document, unsigned int page_padding, + unsigned int pages_per_row, unsigned int first_page_column) +{ + g_return_if_fail(document != NULL); + document->page_padding = page_padding; + document->pages_per_row = pages_per_row; + document->first_page_column = first_page_column; +} + +unsigned int +zathura_document_get_page_padding(zathura_document_t* document) +{ + if (document == NULL) { + return 0; + } + return document->page_padding; +} + +unsigned int +zathura_document_get_pages_per_row(zathura_document_t* document) +{ + if (document == NULL) { + return 0; + } + return document->pages_per_row; +} + +unsigned int +zathura_document_get_first_page_column(zathura_document_t* document) +{ + if (document == NULL) { + return 0; + } + return document->first_page_column; +} + zathura_error_t zathura_document_save_as(zathura_document_t* document, const char* path) { diff --git a/document.h b/document.h index d803d34..3264abe 100644 --- a/document.h +++ b/document.h @@ -188,6 +188,41 @@ void zathura_document_set_data(zathura_document_t* document, void* data); void zathura_document_get_cell_size(zathura_document_t* document, unsigned int* height, unsigned int* width); +/** + * Sets the layout of the pages in the document + * + * @param[in] document The document instance + * @param[in] page_padding pixels of padding between pages + * @param[in] pages_per_row number of pages per row + * @param[in] first_page_column column of the first page (first column is 1) + */ +void zathura_document_set_page_layout(zathura_document_t* document, unsigned int page_padding, + unsigned int pages_per_row, unsigned int first_page_column); + +/** + * Returns the padding in pixels betwen pages + * + * @param document The document + * @return The padding in pixels between pages + */ +unsigned int zathura_document_get_page_padding(zathura_document_t* document); + +/** + * Returns the number of pages per row + * + * @param document The document + * @return The number of pages per row + */ +unsigned int zathura_document_get_pages_per_row(zathura_document_t* document); + +/** + * Returns the column for the first page (first column = 1) + * + * @param document The document + * @return The column for the first page + */ +unsigned int zathura_document_get_first_page_column(zathura_document_t* document); + /** * Save the document *