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 lyx::support::AddName;
30 using lyx::support::FileFilterList;
31 using lyx::support::system_lyxdir;
32 using lyx::support::user_lyxdir;
34 using std::ostringstream;
40 extern BufferList bufferlist;
42 ControlPrefs::ControlPrefs(Dialog & parent)
43 : Dialog::Controller(parent),
45 update_screen_font_(false)
49 bool ControlPrefs::initialiseParams(std::string const &)
53 converters_ = ::converters;
54 converters_.update(formats_);
57 update_screen_font_ = false;
63 void ControlPrefs::dispatchParams()
67 kernel().dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()));
69 // FIXME: these need lfuns
70 bufferlist.setCurrentAuthor(rc_.user_name, rc_.user_email);
74 ::converters = converters_;
75 ::converters.update(::formats);
76 ::converters.buildGraph();
78 vector<string>::const_iterator it = colors_.begin();
79 vector<string>::const_iterator const end = colors_.end();
80 for (; it != end; ++it)
81 kernel().dispatch(FuncRequest(LFUN_SET_COLOR, *it));
89 if (update_screen_font_) {
90 kernel().dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
91 update_screen_font_ = false;
94 // The Save button has been pressed
95 if (dialog().isClosing()) {
96 kernel().dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
101 void ControlPrefs::redrawGUI()
107 void ControlPrefs::setColor(LColor_color col, string const & hex)
109 colors_.push_back(lcolor.getLyXName(col) + ' ' + hex);
113 void ControlPrefs::updateScreenFonts()
115 update_screen_font_ = true;
119 string const ControlPrefs::browsebind(string const & file) const
121 pair<string,string> dir1(_("System Bind|#S#s"),
122 AddName(system_lyxdir(), "bind"));
124 pair<string,string> dir2(_("User Bind|#U#u"),
125 AddName(user_lyxdir(), "bind"));
127 return browseFile(file, _("Choose bind file"),
128 FileFilterList("*.bind"), false, dir1, dir2);
132 string const ControlPrefs::browseUI(string const & file) const
134 pair<string,string> const dir1(_("Sys UI|#S#s"),
135 AddName(system_lyxdir(), "ui"));
137 pair<string,string> const dir2(_("User UI|#U#u"),
138 AddName(user_lyxdir(), "ui"));
140 return browseFile(file, _("Choose UI file"),
141 FileFilterList("*.ui"), false, dir1, dir2);
145 string const ControlPrefs::browsekbmap(string const & file) const
147 pair<string, string> dir(_("Key maps|#K#k"),
148 AddName(system_lyxdir(), "kbd"));
150 return browseFile(file, _("Choose keyboard map"),
151 FileFilterList("*.kmap"), false, dir);
155 string const ControlPrefs::browsedict(string const & file) const
157 return browseFile(file, _("Choose personal dictionary"),
158 FileFilterList("*.ispell"));
162 string const ControlPrefs::browse(string const & file,
163 string const & title) const
165 return browseFile(file, title, FileFilterList(), true);
169 string const ControlPrefs::browsedir(string const & path,
170 string const & title) const
172 return browseDir(path, title);