]> 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 53f303e0906ee1a996f661c2f89c7f1ff9094560..d85c74f1d094b6898c353bf0e45be6a9e6c674bf 100644 (file)
 
 #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;
 
@@ -45,7 +44,7 @@ ControlPrint::ControlPrint(LyXView & lv, Dialogs & d)
 
 PrinterParams & ControlPrint::params() const
 {
-       lyx::Assert(params_);
+       Assert(params_);
        return *params_;
 }
 
@@ -79,8 +78,21 @@ string const ControlPrint::Browse(string const & in_name)
        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);
+}
+
 }
 
 
@@ -133,7 +145,7 @@ void ControlPrint::apply()
                        + tostr(pp.count_copies)
                        + ' ';
        }
-       
+
        if (pp.reverse_order) {
                command += lyxrc.print_reverse_flag + ' ';
        }
@@ -142,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;
        }
 
@@ -199,17 +209,15 @@ void ControlPrint::apply()
                // 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());
 }