]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlPrint.C
Add a buffer_path arg to InsetGraphicsMailer's params2string, string2params.
[lyx.git] / src / frontends / controllers / ControlPrint.C
index 7ad3d926a3042ba3cfa503662de1e750fecacf56..d85c74f1d094b6898c353bf0e45be6a9e6c674bf 100644 (file)
 
 #include <config.h>
 
-
 #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;
 
@@ -42,7 +44,7 @@ ControlPrint::ControlPrint(LyXView & lv, Dialogs & d)
 
 PrinterParams & ControlPrint::params() const
 {
-       lyx::Assert(params_);
+       Assert(params_);
        return *params_;
 }
 
@@ -76,11 +78,24 @@ string const ControlPrint::Browse(string const & in_name)
        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()
 {
@@ -139,12 +154,10 @@ void ControlPrint::apply()
                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;
        }
 
@@ -205,9 +218,6 @@ void ControlPrint::apply()
        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());
 }