mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
Flying high and free...
The user_lyxdir is also now a function. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7399 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b6f6469040
commit
cd16abc0fd
@ -27,9 +27,6 @@ using namespace lyx::support;
|
||||
|
||||
using std::ostream;
|
||||
|
||||
// needed for the browser
|
||||
extern string user_lyxdir;
|
||||
|
||||
|
||||
ControlAboutlyx::ControlAboutlyx(Dialog & parent)
|
||||
: Dialog::Controller(parent)
|
||||
@ -88,7 +85,7 @@ string const ControlAboutlyx::getVersion() const
|
||||
<< MakeDisplayPath(system_lyxdir())
|
||||
<< "\n"
|
||||
<< _("User directory: ")
|
||||
<< MakeDisplayPath(user_lyxdir);
|
||||
<< MakeDisplayPath(user_lyxdir());
|
||||
|
||||
return STRCONV(ss.str());
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "support/LAssert.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/path_defines.h"
|
||||
|
||||
using namespace lyx::support;
|
||||
|
||||
@ -161,7 +162,7 @@ void ControlDocument::saveAsDefault()
|
||||
|
||||
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();
|
||||
|
@ -38,9 +38,6 @@ using std::pair;
|
||||
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)
|
||||
@ -76,7 +73,7 @@ string const ControlGraphics::Browse(string const & in_name)
|
||||
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
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include "format.h"
|
||||
#include "debug.h"
|
||||
|
||||
extern string user_lyxdir;
|
||||
extern BufferList bufferlist;
|
||||
|
||||
using namespace lyx::support;
|
||||
@ -67,7 +66,7 @@ string const ControlPrefs::browsebind(string const & file)
|
||||
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);
|
||||
@ -83,7 +82,7 @@ string const ControlPrefs::browseUI(string const & file)
|
||||
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);
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "support/systemcall.h"
|
||||
#include "support/path.h"
|
||||
#include "support/lyxalgo.h"
|
||||
#include "support/path_defines.h"
|
||||
|
||||
#include <boost/cregex.hpp>
|
||||
#include <vector>
|
||||
@ -33,15 +34,13 @@ using std::endl;
|
||||
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"));
|
||||
@ -51,7 +50,7 @@ void rescanTexStyles()
|
||||
void texhash()
|
||||
{
|
||||
// Run texhash in user lyx directory
|
||||
Path p(user_lyxdir);
|
||||
Path p(user_lyxdir());
|
||||
|
||||
//path to texhash through system
|
||||
Systemcall one;
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/os.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/path_defines.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "gettext.h"
|
||||
@ -182,7 +183,7 @@ void lyx_gui::parse_init(int & argc, char * argv[])
|
||||
|
||||
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;
|
||||
|
@ -40,6 +40,7 @@
|
||||
#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"
|
||||
|
||||
@ -64,8 +65,6 @@ using std::vector;
|
||||
using std::setw;
|
||||
using std::setfill;
|
||||
|
||||
extern string user_lyxdir;
|
||||
|
||||
using namespace lyx::support;
|
||||
|
||||
namespace {
|
||||
@ -330,7 +329,7 @@ void FormPreferences::apply()
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/os.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/path_defines.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "gettext.h"
|
||||
@ -187,7 +188,7 @@ void parse_init(int & argc, char * argv[])
|
||||
|
||||
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;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "support/path.h"
|
||||
#include "support/LAssert.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/path_defines.h"
|
||||
|
||||
using namespace lyx::support;
|
||||
|
||||
@ -27,9 +28,6 @@ using std::endl;
|
||||
using std::ostream;
|
||||
using std::for_each;
|
||||
|
||||
extern string user_lyxdir;
|
||||
|
||||
|
||||
// We have to have dummy default commands for security reasons!
|
||||
|
||||
ExternalTemplate::ExternalTemplate()
|
||||
@ -44,7 +42,7 @@ ExternalTemplate::FormatTemplate::FormatTemplate()
|
||||
ExternalTemplateManager::ExternalTemplateManager()
|
||||
{
|
||||
// gimp gnuchess gnuplot ical netscape tetris xpaint
|
||||
readTemplates(user_lyxdir);
|
||||
readTemplates(user_lyxdir());
|
||||
if (lyxerr.debugging())
|
||||
dumpTemplates();
|
||||
}
|
||||
|
@ -454,7 +454,7 @@ void Reconfigure(BufferView * bv)
|
||||
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"));
|
||||
|
@ -64,8 +64,6 @@ extern void QuitLyX();
|
||||
|
||||
extern LyXServer * lyxserver;
|
||||
|
||||
extern string user_lyxdir;
|
||||
|
||||
DebugStream lyxerr;
|
||||
|
||||
boost::scoped_ptr<LastFiles> lastfiles;
|
||||
@ -253,7 +251,7 @@ void LyX::init(bool gui)
|
||||
}
|
||||
|
||||
if (lyxrc.lastfiles.empty()) {
|
||||
lyxrc.lastfiles = AddName(user_lyxdir, "lastfiles");
|
||||
lyxrc.lastfiles = AddName(user_lyxdir(), "lastfiles");
|
||||
}
|
||||
|
||||
if (lyxrc.roman_font_name.empty())
|
||||
@ -415,16 +413,16 @@ void LyX::queryUserLyXDir(bool explicit_userdir)
|
||||
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;
|
||||
}
|
||||
@ -434,18 +432,18 @@ void LyX::queryUserLyXDir(bool explicit_userdir)
|
||||
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;
|
||||
}
|
||||
@ -656,7 +654,7 @@ int parse_userdir(string const & arg, string const &)
|
||||
lyxerr << _("Missing directory for -userdir switch") << endl;
|
||||
exit(1);
|
||||
}
|
||||
user_lyxdir = arg;
|
||||
user_lyxdir(arg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,6 @@ class Buffer;
|
||||
class kb_keymap;
|
||||
|
||||
|
||||
/// e.g. $HOME/.lyx/
|
||||
extern string user_lyxdir;
|
||||
/// last files loaded
|
||||
extern boost::scoped_ptr<LastFiles> lastfiles;
|
||||
|
||||
|
@ -1538,7 +1538,7 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
|
||||
|
||||
case LFUN_SAVEPREFERENCES:
|
||||
{
|
||||
Path p(user_lyxdir);
|
||||
Path p(user_lyxdir());
|
||||
lyxrc.write("preferences");
|
||||
}
|
||||
break;
|
||||
|
@ -1,7 +1,7 @@
|
||||
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.
|
||||
|
||||
|
@ -80,7 +80,6 @@ using std::ifstream;
|
||||
using std::vector;
|
||||
using std::getline;
|
||||
|
||||
extern string user_lyxdir;
|
||||
|
||||
namespace lyx {
|
||||
namespace support {
|
||||
@ -187,7 +186,7 @@ string const FileOpenSearch(string const & path, string const & name,
|
||||
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);
|
||||
|
||||
@ -292,7 +291,7 @@ string const FileSearch(string const & path, string const & name,
|
||||
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;
|
||||
|
||||
@ -465,7 +464,7 @@ string const CreateTmpDir(string const & tempdir, string const & mask)
|
||||
int destroyDir(string const & tmpdir)
|
||||
{
|
||||
#ifdef __EMX__
|
||||
Path p(user_lyxdir);
|
||||
Path p(user_lyxdir());
|
||||
#endif
|
||||
if (DeleteAllFilesInDir(tmpdir))
|
||||
return -1;
|
||||
@ -497,14 +496,14 @@ string const CreateLyXTmpDir(string const & deflt)
|
||||
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");
|
||||
}
|
||||
|
@ -27,14 +27,15 @@
|
||||
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.)
|
||||
*/
|
||||
@ -89,6 +90,18 @@ void system_lyxdir(string const & sld)
|
||||
}
|
||||
|
||||
|
||||
string const & user_lyxdir()
|
||||
{
|
||||
return user_lyxdir_;
|
||||
}
|
||||
|
||||
|
||||
void user_lyxdir(string const & uld)
|
||||
{
|
||||
user_lyxdir_ = uld;
|
||||
}
|
||||
|
||||
|
||||
bool setLyxPaths()
|
||||
{
|
||||
//
|
||||
@ -241,22 +254,22 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,12 @@ string const & system_lyxdir();
|
||||
/// 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.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user