mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Learing to fly...
system_lyxdir is now a function too. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7396 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d75728c527
commit
eee532a581
@ -59,6 +59,7 @@
|
||||
#include "support/LAssert.h"
|
||||
#include "support/tostr.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/path_defines.h"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/signals/connection.hpp>
|
||||
@ -935,7 +936,7 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen)
|
||||
make_pair(string(_("Documents|#o#O")),
|
||||
string(lyxrc.document_path)),
|
||||
make_pair(string(_("Examples|#E#e")),
|
||||
string(AddPath(system_lyxdir, "examples"))));
|
||||
string(AddPath(system_lyxdir(), "examples"))));
|
||||
|
||||
FileDialog::Result result =
|
||||
fileDlg.open(initpath,
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "support/LOstream.h"
|
||||
#include "support/filetools.h" // FileSearch
|
||||
#include "support/path_defines.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
@ -27,7 +28,6 @@ using namespace lyx::support;
|
||||
using std::ostream;
|
||||
|
||||
// needed for the browser
|
||||
extern string system_lyxdir;
|
||||
extern string user_lyxdir;
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ ControlAboutlyx::ControlAboutlyx(Dialog & parent)
|
||||
|
||||
void ControlAboutlyx::getCredits(ostream & ss) const
|
||||
{
|
||||
string const name = FileSearch(system_lyxdir, "CREDITS");
|
||||
string const name = FileSearch(system_lyxdir(), "CREDITS");
|
||||
|
||||
bool found(!name.empty());
|
||||
|
||||
@ -85,7 +85,7 @@ string const ControlAboutlyx::getVersion() const
|
||||
<< lyx_release_date
|
||||
<< "\n"
|
||||
<< _("Library directory: ")
|
||||
<< MakeDisplayPath(system_lyxdir)
|
||||
<< MakeDisplayPath(system_lyxdir())
|
||||
<< "\n"
|
||||
<< _("User directory: ")
|
||||
<< MakeDisplayPath(user_lyxdir);
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "support/tostr.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/FileInfo.h"
|
||||
#include "support/path_defines.h"
|
||||
|
||||
using namespace lyx::support;
|
||||
|
||||
@ -38,7 +39,6 @@ using std::make_pair;
|
||||
using std::vector;
|
||||
|
||||
// We need these in the file browser.
|
||||
extern string system_lyxdir;
|
||||
extern string user_lyxdir;
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ string const ControlGraphics::Browse(string const & in_name)
|
||||
FileInfo fileInfo(clipdir);
|
||||
if (!(fileInfo.isOK() && fileInfo.isDir()))
|
||||
// No - bail out to system clipart directory
|
||||
clipdir = AddName (system_lyxdir, "clipart");
|
||||
clipdir = AddName (system_lyxdir(), "clipart");
|
||||
pair<string, string> dir1(_("Clipart|#C#c"), clipdir);
|
||||
pair<string, string> dir2(_("Documents|#o#O"), string(lyxrc.document_path));
|
||||
// Show the file browser dialog
|
||||
|
@ -21,12 +21,12 @@
|
||||
#include "helper_funcs.h"
|
||||
#include "gettext.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/path_defines.h"
|
||||
#include "frontends/Dialogs.h"
|
||||
#include "converter.h"
|
||||
#include "format.h"
|
||||
#include "debug.h"
|
||||
|
||||
extern string system_lyxdir;
|
||||
extern string user_lyxdir;
|
||||
extern BufferList bufferlist;
|
||||
|
||||
@ -62,7 +62,7 @@ void ControlPrefs::apply()
|
||||
|
||||
string const ControlPrefs::browsebind(string const & file)
|
||||
{
|
||||
string dir = AddName(system_lyxdir, "bind");
|
||||
string dir = AddName(system_lyxdir(), "bind");
|
||||
// FIXME: stupid name
|
||||
string name = _("System Bind|#S#s");
|
||||
pair<string,string> dir1(name, dir);
|
||||
@ -78,7 +78,7 @@ string const ControlPrefs::browsebind(string const & file)
|
||||
|
||||
string const ControlPrefs::browseUI(string const & file)
|
||||
{
|
||||
string dir = AddName(system_lyxdir, "ui");
|
||||
string dir = AddName(system_lyxdir(), "ui");
|
||||
// FIXME: stupid name
|
||||
string name = _("Sys UI|#S#s");
|
||||
pair<string,string> dir1(name, dir);
|
||||
@ -94,7 +94,7 @@ string const ControlPrefs::browseUI(string const & file)
|
||||
|
||||
string const ControlPrefs::browsekbmap(string const & file)
|
||||
{
|
||||
string const dir = AddName(system_lyxdir, "kbd");
|
||||
string const dir = AddName(system_lyxdir(), "kbd");
|
||||
string const name = _("Key maps|#K#k");
|
||||
pair<string, string> dir1(name, dir);
|
||||
|
||||
|
@ -64,7 +64,6 @@ using std::vector;
|
||||
using std::setw;
|
||||
using std::setfill;
|
||||
|
||||
extern string system_lyxdir;
|
||||
extern string user_lyxdir;
|
||||
|
||||
using namespace lyx::support;
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxalgo.h"
|
||||
#include "support/path.h"
|
||||
#include "support/path_defines.h"
|
||||
#include "support/tostr.h"
|
||||
#include "support/LAssert.h"
|
||||
#include "support/translator.h"
|
||||
@ -559,7 +560,7 @@ string const doSubstitution(InsetExternal::Params const & params,
|
||||
result = subst(result, "$$Basename", basename);
|
||||
result = subst(result, "$$FPath", filepath);
|
||||
result = subst(result, "$$Tempname", params.tempname);
|
||||
result = subst(result, "$$Sysdir", system_lyxdir);
|
||||
result = subst(result, "$$Sysdir", system_lyxdir());
|
||||
|
||||
// Handle the $$Contents(filename) syntax
|
||||
if (contains(result, "$$Contents(\"")) {
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "support/filetools.h"
|
||||
#include "support/forkedcall.h"
|
||||
#include "support/path.h"
|
||||
#include "support/path_defines.h"
|
||||
#include "support/systemcall.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
@ -456,7 +457,7 @@ void Reconfigure(BufferView * bv)
|
||||
Path p(user_lyxdir);
|
||||
Systemcall one;
|
||||
one.startscript(Systemcall::Wait,
|
||||
AddName(system_lyxdir, "configure"));
|
||||
AddName(system_lyxdir(), "configure"));
|
||||
p.pop();
|
||||
bv->owner()->message(_("Reloading configuration..."));
|
||||
lyxrc.read(LibFileSearch(string(), "lyxrc.defaults"));
|
||||
|
@ -64,7 +64,6 @@ extern void QuitLyX();
|
||||
|
||||
extern LyXServer * lyxserver;
|
||||
|
||||
extern string system_lyxdir;
|
||||
extern string user_lyxdir;
|
||||
|
||||
DebugStream lyxerr;
|
||||
@ -250,7 +249,7 @@ void LyX::init(bool gui)
|
||||
lyx_gui::use_gui = gui;
|
||||
|
||||
if (lyxrc.template_path.empty()) {
|
||||
lyxrc.template_path = AddPath(system_lyxdir, "templates");
|
||||
lyxrc.template_path = AddPath(system_lyxdir(), "templates");
|
||||
}
|
||||
|
||||
if (lyxrc.lastfiles.empty()) {
|
||||
@ -413,7 +412,7 @@ void LyX::deadKeyBindings(kb_keymap * kbmap)
|
||||
|
||||
void LyX::queryUserLyXDir(bool explicit_userdir)
|
||||
{
|
||||
string const configure_script = AddName(system_lyxdir, "configure");
|
||||
string const configure_script = AddName(system_lyxdir(), "configure");
|
||||
|
||||
// Does user directory exist?
|
||||
FileInfo fileInfo(user_lyxdir);
|
||||
@ -647,7 +646,7 @@ int parse_sysdir(string const & arg, string const &)
|
||||
lyxerr << _("Missing directory for -sysdir switch") << endl;
|
||||
exit(1);
|
||||
}
|
||||
system_lyxdir = arg;
|
||||
system_lyxdir(arg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,6 @@ class kb_keymap;
|
||||
|
||||
/// e.g. $HOME/.lyx/
|
||||
extern string user_lyxdir;
|
||||
/// e.g. /usr/share/lyx/
|
||||
extern string system_lyxdir;
|
||||
/// last files loaded
|
||||
extern boost::scoped_ptr<LastFiles> lastfiles;
|
||||
|
||||
|
@ -68,6 +68,7 @@
|
||||
#include "support/lstrings.h"
|
||||
#include "support/tostr.h"
|
||||
#include "support/path.h"
|
||||
#include "support/path_defines.h"
|
||||
#include "support/lyxfunctional.h"
|
||||
|
||||
#include <ctime>
|
||||
@ -1783,7 +1784,7 @@ void LyXFunc::open(string const & fname)
|
||||
make_pair(string(_("Documents|#o#O")),
|
||||
string(lyxrc.document_path)),
|
||||
make_pair(string(_("Examples|#E#e")),
|
||||
string(AddPath(system_lyxdir, "examples"))));
|
||||
string(AddPath(system_lyxdir(), "examples"))));
|
||||
|
||||
FileDialog::Result result =
|
||||
fileDlg.open(initpath,
|
||||
@ -1858,7 +1859,7 @@ void LyXFunc::doImport(string const & argument)
|
||||
make_pair(string(_("Documents|#o#O")),
|
||||
string(lyxrc.document_path)),
|
||||
make_pair(string(_("Examples|#E#e")),
|
||||
string(AddPath(system_lyxdir, "examples"))));
|
||||
string(AddPath(system_lyxdir(), "examples"))));
|
||||
|
||||
string const extension = "*." + formats.extension(format)
|
||||
+ "| " + formats.prettyName(format)
|
||||
|
@ -1,7 +1,7 @@
|
||||
2003-07-27 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* path_defines.{h,C.in} (build_lyxdir): is now a function, not a
|
||||
global var.
|
||||
* path_defines.{h,C.in} (build_lyxdir, system_lyxdir): are now
|
||||
functions, not global vars.
|
||||
|
||||
* Makefile.am: set build_lyxdir at make time.
|
||||
|
||||
|
@ -80,7 +80,6 @@ using std::ifstream;
|
||||
using std::vector;
|
||||
using std::getline;
|
||||
|
||||
extern string system_lyxdir;
|
||||
extern string user_lyxdir;
|
||||
|
||||
namespace lyx {
|
||||
@ -187,7 +186,7 @@ string const FileOpenSearch(string const & path, string const & name,
|
||||
path_element = os::slashify_path(path_element);
|
||||
if (!suffixIs(path_element, '/'))
|
||||
path_element+= '/';
|
||||
path_element = subst(path_element, "$$LyX", system_lyxdir);
|
||||
path_element = subst(path_element, "$$LyX", system_lyxdir());
|
||||
path_element = subst(path_element, "$$User", user_lyxdir);
|
||||
|
||||
real_file = FileSearch(path_element, name, ext);
|
||||
@ -302,7 +301,7 @@ string const LibFileSearch(string const & dir, string const & name,
|
||||
if (!fullname.empty())
|
||||
return fullname;
|
||||
|
||||
return FileSearch(AddPath(system_lyxdir, dir), name, ext);
|
||||
return FileSearch(AddPath(system_lyxdir(), dir), name, ext);
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,12 +27,14 @@
|
||||
using std::endl;
|
||||
|
||||
|
||||
string system_lyxdir;
|
||||
string user_lyxdir;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
// Store for the path to the lyx support files we're actually going to use.
|
||||
string system_lyxdir_;
|
||||
|
||||
/* The absolute path to the system-level lyx support files.
|
||||
* (Make-time value.)
|
||||
*/
|
||||
@ -75,6 +77,18 @@ string const & build_lyxdir()
|
||||
}
|
||||
|
||||
|
||||
string const & system_lyxdir()
|
||||
{
|
||||
return system_lyxdir_;
|
||||
}
|
||||
|
||||
|
||||
void system_lyxdir(string const & sld)
|
||||
{
|
||||
system_lyxdir_ = sld;
|
||||
}
|
||||
|
||||
|
||||
bool setLyxPaths()
|
||||
{
|
||||
//
|
||||
@ -112,10 +126,10 @@ bool setLyxPaths()
|
||||
// If no chkconfig.ltx file is found, a warning is given,
|
||||
// and the hardcoded lyx_dir is used.
|
||||
|
||||
// If we had a command line switch, system_lyxdir is already set
|
||||
// If we had a command line switch, system_lyxdir_ is already set
|
||||
string searchpath;
|
||||
if (!system_lyxdir.empty())
|
||||
searchpath = MakeAbsPath(system_lyxdir) + ';';
|
||||
if (!system_lyxdir_.empty())
|
||||
searchpath = MakeAbsPath(system_lyxdir_) + ';';
|
||||
|
||||
string const lyxdir = GetEnvPath("LYX_DIR_14x");
|
||||
|
||||
@ -173,26 +187,26 @@ bool setLyxPaths()
|
||||
|
||||
string const filename = "chkconfig.ltx";
|
||||
string const temp = FileOpenSearch(searchpath, filename, string());
|
||||
system_lyxdir = OnlyPath(temp);
|
||||
system_lyxdir_ = OnlyPath(temp);
|
||||
|
||||
// Reduce "path/../path" stuff out of system directory
|
||||
system_lyxdir = NormalizePath(system_lyxdir);
|
||||
system_lyxdir_ = NormalizePath(system_lyxdir_);
|
||||
|
||||
bool path_shown = false;
|
||||
|
||||
// Warn if environment variable is set, but unusable
|
||||
if (!lyxdir.empty()) {
|
||||
if (system_lyxdir != NormalizePath(lyxdir)) {
|
||||
if (system_lyxdir_ != NormalizePath(lyxdir)) {
|
||||
lyxerr <<_("LYX_DIR_14x environment variable no good.")
|
||||
<< '\n'
|
||||
<< _("System directory set to: ")
|
||||
<< system_lyxdir << endl;
|
||||
<< system_lyxdir_ << endl;
|
||||
path_shown = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Warn the user if we couldn't find "chkconfig.ltx"
|
||||
if (system_lyxdir == "./") {
|
||||
if (system_lyxdir_ == "./") {
|
||||
lyxerr <<_("LyX Warning! Couldn't determine system directory. ")
|
||||
<<_("Try the '-sysdir' command line parameter or ")
|
||||
<<_("set the environment variable LYX_DIR_14x to the "
|
||||
@ -210,13 +224,13 @@ bool setLyxPaths()
|
||||
} else {
|
||||
lyxerr << _("Expect problems.") << endl;
|
||||
}
|
||||
system_lyxdir = lyx_dir();
|
||||
system_lyxdir_ = lyx_dir();
|
||||
path_shown = true;
|
||||
}
|
||||
|
||||
if (!path_shown)
|
||||
lyxerr[Debug::INIT] << "System directory: '"
|
||||
<< system_lyxdir << '\'' << endl;
|
||||
<< system_lyxdir_ << '\'' << endl;
|
||||
|
||||
//
|
||||
// Determine user lyx-dir
|
||||
|
@ -22,6 +22,12 @@ namespace support {
|
||||
*/
|
||||
string const & build_lyxdir();
|
||||
|
||||
/// The absolute path to the lyx support files we're actually going to use.
|
||||
string const & system_lyxdir();
|
||||
|
||||
/// Set the absolute path to the lyx support files (from the command line).
|
||||
void system_lyxdir(string const &);
|
||||
|
||||
/** \returns true if the user lyx dir existed already and did not need
|
||||
* to be created afresh.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user