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