X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fcontrollers%2FControlLog.C;h=1ce66963a84b65aa5c2f17512c6ca781e0df7e49;hb=534095ce9e82d0b0f875540f7306ff218df3b5aa;hp=5e0a7a41e886ca569f24ff3de7538d86644a92ff;hpb=a12309c76b8fdcc69d0daf38f0b3068ca54d70d2;p=lyx.git diff --git a/src/frontends/controllers/ControlLog.C b/src/frontends/controllers/ControlLog.C index 5e0a7a41e8..1ce66963a8 100644 --- a/src/frontends/controllers/ControlLog.C +++ b/src/frontends/controllers/ControlLog.C @@ -1,64 +1,128 @@ -/* This file is part of - * ====================================================== +/** + * \file ControlLog.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * - * LyX, The Document Processor + * \author John Levon + * \author Angus Leeming * - * Copyright 2001 The LyX Team. - * - * ====================================================== - * - * \file ControlLog.h - * \author John Levon, moz@compsoc.man.ac.uk - * \author Angus Leeming + * Full author contact details are available in file CREDITS. */ -#ifdef __GNUG__ -#pragma implementation -#endif - #include + #include "ControlLog.h" -#include "LyXView.h" -#include "Dialogs.h" -#include "lyxrc.h" -using std::make_pair; -using SigC::slot; +#include "gettext.h" +#include "lyxlex.h" -ControlLog::ControlLog(LyXView & lv, Dialogs & d) - : ControlConnectBD(lv, d) -{ - d_.showLogFile.connect(slot(this, &ControlLog::show)); -} +#include +#include +using std::istringstream; +using std::ostream; +using std::string; -void ControlLog::show() +namespace lyx { + +using support::FileName; + +namespace frontend { + +ControlLog::ControlLog(Dialog & parent) + : Dialog::Controller(parent), + type_(LatexLog) +{} + + +bool ControlLog::initialiseParams(string const & data) { - if (!lv_.view()->available()) - return; + istringstream is(data); + LyXLex lex(0,0); + lex.setStream(is); - logfile_ = lv_.view()->buffer()->getLogName(); + string logtype, logfile; + lex >> logtype; + if (lex.isOK()) { + lex.next(true); + logfile = lex.getString(); + } + if (!lex) + // Parsing of the data failed. + return false; - bc().readOnly(isReadonly()); - view().show(); + if (logtype == "latex") + type_ = LatexLog; + else if (logtype == "literate") + type_ = LiterateLog; + else if (logtype == "lyx2lyx") + type_ = Lyx2lyxLog; + else if (logtype == "vc") + type_ = VCLog; + else + return false; + + logfile_ = FileName(logfile); + return true; } -void ControlLog::update() +void ControlLog::clearParams() { - if (!lv_.view()->available()) - return; + logfile_.erase(); +} - logfile_ = lv_.view()->buffer()->getLogName(); - - bc().readOnly(isReadonly()); - view().update(); + +docstring const ControlLog::title() const +{ + docstring t; + switch (type_) { + case LatexLog: + t = _("LaTeX Log"); + break; + case LiterateLog: + t = _("Literate Programming Build Log"); + break; + case Lyx2lyxLog: + t = _("lyx2lyx Error Log"); + break; + case VCLog: + t = _("Version Control Log"); + break; + } + return t; } -void ControlLog::hide() +void ControlLog::getContents(std::ostream & ss) const { - logfile_.second.erase(); - disconnect(); - view().hide(); + std::ifstream in(logfile_.toFilesystemEncoding().c_str()); + + bool success = false; + + if (in) { + ss << in.rdbuf(); + success = ss.good(); + } + + if (success) + return; + + switch (type_) { + case LatexLog: + ss << lyx::to_utf8(_("No LaTeX log file found.")); + break; + case LiterateLog: + ss << lyx::to_utf8(_("No literate programming build log file found.")); + break; + case Lyx2lyxLog: + ss << lyx::to_utf8(_("No lyx2lyx error log file found.")); + break; + case VCLog: + ss << lyx::to_utf8(_("No version control log file found.")); + break; + } } + +} // namespace frontend +} // namespace lyx