From 647f26a77f2f8a020d32b87a3151deb8a8913cbd Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Tue, 27 Mar 2012 14:44:09 +0200 Subject: [PATCH] Implemented some zathura_document wrapper functions --- document.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ document.h | 66 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+) diff --git a/document.c b/document.c index 6f3709b..605f46f 100644 --- a/document.c +++ b/document.c @@ -235,6 +235,87 @@ zathura_document_free(zathura_document_t* document) return error; } +const char* +zathura_document_get_path(zathura_document_t* document) +{ + if (document == NULL) { + return NULL; + } + + return document->file_path; +} + +const char* +zathura_document_get_password(zathura_document_t* document) +{ + if (document == NULL) { + return NULL; + } + + return document->password; +} + +void* +zathura_document_get_data(zathura_document_t* document) +{ + if (document == NULL) { + return NULL; + } + + return document->data; +} + +void +zathura_document_set_data(zathura_document_t* document, void* data) +{ + if (document == NULL) { + return; + } + + document->data = data; +} + +unsigned int +zathura_document_get_number_of_pages(zathura_document_t* document) +{ + if (document == NULL) { + return 0; + } + + return document->number_of_pages; +} + +void +zathura_document_set_number_of_pages(zathura_document_t* document, unsigned int number_of_pages) +{ + if (document == NULL) { + return; + } + + document->number_of_pages = number_of_pages; +} + +unsigned int +zathura_document_get_current_page(zathura_document_t* document) +{ + if (document == NULL) { + return 0; + } + + return document->current_page_number; +} + +void +zathura_document_set_current_page(zathura_document_t* document, unsigned int + current_page) +{ + if (document == NULL) { + return; + } + + document->current_page_number = current_page; +} + zathura_error_t zathura_document_save_as(zathura_document_t* document, const char* path) { diff --git a/document.h b/document.h index 316e666..4c0a4c2 100644 --- a/document.h +++ b/document.h @@ -64,6 +64,22 @@ struct zathura_document_s zathura_document_t* zathura_document_open(zathura_t* zathura, const char* path, const char* password); +/** + * Returns the path of the document + * + * @param document The document + * @return The file path of the document + */ +const char* zathura_document_get_path(zathura_document_t* document); + +/** + * Returns the password of the document + * + * @param document The document + * @return Returns the password of the document + */ +const char* zathura_document_get_password(zathura_document_t* document); + /** * Free the document * @@ -73,6 +89,56 @@ zathura_document_t* zathura_document_open(zathura_t* zathura, const char* path, */ zathura_error_t zathura_document_free(zathura_document_t* document); +/** + * Returns the private data of the document + * + * @param document The document + * @return The private data or NULL + */ +void* zathura_document_get_data(zathura_document_t* document); + +/** + * Returns the number of pages + * + * @param document The document + * @return Number of pages + */ +unsigned int zathura_document_get_number_of_pages(zathura_document_t* document); + +/** + * Sets the number of pages + * + * @param document The document + * @param number_of_pages Number of pages + */ +void zathura_document_set_number_of_pages(zathura_document_t* document, unsigned + int number_of_pages); + +/** + * Returns the current page number + * + * @param document The document + * @return Current page + */ +unsigned int zathura_document_get_current_page(zathura_document_t* document); + +/** + * Sets the number of pages + * + * @param document The document + * @param current_page The current page number + */ +void zathura_document_set_current_page(zathura_document_t* document, unsigned + int current_page); + +/** + * Sets the private data of the document + * + * @param document The document + * @param data The new private data + */ +void zathura_document_set_data(zathura_document_t* document, void* data); + /** * Save the document *