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"
|
2002-11-15 02:41:54 +00:00
|
|
|
#include "ViewBase.h"
|
2002-11-13 02:22:48 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
#include "bufferlist.h"
|
2003-09-05 15:31:19 +00:00
|
|
|
#include "converter.h"
|
|
|
|
#include "format.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-07 21:25:37 +00:00
|
|
|
#include "lfuns.h"
|
2003-09-05 15:31:19 +00:00
|
|
|
|
|
|
|
#include "frontends/Dialogs.h"
|
|
|
|
#include "frontends/LyXView.h"
|
|
|
|
|
2002-11-15 02:41:54 +00:00
|
|
|
#include "support/filetools.h"
|
2003-07-27 21:04:02 +00:00
|
|
|
#include "support/path_defines.h"
|
2002-11-13 02:22:48 +00:00
|
|
|
|
2003-09-05 15:31:19 +00:00
|
|
|
#include <utility>
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
using lyx::support::AddName;
|
|
|
|
using lyx::support::system_lyxdir;
|
|
|
|
using lyx::support::user_lyxdir;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
2002-11-15 02:41:54 +00:00
|
|
|
using std::pair;
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2003-09-05 15:31:19 +00:00
|
|
|
|
|
|
|
extern BufferList bufferlist;
|
|
|
|
|
2002-11-13 02:22:48 +00:00
|
|
|
ControlPrefs::ControlPrefs(LyXView & lv, Dialogs & d)
|
|
|
|
: ControlDialogBI(lv, d)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2002-11-15 02:53:47 +00:00
|
|
|
void ControlPrefs::setParams()
|
2002-11-15 02:41:54 +00:00
|
|
|
{
|
|
|
|
rc_ = lyxrc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-13 02:22:48 +00:00
|
|
|
void ControlPrefs::apply()
|
|
|
|
{
|
2002-11-15 02:41:54 +00:00
|
|
|
view().apply();
|
2002-11-27 10:30:28 +00:00
|
|
|
lyxrc = rc_;
|
2002-11-13 02:22:48 +00:00
|
|
|
|
2003-02-08 21:48:54 +00:00
|
|
|
bufferlist.setCurrentAuthor(rc_.user_name, rc_.user_email);
|
|
|
|
|
2002-11-29 10:16:58 +00:00
|
|
|
// The Save button has been pressed
|
|
|
|
if (isClosing()) {
|
|
|
|
lv_.dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
|
|
|
|
}
|
2002-11-13 02:22:48 +00:00
|
|
|
}
|
2002-11-15 02:41:54 +00:00
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-15 02:41:54 +00:00
|
|
|
string const ControlPrefs::browsebind(string const & file)
|
|
|
|
{
|
2003-07-27 21:04:02 +00:00
|
|
|
string dir = AddName(system_lyxdir(), "bind");
|
2002-11-15 02:41:54 +00:00
|
|
|
// FIXME: stupid name
|
|
|
|
string name = _("System Bind|#S#s");
|
|
|
|
pair<string,string> dir1(name, dir);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2003-07-27 22:13:29 +00:00
|
|
|
dir = AddName(user_lyxdir(), "bind");
|
2002-11-15 02:41:54 +00:00
|
|
|
// FIXME: stupid name
|
|
|
|
name = _("User Bind|#U#u");
|
|
|
|
pair<string,string> dir2(name, dir);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2003-02-21 12:22:25 +00:00
|
|
|
return browseFile(file, _("Choose bind file"), "*.bind", false, dir1, dir2);
|
2002-11-15 02:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const ControlPrefs::browseUI(string const & file)
|
|
|
|
{
|
2003-07-27 21:04:02 +00:00
|
|
|
string dir = AddName(system_lyxdir(), "ui");
|
2002-11-15 02:41:54 +00:00
|
|
|
// FIXME: stupid name
|
|
|
|
string name = _("Sys UI|#S#s");
|
|
|
|
pair<string,string> dir1(name, dir);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2003-07-27 22:13:29 +00:00
|
|
|
dir = AddName(user_lyxdir(), "ui");
|
2002-11-15 02:41:54 +00:00
|
|
|
// FIXME: stupid name
|
|
|
|
name = _("User UI|#U#u");
|
|
|
|
pair<string,string> dir2(name, dir);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2003-02-21 12:22:25 +00:00
|
|
|
return browseFile(file, _("Choose UI file"), "*.ui", false, dir1, dir2);
|
2002-11-15 02:41:54 +00:00
|
|
|
}
|
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-15 02:41:54 +00:00
|
|
|
string const ControlPrefs::browsekbmap(string const & file)
|
|
|
|
{
|
2003-07-27 21:04:02 +00:00
|
|
|
string const dir = AddName(system_lyxdir(), "kbd");
|
2002-11-15 02:41:54 +00:00
|
|
|
string const name = _("Key maps|#K#k");
|
|
|
|
pair<string, string> dir1(name, dir);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2003-02-21 12:22:25 +00:00
|
|
|
return browseFile(file, _("Choose keyboard map"), "*.kmap", false, dir1);
|
2002-11-15 02:41:54 +00:00
|
|
|
}
|
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-15 02:41:54 +00:00
|
|
|
string const ControlPrefs::browsedict(string const & file)
|
|
|
|
{
|
2003-02-21 12:22:25 +00:00
|
|
|
return browseFile(file, _("Choose personal dictionary"), "*.ispell");
|
2002-11-15 02:41:54 +00:00
|
|
|
}
|
2002-11-27 10:30:28 +00:00
|
|
|
|
|
|
|
|
2002-11-15 02:41:54 +00:00
|
|
|
string const ControlPrefs::browse(string const & file, string const & title)
|
|
|
|
{
|
2003-02-21 12:22:25 +00:00
|
|
|
return browseFile(file, title, "*", true);
|
2002-11-15 02:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-14 21:51:34 +00:00
|
|
|
string const ControlPrefs::browsedir(string const & path, string const & title)
|
|
|
|
{
|
2003-02-21 12:22:25 +00:00
|
|
|
return browseDir(path, title);
|
2003-01-14 21:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-15 02:41:54 +00:00
|
|
|
void ControlPrefs::redrawGUI()
|
|
|
|
{
|
|
|
|
// we must be sure to get the new values first
|
|
|
|
lyxrc = rc_;
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-15 02:41:54 +00:00
|
|
|
lv_.getDialogs().redrawGUI();
|
|
|
|
}
|
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2003-09-18 11:48:11 +00:00
|
|
|
void ControlPrefs::setColor(LColor_color col, string const & hex)
|
2002-11-15 02:41:54 +00:00
|
|
|
{
|
2002-11-27 10:30:28 +00:00
|
|
|
string const s = lcolor.getLyXName(col) + ' ' + hex;
|
2002-11-15 02:41:54 +00:00
|
|
|
lv_.dispatch(FuncRequest(LFUN_SET_COLOR, s));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlPrefs::updateScreenFonts()
|
|
|
|
{
|
|
|
|
// we must be sure to get the new values first
|
|
|
|
lyxrc = rc_;
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-15 02:41:54 +00:00
|
|
|
lv_.dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
|
|
|
|
}
|
2002-11-27 10:30:28 +00:00
|
|
|
|
|
|
|
|
2002-11-15 02:41:54 +00:00
|
|
|
void ControlPrefs::setConverters(Converters const & conv)
|
2002-11-27 10:30:28 +00:00
|
|
|
{
|
2002-11-15 02:41:54 +00:00
|
|
|
converters = conv;
|
|
|
|
converters.update(formats);
|
|
|
|
converters.buildGraph();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlPrefs::setFormats(Formats const & form)
|
|
|
|
{
|
|
|
|
formats = form;
|
|
|
|
}
|