Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:

| This patch adds code for LyX/Mac to find its locale files correctly
| and changes the default user directory from .lyx to
| ~/Library/Preferences/LyX (for Qt/Mac too).
>
| Lars, this changes some of your code in message.C. Is it OK with you?

It might be....

I am not overly fond of the "inOSXbundle" stuff.


>
| JMarc
>
>
| Index: src/ChangeLog
| ===================================================================
| RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
| retrieving revision 1.1922
| diff -u -p -r1.1922 ChangeLog
| --- src/ChangeLog     1 Jun 2004 17:54:33 -0000       1.1922
| +++ src/ChangeLog     2 Jun 2004 13:39:55 -0000
| @@ -1,3 +1,13 @@
| +2004-05-10  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
| +
| +     * lyxrc.C: do not set user_email to a default value but use empty
| +     instead. The entry used to be translated, which does not work
| +     since at the point where lyxrc is constructed there is not
| +     translation service available
| +
| +     * messages.C (getLocaleDir): remove and use directly
| +     lyx_localedir() instead
| +
|  2004-06-01  Angus Leeming  <[EMAIL PROTECTED]>
|  
|       * output_linuxdoc.C (linuxdocParagraphs): Check that the paragraph
| Index: src/messages.C
| ===================================================================
| RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/messages.C,v
| retrieving revision 1.15
| diff -u -p -r1.15 messages.C
| --- src/messages.C    6 Oct 2003 15:42:29 -0000       1.15
| +++ src/messages.C    2 Jun 2004 13:39:56 -0000
| @@ -99,8 +84,6 @@ public:
|               //lyxerr << "Messages: language(" << l
|               //       << ") in dir(" << dir << ")" << std::endl;
|  
| -           bindtextdomain(PACKAGE, getLocaleDir().c_str());
| -           textdomain(PACKAGE);
|       }
|  
|       ~Pimpl() {}
| @@ -112,6 +95,8 @@ public:
|  
|               char * old = strdup(setlocale(LC_ALL, 0));
|               char * n = setlocale(LC_ALL, lang_.c_str());
| +             bindtextdomain(PACKAGE, lyx_localedir().c_str());
| +             textdomain(PACKAGE);

Why the move?

