]> git.lyx.org Git - features.git/commitdiff
Flying high and free...
authorAngus Leeming <leeming@lyx.org>
Sun, 27 Jul 2003 22:13:29 +0000 (22:13 +0000)
committerAngus Leeming <leeming@lyx.org>
Sun, 27 Jul 2003 22:13:29 +0000 (22:13 +0000)
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

17 files changed:
src/frontends/controllers/ControlAboutlyx.C
src/frontends/controllers/ControlDocument.C
src/frontends/controllers/ControlGraphics.C
src/frontends/controllers/ControlPrefs.C
src/frontends/controllers/tex_helpers.C
src/frontends/gnome/lyx_gui.C
src/frontends/xforms/FormPreferences.C
src/frontends/xforms/lyx_gui.C
src/insets/ExternalTemplate.C
src/lyx_cb.C
src/lyx_main.C
src/lyx_main.h
src/lyxfunc.C
src/support/ChangeLog
src/support/filetools.C
src/support/path_defines.C.in
src/support/path_defines.h

index 8506fcbcddd211b00228244b1c7b89f584cfb1c5..8f1c94382679392929e1d237f098733a90254b57 100644 (file)
@@ -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());
 }
index 43d81897e7241b1256d36e78942fea5f56f7c924..8e5ae244e17da37269cd7107a7fdc516d253016d 100644 (file)
@@ -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();
index 8d3e8e5213fdc1c8034650d0f51cc269a753aefe..ef667050d32822e59515de8653b7e17f47e0b09c 100644 (file)
@@ -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
index 32c0626cb4d50f2709e20c81d8fe93138bc7877a..b7ecec159274578ec015228898fb0a7b0f9ae762 100644 (file)
@@ -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);
index ad72098e1558f72551403b14bd2724489b23bc6b..500f20bd0c8fab1745abe9658fc9674fd2d3fba6 100644 (file)
@@ -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;
index ca1b6f82bc849d5c2156ac09fde1c01df83c95c0..4a1d3963d0c78732d3e209984f836b7a5ad57f63 100644 (file)
@@ -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;
index 852ce0e4de6b2b51a956ca9e02dbf1e326aa06e1..1859eadc7d342e1f20e3475c82843da85d3f843c 100644 (file)
@@ -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);
        }
 }
index 74733e0f60e6109b166031f602d3cd332d991fa2..c97b591b3da2626430e46a9914eff61fea94d269 100644 (file)
@@ -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;
index 45e2362ac7546216ff5dd2803ccf4f6d5a3b57e7..8c7a3c65aeb5c3312ecc976c63f1d2b19bdf532a 100644 (file)
@@ -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();
 }
index 933b050f648727851e991358af8314f8815d9c98..1b49bafece967b5478bbdd34e9879653aab738ce 100644 (file)
@@ -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"));
index 0a5ee65ceecc6dbb23f707e233f634656c0c53e6..f12367b635a9517618eebed035035155a94a32f7 100644 (file)
@@ -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;
 }
 
index 2451f400d0485bf9c16a29d963b32b0b86102c72..21e7b7d6f692d1076b5a8e5fc47619c97fceeded 100644 (file)
@@ -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;
 
index 3f4edb35af20dc0f7223238099d90e5343540ff6..7510fec113a573a6be998af5a83a3dcb1e3c5df4 100644 (file)
@@ -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;
index 4fc0ff41725d7395a98c6ead397032cb7eb0292a..f2e7616735cb77fcbde738b949ffe19444b65fc5 100644 (file)
@@ -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.
 
index 501ef61f7ae4440b510a200842cec486a7b91eca..b7f4eea293e0cdd9acb96967ea7cf6518222e861 100644 (file)
@@ -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");
        }
index 478757a71a64e549ae729522062c1e46ffba8ec5..ec5689b696894914c95cd907541360230b5b2407 100644 (file)
 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;
 }
 
index 61d43a3f2720758bb1e6d330c013443fdf3d2422..cfb5728bb11015a2b5cccfd6f8d13d57dfe7829e 100644 (file)
@@ -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.
  */