From 0049b6fa4bf123d17f1b0696820e67569338eb84 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Sun, 4 Mar 2012 23:54:03 +0100 Subject: [PATCH] Notify if an error occurs in the :write command --- commands.c | 12 ++++++++++-- document.c | 4 ++-- po/de.po | 14 +++++++------- po/zathura.pot | 14 +++++++------- zathura.c | 5 +++-- 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/commands.c b/commands.c index 8ed9274..03cfeef 100644 --- a/commands.c +++ b/commands.c @@ -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; diff --git a/document.c b/document.c index c16949e..4ed2d00 100644 --- a/document.c +++ b/document.c @@ -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); diff --git a/po/de.po b/po/de.po index ed21122..7aad0f8 100644 --- a/po/de.po +++ b/po/de.po @@ -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 \n" "Language-Team: LANGUAGE \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 "" diff --git a/po/zathura.pot b/po/zathura.pot index e83e7e8..5a9ea4b 100644 --- a/po/zathura.pot +++ b/po/zathura.pot @@ -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 \n" "Language-Team: LANGUAGE \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 "" diff --git a/zathura.c b/zathura.c index 4feff10..d0829b1 100644 --- a/zathura.c +++ b/zathura.c @@ -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