diff --git a/zathura/commands.c b/zathura/commands.c index 70ecfa9..f52215b 100644 --- a/zathura/commands.c +++ b/zathura/commands.c @@ -313,11 +313,7 @@ cmd_save(girara_session_t* session, girara_list_t* argument_list) } if (girara_list_size(argument_list) == 1) { - if (document_save(zathura, girara_list_nth(argument_list, 0), false) == true) { - girara_notify(session, GIRARA_INFO, _("Document saved.")); - } else { - girara_notify(session, GIRARA_INFO, _("Failed to save document.")); - } + document_save(zathura, girara_list_nth(argument_list, 0), false); } else { girara_notify(session, GIRARA_ERROR, _("Invalid number of arguments.")); return false; @@ -339,11 +335,7 @@ cmd_savef(girara_session_t* session, girara_list_t* argument_list) } if (girara_list_size(argument_list) == 1) { - if (document_save(zathura, girara_list_nth(argument_list, 0), true) == true) { - girara_notify(session, GIRARA_INFO, _("Document saved.")); - } else { - girara_notify(session, GIRARA_INFO, _("Failed to save document.")); - } + document_save(zathura, girara_list_nth(argument_list, 0), true); } else { girara_notify(session, GIRARA_ERROR, _("Invalid number of arguments.")); return false; diff --git a/zathura/zathura.c b/zathura/zathura.c index 4185ff1..29ec68b 100644 --- a/zathura/zathura.c +++ b/zathura/zathura.c @@ -1356,15 +1356,21 @@ document_save(zathura_t* zathura, const char* path, bool overwrite) } if ((overwrite == false) && g_file_test(file_path, G_FILE_TEST_EXISTS)) { - girara_error("File already exists: %s. Use :write! to overwrite it.", file_path); + girara_notify(zathura->ui.session, GIRARA_ERROR, _("File already exists: %s. Use :write! to overwrite it."), file_path); g_free(file_path); return false; } - zathura_error_t error = zathura_document_save_as(zathura->document, file_path); + const zathura_error_t error = zathura_document_save_as(zathura->document, file_path); g_free(file_path); - return (error == ZATHURA_ERROR_OK) ? true : false; + if (error != ZATHURA_ERROR_OK) { + girara_notify(zathura->ui.session, GIRARA_ERROR, _("Failed to save document.")); + return false; + } + + girara_notify(zathura->ui.session, GIRARA_INFO, _("Document saved.")); + return true; } static void