|               const char* msg = gettext(m.c_str());
|               setlocale(LC_ALL, old);
|               free(old);
| Index: src/support/ChangeLog
| ===================================================================
| RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/ChangeLog,v
| retrieving revision 1.254
| diff -u -p -r1.254 ChangeLog
| --- src/support/ChangeLog     27 May 2004 07:41:51 -0000      1.254
| +++ src/support/ChangeLog     2 Jun 2004 13:39:56 -0000
| @@ -1,3 +1,11 @@
| +2004-05-04  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
| +
| +     * path_defines.C.in (setLyxPaths): make sure that LyX/Mac can find
| +     its po files when moved around; set default user directory to
| +     ~/Library/Preferences/LyX/ for LyX/Mac.
| +     (lyx_localedir): return the value that may have been computed in
| +     setLyXPaths 
| +
|  2004-05-27  Kayvan Sylvan <[EMAIL PROTECTED]>
|       
|       * Makefile.am (libsupport_la_SOURCES): remove reference to
| Index: src/support/path_defines.C.in
| ===================================================================
| RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/path_defines.C.in,v
| retrieving revision 1.11
| diff -u -p -r1.11 path_defines.C.in
| --- src/support/path_defines.C.in     27 Apr 2004 12:48:45 -0000      1.11
| +++ src/support/path_defines.C.in     2 Jun 2004 13:39:56 -0000
| @@ -40,6 +40,8 @@ string build_lyxdir_;
|  // Store for the path to the user-level support files.
|  string user_lyxdir_;
|  
| +// Store for the path to the locale directory.
| +string localedir_;
|  
|  /* The absolute path to the system-level lyx support files.
|   * (Make-time value.)
| @@ -73,7 +75,10 @@ string const & top_srcdir()
|  string const & lyx_localedir()
|  {
|       static string const ll = "%LOCALEDIR%";
| -     return ll;
| +     if (localedir_.empty())
| +             return ll;
| +     else
| +             return localedir_;
|  }

Is the else needed?


|  
|  
| @@ -287,6 +292,15 @@ bool setLyxPaths()
|               lyxerr[Debug::INIT] << "System directory: '"
|                                   << system_lyxdir_ << '\'' << endl;
|  
| +     // This is true when we are running from a Mac OS X bundle
| +     // (for LyX/Mac)
| +     bool const inOSXBundle = 
| +             system_lyxdir_ == NormalizePath(AddPath(binpath, "../Resources/")
| +                                             + OnlyFilename(binname));
| +     if (inOSXBundle)
| +             lyxerr[Debug::INIT] << "Running from LyX/Mac bundle."
| +                                 << endl;

This should not be runtime...
We know when we compile if we are in OSX or not.

| +
|       //
|       // Set PATH for LyX/Mac
|       // LyX/Mac is a relocatable application bundle; here we add to
| @@ -295,14 +309,32 @@ bool setLyxPaths()
|       // needs to run latex, previewers, etc.
|       //
|  
| -     if (system_lyxdir_ == NormalizePath(AddPath(binpath, "../Resources/")
| -                                         + OnlyFilename(binname))) {
| -       const string newpath = GetEnv("PATH") + ":" + binpath
| -         + ":/sw/bin:/usr/local/bin"
| -         + ":/usr/local/teTeX/bin/powerpc-apple-darwin-current";
| -       lyx::support::putenv("PATH", newpath);
| -       lyxerr[Debug::INIT] << "Running from LyX/Mac bundle. "
| -         "Setting PATH to: " << GetEnv("PATH") << endl;
| +     if (inOSXBundle) {
| +             const string newpath = GetEnv("PATH") + ":" + binpath
| +                     + ":/sw/bin:/usr/local/bin"
| +                     + ":/usr/local/teTeX/bin/powerpc-apple-darwin-current";
| +             lyx::support::putenv("PATH", newpath);
| +             lyxerr[Debug::INIT] << "LyX/Mac: setting PATH to: " 
| +                                 << GetEnv("PATH") << endl;
| +     }

  os::setupEnvironment();

| +
| +     // 
| +     // Determine locale directory
| +     //
| +     if (!GetEnv("LYX_LOCALEDIR").empty()) {
| +             localedir_ = GetEnv("LYX_LOCALEDIR");
| +             lyxerr[Debug::INIT] << "LYX_LOCALEDIR=" << localedir_ << endl;
| +     } else if (inOSXBundle) {
| +             string const maybe_localedir = 
| +                     NormalizePath(AddPath(system_lyxdir_, "../locale")); 
| +             FileInfo fi(maybe_localedir);
| +             if (fi.isOK() && fi.isDir()) {
| +                     lyxerr[Debug::INIT] 
| +                             << "LyX/Mac: setting locale directory to "
| +                             << maybe_localedir << endl;
| +                     localedir_ = maybe_localedir;
| +             }

  } else {
    localedir_ = os::guessLocaleDir();
  }

Btw is the maybe really a maybe? (the maybe will be used always)

shouldn't this be fixed by LOCALEDIR in the first place, in the
configure system?

|       }
|  
|       //
| @@ -323,9 +355,13 @@ bool setLyxPaths()
|  
|               // default behaviour
|               if (user_lyxdir_.empty())
| -                     user_lyxdir_ = AddPath(GetEnvPath("HOME"),
| -                                            string(".") + PACKAGE);
| -                     explicit_userdir = false;
| +                     if (inOSXBundle)
| +                             user_lyxdir_ = AddPath(GetEnvPath("HOME"),
| +                                                    "Library/Preferences/LyX");
| +                     else
| +                             user_lyxdir_ = AddPath(GetEnvPath("HOME"),
| +                                                    string(".") + PACKAGE);
| +             explicit_userdir = false;

  use_lyxdir_ = os::preferencesDir();


-- 
        Lgb

Reply via email to