mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-10 22:13:48 +01:00
Update plugin system return values and notifications
This commit is contained in:
parent
394fbd934d
commit
8fdf18b088
105
document.c
105
document.c
@ -387,7 +387,7 @@ error_free:
|
||||
zathura_plugin_error_t
|
||||
zathura_document_free(zathura_document_t* document)
|
||||
{
|
||||
if (document == NULL) {
|
||||
if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -402,6 +402,7 @@ zathura_document_free(zathura_document_t* document)
|
||||
/* free document */
|
||||
bool r = true;
|
||||
if (document->functions.document_free == NULL) {
|
||||
girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
|
||||
girara_error("%s not implemented", __FUNCTION__);
|
||||
} else {
|
||||
r = document->functions.document_free(document);
|
||||
@ -419,11 +420,12 @@ zathura_document_free(zathura_document_t* document)
|
||||
zathura_plugin_error_t
|
||||
zathura_document_save_as(zathura_document_t* document, const char* path)
|
||||
{
|
||||
if (document == NULL || path == NULL) {
|
||||
if (document == NULL || path == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (document->functions.document_save_as == NULL) {
|
||||
girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
|
||||
girara_error("%s not implemented", __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
@ -434,11 +436,12 @@ zathura_document_save_as(zathura_document_t* document, const char* path)
|
||||
girara_tree_node_t*
|
||||
zathura_document_index_generate(zathura_document_t* document, zathura_plugin_error_t* error)
|
||||
{
|
||||
if (document == NULL) {
|
||||
if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (document->functions.document_index_generate == NULL) {
|
||||
girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
|
||||
girara_error("%s not implemented", __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
@ -449,11 +452,12 @@ zathura_document_index_generate(zathura_document_t* document, zathura_plugin_err
|
||||
girara_list_t*
|
||||
zathura_document_attachments_get(zathura_document_t* document, zathura_plugin_error_t* error)
|
||||
{
|
||||
if (document == NULL) {
|
||||
if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (document->functions.document_attachments_get == NULL) {
|
||||
girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
|
||||
girara_error("%s not implemented", __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
@ -464,11 +468,13 @@ zathura_document_attachments_get(zathura_document_t* document, zathura_plugin_er
|
||||
zathura_plugin_error_t
|
||||
zathura_document_attachment_save(zathura_document_t* document, const char* attachment, const char* file)
|
||||
{
|
||||
if (document == NULL) {
|
||||
if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) {
|
||||
return ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
if (document->functions.document_attachment_save == NULL) {
|
||||
girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
|
||||
girara_error("%s not implemented", __FUNCTION__);
|
||||
return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
@ -478,9 +484,9 @@ zathura_document_attachment_save(zathura_document_t* document, const char* attac
|
||||
char*
|
||||
zathura_document_meta_get(zathura_document_t* document, zathura_document_meta_t meta, zathura_plugin_error_t* error)
|
||||
{
|
||||
if (document == NULL) {
|
||||
if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) {
|
||||
if (error != NULL) {
|
||||
*error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
|
||||
*error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -489,6 +495,8 @@ zathura_document_meta_get(zathura_document_t* document, zathura_document_meta_t
|
||||
if (error != NULL) {
|
||||
*error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
|
||||
girara_error("%s not implemented", __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -498,12 +506,19 @@ zathura_document_meta_get(zathura_document_t* document, zathura_document_meta_t
|
||||
zathura_page_t*
|
||||
zathura_page_get(zathura_document_t* document, unsigned int page_id, zathura_plugin_error_t* error)
|
||||
{
|
||||
if (document == NULL) {
|
||||
if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) {
|
||||
if (error != NULL) {
|
||||
*error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (document->functions.page_get == NULL) {
|
||||
girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
|
||||
girara_error("%s not implemented", __FUNCTION__);
|
||||
if (error != NULL) {
|
||||
*error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -534,13 +549,14 @@ zathura_page_get(zathura_document_t* document, unsigned int page_id, zathura_plu
|
||||
zathura_plugin_error_t
|
||||
zathura_page_free(zathura_page_t* page)
|
||||
{
|
||||
if (page == NULL || page->document == NULL) {
|
||||
return false;
|
||||
if (page == NULL || page->document == NULL || page->document->zathura == NULL || page->document->zathura->ui.session == NULL) {
|
||||
return ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
if (page->document->functions.page_free == NULL) {
|
||||
girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
|
||||
girara_error("%s not implemented", __FUNCTION__);
|
||||
return false;
|
||||
return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
return page->document->functions.page_free(page);
|
||||
@ -549,12 +565,20 @@ zathura_page_free(zathura_page_t* page)
|
||||
girara_list_t*
|
||||
zathura_page_search_text(zathura_page_t* page, const char* text, zathura_plugin_error_t* error)
|
||||
{
|
||||
if (page == NULL || page->document == NULL || text == NULL) {
|
||||
if (page == NULL || page->document == NULL || text == NULL ||
|
||||
page->document->zathura == NULL || page->document->zathura->ui.session == NULL) {
|
||||
if (error != NULL) {
|
||||
*error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (page->document->functions.page_search_text == NULL) {
|
||||
girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
|
||||
girara_error("%s not implemented", __FUNCTION__);
|
||||
if (error != NULL) {
|
||||
*error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -564,12 +588,20 @@ zathura_page_search_text(zathura_page_t* page, const char* text, zathura_plugin_
|
||||
girara_list_t*
|
||||
zathura_page_links_get(zathura_page_t* page, zathura_plugin_error_t* error)
|
||||
{
|
||||
if (page == NULL || page->document == NULL) {
|
||||
if (page == NULL || page->document == NULL || page->document->zathura == NULL
|
||||
|| page->document->zathura->ui.session == NULL) {
|
||||
if (error != NULL) {
|
||||
*error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (page->document->functions.page_links_get == NULL) {
|
||||
girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
|
||||
girara_error("%s not implemented", __FUNCTION__);
|
||||
if (error != NULL) {
|
||||
*error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -585,12 +617,20 @@ zathura_page_links_free(girara_list_t* UNUSED(list))
|
||||
girara_list_t*
|
||||
zathura_page_form_fields_get(zathura_page_t* page, zathura_plugin_error_t* error)
|
||||
{
|
||||
if (page == NULL || page->document == NULL) {
|
||||
if (page == NULL || page->document == NULL || page->document->zathura == NULL
|
||||
|| page->document->zathura->ui.session == NULL) {
|
||||
if (error != NULL) {
|
||||
*error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (page->document->functions.page_form_fields_get == NULL) {
|
||||
girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
|
||||
girara_error("%s not implemented", __FUNCTION__);
|
||||
if (error != NULL) {
|
||||
*error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -600,19 +640,27 @@ zathura_page_form_fields_get(zathura_page_t* page, zathura_plugin_error_t* error
|
||||
zathura_plugin_error_t
|
||||
zathura_page_form_fields_free(girara_list_t* UNUSED(list))
|
||||
{
|
||||
return false;
|
||||
return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
girara_list_t*
|
||||
zathura_page_images_get(zathura_page_t* page, zathura_plugin_error_t* error)
|
||||
{
|
||||
if (page == NULL || page->document == NULL) {
|
||||
if (page == NULL || page->document == NULL || page->document->zathura == NULL
|
||||
|| page->document->zathura->ui.session == NULL) {
|
||||
if (error != NULL) {
|
||||
*error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (page->document->functions.page_images_get == NULL) {
|
||||
girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
|
||||
girara_error("%s not implemented", __FUNCTION__);
|
||||
return false;
|
||||
if (error != NULL) {
|
||||
*error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return page->document->functions.page_images_get(page, error);
|
||||
@ -621,13 +669,22 @@ zathura_page_images_get(zathura_page_t* page, zathura_plugin_error_t* error)
|
||||
cairo_surface_t*
|
||||
zathura_page_image_get_cairo(zathura_page_t* page, zathura_image_t* image, zathura_plugin_error_t* error)
|
||||
{
|
||||
if (page == NULL || page->document == NULL || image == NULL) {
|
||||
return false;
|
||||
if (page == NULL || page->document == NULL || image == NULL ||
|
||||
page->document->zathura == NULL || page->document->zathura->ui.session ==
|
||||
NULL) {
|
||||
if (error != NULL) {
|
||||
*error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (page->document->functions.page_image_get_cairo == NULL) {
|
||||
girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
|
||||
girara_error("%s not implemented", __FUNCTION__);
|
||||
return false;
|
||||
if (error != NULL) {
|
||||
*error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return page->document->functions.page_image_get_cairo(page, image, error);
|
||||
@ -635,7 +692,7 @@ zathura_page_image_get_cairo(zathura_page_t* page, zathura_image_t* image, zathu
|
||||
|
||||
char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle, zathura_plugin_error_t* error)
|
||||
{
|
||||
if (page == NULL || page->document == NULL) {
|
||||
if (page == NULL || page->document == NULL || page->document->zathura == NULL || page->document->zathura->ui.session == NULL) {
|
||||
if (error) {
|
||||
*error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
@ -643,6 +700,7 @@ char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle,
|
||||
}
|
||||
|
||||
if (page->document->functions.page_get_text == NULL) {
|
||||
girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
|
||||
girara_error("%s not implemented", __FUNCTION__);
|
||||
if (error) {
|
||||
*error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
|
||||
@ -656,11 +714,14 @@ char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle,
|
||||
zathura_plugin_error_t
|
||||
zathura_page_render(zathura_page_t* page, cairo_t* cairo, bool printing)
|
||||
{
|
||||
if (page == NULL || page->document == NULL || cairo == NULL) {
|
||||
if (page == NULL || page->document == NULL || cairo == NULL ||
|
||||
page->document->zathura == NULL || page->document->zathura->ui.session ==
|
||||
NULL) {
|
||||
return ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
if (page->document->functions.page_render_cairo == NULL) {
|
||||
girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
|
||||
girara_error("%s not implemented", __FUNCTION__);
|
||||
return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user