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 "frontends/Dialogs.h"
24 #include "frontends/LyXView.h"
26 #include "support/filetools.h"
27 #include "support/globbing.h"
28 #include "support/path_defines.h"
30 #include "support/std_sstream.h"
34 using lyx::support::AddName;
35 using lyx::support::FileFilterList;
36 using lyx::support::system_lyxdir;
37 using lyx::support::user_lyxdir;
39 using std::ostringstream;
45 extern BufferList bufferlist;
47 ControlPrefs::ControlPrefs(LyXView & lv, Dialogs & d)
48 : ControlDialogBI(lv, d),
50 update_screen_font_(false)
54 void ControlPrefs::setParams()
58 converters_ = ::converters;
59 converters_.update(formats_);
62 update_screen_font_ = false;
66 void ControlPrefs::apply()
72 lv_.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 lv_.dispatch(FuncRequest(LFUN_SET_COLOR, *it));
90 lv_.getDialogs().redrawGUI();
94 if (update_screen_font_) {
95 lv_.dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
96 update_screen_font_ = false;
99 // The Save button has been pressed
101 lv_.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);