Commit a17a6e5e authored by Sebastian Ramacher's avatar Sebastian Ramacher

Refactor notification when writing files

parent c6b50cbd
Pipeline #308 passed with stages
in 1 minute and 49 seconds
......@@ -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;
......
......@@ -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
......
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