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