Commit 3facd5be authored by Moritz Lipp's avatar Moritz Lipp

Replace image_save with image_get_cairo

parent 95c85101
......@@ -332,14 +332,20 @@ cmd_export(girara_session_t* session, girara_list_t* argument_list)
}
const char* attachment_name = girara_list_nth(argument_list, 0);
const char* file_name = girara_list_nth(argument_list, 1);
const char* file_name = girara_list_nth(argument_list, 1);
if (file_name == NULL || attachment_name == NULL) {
return false;
}
char* file_name2 = girara_fix_path(file_name);
if (!zathura_document_attachment_save(zathura->document, attachment_name, file_name)) {
if (zathura_document_attachment_save(zathura->document, attachment_name, file_name) == false) {
girara_notify(session, GIRARA_ERROR, "Couldn't write attachment '%s' to '%s'.", attachment_name, file_name);
} else {
girara_notify(session, GIRARA_INFO, "Wrote attachment '%s' to '%s'.", attachment_name, file_name2);
}
g_free(file_name2);
return true;
}
......@@ -610,19 +610,19 @@ zathura_page_images_get(zathura_page_t* page, zathura_plugin_error_t* error)
return page->document->functions.page_images_get(page, error);
}
zathura_plugin_error_t
zathura_page_image_save(zathura_page_t* page, zathura_image_t* image, const char* file)
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 || file == NULL) {
if (page == NULL || page->document == NULL || image == NULL) {
return false;
}
if (page->document->functions.page_image_save == NULL) {
if (page->document->functions.page_image_get_cairo == NULL) {
girara_error("%s not implemented", __FUNCTION__);
return false;
}
return page->document->functions.page_image_save(page, image, file);
return page->document->functions.page_image_get_cairo(page, image, error);
}
char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle, zathura_plugin_error_t* error)
......
......@@ -271,9 +271,9 @@ struct zathura_document_s
girara_list_t* (*page_images_get)(zathura_page_t* page, zathura_plugin_error_t* error);
/**
* Save image to a file
* Get the image
*/
zathura_plugin_error_t (*page_image_save)(zathura_page_t* page, zathura_image_t* image, const char* file);
cairo_surface_t* (*page_image_get_cairo)(zathura_page_t* page, zathura_image_t* image, zathura_plugin_error_t* error);
/**
* Get text for selection
......@@ -477,15 +477,15 @@ zathura_plugin_error_t zathura_page_form_fields_free(girara_list_t* list);
girara_list_t* zathura_page_images_get(zathura_page_t* page, zathura_plugin_error_t* error);
/**
* Save image
* Get image
*
* @param page Page
* @param image The image
* @param file Path to the file
* @return ZATHURA_PLUGIN_ERROR_OK when no error occured, otherwise see
* zathura_plugin_error_t
* @param image Image identifier
* @param error Set to an error value (see \ref zathura_plugin_error_t) if an
* error occured
* @return The cairo image surface or NULL if an error occured
*/
zathura_plugin_error_t zathura_page_image_save(zathura_page_t* page, zathura_image_t* image, const char* file);
cairo_surface_t* zathura_page_image_get_cairo(zathura_page_t* page, zathura_image_t* image, zathura_plugin_error_t* error);
/**
* Get text for selection
......
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