]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlPrint.C
Really dull and boring header shit
[lyx.git] / src / frontends / controllers / ControlPrint.C
1 /**
2  * \file ControlPrint.C
3  * See the file COPYING.
4  *
5  * \author Angus Leeming
6  *
7  * Full author contact details are available in file CREDITS
8  */
9
10 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include "ControlPrint.h"
17
18 #include "ViewBase.h"
19 #include "ButtonControllerBase.h"
20
21 #include "buffer.h"
22 #include "gettext.h"
23 #include "helper_funcs.h"
24 #include "PrinterParams.h"
25
26 #include "frontends/Alert.h"
27 #include "frontends/Liason.h"
28
29 #include "support/LAssert.h"
30
31 using Liason::printBuffer;
32 using Liason::getPrinterParams;
33
34
35 ControlPrint::ControlPrint(LyXView & lv, Dialogs & d)
36         : ControlDialogBD(lv, d),
37           params_(0)
38 {}
39
40
41 void ControlPrint::apply()
42 {
43         if (!bufferIsAvailable())
44                 return;
45
46         view().apply();
47
48         if (!printBuffer(buffer(), params())) {
49                 Alert::alert(_("Error:"),
50                            _("Unable to print"),
51                            _("Check that your parameters are correct"));
52         }
53 }
54
55
56 PrinterParams & ControlPrint::params() const
57 {
58         lyx::Assert(params_);
59         return *params_;
60 }
61
62
63 void ControlPrint::setParams()
64 {
65         if (params_) delete params_;
66         params_ = new PrinterParams(getPrinterParams(buffer()));
67
68         bc().valid(); // so that the user can press Ok
69 }
70
71
72 void ControlPrint::clearParams()
73 {
74         if (params_) {
75                 delete params_;
76                 params_ = 0;
77         }
78 }
79
80
81 string const ControlPrint::Browse(string const & in_name)
82 {
83         string const title = _("Print to file");
84         string const pattern = "*.ps";
85
86         // Show the file browser dialog
87         return browseRelFile(&lv_, in_name, buffer()->filePath(),
88                              title, pattern);
89 }