Commit 27d79735 authored by Benoît Knecht's avatar Benoît Knecht Committed by Sebastian Ramacher

Add document method to compute the size of a cell

A document is laid out on a homogeneous gtk table/grid. This new method,
zathura_document_get_cell_size, computes the size of the cells in that
table/grid, at the current scale.
Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <>
parent ff305e69
......@@ -389,6 +389,34 @@ zathura_document_set_page_offset(zathura_document_t* document, unsigned int page
zathura_document_get_cell_size(zathura_document_t* document,
unsigned int* height, unsigned int* width)
g_return_if_fail(document != NULL && height != NULL && width != NULL);
unsigned int number_of_pages =
*width = 0;
*height = 0;
/* Get the size of each cell of the table/grid, assuming it is homogeneous
* (i.e. each cell has the same dimensions. */
for (unsigned int page_id = 0; page_id < number_of_pages; page_id++) {
zathura_page_t* page = zathura_document_get_page(document, page_id);
if (page == NULL)
unsigned int page_width = 0, page_height = 0;
page_calc_height_width(page, &page_height, &page_width, true);
if (*width < page_width)
*width = page_width;
if (*height < page_height)
*height = page_height;
zathura_document_save_as(zathura_document_t* document, const char* path)
......@@ -169,6 +169,15 @@ void* zathura_document_get_data(zathura_document_t* document);
void zathura_document_set_data(zathura_document_t* document, void* data);
* Computes the size of a cell in the document's layout table, assuming that the table is homogeneous (i.e. every cell has the same dimensions). It takes the current scale into account.
* @param[in] document The document instance
* @param[out] height,width The computed height and width of the cell
void zathura_document_get_cell_size(zathura_document_t* document,
unsigned int* height, unsigned int* width);
* Save the document
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment