Commit 334b4fbb authored by Moritz Lipp's avatar Moritz Lipp
Browse files

Introduce and use zathura_document wrapper functions

parent c82c2aaf
...@@ -34,7 +34,8 @@ zathura_bookmark_add(zathura_t* zathura, const gchar* id, unsigned int page) ...@@ -34,7 +34,8 @@ zathura_bookmark_add(zathura_t* zathura, const gchar* id, unsigned int page)
girara_list_append(zathura->bookmarks.bookmarks, bookmark); girara_list_append(zathura->bookmarks.bookmarks, bookmark);
if (zathura->database != NULL) { if (zathura->database != NULL) {
if (zathura_db_add_bookmark(zathura->database, zathura->document->file_path, bookmark) == false) { const char* path = zathura_document_get_path(zathura->document);
if (zathura_db_add_bookmark(zathura->database, path, bookmark) == false) {
girara_warning("Failed to add bookmark to database."); girara_warning("Failed to add bookmark to database.");
} }
} }
...@@ -54,7 +55,8 @@ zathura_bookmark_remove(zathura_t* zathura, const gchar* id) ...@@ -54,7 +55,8 @@ zathura_bookmark_remove(zathura_t* zathura, const gchar* id)
} }
if (zathura->database != NULL) { if (zathura->database != NULL) {
if (zathura_db_remove_bookmark(zathura->database, zathura->document->file_path, bookmark->id) == false) { const char* path = zathura_document_get_path(zathura->document);
if (zathura_db_remove_bookmark(zathura->database, path, bookmark->id) == false) {
girara_warning("Failed to remove bookmark from database."); girara_warning("Failed to remove bookmark from database.");
} }
} }
......
...@@ -51,8 +51,7 @@ void ...@@ -51,8 +51,7 @@ void
cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpointer data) cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpointer data)
{ {
zathura_t* zathura = data; zathura_t* zathura = data;
if (zathura == NULL || zathura->document == NULL || zathura->document->pages == NULL if (zathura == NULL || zathura->document == NULL || zathura->ui.page_widget == NULL) {
|| zathura->ui.page_widget == NULL) {
return; return;
} }
...@@ -74,23 +73,26 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi ...@@ -74,23 +73,26 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi
center.y = (view_rect.height + 1) / 2; center.y = (view_rect.height + 1) / 2;
center.height = center.width = (2 * page_padding) + 1; center.height = center.width = (2 * page_padding) + 1;
unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document);
double scale = zathura_document_get_scale(zathura->document);
bool updated = false; bool updated = false;
/* find page that fits */ /* find page that fits */
for (unsigned int page_id = 0; page_id < zathura->document->number_of_pages; page_id++) { for (unsigned int page_id = 0; page_id < number_of_pages; page_id++) {
zathura_page_t* page = zathura->document->pages[page_id]; zathura_page_t* page = zathura_document_get_page(zathura->document, page_id);
GdkRectangle page_rect; GdkRectangle page_rect;
GtkWidget* page_widget = zathura_page_get_widget(page); GtkWidget* page_widget = zathura_page_get_widget(page);
gtk_widget_translate_coordinates(page_widget, gtk_widget_translate_coordinates(page_widget,
zathura->ui.session->gtk.view, 0, 0, &page_rect.x, &page_rect.y); zathura->ui.session->gtk.view, 0, 0, &page_rect.x, &page_rect.y);
page_rect.width = zathura_page_get_width(page) * zathura->document->scale; page_rect.width = zathura_page_get_width(page) * scale;
page_rect.height = zathura_page_get_height(page) * zathura->document->scale; page_rect.height = zathura_page_get_height(page) * scale;
if (gdk_rectangle_intersect(&view_rect, &page_rect, NULL) == TRUE) { if (gdk_rectangle_intersect(&view_rect, &page_rect, NULL) == TRUE) {
zathura_page_set_visibility(page, true); zathura_page_set_visibility(page, true);
if (zathura->global.update_page_number == true && updated == false if (zathura->global.update_page_number == true && updated == false
&& gdk_rectangle_intersect(&center, &page_rect, NULL) == TRUE) { && gdk_rectangle_intersect(&center, &page_rect, NULL) == TRUE) {
zathura->document->current_page_number = page_id; zathura_document_set_current_page_number(zathura->document, page_id);
updated = true; updated = true;
} }
} else { } else {
...@@ -119,7 +121,7 @@ cb_pages_per_row_value_changed(girara_session_t* session, const char* UNUSED(nam ...@@ -119,7 +121,7 @@ cb_pages_per_row_value_changed(girara_session_t* session, const char* UNUSED(nam
page_widget_set_mode(zathura, pages_per_row); page_widget_set_mode(zathura, pages_per_row);
if (zathura->document != NULL) { if (zathura->document != NULL) {
unsigned int current_page = zathura->document->current_page_number; unsigned int current_page = zathura_document_get_current_page_number(zathura->document);
page_set_delayed(zathura, current_page); page_set_delayed(zathura, current_page);
} }
} }
...@@ -185,8 +187,9 @@ cb_sc_follow(GtkEntry* entry, girara_session_t* session) ...@@ -185,8 +187,9 @@ cb_sc_follow(GtkEntry* entry, girara_session_t* session)
/* set pages to draw links */ /* set pages to draw links */
bool invalid_index = true; bool invalid_index = true;
for (unsigned int page_id = 0; page_id < zathura->document->number_of_pages; page_id++) { unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document);
zathura_page_t* page = zathura->document->pages[page_id]; for (unsigned int page_id = 0; page_id < number_of_pages; page_id++) {
zathura_page_t* page = zathura_document_get_page(zathura->document, page_id);
if (page == NULL || zathura_page_get_visibility(page) == false) { if (page == NULL || zathura_page_get_visibility(page) == false) {
continue; continue;
} }
...@@ -322,7 +325,7 @@ cb_view_resized(GtkWidget* UNUSED(widget), GtkAllocation* allocation, zathura_t* ...@@ -322,7 +325,7 @@ cb_view_resized(GtkWidget* UNUSED(widget), GtkAllocation* allocation, zathura_t*
/* adjust only if the allocation changed */ /* adjust only if the allocation changed */
if (width != allocation->width || height != allocation->height) { if (width != allocation->width || height != allocation->height) {
girara_argument_t argument = { zathura->document->adjust_mode, NULL }; girara_argument_t argument = { zathura_document_get_adjust_mode(zathura->document), NULL };
sc_adjust_window(zathura->ui.session, &argument, NULL, 0); sc_adjust_window(zathura->ui.session, &argument, NULL, 0);
width = allocation->width; width = allocation->width;
......
...@@ -40,12 +40,12 @@ cmd_bookmark_create(girara_session_t* session, girara_list_t* argument_list) ...@@ -40,12 +40,12 @@ cmd_bookmark_create(girara_session_t* session, girara_list_t* argument_list)
const char* bookmark_name = girara_list_nth(argument_list, 0); const char* bookmark_name = girara_list_nth(argument_list, 0);
zathura_bookmark_t* bookmark = zathura_bookmark_get(zathura, bookmark_name); zathura_bookmark_t* bookmark = zathura_bookmark_get(zathura, bookmark_name);
if (bookmark != NULL) { if (bookmark != NULL) {
bookmark->page = zathura->document->current_page_number + 1; bookmark->page = zathura_document_get_current_page_number(zathura->document) + 1;
girara_notify(session, GIRARA_INFO, _("Bookmark successfuly updated: %s"), bookmark_name); girara_notify(session, GIRARA_INFO, _("Bookmark successfuly updated: %s"), bookmark_name);
return true; return true;
} }
bookmark = zathura_bookmark_add(zathura, bookmark_name, zathura->document->current_page_number + 1); bookmark = zathura_bookmark_add(zathura, bookmark_name, zathura_document_get_current_page_number(zathura->document) + 1);
if (bookmark == NULL) { if (bookmark == NULL) {
girara_notify(session, GIRARA_ERROR, _("Could not create bookmark: %s"), bookmark_name); girara_notify(session, GIRARA_ERROR, _("Could not create bookmark: %s"), bookmark_name);
return false; return false;
...@@ -304,8 +304,13 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu ...@@ -304,8 +304,13 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu
bool firsthit = true; bool firsthit = true;
zathura_error_t error = ZATHURA_ERROR_OK; zathura_error_t error = ZATHURA_ERROR_OK;
for (unsigned int page_id = 0; page_id < zathura->document->number_of_pages; ++page_id) {
zathura_page_t* page = zathura->document->pages[(page_id + zathura->document->current_page_number) % zathura->document->number_of_pages]; unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document);
unsigned int current_page_number = zathura_document_get_current_page_number(zathura->document);
for (unsigned int page_id = 0; page_id < number_of_pages; ++page_id) {
unsigned int index = (page_id + current_page_number) % number_of_pages;
zathura_page_t* page = zathura_document_get_page(zathura->document, index);
if (page == NULL) { if (page == NULL) {
continue; continue;
} }
...@@ -385,7 +390,7 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list) ...@@ -385,7 +390,7 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list)
} }
/* no argument: take current page as offset */ /* no argument: take current page as offset */
unsigned int page_offset = zathura->document->current_page_number; unsigned int page_offset = zathura_document_get_current_page_number(zathura->document);
/* retrieve offset from argument */ /* retrieve offset from argument */
if (girara_list_size(argument_list) == 1) { if (girara_list_size(argument_list) == 1) {
...@@ -399,8 +404,8 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list) ...@@ -399,8 +404,8 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list)
} }
} }
if (page_offset < zathura->document->number_of_pages) { if (page_offset < zathura_document_get_number_of_pages(zathura->document)) {
zathura->document->page_offset = page_offset; zathura_document_set_page_offset(zathura->document, page_offset);
} }
return true; return true;
......
...@@ -126,8 +126,8 @@ config_load_default(zathura_t* zathura) ...@@ -126,8 +126,8 @@ config_load_default(zathura_t* zathura)
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_c, NULL, sc_abort, 0, 0, NULL); girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_c, NULL, sc_abort, 0, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Escape, NULL, sc_abort, 0, 0, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_Escape, NULL, sc_abort, 0, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_a, NULL, sc_adjust_window, NORMAL, ADJUST_BESTFIT, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_a, NULL, sc_adjust_window, NORMAL, ZATHURA_ADJUST_BESTFIT, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_s, NULL, sc_adjust_window, NORMAL, ADJUST_WIDTH, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_s, NULL, sc_adjust_window, NORMAL, ZATHURA_ADJUST_WIDTH, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_m, NULL, sc_change_mode, NORMAL, ADD_MARKER, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_m, NULL, sc_change_mode, NORMAL, ADD_MARKER, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_apostrophe, NULL, sc_change_mode, NORMAL, EVAL_MARKER, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_apostrophe, NULL, sc_change_mode, NORMAL, EVAL_MARKER, NULL);
...@@ -302,8 +302,8 @@ config_load_default(zathura_t* zathura) ...@@ -302,8 +302,8 @@ config_load_default(zathura_t* zathura)
girara_argument_mapping_add(gsession, "specific", ZOOM_SPECIFIC); girara_argument_mapping_add(gsession, "specific", ZOOM_SPECIFIC);
girara_argument_mapping_add(gsession, "top", TOP); girara_argument_mapping_add(gsession, "top", TOP);
girara_argument_mapping_add(gsession, "up", UP); girara_argument_mapping_add(gsession, "up", UP);
girara_argument_mapping_add(gsession, "best-fit", ADJUST_BESTFIT); girara_argument_mapping_add(gsession, "best-fit", ZATHURA_ADJUST_BESTFIT);
girara_argument_mapping_add(gsession, "width", ADJUST_WIDTH); girara_argument_mapping_add(gsession, "width", ZATHURA_ADJUST_WIDTH);
girara_argument_mapping_add(gsession, "rotate-cw", ROTATE_CW); girara_argument_mapping_add(gsession, "rotate-cw", ROTATE_CW);
girara_argument_mapping_add(gsession, "rotate-ccw", ROTATE_CCW); girara_argument_mapping_add(gsession, "rotate-ccw", ROTATE_CCW);
} }
......
...@@ -32,6 +32,34 @@ static const size_t GT_MAX_READ = 1 << 16; ...@@ -32,6 +32,34 @@ static const size_t GT_MAX_READ = 1 << 16;
static const gchar* guess_type(const char* path); static const gchar* guess_type(const char* path);
/**
* Document
*/
struct zathura_document_s
{
char* file_path; /**< File path of the document */
const char* password; /**< Password of the document */
unsigned int current_page_number; /**< Current page number */
unsigned int number_of_pages; /**< Number of pages */
double scale; /**< Scale value */
unsigned int rotate; /**< Rotation */
void* data; /**< Custom data */
zathura_adjust_mode_t adjust_mode; /**< Adjust mode (best-fit, width) */
zathura_t* zathura; /**< Zathura instance */
unsigned int page_offset; /**< Page offset */
/**
* Document pages
*/
zathura_page_t** pages;
/**
* Used plugin
*/
zathura_plugin_t* plugin;
};
zathura_document_t* zathura_document_t*
zathura_document_open(zathura_t* zathura, const char* path, const char* password) zathura_document_open(zathura_t* zathura, const char* path, const char* password)
{ {
...@@ -94,8 +122,8 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* password ...@@ -94,8 +122,8 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* password
document->file_path = real_path; document->file_path = real_path;
document->password = password; document->password = password;
document->scale = 1.0; document->scale = 1.0;
document->zathura = zathura;
document->plugin = plugin; document->plugin = plugin;
document->zathura = zathura;
/* open document */ /* open document */
if (plugin->functions.document_open == NULL) { if (plugin->functions.document_open == NULL) {
...@@ -170,14 +198,14 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* password ...@@ -170,14 +198,14 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* password
/* apply open adjustment */ /* apply open adjustment */
char* adjust_open = "best-fit"; char* adjust_open = "best-fit";
document->adjust_mode = ADJUST_BESTFIT; document->adjust_mode = ZATHURA_ADJUST_BESTFIT;
if (girara_setting_get(zathura->ui.session, "adjust-open", &(adjust_open)) == true) { if (girara_setting_get(zathura->ui.session, "adjust-open", &(adjust_open)) == true) {
if (g_strcmp0(adjust_open, "best-fit") == 0) { if (g_strcmp0(adjust_open, "best-fit") == 0) {
document->adjust_mode = ADJUST_BESTFIT; document->adjust_mode = ZATHURA_ADJUST_BESTFIT;
} else if (g_strcmp0(adjust_open, "width") == 0) { } else if (g_strcmp0(adjust_open, "width") == 0) {
document->adjust_mode = ADJUST_WIDTH; document->adjust_mode = ZATHURA_ADJUST_WIDTH;
} else { } else {
document->adjust_mode = ADJUST_NONE; document->adjust_mode = ZATHURA_ADJUST_NONE;
} }
g_free(adjust_open); g_free(adjust_open);
} }
...@@ -203,8 +231,7 @@ error_free: ...@@ -203,8 +231,7 @@ error_free:
zathura_error_t zathura_error_t
zathura_document_free(zathura_document_t* document) zathura_document_free(zathura_document_t* document)
{ {
if (document == NULL || document->plugin == NULL || document->zathura == NULL if (document == NULL || document->plugin == NULL) {
|| document->zathura->ui.session == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS; return ZATHURA_ERROR_INVALID_ARGUMENTS;
} }
...@@ -219,8 +246,6 @@ zathura_document_free(zathura_document_t* document) ...@@ -219,8 +246,6 @@ zathura_document_free(zathura_document_t* document)
/* free document */ /* free document */
zathura_error_t error = ZATHURA_ERROR_OK; zathura_error_t error = ZATHURA_ERROR_OK;
if (document->plugin->functions.document_free == NULL) { if (document->plugin->functions.document_free == NULL) {
girara_notify(document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
error = ZATHURA_ERROR_NOT_IMPLEMENTED; error = ZATHURA_ERROR_NOT_IMPLEMENTED;
} else { } else {
error = document->plugin->functions.document_free(document, document->data); error = document->plugin->functions.document_free(document, document->data);
...@@ -255,6 +280,16 @@ zathura_document_get_password(zathura_document_t* document) ...@@ -255,6 +280,16 @@ zathura_document_get_password(zathura_document_t* document)
return document->password; return document->password;
} }
zathura_page_t*
zathura_document_get_page(zathura_document_t* document, unsigned int index)
{
if (document == NULL || document->pages == NULL || (document->number_of_pages <= index)) {
return NULL;
}
return document->pages[index];
}
void* void*
zathura_document_get_data(zathura_document_t* document) zathura_document_get_data(zathura_document_t* document)
{ {
...@@ -296,7 +331,7 @@ zathura_document_set_number_of_pages(zathura_document_t* document, unsigned int ...@@ -296,7 +331,7 @@ zathura_document_set_number_of_pages(zathura_document_t* document, unsigned int
} }
unsigned int unsigned int
zathura_document_get_current_page(zathura_document_t* document) zathura_document_get_current_page_number(zathura_document_t* document)
{ {
if (document == NULL) { if (document == NULL) {
return 0; return 0;
...@@ -306,7 +341,7 @@ zathura_document_get_current_page(zathura_document_t* document) ...@@ -306,7 +341,7 @@ zathura_document_get_current_page(zathura_document_t* document)
} }
void void
zathura_document_set_current_page(zathura_document_t* document, unsigned int zathura_document_set_current_page_number(zathura_document_t* document, unsigned int
current_page) current_page)
{ {
if (document == NULL) { if (document == NULL) {
...@@ -316,17 +351,110 @@ zathura_document_set_current_page(zathura_document_t* document, unsigned int ...@@ -316,17 +351,110 @@ zathura_document_set_current_page(zathura_document_t* document, unsigned int
document->current_page_number = current_page; document->current_page_number = current_page;
} }
double
zathura_document_get_scale(zathura_document_t* document)
{
if (document == NULL) {
return 0;
}
return document->scale;
}
void
zathura_document_set_scale(zathura_document_t* document, double scale)
{
if (document == NULL) {
return;
}
document->scale = scale;
}
unsigned int
zathura_document_get_rotation(zathura_document_t* document)
{
if (document == NULL) {
return 0;
}
return document->rotate;
}
void
zathura_document_set_rotation(zathura_document_t* document, unsigned int rotation)
{
if (document == NULL) {
return;
}
document->rotate = rotation % 360;
if (document->rotate > 0 && document->rotate < 90) {
document->rotate = 90;
} else if (document->rotate > 0 && document->rotate < 180) {
document->rotate = 180;
} else if (document->rotate > 0 && document->rotate < 270) {
document->rotate = 270;
} else {
document->rotate = 0;
}
}
zathura_adjust_mode_t
zathura_document_get_adjust_mode(zathura_document_t* document)
{
if (document == NULL) {
return ZATHURA_ADJUST_NONE;
}
return document->adjust_mode;
}
void
zathura_document_set_adjust_mode(zathura_document_t* document, zathura_adjust_mode_t mode)
{
if (document == NULL) {
return;
}
if (mode == ZATHURA_ADJUST_BESTFIT || mode == ZATHURA_ADJUST_WIDTH) {
document->adjust_mode = mode;
} else {
document->adjust_mode = ZATHURA_ADJUST_NONE;
}
}
unsigned int
zathura_document_get_page_offset(zathura_document_t* document)
{
if (document == NULL) {
return 0;
}
return document->page_offset;
}
void
zathura_document_set_page_offset(zathura_document_t* document, unsigned int page_offset)
{
if (document == NULL) {
return;
}
if (page_offset < document->number_of_pages) {
document->page_offset = page_offset;
}
}
zathura_error_t zathura_error_t
zathura_document_save_as(zathura_document_t* document, const char* path) zathura_document_save_as(zathura_document_t* document, const char* path)
{ {
if (document == NULL || document->plugin == NULL || path == NULL || if (document == NULL || document->plugin == NULL || path == NULL) {
document->zathura == NULL || document->zathura->ui.session == NULL) {
return ZATHURA_ERROR_UNKNOWN; return ZATHURA_ERROR_UNKNOWN;
} }
if (document->plugin->functions.document_save_as == NULL) { if (document->plugin->functions.document_save_as == NULL) {
girara_notify(document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
return ZATHURA_ERROR_NOT_IMPLEMENTED; return ZATHURA_ERROR_NOT_IMPLEMENTED;
} }
...@@ -336,8 +464,7 @@ zathura_document_save_as(zathura_document_t* document, const char* path) ...@@ -336,8 +464,7 @@ zathura_document_save_as(zathura_document_t* document, const char* path)
girara_tree_node_t* girara_tree_node_t*
zathura_document_index_generate(zathura_document_t* document, zathura_error_t* error) zathura_document_index_generate(zathura_document_t* document, zathura_error_t* error)
{ {
if (document == NULL || document->plugin == NULL || document->zathura == NULL if (document == NULL || document->plugin == NULL) {
|| document->zathura->ui.session == NULL) {
if (error != NULL) { if (error != NULL) {
*error = ZATHURA_ERROR_INVALID_ARGUMENTS; *error = ZATHURA_ERROR_INVALID_ARGUMENTS;
} }
...@@ -345,8 +472,6 @@ zathura_document_index_generate(zathura_document_t* document, zathura_error_t* e ...@@ -345,8 +472,6 @@ zathura_document_index_generate(zathura_document_t* document, zathura_error_t* e
} }
if (document->plugin->functions.document_index_generate == NULL) { if (document->plugin->functions.document_index_generate == NULL) {
girara_notify(document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
if (error != NULL) { if (error != NULL) {
*error = ZATHURA_ERROR_NOT_IMPLEMENTED; *error = ZATHURA_ERROR_NOT_IMPLEMENTED;
} }
...@@ -359,8 +484,7 @@ zathura_document_index_generate(zathura_document_t* document, zathura_error_t* e ...@@ -359,8 +484,7 @@ zathura_document_index_generate(zathura_document_t* document, zathura_error_t* e
girara_list_t* girara_list_t*
zathura_document_attachments_get(zathura_document_t* document, zathura_error_t* error) zathura_document_attachments_get(zathura_document_t* document, zathura_error_t* error)
{ {
if (document == NULL || document->plugin == NULL || document->zathura == NULL if (document == NULL || document->plugin == NULL) {
|| document->zathura->ui.session == NULL) {
if (error != NULL) { if (error != NULL) {
*error = ZATHURA_ERROR_INVALID_ARGUMENTS; *error = ZATHURA_ERROR_INVALID_ARGUMENTS;
} }
...@@ -368,8 +492,6 @@ zathura_document_attachments_get(zathura_document_t* document, zathura_error_t* ...@@ -368,8 +492,6 @@ zathura_document_attachments_get(zathura_document_t* document, zathura_error_t*
} }
if (document->plugin->functions.document_attachments_get == NULL) { if (document->plugin->functions.document_attachments_get == NULL) {
girara_notify(document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
if (error != NULL) { if (error != NULL) {
*error = ZATHURA_ERROR_NOT_IMPLEMENTED; *error = ZATHURA_ERROR_NOT_IMPLEMENTED;
} }
...@@ -382,14 +504,11 @@ zathura_document_attachments_get(zathura_document_t* document, zathura_error_t* ...@@ -382,14 +504,11 @@ zathura_document_attachments_get(zathura_document_t* document, zathura_error_t*
zathura_error_t zathura_error_t
zathura_document_attachment_save(zathura_document_t* document, const char* attachment, const char* file) zathura_document_attachment_save(zathura_document_t* document, const char* attachment, const char* file)
{ {
if (document == NULL || document->plugin == NULL || document->zathura == NULL if (document == NULL || document->plugin == NULL) {
|| document->zathura->ui.session == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS; return ZATHURA_ERROR_INVALID_ARGUMENTS;
} }
if (document->plugin->functions.document_attachment_save == NULL) { if (document->plugin->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_ERROR_NOT_IMPLEMENTED; return ZATHURA_ERROR_NOT_IMPLEMENTED;
} }
...@@ -399,7 +518,7 @@ zathura_document_attachment_save(zathura_document_t* document, const char* attac ...@@ -399,7 +518,7 @@ zathura_document_attachment_save(zathura_document_t* document, const char* attac
char* char*
zathura_document_meta_get(zathura_document_t* document, zathura_document_meta_t meta, zathura_error_t* error) zathura_document_meta_get(zathura_document_t* document, zathura_document_meta_t meta, zathura_error_t* error)
{ {
if (document == NULL || document->plugin == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) { if (document == NULL || document->plugin == NULL) {
if (error != NULL) { if (error != NULL) {
*error = ZATHURA_ERROR_INVALID_ARGUMENTS; *error = ZATHURA_ERROR_INVALID_ARGUMENTS;
} }
...@@ -410,8 +529,6 @@ zathura_document_meta_get(zathura_document_t* document, zathura_document_meta_t ...@@ -410,8 +529,6 @@ zathura_document_meta_get(zathura_document_t* document, zathura_document_meta_t
if (error != NULL) { if (error != NULL) {
*error = ZATHURA_ERROR_NOT_IMPLEMENTED; *error = ZATHURA_ERROR_NOT_IMPLEMENTED;
} }
girara_notif