]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlPrint.C
do not include language.h and gettext.h in lyxfont.h and lyxparagraph.h
[lyx.git] / src / frontends / controllers / ControlPrint.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *          Copyright 2001 The LyX Team.
7  *
8  *======================================================
9  *
10  * \file ControlPrint.C
11  * \author Angus Leeming, a.leeming@.ac.uk
12  */
13
14 #include <config.h>
15 #include <utility>
16
17 #ifdef __GNUG__
18 #pragma implementation
19 #endif
20
21 #include "ControlPrint.h"
22 #include "buffer.h"
23 #include "Dialogs.h"
24 #include "LyXView.h"
25 #include "lyxrc.h"
26 #include "PrinterParams.h"
27 #include "Liason.h"
28 #include "helper_funcs.h" // browseFile
29 #include "lyx_gui_misc.h" // WriteAlert
30 #include "gettext.h"
31
32 using Liason::printBuffer;
33 using Liason::getPrinterParams;
34 using std::make_pair;
35
36 ControlPrint::ControlPrint(LyXView & lv, Dialogs & d)
37         : ControlDialog<ControlConnectBD>(lv, d)
38 {
39         d_.showPrint.connect(SigC::slot(this, &ControlPrint::show));
40 }
41
42
43 void ControlPrint::apply()
44 {
45         if (!lv_.view()->available())
46                 return;
47    
48         view().apply();
49
50         if (!printBuffer(lv_.buffer(), params())) {
51                 WriteAlert(_("Error:"),
52                            _("Unable to print"),
53                            _("Check that your parameters are correct"));
54         }
55 }
56
57
58 PrinterParams & ControlPrint::params() const
59 {
60         Assert(params_);
61         return *params_;
62 }
63
64
65 void ControlPrint::setParams()
66 {
67         if (params_) delete params_;
68         params_ = new PrinterParams(getPrinterParams(lv_.buffer()));
69
70         bc().valid(); // so that the user can press Ok
71 }
72
73
74 void ControlPrint::clearParams()
75 {
76         if (params_) {
77                 delete params_;
78                 params_ = 0;
79         }
80 }
81
82
83 string const ControlPrint::Browse(string const & in_name)
84 {
85         string const title = N_("Print to file");
86         string const pattern = "*.ps";
87
88         // Show the file browser dialog
89         return browseFile(&lv_, in_name, title, pattern,
90                            make_pair(string(), string()),
91                            make_pair(string(), string()));
92 }