Notify if an error occurs in the :write command

This commit is contained in:
Moritz Lipp 2012-03-04 23:54:03 +01:00
parent 91f82416fc
commit 0049b6fa4b
5 changed files with 29 additions and 20 deletions

View file

@ -237,7 +237,11 @@ cmd_save(girara_session_t* session, girara_list_t* argument_list)
}
if (girara_list_size(argument_list) == 1) {
document_save(zathura, girara_list_nth(argument_list, 0), false);
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.");
}
} else {
girara_notify(session, GIRARA_ERROR, _("Invalid number of arguments."));
return false;
@ -259,7 +263,11 @@ cmd_savef(girara_session_t* session, girara_list_t* argument_list)
}
if (girara_list_size(argument_list) == 1) {
document_save(zathura, girara_list_nth(argument_list, 0), true);
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.");
}
} else {
girara_notify(session, GIRARA_ERROR, _("Invalid number of arguments."));
return false;

View file

@ -399,13 +399,13 @@ zathura_plugin_error_t
zathura_document_save_as(zathura_document_t* document, const char* path)
{
if (document == NULL || path == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) {
return false;
return ZATHURA_PLUGIN_ERROR_UNKNOWN;
}
if (document->functions.document_save_as == NULL) {
girara_notify(document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
return false;
return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
}
return document->functions.document_save_as(document, path);

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-03-04 18:53+0100\n"
"POT-Creation-Date: 2012-03-04 23:52+0100\n"
"PO-Revision-Date: 2012-03-04 17:77+0100\n"
"Last-Translator: Sebastian Ramacher <s.ramacher@gmx.at>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -32,11 +32,11 @@ msgid "Invalid index '%s' given."
msgstr ""
#: ../commands.c:28 ../commands.c:63 ../commands.c:90 ../commands.c:132
#: ../commands.c:327
#: ../commands.c:335
msgid "No document opened."
msgstr ""
#: ../commands.c:34 ../commands.c:69 ../commands.c:96 ../commands.c:333
#: ../commands.c:34 ../commands.c:69 ../commands.c:96 ../commands.c:341
msgid "Invalid number of arguments given."
msgstr ""
@ -78,20 +78,20 @@ msgstr ""
msgid "No arguments given."
msgstr ""
#: ../commands.c:218 ../commands.c:235 ../commands.c:257
#: ../commands.c:218 ../commands.c:235 ../commands.c:261
msgid "No open document."
msgstr ""
#: ../commands.c:242 ../commands.c:264
#: ../commands.c:246 ../commands.c:272
msgid "Invalid number of arguments."
msgstr ""
#: ../commands.c:346
#: ../commands.c:354
#, c-format
msgid "Couldn't write attachment '%s' to '%s'."
msgstr ""
#: ../commands.c:348
#: ../commands.c:356
#, c-format
msgid "Wrote attachment '%s' to '%s'."
msgstr ""

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-03-04 18:53+0100\n"
"POT-Creation-Date: 2012-03-04 23:52+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -32,11 +32,11 @@ msgid "Invalid index '%s' given."
msgstr ""
#: ../commands.c:28 ../commands.c:63 ../commands.c:90 ../commands.c:132
#: ../commands.c:327
#: ../commands.c:335
msgid "No document opened."
msgstr ""
#: ../commands.c:34 ../commands.c:69 ../commands.c:96 ../commands.c:333
#: ../commands.c:34 ../commands.c:69 ../commands.c:96 ../commands.c:341
msgid "Invalid number of arguments given."
msgstr ""
@ -78,20 +78,20 @@ msgstr ""
msgid "No arguments given."
msgstr ""
#: ../commands.c:218 ../commands.c:235 ../commands.c:257
#: ../commands.c:218 ../commands.c:235 ../commands.c:261
msgid "No open document."
msgstr ""
#: ../commands.c:242 ../commands.c:264
#: ../commands.c:246 ../commands.c:272
msgid "Invalid number of arguments."
msgstr ""
#: ../commands.c:346
#: ../commands.c:354
#, c-format
msgid "Couldn't write attachment '%s' to '%s'."
msgstr ""
#: ../commands.c:348
#: ../commands.c:356
#, c-format
msgid "Wrote attachment '%s' to '%s'."
msgstr ""

View file

@ -529,9 +529,10 @@ document_save(zathura_t* zathura, const char* path, bool overwrite)
return false;
}
bool res = zathura_document_save_as(zathura->document, file_path);
zathura_plugin_error_t error = zathura_document_save_as(zathura->document, file_path);
g_free(file_path);
return res;
return (error == ZATHURA_PLUGIN_ERROR_OK) ? true : false;
}
static void