1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2001 The LyX Team.
8 *======================================================
10 * \file ControlPrint.C
11 * \author Angus Leeming, a.leeming@.ac.uk
18 #pragma implementation
22 #include "ButtonControllerBase.h"
23 #include "ControlPrint.h"
28 #include "PrinterParams.h"
30 #include "helper_funcs.h" // browseFile
31 #include "lyx_gui_misc.h" // WriteAlert
33 #include "BufferView.h"
34 #include "support/LAssert.h"
36 using Liason::printBuffer;
37 using Liason::getPrinterParams;
40 ControlPrint::ControlPrint(LyXView & lv, Dialogs & d)
41 : ControlDialog<ControlConnectBD>(lv, d),
44 d_.showPrint.connect(SigC::slot(this, &ControlPrint::show));
48 void ControlPrint::apply()
50 if (!lv_.view()->available())
55 if (!printBuffer(lv_.buffer(), params())) {
56 WriteAlert(_("Error:"),
58 _("Check that your parameters are correct"));
63 PrinterParams & ControlPrint::params() const
70 void ControlPrint::setParams()
72 if (params_) delete params_;
73 params_ = new PrinterParams(getPrinterParams(lv_.buffer()));
75 bc().valid(); // so that the user can press Ok
79 void ControlPrint::clearParams()
88 string const ControlPrint::Browse(string const & in_name)
90 string const title = N_("Print to file");
91 string const pattern = "*.ps";
93 // Show the file browser dialog
94 return browseFile(&lv_, in_name, title, pattern,
95 make_pair(string(), string()),
96 make_pair(string(), string()));