Add new function to get signatures from pages

This commit is contained in:
Sebastian Ramacher 2023-10-26 21:46:51 +02:00
parent d9bdd00b53
commit 1ecd8d69c6
3 changed files with 58 additions and 1 deletions

View File

@ -412,3 +412,41 @@ zathura_page_get_label(zathura_page_t* page, zathura_error_t* error)
return ret;
}
static void
sig_free(void* sig)
{
zathura_signature_info_free(sig);
}
girara_list_t*
zathura_page_get_signatures(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);
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
if (functions->page_get_signatures == NULL) {
if (error) {
*error = ZATHURA_ERROR_NOT_IMPLEMENTED;
}
return NULL;
}
girara_list_t* ret = girara_list_new2(sig_free);
zathura_error_t e = functions->page_get_signatures(page, page->data, ret);
if (e != ZATHURA_ERROR_OK) {
if (error) {
*error = e;
}
girara_list_free(ret);
return NULL;
}
return ret;
}

View File

@ -218,10 +218,20 @@ ZATHURA_PLUGIN_API zathura_error_t zathura_page_render(zathura_page_t* page, cai
* is returned.
*
* @param page Page
* @param error Set to an error value (see \ref zathura_Error_t) if an error
* @param error Set to an error value (see \ref zathura_error_t) if an error
* occurred.
* @return Page label
*/
ZATHURA_PLUGIN_API char* zathura_page_get_label(zathura_page_t* page, zathura_error_t* error);
/**
* Get signatures of a page
*
* @param page Page
* @param error Set to an error value (see \ref zathura_error_t) if an error
* occurred.
* @return List of signatures
*/
ZATHURA_PLUGIN_API girara_list_t* zathura_page_get_signatures(zathura_page_t* page, zathura_error_t* error);
#endif // PAGE_H

View File

@ -108,6 +108,10 @@ typedef zathura_error_t (*zathura_plugin_page_render_cairo_t)(zathura_page_t* pa
*/
typedef zathura_error_t (*zathura_plugin_page_get_label_t)(zathura_page_t* page, void* data, char** label);
/**
* Get signatures
*/
typedef zathura_error_t (*zathura_plugin_page_get_signatures)(zathura_page_t* page, void* data, girara_list_t*);
struct zathura_plugin_functions_s
{
@ -205,6 +209,11 @@ struct zathura_plugin_functions_s
* Get page label.
*/
zathura_plugin_page_get_label_t page_get_label;
/**
* Get signatures.
*/
zathura_plugin_page_get_signatures page_get_signatures;
};
typedef struct zathura_plugin_version_s {