From fa0c2d96311d275a6ac971440ea926e03527705a Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Fri, 9 Mar 2012 22:24:20 +0000 Subject: [PATCH] Show backends rather than formats in the View>Source combo box. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40900 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 6 ++++++ src/BufferParams.cpp | 2 ++ src/frontends/qt4/GuiViewSource.cpp | 28 ++++++++++++++++------------ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index a53df7b752..3fdd32b813 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -3309,6 +3309,12 @@ void Buffer::getSourceCode(odocstream & os, string const format, XHTMLStream xs(os); setMathFlavor(runparams); 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); diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 81a13bdb2b..5f848a6256 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -2172,6 +2172,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 backs = backends(); diff --git a/src/frontends/qt4/GuiViewSource.cpp b/src/frontends/qt4/GuiViewSource.cpp index 8a2309d75d..6a49febd7d 100644 --- a/src/frontends/qt4/GuiViewSource.cpp +++ b/src/frontends/qt4/GuiViewSource.cpp @@ -197,19 +197,23 @@ void ViewSourceWidget::updateDefaultFormat() outputFormatCO->addItem(qt_("Default"), QVariant(QString("default"))); - int index = 0; - typedef vector 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 tmp = bv_->buffer().params().backends(); + vector::const_iterator it = tmp.begin(); + vector::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); } -- 2.39.2