Hi,

Jürgen's  improvements for "GNU Gettext" are now includet.
I looked into the documentation (chapter "Child Documents" in the
"Embedded Objects" helpfile ): a change seems to me not really necessary.
Maybe it is self explanatory enough.

Jürgen

Am 10.03.2019 um 19:17 schrieb Jürgen Spitzmüller:
> Am Sonntag, den 10.03.2019, 19:08 +0100 schrieb Jürgen Womser-Schütz:
>> Ahh, I see: _() is the C++ user defined flag for enabling the
>> translation machinery! I couldn't find the definition :-(
> src/support/getttext.h
>
> Jürgen

diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp
old mode 100644
new mode 100755
index 51cc147333..f77dad2b03
--- a/src/insets/InsetInclude.cpp
+++ b/src/insets/InsetInclude.cpp
@@ -55,6 +55,7 @@
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/docstream.h"
+#include "support/FileName.h"
 #include "support/FileNameList.h"
 #include "support/filetools.h"
 #include "support/gettext.h"
@@ -188,7 +189,7 @@ char_type replaceCommaInBraces(docstring & params)
 InsetInclude::InsetInclude(Buffer * buf, InsetCommandParams const & p)
        : InsetCommand(buf, p), include_label(uniqueID()),
          preview_(make_unique<RenderMonitoredPreview>(this)), 
failedtoload_(false),
-         set_label_(false), label_(0), child_buffer_(0)
+         set_label_(false), label_(0), child_buffer_(0), file_exist_(false)
 {
        preview_->connect([=](){ fileChanged(); });
 
@@ -203,7 +204,7 @@ InsetInclude::InsetInclude(Buffer * buf, InsetCommandParams 
const & p)
 InsetInclude::InsetInclude(InsetInclude const & other)
        : InsetCommand(other), include_label(other.include_label),
          preview_(make_unique<RenderMonitoredPreview>(this)), 
failedtoload_(false),
-         set_label_(false), label_(0), child_buffer_(0)
+         set_label_(false), label_(0), child_buffer_(0), 
file_exist_(other.file_exist_)
 {
        preview_->connect([=](){ fileChanged(); });
 
@@ -391,6 +392,8 @@ bool InsetInclude::isChildIncluded() const
 
 docstring InsetInclude::screenLabel() const
 {
+       docstring pre = file_exist_ ? docstring() : _("FILE MISSING:");
+
        docstring temp;
 
        switch (type(params())) {
@@ -418,13 +421,9 @@ docstring InsetInclude::screenLabel() const
        }
 
        temp += ": ";
+       temp += from_utf8(onlyFileName(to_utf8(params()["filename"])));
 
-       if (params()["filename"].empty())
-               temp += "???";
-       else
-               temp += from_utf8(onlyFileName(to_utf8(params()["filename"])));
-
-       return temp;
+       return pre.empty() ? temp : pre + from_ascii(" ") + temp;
 }
 
 
@@ -513,8 +512,8 @@ void InsetInclude::latex(otexstream & os, OutputParams 
const & runparams) const
 {
        string incfile = to_utf8(params()["filename"]);
 
-       // Do nothing if no file name has been specified
-       if (incfile.empty())
+       // Do nothing if file doesn't exist
+       if (!listingFileExist())
                return;
 
        FileName const included_file = includedFileName(buffer(), params());
@@ -1330,6 +1329,8 @@ void InsetInclude::updateCommand()
 
 void InsetInclude::updateBuffer(ParIterator const & it, UpdateType utype)
 {
+       file_exist_ = listingFileExist();
+
        button_.update(screenLabel(), true, false);
 
        Buffer const * const childbuffer = getChildBuffer();
@@ -1359,4 +1360,12 @@ void InsetInclude::updateBuffer(ParIterator const & it, 
UpdateType utype)
 }
 
 
+bool InsetInclude::listingFileExist() const
+{
+       // check whether the file of the listing exist
+       string listingFileName = to_utf8(params()["filename"]);
+       FileName fn = support::makeAbsPath(listingFileName, 
support::onlyPath(buffer().absFileName()));
+       return fn.exists();
+}
+
 } // namespace lyx
diff --git a/src/insets/InsetInclude.h b/src/insets/InsetInclude.h
old mode 100644
new mode 100755
index 9ecaf42e7e..65e2945c92
--- a/src/insets/InsetInclude.h
+++ b/src/insets/InsetInclude.h
@@ -137,6 +137,8 @@ private:
        void editIncluded(std::string const & file);
        ///
        bool isChildIncluded() const;
+       /// check whether the file of the listing exist
+       bool listingFileExist() const;
 
        /// \name Private functions inherited from Inset class
        //@{
@@ -170,6 +172,7 @@ private:
        mutable docstring listings_label_;
        InsetLabel * label_;
        mutable Buffer * child_buffer_;
+       mutable bool file_exist_;
 };
 
 

Reply via email to