]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlPreamble.C
Added // -*- C++ -*- to the top of all files in controllers/ and xforms/
[lyx.git] / src / frontends / controllers / ControlPreamble.C
1 // -*- C++ -*-
2 /**
3  * \file FormPreamble.C
4  * Copyright 2001 The LyX Team.
5  * See the file COPYING.
6  *
7  * \author Edwin Leuven, leuven@fee.uva.nl
8  */
9
10 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include "ViewBase.h"
17 #include "ButtonControllerBase.h"
18 #include "ControlPreamble.h"
19 #include "LyXView.h"
20 #include "Dialogs.h"
21 #include "buffer.h"
22 #include "lyxrc.h"
23 #include "Liason.h"
24 #include "gettext.h"
25
26
27 ControlPreamble::ControlPreamble(LyXView & lv, Dialogs & d)
28         : ControlDialog<ControlConnectBD>(lv, d),
29           params_(0)
30 {
31     d_.showPreamble.connect(SigC::slot(this, &ControlPreamble::show));
32 }
33
34
35 void ControlPreamble::apply()
36 {
37         if (!lv_.view()->available())
38                 return;
39    
40         view().apply();
41
42         lv_.buffer()->params.preamble = params();
43         lv_.buffer()->markDirty();
44         Liason::setMinibuffer(&lv_, _("LaTeX preamble set"));
45 }
46
47
48 string & ControlPreamble::params() const
49 {
50         lyx::Assert(params_);
51         return *params_;
52 }
53
54
55 void ControlPreamble::setParams()
56 {
57         if (params_) delete params_;
58         params_ = new string(lv_.buffer()->params.preamble);
59 }
60
61
62 void ControlPreamble::clearParams()
63 {
64         if (params_) {
65                 delete params_;
66                 params_ = 0;
67         }
68 }