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