3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "ControlPrefs.h"
15 #include "helper_funcs.h"
18 #include "bufferlist.h"
20 #include "funcrequest.h"
23 #include "support/filetools.h"
24 #include "support/globbing.h"
25 #include "support/path_defines.h"
27 #include "support/std_sstream.h"
29 using std::ostringstream;
35 extern BufferList bufferlist;
39 using support::AddName;
40 using support::FileFilterList;
41 using support::system_lyxdir;
42 using support::user_lyxdir;
47 ControlPrefs::ControlPrefs(Dialog & parent)
48 : Dialog::Controller(parent),
50 update_screen_font_(false)
54 bool ControlPrefs::initialiseParams(std::string const &)
58 converters_ = ::converters;
59 converters_.update(formats_);
62 update_screen_font_ = false;
68 void ControlPrefs::dispatchParams()
72 kernel().dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()));
74 // FIXME: these need lfuns
75 bufferlist.setCurrentAuthor(rc_.user_name, rc_.user_email);
79 ::converters = converters_;
80 ::converters.update(::formats);
81 ::converters.buildGraph();
83 vector<string>::const_iterator it = colors_.begin();
84 vector<string>::const_iterator const end = colors_.end();
85 for (; it != end; ++it)
86 kernel().dispatch(FuncRequest(LFUN_SET_COLOR, *it));
94 if (update_screen_font_) {
95 kernel().dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
96 update_screen_font_ = false;
99 // The Save button has been pressed
100 if (dialog().isClosing()) {
101 kernel().dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
106 void ControlPrefs::redrawGUI()
112 void ControlPrefs::setColor(LColor_color col, string const & hex)
114 colors_.push_back(lcolor.getLyXName(col) + ' ' + hex);
118 void ControlPrefs::updateScreenFonts()
120 update_screen_font_ = true;
124 string const ControlPrefs::browsebind(string const & file) const
126 pair<string,string> dir1(_("System Bind|#S#s"),
127 AddName(system_lyxdir(), "bind"));
129 pair<string,string> dir2(_("User Bind|#U#u"),
130 AddName(user_lyxdir(), "bind"));
132 return browseFile(file, _("Choose bind file"),
133 FileFilterList("*.bind"), false, dir1, dir2);
137 string const ControlPrefs::browseUI(string const & file) const
139 pair<string,string> const dir1(_("Sys UI|#S#s"),
140 AddName(system_lyxdir(), "ui"));
142 pair<string,string> const dir2(_("User UI|#U#u"),
143 AddName(user_lyxdir(), "ui"));
145 return browseFile(file, _("Choose UI file"),
146 FileFilterList("*.ui"), false, dir1, dir2);
150 string const ControlPrefs::browsekbmap(string const & file) const
152 pair<string, string> dir(_("Key maps|#K#k"),
153 AddName(system_lyxdir(), "kbd"));
155 return browseFile(file, _("Choose keyboard map"),
156 FileFilterList("*.kmap"), false, dir);
160 string const ControlPrefs::browsedict(string const & file) const
162 return browseFile(file, _("Choose personal dictionary"),
163 FileFilterList("*.ispell"));
167 string const ControlPrefs::browse(string const & file,
168 string const & title) const
170 return browseFile(file, title, FileFilterList(), true);
174 string const ControlPrefs::browsedir(string const & path,
175 string const & title) const
177 return browseDir(path, title);
180 } // namespace frontend