#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
#include "ControlPrint.h"
#include "ViewBase.h"
-#include "ButtonControllerBase.h"
+#include "ButtonController.h"
#include "buffer.h"
+#include "bufferparams.h"
#include "gettext.h"
#include "helper_funcs.h"
#include "PrinterParams.h"
#include "exporter.h"
-#include "converter.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(),
- title, pattern);
+ 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);
+}
+
}
+ tostr(pp.count_copies)
+ ' ';
}
-
+
if (pp.reverse_order) {
command += lyxrc.print_reverse_flag + ' ';
}
command += lyxrc.print_extra_options + ' ';
}
- command += converters.dvips_options(buffer()) + ' ';
+ command += buffer()->params.dvips_options() + ' ';
if (!Exporter::Export(buffer(), "dvi", true)) {
- Alert::alert(_("Error:"),
- _("Unable to print"),
- _("Check that your parameters are correct"));
+ showPrintError(buffer()->fileName());
return;
}
// case 1: print to a file
command += lyxrc.print_to_file
+ QuoteName(MakeAbsPath(pp.file_name, path))
- + ' '
+ + ' '
+ QuoteName(dviname);
res = one.startscript(Systemcall::DontWait, command);
break;
}
- lyxerr[Debug::LATEX] << "ControlPrint::apply(): print command = \"" << command << "\"" << endl;
+ 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());
}