]> git.lyx.org Git - features.git/commitdiff
Backport fix for #7652, so that we show backends, not formats, in the
authorRichard Heck <rgheck@lyx.org>
Fri, 29 Jun 2012 14:37:02 +0000 (10:37 -0400)
committerRichard Heck <rgheck@lyx.org>
Fri, 29 Jun 2012 15:13:07 +0000 (11:13 -0400)
View>Source combo.

ANNOUNCE
src/Buffer.cpp
src/BufferParams.cpp
src/BufferParams.h
src/frontends/qt4/GuiViewSource.cpp
status.20x

index 4ef2d125b5678175f3152dbf6f7c8c0ddf7ed4da..7ebb35f5803e39889d2a3ba3529613e9c6e9b985 100644 (file)
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -33,6 +33,12 @@ http://www.lyx.org
 What's new in LyX 2.0.5
 =======================
 
+The View>Source widget now allows you to select the backend to display,
+e.g., LaTeX or XHTML, rather than the output format. The previous choice
+really made no sense: You didn't see a PDF there if you chose one of the
+PDF output formats, but rather LaTeX. This solves some long-standing issues
+with View>Source.
+
 
 What's new
 ==========
index 6560da73432966fb9c8f33bd67dac5d7ad7ad880..2ed74091c7f31e548213176c855022db3277c9dc 100644 (file)
@@ -3225,6 +3225,12 @@ void Buffer::getSourceCode(odocstream & os, string const format,
                else if (runparams.flavor == OutputParams::HTML) {
                        XHTMLStream xs(os);
                        xhtmlParagraphs(text(), *this, xs, runparams);
+               } else if (runparams.flavor == OutputParams::TEXT) {
+                       bool dummy;
+                       // FIXME Handles only one paragraph, unlike the others.
+                       // Probably should have some routine with a signature like them.
+                       writePlaintextParagraph(*this,
+                               text().paragraphs()[par_begin], os, runparams, dummy);
                } else {
                        // latex or literate
                        otexstream ots(os, texrow);
index c64597c3a1aa901505d1e8e4ed7ca2f991d38770..cb3d673b1645e3a8bc8e334d18e7b09e86965021 100644 (file)
@@ -2130,17 +2130,24 @@ bool BufferParams::isExportableFormat(string const & format) const
 vector<string> BufferParams::backends() const
 {
        vector<string> v;
-       v.push_back(bufferFormat());
+       string const buffmt = bufferFormat();
+
        // FIXME: Don't hardcode format names here, but use a flag
-       if (v.back() == "latex") {
-               v.push_back("pdflatex");
+       if (buffmt == "latex") {
+               if (!useNonTeXFonts) {
+                       v.push_back("pdflatex");
+                       v.push_back("latex");
+               }
                v.push_back("luatex");
                v.push_back("dviluatex");
                v.push_back("xetex");
-       } else if (v.back() == "xetex") {
+       } else if (buffmt == "xetex") {
+               v.push_back("xetex");
                v.push_back("luatex");
                v.push_back("dviluatex");
-       }
+       } else
+               v.push_back(buffmt);
+
        v.push_back("xhtml");
        v.push_back("text");
        v.push_back("lyx");
@@ -2162,6 +2169,8 @@ OutputParams::FLAVOR BufferParams::getOutputFlavor(string const format) const
 
        if (dformat == "xhtml")
                result = OutputParams::HTML;
+       else if (dformat == "text")
+               result = OutputParams::TEXT;
        else {
                // Try to determine flavor of default output format
                vector<string> backs = backends();
index 2c4828e1c48ecae4a03a6813da4ce6f1579940cf..bb29f01d52a5f2560b567020367edb7af179227a 100644 (file)
@@ -176,7 +176,8 @@ public:
        std::vector<Format const *> exportableFormats(bool only_viewable) const;
        ///
        bool isExportableFormat(std::string const & format) const;
-       ///
+       /// the backends appropriate for use with this document.
+       /// so, e.g., latex is excluded , if we're using non-TeX fonts
        std::vector<std::string> backends() const;
 
        /// List of included children (for includeonly)
index 8a2309d75dbebe39ca4aef88acfe7b373f78dc63..6a49febd7de3dd552c656263472a606ab13bdd8d 100644 (file)
@@ -197,19 +197,23 @@ void ViewSourceWidget::updateDefaultFormat()
        outputFormatCO->addItem(qt_("Default"),
                                QVariant(QString("default")));
 
-       int index = 0;
-       typedef vector<Format const *> Formats;
-       Formats formats = bv_->buffer().params().exportableFormats(true);
-       Formats::const_iterator cit = formats.begin();
-       Formats::const_iterator end = formats.end();
-       for (; cit != end; ++cit) {
-               QString const fname = toqstr((*cit)->name());
-               outputFormatCO->addItem(qt_((*cit)->prettyname()),
-                               QVariant(fname));
-               if (fname == view_format_)
-                   index = outputFormatCO->count() -1;
+       vector<string> tmp = bv_->buffer().params().backends();
+       vector<string>::const_iterator it = tmp.begin();
+       vector<string>::const_iterator en = tmp.end();
+       for (; it != en; ++it) {
+               string const format = *it;
+               Format const * fmt = formats.getFormat(format);
+               if (!fmt)
+                       LYXERR0("Can't find format for backend " << format << "!");
+               else if (fmt->name() == "lyx")
+                       // we can't presently display the LyX format itself
+                       continue;
+
+               QString const pretty =
+                       fmt ? qt_(fmt->prettyname()) : toqstr(format);
+               outputFormatCO->addItem(pretty, QVariant(toqstr(format)));
        }
-       outputFormatCO->setCurrentIndex(index);
+
        outputFormatCO->blockSignals(false);
 }
 
index 304a32972af0f8b169827fa82deb21110ff5f150..3de50eb3af9cf5101143c3454ce34bcfa4d56150 100644 (file)
@@ -36,6 +36,7 @@ What's new
 
 * USER INTERFACE
 
+- Show backends, not formats, in View>Source (bug #7652).
 
 
 * DOCUMENTATION AND LOCALIZATION