diff --git a/zathura/page.c b/zathura/page.c index a40651a..9659227 100644 --- a/zathura/page.c +++ b/zathura/page.c @@ -359,3 +359,34 @@ zathura_page_render(zathura_page_t* page, cairo_t* cairo, bool printing) return functions->page_render_cairo(page, page->data, cairo, printing); } + +char* +zathura_page_get_label(zathura_page_t* page, zathura_error_t* error) +{ + if (page == NULL || page->document == NULL) { + if (error) { + *error = ZATHURA_ERROR_INVALID_ARGUMENTS; + } + return NULL; + } + + zathura_plugin_t* plugin = zathura_document_get_plugin(page->document); + zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin); + if (functions->page_get_label == NULL) { + if (error) { + *error = ZATHURA_ERROR_NOT_IMPLEMENTED; + } + return NULL; + } + + char* ret = NULL; + zathura_error_t e = functions->page_get_label(page, page->data, &ret); + if (e != ZATHURA_ERROR_OK) { + if (error) { + *error = e; + } + return NULL; + } + + return ret; +} diff --git a/zathura/page.h b/zathura/page.h index d8f260e..0db3cfa 100644 --- a/zathura/page.h +++ b/zathura/page.h @@ -203,4 +203,15 @@ char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle, */ zathura_error_t zathura_page_render(zathura_page_t* page, cairo_t* cairo, bool printing); +/** + * Get page label. Note that the page label might not exist, in this case NULL + * is returned. + * + * @param page Page + * @param error Set to an error value (see \ref zathura_Error_t) if an error + * occurred. + * @return Page label + */ +char* zathura_page_get_label(zathura_page_t* page, zathura_error_t* error); + #endif // PAGE_H diff --git a/zathura/plugin-api.h b/zathura/plugin-api.h index c372756..3af18e5 100644 --- a/zathura/plugin-api.h +++ b/zathura/plugin-api.h @@ -91,10 +91,15 @@ typedef char* (*zathura_plugin_page_get_text_t)(zathura_page_t* page, void* data typedef zathura_image_buffer_t* (*zathura_plugin_page_render_t)(zathura_page_t* page, void* data, zathura_error_t* error); /** - * Renders the page + * Renders the page to a cairo surface. */ typedef zathura_error_t (*zathura_plugin_page_render_cairo_t)(zathura_page_t* page, void* data, cairo_t* cairo, bool printing); +/** + * Get page label. + */ +typedef zathura_error_t (*zathura_plugin_page_get_label_t)(zathura_page_t* page, void* data, char** label); + struct zathura_plugin_functions_s { @@ -179,9 +184,14 @@ struct zathura_plugin_functions_s zathura_plugin_page_render_t page_render; /** - * Renders the page + * Renders the page to a cairo surface. */ zathura_plugin_page_render_cairo_t page_render_cairo; + + /** + * Get page label. + */ + zathura_plugin_page_get_label_t page_get_label; }; /**