2002-11-13 02:22:48 +00:00
|
|
|
/**
|
|
|
|
* \file ControlPrefs.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-11-13 02:22:48 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "ControlPrefs.h"
|
2003-09-05 15:31:19 +00:00
|
|
|
|
|
|
|
#include "helper_funcs.h"
|
2004-03-31 18:51:11 +00:00
|
|
|
#include "Kernel.h"
|
2002-11-13 02:22:48 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
#include "bufferlist.h"
|
2002-11-15 02:41:54 +00:00
|
|
|
#include "gettext.h"
|
2003-09-07 21:25:37 +00:00
|
|
|
#include "funcrequest.h"
|
2003-09-15 15:20:22 +00:00
|
|
|
#include "LColor.h"
|
2003-09-05 15:31:19 +00:00
|
|
|
|
2004-11-25 11:08:32 +00:00
|
|
|
#include "support/filefilterlist.h"
|
2002-11-13 02:22:48 +00:00
|
|
|
|
2004-07-24 10:55:30 +00:00
|
|
|
#include <sstream>
|
2004-03-31 16:50:59 +00:00
|
|
|
|
|
|
|
using std::ostringstream;
|
2002-11-15 02:41:54 +00:00
|
|
|
using std::pair;
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
2004-03-31 16:50:59 +00:00
|
|
|
using std::vector;
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2003-09-05 15:31:19 +00:00
|
|
|
|
|
|
|
extern BufferList bufferlist;
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
using support::FileFilterList;
|
|
|
|
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
|
2004-03-31 18:51:11 +00:00
|
|
|
ControlPrefs::ControlPrefs(Dialog & parent)
|
|
|
|
: Dialog::Controller(parent),
|
2004-03-31 16:50:59 +00:00
|
|
|
redraw_gui_(false),
|
|
|
|
update_screen_font_(false)
|
2002-11-13 02:22:48 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2004-03-31 18:51:11 +00:00
|
|
|
bool ControlPrefs::initialiseParams(std::string const &)
|
2002-11-15 02:41:54 +00:00
|
|
|
{
|
|
|
|
rc_ = lyxrc;
|
2004-03-31 16:50:59 +00:00
|
|
|
formats_ = ::formats;
|
|
|
|
converters_ = ::converters;
|
|
|
|
converters_.update(formats_);
|
2004-10-26 18:39:13 +00:00
|
|
|
movers_ = ::movers;
|
2004-03-31 16:50:59 +00:00
|
|
|
colors_.clear();
|
|
|
|
redraw_gui_ = false;
|
|
|
|
update_screen_font_ = false;
|
2004-03-31 18:51:11 +00:00
|
|
|
|
|
|
|
return true;
|
2002-11-15 02:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-31 18:51:11 +00:00
|
|
|
void ControlPrefs::dispatchParams()
|
2002-11-13 02:22:48 +00:00
|
|
|
{
|
2004-04-03 08:37:12 +00:00
|
|
|
ostringstream ss;
|
2004-04-05 18:21:25 +00:00
|
|
|
rc_.write(ss, true);
|
2004-04-03 08:37:12 +00:00
|
|
|
kernel().dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()));
|
2004-03-31 16:50:59 +00:00
|
|
|
|
|
|
|
// FIXME: these need lfuns
|
2003-02-08 21:48:54 +00:00
|
|
|
bufferlist.setCurrentAuthor(rc_.user_name, rc_.user_email);
|
|
|
|
|
2004-03-31 16:50:59 +00:00
|
|
|
::formats = formats_;
|
|
|
|
|
|
|
|
::converters = converters_;
|
|
|
|
::converters.update(::formats);
|
|
|
|
::converters.buildGraph();
|
|
|
|
|
2004-10-26 18:39:13 +00:00
|
|
|
::movers = movers_;
|
|
|
|
|
2004-03-31 16:50:59 +00:00
|
|
|
vector<string>::const_iterator it = colors_.begin();
|
|
|
|
vector<string>::const_iterator const end = colors_.end();
|
|
|
|
for (; it != end; ++it)
|
2004-03-31 18:51:11 +00:00
|
|
|
kernel().dispatch(FuncRequest(LFUN_SET_COLOR, *it));
|
2004-03-31 16:50:59 +00:00
|
|
|
colors_.clear();
|
|
|
|
|
|
|
|
if (redraw_gui_) {
|
2004-03-31 18:51:11 +00:00
|
|
|
kernel().redrawGUI();
|
2004-03-31 16:50:59 +00:00
|
|
|
redraw_gui_ = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (update_screen_font_) {
|
2004-03-31 18:51:11 +00:00
|
|
|
kernel().dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
|
2004-03-31 16:50:59 +00:00
|
|
|
update_screen_font_ = false;
|
|
|
|
}
|
|
|
|
|
2002-11-29 10:16:58 +00:00
|
|
|
// The Save button has been pressed
|
2004-03-31 18:51:11 +00:00
|
|
|
if (dialog().isClosing()) {
|
|
|
|
kernel().dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
|
2002-11-29 10:16:58 +00:00
|
|
|
}
|
2002-11-13 02:22:48 +00:00
|
|
|
}
|
2002-11-15 02:41:54 +00:00
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2004-03-31 16:50:59 +00:00
|
|
|
void ControlPrefs::redrawGUI()
|
|
|
|
{
|
|
|
|
redraw_gui_ = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlPrefs::setColor(LColor_color col, string const & hex)
|
|
|
|
{
|
|
|
|
colors_.push_back(lcolor.getLyXName(col) + ' ' + hex);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlPrefs::updateScreenFonts()
|
|
|
|
{
|
|
|
|
update_screen_font_ = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-08 10:59:51 +00:00
|
|
|
string const ControlPrefs::browsebind(string const & file) const
|
2002-11-15 02:41:54 +00:00
|
|
|
{
|
2004-08-08 15:23:43 +00:00
|
|
|
return browseLibFile("bind", file, "bind", _("Choose bind file"),
|
|
|
|
FileFilterList("LyX bind files (*.bind)"));
|
2002-11-15 02:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-08 10:59:51 +00:00
|
|
|
string const ControlPrefs::browseUI(string const & file) const
|
2002-11-15 02:41:54 +00:00
|
|
|
{
|
2004-08-08 15:23:43 +00:00
|
|
|
return browseLibFile("ui", file, "ui", _("Choose UI file"),
|
|
|
|
FileFilterList("LyX UI files (*.ui)"));
|
2002-11-15 02:41:54 +00:00
|
|
|
}
|
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2004-01-08 10:59:51 +00:00
|
|
|
string const ControlPrefs::browsekbmap(string const & file) const
|
2002-11-15 02:41:54 +00:00
|
|
|
{
|
2004-08-08 15:23:43 +00:00
|
|
|
return browseLibFile("kbd", file, "kmap", _("Choose keyboard map"),
|
|
|
|
FileFilterList("LyX keyboard maps (*.kmap)"));
|
2002-11-15 02:41:54 +00:00
|
|
|
}
|
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2004-01-08 10:59:51 +00:00
|
|
|
string const ControlPrefs::browsedict(string const & file) const
|
2002-11-15 02:41:54 +00:00
|
|
|
{
|
2004-01-08 10:59:51 +00:00
|
|
|
return browseFile(file, _("Choose personal dictionary"),
|
|
|
|
FileFilterList("*.ispell"));
|
2002-11-15 02:41:54 +00:00
|
|
|
}
|
2002-11-27 10:30:28 +00:00
|
|
|
|
|
|
|
|
2004-01-08 10:59:51 +00:00
|
|
|
string const ControlPrefs::browse(string const & file,
|
|
|
|
string const & title) const
|
2002-11-15 02:41:54 +00:00
|
|
|
{
|
2004-01-08 10:59:51 +00:00
|
|
|
return browseFile(file, title, FileFilterList(), true);
|
2002-11-15 02:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-08 10:59:51 +00:00
|
|
|
string const ControlPrefs::browsedir(string const & path,
|
|
|
|
string const & title) const
|
2003-01-14 21:51:34 +00:00
|
|
|
{
|
2003-02-21 12:22:25 +00:00
|
|
|
return browseDir(path, title);
|
2003-01-14 21:51:34 +00:00
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|