using std::ostream;
-// needed for the browser
-extern string user_lyxdir;
-
ControlAboutlyx::ControlAboutlyx(Dialog & parent)
: Dialog::Controller(parent)
<< MakeDisplayPath(system_lyxdir())
<< "\n"
<< _("User directory: ")
- << MakeDisplayPath(user_lyxdir);
+ << MakeDisplayPath(user_lyxdir());
return STRCONV(ss.str());
}
#include "support/LAssert.h"
#include "support/lstrings.h"
#include "support/filetools.h"
+#include "support/path_defines.h"
using namespace lyx::support;
lv_.buffer()->params.preamble = bp_->preamble;
- string const fname = AddName(AddPath(user_lyxdir, "templates/"),
+ string const fname = AddName(AddPath(user_lyxdir(), "templates/"),
"defaults.lyx");
Buffer defaults(fname);
defaults.params = params();
using std::make_pair;
using std::vector;
-// We need these in the file browser.
-extern string user_lyxdir;
-
ControlGraphics::ControlGraphics(Dialog & parent)
: Dialog::Controller(parent)
string const title = _("Select graphics file");
// Does user clipart directory exist?
- string clipdir = AddName (user_lyxdir, "clipart");
+ string clipdir = AddName (user_lyxdir(), "clipart");
FileInfo fileInfo(clipdir);
if (!(fileInfo.isOK() && fileInfo.isDir()))
// No - bail out to system clipart directory
#include "format.h"
#include "debug.h"
-extern string user_lyxdir;
extern BufferList bufferlist;
using namespace lyx::support;
string name = _("System Bind|#S#s");
pair<string,string> dir1(name, dir);
- dir = AddName(user_lyxdir, "bind");
+ dir = AddName(user_lyxdir(), "bind");
// FIXME: stupid name
name = _("User Bind|#U#u");
pair<string,string> dir2(name, dir);
string name = _("Sys UI|#S#s");
pair<string,string> dir1(name, dir);
- dir = AddName(user_lyxdir, "ui");
+ dir = AddName(user_lyxdir(), "ui");
// FIXME: stupid name
name = _("User UI|#U#u");
pair<string,string> dir2(name, dir);
#include "support/systemcall.h"
#include "support/path.h"
#include "support/lyxalgo.h"
+#include "support/path_defines.h"
#include <boost/cregex.hpp>
#include <vector>
using std::sort;
using std::unique;
-extern string user_lyxdir; // home of *Files.lst
-
// build filelists of all availabe bst/cls/sty-files. done through
// kpsewhich and an external script, saved in *Files.lst
void rescanTexStyles()
{
// Run rescan in user lyx directory
- Path p(user_lyxdir);
+ Path p(user_lyxdir());
Systemcall one;
one.startscript(Systemcall::Wait,
LibFileSearch("scripts", "TeXFiles.sh"));
void texhash()
{
// Run texhash in user lyx directory
- Path p(user_lyxdir);
+ Path p(user_lyxdir());
//path to texhash through system
Systemcall one;
#include "support/lyxlib.h"
#include "support/os.h"
#include "support/filetools.h"
+#include "support/path_defines.h"
#include "debug.h"
#include "gettext.h"
void lyx_gui::parse_lyxrc()
{
- XformsColor::read(AddName(user_lyxdir, "preferences.xform"));
+ XformsColor::read(AddName(user_lyxdir(), "preferences.xform"));
if (lyxrc.popup_font_encoding.empty())
lyxrc.popup_font_encoding = lyxrc.font_norm;
#include "support/lyxfunctional.h"
#include "support/lyxmanip.h"
#include "support/tostr.h"
+#include "support/path_defines.h"
#include "support/filetools.h"
#include "support/LAssert.h"
using std::setw;
using std::setfill;
-extern string user_lyxdir;
-
using namespace lyx::support;
namespace {
// The "Save" button has been pressed.
if (controller().isClosing() && colors_.modifiedXformsPrefs) {
string const filename =
- AddName(user_lyxdir, "preferences.xform");
+ AddName(user_lyxdir(), "preferences.xform");
colors_.modifiedXformsPrefs = !XformsColor::write(filename);
}
}
#include "support/lyxlib.h"
#include "support/os.h"
#include "support/filetools.h"
+#include "support/path_defines.h"
#include "debug.h"
#include "gettext.h"
void parse_lyxrc()
{
- XformsColor::read(AddName(user_lyxdir, "preferences.xform"));
+ XformsColor::read(AddName(user_lyxdir(), "preferences.xform"));
if (lyxrc.popup_font_encoding.empty())
lyxrc.popup_font_encoding = lyxrc.font_norm;
#include "support/path.h"
#include "support/LAssert.h"
#include "support/filetools.h"
+#include "support/path_defines.h"
using namespace lyx::support;
using std::ostream;
using std::for_each;
-extern string user_lyxdir;
-
-
// We have to have dummy default commands for security reasons!
ExternalTemplate::ExternalTemplate()
ExternalTemplateManager::ExternalTemplateManager()
{
// gimp gnuchess gnuplot ical netscape tetris xpaint
- readTemplates(user_lyxdir);
+ readTemplates(user_lyxdir());
if (lyxerr.debugging())
dumpTemplates();
}
bv->owner()->message(_("Running configure..."));
// Run configure in user lyx directory
- Path p(user_lyxdir);
+ Path p(user_lyxdir());
Systemcall one;
one.startscript(Systemcall::Wait,
AddName(system_lyxdir(), "configure"));
extern LyXServer * lyxserver;
-extern string user_lyxdir;
-
DebugStream lyxerr;
boost::scoped_ptr<LastFiles> lastfiles;
}
if (lyxrc.lastfiles.empty()) {
- lyxrc.lastfiles = AddName(user_lyxdir, "lastfiles");
+ lyxrc.lastfiles = AddName(user_lyxdir(), "lastfiles");
}
if (lyxrc.roman_font_name.empty())
string const configure_script = AddName(system_lyxdir(), "configure");
// Does user directory exist?
- FileInfo fileInfo(user_lyxdir);
+ FileInfo fileInfo(user_lyxdir());
if (fileInfo.isOK() && fileInfo.isDir()) {
first_start = false;
FileInfo script(configure_script);
- FileInfo defaults(AddName(user_lyxdir, "lyxrc.defaults"));
+ FileInfo defaults(AddName(user_lyxdir(), "lyxrc.defaults"));
if (defaults.isOK() && script.isOK()
&& defaults.getModificationTime() < script.getModificationTime()) {
lyxerr << _("LyX: reconfiguring user directory")
<< endl;
- Path p(user_lyxdir);
+ Path p(user_lyxdir());
::system(configure_script.c_str());
lyxerr << "LyX: " << _("Done!") << endl;
}
first_start = !explicit_userdir;
lyxerr << bformat(_("LyX: Creating directory %1$s"
- " and running configure..."), user_lyxdir) << endl;
+ " and running configure..."), user_lyxdir()) << endl;
- if (!createDirectory(user_lyxdir, 0755)) {
+ if (!createDirectory(user_lyxdir(), 0755)) {
// Failed, let's use $HOME instead.
- user_lyxdir = GetEnvPath("HOME");
+ user_lyxdir(GetEnvPath("HOME"));
lyxerr << bformat(_("Failed. Will use %1$s instead."),
- user_lyxdir) << endl;
+ user_lyxdir()) << endl;
return;
}
// Run configure in user lyx directory
- Path p(user_lyxdir);
+ Path p(user_lyxdir());
::system(configure_script.c_str());
lyxerr << "LyX: " << _("Done!") << endl;
}
lyxerr << _("Missing directory for -userdir switch") << endl;
exit(1);
}
- user_lyxdir = arg;
+ user_lyxdir(arg);
return 1;
}
class kb_keymap;
-/// e.g. $HOME/.lyx/
-extern string user_lyxdir;
/// last files loaded
extern boost::scoped_ptr<LastFiles> lastfiles;
case LFUN_SAVEPREFERENCES:
{
- Path p(user_lyxdir);
+ Path p(user_lyxdir());
lyxrc.write("preferences");
}
break;
2003-07-27 Angus Leeming <leeming@lyx.org>
- * path_defines.{h,C.in} (build_lyxdir, system_lyxdir): are now
- functions, not global vars.
+ * path_defines.{h,C.in} (build_lyxdir, system_lyxdir,
+ user_lyxdir): are now functions, not global vars.
* Makefile.am: set build_lyxdir at make time.
using std::vector;
using std::getline;
-extern string user_lyxdir;
namespace lyx {
namespace support {
if (!suffixIs(path_element, '/'))
path_element+= '/';
path_element = subst(path_element, "$$LyX", system_lyxdir());
- path_element = subst(path_element, "$$User", user_lyxdir);
+ path_element = subst(path_element, "$$User", user_lyxdir());
real_file = FileSearch(path_element, name, ext);
string const LibFileSearch(string const & dir, string const & name,
string const & ext)
{
- string fullname = FileSearch(AddPath(user_lyxdir, dir), name, ext);
+ string fullname = FileSearch(AddPath(user_lyxdir(), dir), name, ext);
if (!fullname.empty())
return fullname;
int destroyDir(string const & tmpdir)
{
#ifdef __EMX__
- Path p(user_lyxdir);
+ Path p(user_lyxdir());
#endif
if (DeleteAllFilesInDir(tmpdir))
return -1;
if ((!deflt.empty()) && (deflt != "/tmp")) {
if (mkdir(deflt, 0777)) {
#ifdef __EMX__
- Path p(user_lyxdir);
+ Path p(user_lyxdir());
#endif
return CreateTmpDir(deflt, "lyx_tmpdir");
} else
return deflt;
} else {
#ifdef __EMX__
- Path p(user_lyxdir);
+ Path p(user_lyxdir());
#endif
return CreateTmpDir("/tmp", "lyx_tmpdir");
}
using std::endl;
-string user_lyxdir;
-
-
namespace {
// Store for the path to the lyx support files we're actually going to use.
string system_lyxdir_;
+// Store for the path to the user-level support files.
+string user_lyxdir_;
+
+
/* The absolute path to the system-level lyx support files.
* (Make-time value.)
*/
}
+string const & user_lyxdir()
+{
+ return user_lyxdir_;
+}
+
+
+void user_lyxdir(string const & uld)
+{
+ user_lyxdir_ = uld;
+}
+
+
bool setLyxPaths()
{
//
// 2) LYX_USERDIR_14x environment variable
// 3) $HOME/.<name of binary>
- // If we had a command line switch, user_lyxdir is already set
+ // If we had a command line switch, user_lyxdir_ is already set
bool explicit_userdir = true;
- if (user_lyxdir.empty()) {
+ if (user_lyxdir_.empty()) {
// LYX_USERDIR_14x environment variable
- user_lyxdir = GetEnvPath("LYX_USERDIR_14x");
+ user_lyxdir_ = GetEnvPath("LYX_USERDIR_14x");
// default behaviour
- if (user_lyxdir.empty())
- user_lyxdir = AddPath(GetEnvPath("HOME"),
- string(".") + PACKAGE);
+ if (user_lyxdir_.empty())
+ user_lyxdir_ = AddPath(GetEnvPath("HOME"),
+ string(".") + PACKAGE);
explicit_userdir = false;
}
lyxerr[Debug::INIT] << "User LyX directory: '"
- << user_lyxdir << '\'' << endl;
+ << user_lyxdir_ << '\'' << endl;
return explicit_userdir;
}
/// Set the absolute path to the lyx support files (from the command line).
void system_lyxdir(string const &);
+/// The absolute path to the user-level lyx support files.
+string const & user_lyxdir();
+
+/// Set the absolute path to the user-level lyx support files.
+void user_lyxdir(string const &);
+
/** \returns true if the user lyx dir existed already and did not need
* to be created afresh.
*/