]> git.lyx.org Git - features.git/blob - src/frontends/controllers/ControlPrefs.C
547cc742b4c9b91cc888f23ca6629d13dbc20dec
[features.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 lyx::support::AddName;
34 using lyx::support::system_lyxdir;
35 using lyx::support::user_lyxdir;
36
37 using std::pair;
38
39
40 extern BufferList bufferlist;
41
42 ControlPrefs::ControlPrefs(LyXView & lv, Dialogs & d)
43         : ControlDialogBI(lv, d)
44 {}
45
46
47 void ControlPrefs::setParams()
48 {
49         rc_ = lyxrc;
50 }
51
52
53 void ControlPrefs::apply()
54 {
55         view().apply();
56         lyxrc = rc_;
57
58         bufferlist.setCurrentAuthor(rc_.user_name, rc_.user_email);
59
60         // The Save button has been pressed
61         if (isClosing()) {
62                 lv_.dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
63         }
64 }
65
66
67 string const ControlPrefs::browsebind(string const & file)
68 {
69         string dir  = AddName(system_lyxdir(), "bind");
70         // FIXME: stupid name
71         string name = _("System Bind|#S#s");
72         pair<string,string> dir1(name, dir);
73
74         dir = AddName(user_lyxdir(), "bind");
75         // FIXME: stupid name
76         name = _("User Bind|#U#u");
77         pair<string,string> dir2(name, dir);
78
79         return browseFile(file, _("Choose bind file"), "*.bind", false, dir1, dir2);
80 }
81
82
83 string const ControlPrefs::browseUI(string const & file)
84 {
85         string dir  = AddName(system_lyxdir(), "ui");
86         // FIXME: stupid name
87         string name = _("Sys UI|#S#s");
88         pair<string,string> dir1(name, dir);
89
90         dir = AddName(user_lyxdir(), "ui");
91         // FIXME: stupid name
92         name = _("User UI|#U#u");
93         pair<string,string> dir2(name, dir);
94
95         return browseFile(file, _("Choose UI file"), "*.ui", false, dir1, dir2);
96 }
97
98
99 string const ControlPrefs::browsekbmap(string const & file)
100 {
101         string const dir = AddName(system_lyxdir(), "kbd");
102         string const name = _("Key maps|#K#k");
103         pair<string, string> dir1(name, dir);
104
105         return browseFile(file, _("Choose keyboard map"), "*.kmap", false, dir1);
106 }
107
108
109 string const ControlPrefs::browsedict(string const & file)
110 {
111         return browseFile(file, _("Choose personal dictionary"), "*.ispell");
112 }
113
114
115 string const ControlPrefs::browse(string const & file, string const & title)
116 {
117         return browseFile(file, title, "*", true);
118 }
119
120
121 string const ControlPrefs::browsedir(string const & path, string const & title)
122 {
123         return browseDir(path, title);
124 }
125
126
127 void ControlPrefs::redrawGUI()
128 {
129         // we must be sure to get the new values first
130         lyxrc = rc_;
131
132         lv_.getDialogs().redrawGUI();
133 }
134
135
136 void ControlPrefs::setColor(LColor::color col, string const & hex)
137 {
138         string const s = lcolor.getLyXName(col) + ' ' + hex;
139         lv_.dispatch(FuncRequest(LFUN_SET_COLOR, s));
140 }
141
142
143 void ControlPrefs::updateScreenFonts()
144 {
145         // we must be sure to get the new values first
146         lyxrc = rc_;
147
148         lv_.dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
149 }
150
151
152 void ControlPrefs::setConverters(Converters const & conv)
153 {
154         converters = conv;
155         converters.update(formats);
156         converters.buildGraph();
157 }
158
159
160 void ControlPrefs::setFormats(Formats const & form)
161 {
162         formats = form;
163 }