]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlPrefs.C
Finish the task of removing all cruft from the header files.
[lyx.git] / src / frontends / controllers / ControlPrefs.C
1 /**
2  * \file ControlPrefs.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "ControlPrefs.h"
14
15 #include "helper_funcs.h"
16 #include "ViewBase.h"
17
18 #include "bufferlist.h"
19 #include "converter.h"
20 #include "format.h"
21 #include "gettext.h"
22 #include "funcrequest.h"
23 #include "lfuns.h"
24
25 #include "frontends/Dialogs.h"
26 #include "frontends/LyXView.h"
27
28 #include "support/filetools.h"
29 #include "support/path_defines.h"
30
31 #include <utility>
32
33 using namespace lyx::support;
34
35 using std::endl;
36 using std::pair;
37
38
39 extern BufferList bufferlist;
40
41 ControlPrefs::ControlPrefs(LyXView & lv, Dialogs & d)
42         : ControlDialogBI(lv, d)
43 {}
44
45
46 void ControlPrefs::setParams()
47 {
48         rc_ = lyxrc;
49 }
50
51
52 void ControlPrefs::apply()
53 {
54         view().apply();
55         lyxrc = rc_;
56
57         bufferlist.setCurrentAuthor(rc_.user_name, rc_.user_email);
58
59         // The Save button has been pressed
60         if (isClosing()) {
61                 lv_.dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
62         }
63 }
64
65
66 string const ControlPrefs::browsebind(string const & file)
67 {
68         string dir  = AddName(system_lyxdir(), "bind");
69         // FIXME: stupid name
70         string name = _("System Bind|#S#s");
71         pair<string,string> dir1(name, dir);
72
73         dir = AddName(user_lyxdir(), "bind");
74         // FIXME: stupid name
75         name = _("User Bind|#U#u");
76         pair<string,string> dir2(name, dir);
77
78         return browseFile(file, _("Choose bind file"), "*.bind", false, dir1, dir2);
79 }
80
81
82 string const ControlPrefs::browseUI(string const & file)
83 {
84         string dir  = AddName(system_lyxdir(), "ui");
85         // FIXME: stupid name
86         string name = _("Sys UI|#S#s");
87         pair<string,string> dir1(name, dir);
88
89         dir = AddName(user_lyxdir(), "ui");
90         // FIXME: stupid name
91         name = _("User UI|#U#u");
92         pair<string,string> dir2(name, dir);
93
94         return browseFile(file, _("Choose UI file"), "*.ui", false, dir1, dir2);
95 }
96
97
98 string const ControlPrefs::browsekbmap(string const & file)
99 {
100         string const dir = AddName(system_lyxdir(), "kbd");
101         string const name = _("Key maps|#K#k");
102         pair<string, string> dir1(name, dir);
103
104         return browseFile(file, _("Choose keyboard map"), "*.kmap", false, dir1);
105 }
106
107
108 string const ControlPrefs::browsedict(string const & file)
109 {
110         return browseFile(file, _("Choose personal dictionary"), "*.ispell");
111 }
112
113
114 string const ControlPrefs::browse(string const & file, string const & title)
115 {
116         return browseFile(file, title, "*", true);
117 }
118
119
120 string const ControlPrefs::browsedir(string const & path, string const & title)
121 {
122         return browseDir(path, title);
123 }
124
125
126 void ControlPrefs::redrawGUI()
127 {
128         // we must be sure to get the new values first
129         lyxrc = rc_;
130
131         lv_.getDialogs().redrawGUI();
132 }
133
134
135 void ControlPrefs::setColor(LColor::color col, string const & hex)
136 {
137         string const s = lcolor.getLyXName(col) + ' ' + hex;
138         lv_.dispatch(FuncRequest(LFUN_SET_COLOR, s));
139 }
140
141
142 void ControlPrefs::updateScreenFonts()
143 {
144         // we must be sure to get the new values first
145         lyxrc = rc_;
146
147         lv_.dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
148 }
149
150
151 void ControlPrefs::setConverters(Converters const & conv)
152 {
153         converters = conv;
154         converters.update(formats);
155         converters.buildGraph();
156 }
157
158
159 void ControlPrefs::setFormats(Formats const & form)
160 {
161         formats = form;
162 }