]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBranch.cpp
Fix previews in yellow notes and disabled branches
[lyx.git] / src / insets / InsetBranch.cpp
index af4140bccab31f06956211824b30403e404300d3..229e1bc37e3a051769cc133fa36486155f70eecd 100644 (file)
@@ -21,6 +21,8 @@
 #include "DispatchResult.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
+#include "Inset.h"
+#include "LaTeXFeatures.h"
 #include "Lexer.h"
 #include "LyX.h"
 #include "output_docbook.h"
@@ -117,6 +119,18 @@ docstring const InsetBranch::buttonLabel(BufferView const &) const
        if (decoration() == InsetDecoration::MINIMALISTIC)
                return symb + inv_symb + params_.branch;
 
+       if (!buffer_) {
+               return symb + inv_symb + _("Branch (undefined): ")
+                       + params_.branch;
+       }
+       bool const has_layout =
+               buffer().params().documentClass().hasInsetLayout(layoutName());
+       if (has_layout) {
+               InsetLayout const & il = getLayout();
+               docstring const & label_string = il.labelstring();
+               if (!label_string.empty())
+                       return symb + inv_symb + label_string;
+       }
        docstring s;
        if (inmaster && inchild)
                s = _("Branch: ");
@@ -327,7 +341,8 @@ void InsetBranch::forOutliner(docstring & os, size_t const maxlen,
 
 void InsetBranch::validate(LaTeXFeatures & features) const
 {
-       if (producesOutput())
+       // Showing previews in a disabled branch may require stuff
+       if (producesOutput() || features.runparams().for_preview)
                InsetCollapsible::validate(features);
 }