~ubuntu-branches/ubuntu/maverick/poedit/maverick

« back to all changes in this revision

Viewing changes to src/edapp.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2007-11-26 21:58:00 UTC
  • mfrom: (0.2.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071126215800-x4p16ysb2la158fu
Tags: 1.3.8~pre1-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
22
 *  DEALINGS IN THE SOFTWARE.
23
23
 *
24
 
 *  $Id: edapp.cpp 1175 2007-10-03 06:38:00Z vaclavslavik $
 
24
 *  $Id: edapp.cpp 1218 2007-11-24 16:34:07Z vaclavslavik $
25
25
 *
26
26
 *  Application class
27
27
 *
38
38
#include <wx/xrc/xmlres.h>
39
39
#include <wx/xrc/xh_all.h>
40
40
#include <wx/stdpaths.h>
 
41
#include <wx/filename.h>
 
42
#include <wx/sysopt.h>
 
43
 
 
44
#ifdef USE_SPARKLE
 
45
#include <Sparkle/SUCarbonAPI.h>
 
46
#endif // USE_SPARKLE
41
47
 
42
48
#if !wxUSE_UNICODE
43
49
    #error "Unicode build of wxWidgets is required by Poedit"
62
68
        home = wxString::FromAscii(POEDIT_PREFIX);
63
69
    return home;
64
70
#elif defined(__WXMSW__)
65
 
    wxString regkey;
66
 
    regkey.Printf(_T("%s/application_path"), GetAppVersion().c_str());
67
 
    wxString path = wxConfigBase::Get()->Read(regkey, wxEmptyString);
68
 
    if (!path)
69
 
    {
70
 
        wxLogError(_("Poedit installation is broken, cannot find application's home directory."));
71
 
        path = _T(".");
72
 
    }
73
 
    return path;
 
71
    wxString exedir;
 
72
    wxFileName::SplitPath(wxStandardPaths::Get().GetExecutablePath(),
 
73
                          &exedir, NULL, NULL);
 
74
    wxFileName fn = wxFileName::DirName(exedir);
 
75
    fn.RemoveLastDir();
 
76
    return fn.GetFullPath();
74
77
#else
75
78
#error "Unsupported platform!"
76
79
#endif
78
81
 
79
82
wxString PoeditApp::GetAppVersion() const
80
83
{
81
 
    wxString version(_T("1.3.7"));
 
84
    wxString version(_T("1.3.8"));
82
85
    return version;
83
86
}
84
87
 
94
97
    if (!wxApp::OnInit())
95
98
        return false;
96
99
 
 
100
#ifdef __WXMAC__
 
101
    wxSystemOptions::SetOption(wxMAC_TEXTCONTROL_USE_SPELL_CHECKER, 1);
 
102
#endif
 
103
 
97
104
#if defined(__UNIX__) && !defined(__WXMAC__)
98
105
    wxString home = wxGetHomeDir() + _T("/");
99
106
 
157
164
    m_locale.Init(GetUILanguage());
158
165
    
159
166
    m_locale.AddCatalog(_T("poedit"));
160
 
    m_locale.AddCatalog(_T("poedit-wxstd")); // for semistatic builds
161
167
 
162
168
    if (wxConfig::Get()->Read(_T("translator_name"), _T("nothing")) == _T("nothing"))
163
169
    {
185
191
    }
186
192
#endif // !__WXMAC__
187
193
 
 
194
#ifdef USE_SPARKLE
 
195
    SUSparkleInitializeForCarbon();
 
196
#endif // USE_SPARKLE
 
197
 
188
198
    return true;
189
199
}
190
200
 
299
309
#elif defined(__UNIX__)
300
310
        dbpath = wxGetHomeDir() + _T("/.poedit/tm");
301
311
#elif defined(__WXMSW__)
302
 
        // VS: this distinguishes between NT and Win9X systems -- the former
303
 
        //     has users' home directories while on the latter wxGetHomeDir
304
 
        //     will return path of the executable
305
 
        if (wxGetHomeDir().IsSameAs(GetAppPath() + _T("\\bin"), false))      
306
 
            dbpath = GetAppPath() + _T("\\share\\poedit\\tm");
307
 
        else
308
 
            dbpath = wxGetHomeDir() + _T("\\poedit_tm");
 
312
        dbpath = wxGetHomeDir() + _T("\\poedit_tm");
309
313
#endif
310
314
        cfg->Write(_T("TM/database_path"), dbpath);
311
315
    }