#include <config.h>
-
#include "ControlPrint.h"
#include "ViewBase.h"
-#include "ButtonControllerBase.h"
+#include "ButtonController.h"
#include "buffer.h"
#include "gettext.h"
#include "frontends/Alert.h"
+#include "support/tostr.h"
#include "support/LAssert.h"
#include "support/filetools.h"
#include "support/path.h"
#include "support/systemcall.h"
-#include "debug.h" // for lyxerr
+#include "debug.h"
+
+using namespace lyx::support;
using std::endl;
PrinterParams & ControlPrint::params() const
{
- lyx::Assert(params_);
+ Assert(params_);
return *params_;
}
string const pattern = "*.ps";
// Show the file browser dialog
- return browseRelFile(&lv_, in_name, buffer()->filePath(),
+ return browseRelFile(in_name, buffer()->filePath(),
title, pattern, true);
}
+namespace {
+
+void showPrintError(string const & name)
+{
+ string str = bformat(_("Could not print the document %1$s.\n"
+ "Check that your printer is set up correctly."),
+ MakeDisplayPath(name, 50));
+ Alert::error(_("Print document failed"), str);
+}
+
+}
+
+
/// print the current buffer
void ControlPrint::apply()
{
command += converters.dvips_options(buffer()) + ' ';
if (!Exporter::Export(buffer(), "dvi", true)) {
- Alert::alert(_("Error:"),
- _("Unable to print"),
- _("Check that your parameters are correct"));
+ showPrintError(buffer()->fileName());
return;
}
lyxerr[Debug::LATEX] << "ControlPrint::apply(): print command = \""
<< command << '"' << endl;
- if (res != 0) {
- Alert::alert(_("Error:"),
- _("Unable to print"),
- _("Check that your parameters are correct"));
- }
+ if (res != 0)
+ showPrintError(buffer()->fileName());
}