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