Commit bba265cc authored by Sebastian Ramacher's avatar Sebastian Ramacher

Add function to get page labels

Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <sebastian+dev@ramacher.at>
parent c4ef771c
......@@ -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;
}
......@@ -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
......@@ -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;
};
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment