diff --git a/document.c b/document.c index bbd79e7..e2b5572 100644 --- a/document.c +++ b/document.c @@ -521,6 +521,37 @@ zathura_page_form_fields_free(girara_list_t* UNUSED(list)) return false; } +girara_list_t* +zathura_page_images_get(zathura_page_t* page) +{ + if (page == NULL || page->document == NULL) { + return NULL; + } + + if (page->document->functions.page_images_get == NULL) { + girara_error("%s not implemented", __FUNCTION__); + return false; + } + + return page->document->functions.page_images_get(page); + +} + +bool +zathura_page_image_save(zathura_page_t* page, zathura_image_t* image, const char* file) +{ + if (page == NULL || page->document == NULL || image == NULL || file == NULL) { + return false; + } + + if (page->document->functions.page_image_save == NULL) { + girara_error("%s not implemented", __FUNCTION__); + return false; + } + + return page->document->functions.page_image_save(page, image, file); +} + bool zathura_page_render(zathura_page_t* page, cairo_t* cairo) { diff --git a/document.h b/document.h index aae6702..64e205d 100644 --- a/document.h +++ b/document.h @@ -87,6 +87,15 @@ typedef struct zathura_rectangle_s double y2; /**< Y coordinate of point 2 */ } zathura_rectangle_t; +/** + * Image structure + */ +typedef struct zathura_image_s +{ + zathura_rectangle_t position; /**< Coordinates of the image */ + void* data; /**< Custom data of the plugin */ +} zathura_image_t; + /** * Possible link types */ @@ -225,6 +234,16 @@ struct zathura_document_s */ girara_list_t* (*page_form_fields_get)(zathura_page_t* page); + /** + * Get list of images + */ + girara_list_t* (*page_images_get)(zathura_page_t* page); + + /** + * Save image to a file + */ + bool (*page_image_save)(zathura_page_t* page, zathura_image_t* image, const char* file); + /** * Renders the page */ @@ -305,7 +324,7 @@ girara_tree_node_t* zathura_document_index_generate(zathura_document_t* document girara_list_t* zathura_document_attachments_get(zathura_document_t* document); /** - * Free document attachments + * Save document attachment * * @param document The document objects * @param attachment name of the attachment @@ -381,6 +400,24 @@ girara_list_t* zathura_page_form_fields_get(zathura_page_t* page); */ bool zathura_page_form_fields_free(girara_list_t* list); +/** + * Get list of images + * + * @param page Page + * @return List of images + */ +girara_list_t* zathura_page_images_get(zathura_page_t* page); + +/** + * Save image + * + * @param page Page + * @param image The image + * @param file Path to the file + * @return true if no error occured + */ +bool zathura_page_image_save(zathura_page_t* page, zathura_image_t* image, const char* file); + /** * Render page *