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