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