]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlPrefs.C
prefs/tabular MVC work
[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 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include <utility>
18  
19 #include "ControlPrefs.h"
20 #include "ViewBase.h"
21
22 #include "frontends/LyXView.h"
23 #include "helper_funcs.h"
24 #include "gettext.h"
25 #include "support/filetools.h"
26 #include "frontends/Dialogs.h"
27 #include "converter.h"
28 #include "debug.h"
29
30 extern string system_lyxdir;
31 extern string user_lyxdir;
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::update()
42 {
43         rc_ = lyxrc;
44         view().update();
45 }
46
47
48 void ControlPrefs::apply()
49 {
50         view().apply();
51         lyxrc = rc_; 
52 }
53
54
55 void ControlPrefs::OKButton()
56 {
57         ControlDialogBI::OKButton();
58         lv_.dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
59 }
60
61  
62 string const ControlPrefs::browsebind(string const & file)
63 {
64         string dir  = AddName(system_lyxdir, "bind");
65         // FIXME: stupid name
66         string name = _("System Bind|#S#s");
67         pair<string,string> dir1(name, dir);
68  
69         dir = AddName(user_lyxdir, "bind");
70         // FIXME: stupid name
71         name = _("User Bind|#U#u");
72         pair<string,string> dir2(name, dir);
73  
74         return browseFile(&lv_, file, _("Choose bind file"), "*.bind", dir1, dir2);
75 }
76
77
78 string const ControlPrefs::browseUI(string const & file)
79 {
80         string dir  = AddName(system_lyxdir, "ui");
81         // FIXME: stupid name
82         string name = _("Sys UI|#S#s");
83         pair<string,string> dir1(name, dir);
84  
85         dir = AddName(user_lyxdir, "ui");
86         // FIXME: stupid name
87         name = _("User UI|#U#u");
88         pair<string,string> dir2(name, dir);
89  
90         return browseFile(&lv_, file, _("Choose UI file"), "*.ui", dir1, dir2);
91 }
92
93  
94 string const ControlPrefs::browsekbmap(string const & file)
95 {
96         string const dir = AddName(system_lyxdir, "kbd");
97         string const name = _("Key maps|#K#k");
98         pair<string, string> dir1(name, dir);
99  
100         return browseFile(&lv_, file, _("Choose keyboard map"), "*.kmap", dir1);
101 }
102
103  
104 string const ControlPrefs::browsedict(string const & file)
105 {
106         return browseFile(&lv_, file, _("Choose personal dictionary"), "*.ispell");
107 }
108  
109  
110 string const ControlPrefs::browse(string const & file, string const & title)
111 {
112         return browseFile(&lv_, file, title, "*");
113 }
114
115
116 void ControlPrefs::redrawGUI()
117 {
118         // we must be sure to get the new values first
119         lyxrc = rc_;
120  
121         lv_.getDialogs().redrawGUI();
122 }
123
124  
125 void ControlPrefs::setColor(LColor::color col, string const & hex)
126 {
127         string const s = lcolor.getLyXName(col) + string(" ") + hex;
128         lv_.dispatch(FuncRequest(LFUN_SET_COLOR, s));
129 }
130
131
132 void ControlPrefs::updateScreenFonts()
133 {
134         // we must be sure to get the new values first
135         lyxrc = rc_;
136  
137         lv_.dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
138 }
139  
140  
141 void ControlPrefs::setConverters(Converters const & conv)
142
143         converters = conv;
144         converters.update(formats);
145         converters.buildGraph();
146 }
147
148
149 void ControlPrefs::setFormats(Formats const & form)
150 {
151         formats = form;
152 }