mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-27 13:46:01 +01:00
Refactor notification when writing files
This commit is contained in:
parent
c6b50cbdcb
commit
a17a6e5e83
2 changed files with 11 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue