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