Skip to content

Commit

Permalink
Replaced all occurances of wxStandardPaths with clStandardPaths
Browse files Browse the repository at this point in the history
Fixed: SpellChecker: don't show dialog messages during CodeLite startup
  • Loading branch information
eranif committed Jul 31, 2015
1 parent 7958bca commit 7e4ee85
Show file tree
Hide file tree
Showing 18 changed files with 49 additions and 33 deletions.
3 changes: 2 additions & 1 deletion CMakePlugin/CMake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

// Declaration
#include "CMake.h"
#include "cl_standard_paths.h"

// C++
#include <utility>
Expand Down Expand Up @@ -101,7 +102,7 @@ static wxString CreateHtml(const wxArrayString& array)
CMake::CMake(const wxFileName& path)
: m_path(path)
, m_version("?")
, m_dbFileName(wxStandardPaths::Get().GetUserDataDir(), "cmake.db")
, m_dbFileName(clStandardPaths::Get().GetUserDataDir(), "cmake.db")
{
// Prepare database
PrepareDatabase();
Expand Down
2 changes: 1 addition & 1 deletion CMakePlugin/CMakePlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ CMakePlugin::CMakePlugin(IManager* manager)
m_shortName = "CMakePlugin";

// Create CMake configuration file
m_configuration.reset(new CMakeConfiguration(wxStandardPaths::Get().GetUserDataDir() +
m_configuration.reset(new CMakeConfiguration(clStandardPaths::Get().GetUserDataDir() +
wxFileName::GetPathSeparator() + "config/cmake.ini"));

// Create cmake application
Expand Down
4 changes: 2 additions & 2 deletions CodeFormatter/codeformatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ bool CodeFormatter::ClangFormatBuffer(const wxString& content,
int length)
{
// Write the content into a temporary file
wxFileName fn(wxStandardPaths::Get().GetTempDir(), "code-formatter-tmp.cpp");
wxFileName fn(clStandardPaths::Get().GetTempDir(), "code-formatter-tmp.cpp");
fn.SetExt(filename.GetExt());

wxFFile fp(fn.GetFullPath(), "w+b");
Expand Down Expand Up @@ -671,7 +671,7 @@ bool CodeFormatter::ClangPreviewFormat(const wxString& content, wxString& format
int startOffset, length, cursorPosition;
startOffset = length = cursorPosition = wxNOT_FOUND;

wxFileName fn(wxStandardPaths::Get().GetTempDir(), "code-formatter-tmp.cpp");
wxFileName fn(clStandardPaths::Get().GetTempDir(), "code-formatter-tmp.cpp");
wxFFile fp(fn.GetFullPath(), "w+b");
if(fp.IsOpened()) {
fp.Write(content, wxConvUTF8);
Expand Down
4 changes: 4 additions & 0 deletions CodeLite/cl_standard_paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,7 @@ wxString clStandardPaths::GetUserProjectTemplatesDir() const
fn.AppendDir("projects");
return fn.GetPath();
}

wxString clStandardPaths::GetExecutablePath() const { return wxStandardPaths::Get().GetExecutablePath(); }

wxString clStandardPaths::GetTempDir() const { return wxStandardPaths::Get().GetTempDir(); }
10 changes: 10 additions & 0 deletions CodeLite/cl_standard_paths.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class WXDLLIMPEXP_CL clStandardPaths
*/
void SetUserDataDir(const wxString& path);

/**
* @brief return the temp folder for this OS
*/
wxString GetTempDir() const;

/**
* @brief return the path to the plugins folder
*/
Expand Down Expand Up @@ -80,6 +85,11 @@ class WXDLLIMPEXP_CL clStandardPaths
*/
wxString GetBinaryFullPath(const wxString &toolname) const;

/**
* @brief get CodeLite executale path
*/
wxString GetExecutablePath() const;

/**
* @brief return the user lexers directory
*/
Expand Down
2 changes: 1 addition & 1 deletion Interfaces/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class IPlugin : public wxEvtHandler
wxString pluginsDir(PLUGINS_DIR, wxConvUTF8);
#else
#ifdef USE_POSIX_LAYOUT
wxString pluginsDir(wxStandardPaths::Get().GetDataDir() + wxT(PLUGINS_DIR));
wxString pluginsDir(clStandardPaths::Get().GetDataDir() + wxT(PLUGINS_DIR));
#else
wxString pluginsDir(m_mgr->GetInstallDirectory() + wxT("/plugins"));
#endif
Expand Down
12 changes: 6 additions & 6 deletions LiteEditor/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ bool CodeLiteApp::OnInit()
#endif

#ifdef USE_POSIX_LAYOUT
wxStandardPaths::Get().IgnoreAppSubDir("bin");
clStandardPaths::Get().IgnoreAppSubDir("bin");
#endif

// Init resources and add the PNG handler
Expand Down Expand Up @@ -485,7 +485,7 @@ bool CodeLiteApp::OnInit()
#else //__WXMSW__
if(homeDir.IsEmpty()) { // did we got a basedir from user?
#ifdef USE_POSIX_LAYOUT
homeDir = wxStandardPaths::Get().GetDataDir() + wxT(INSTALL_DIR);
homeDir = clStandardPaths::Get().GetDataDir() + wxT(INSTALL_DIR);
#else
homeDir = ::wxGetCwd();
#endif
Expand Down Expand Up @@ -640,7 +640,7 @@ bool CodeLiteApp::OnInit()

#elif defined(__WXMSW__)
#ifdef USE_POSIX_LAYOUT
wxLocale::AddCatalogLookupPathPrefix(wxStandardPaths::Get().GetDataDir() + wxT("/share/locale"));
wxLocale::AddCatalogLookupPathPrefix(clStandardPaths::Get().GetDataDir() + wxT("/share/locale"));
#else
wxLocale::AddCatalogLookupPathPrefix(ManagerST::Get()->GetInstallDir() + wxT("\\locale"));
#endif
Expand Down Expand Up @@ -673,7 +673,7 @@ bool CodeLiteApp::OnInit()
#endif
wxString oldpath;
wxGetEnv(wxT("PATH"), &oldpath);
wxFileName execfpath(wxStandardPaths::Get().GetExecutablePath());
wxFileName execfpath(clStandardPaths::Get().GetExecutablePath());
wxSetEnv(wxT("PATH"), oldpath + pathsep + execfpath.GetPath());
wxString newpath;
wxGetEnv(wxT("PATH"), &newpath);
Expand Down Expand Up @@ -928,10 +928,10 @@ void CodeLiteApp::DoCopyGdbPrinters()
printersInstallDir = wxFileName(wxString(INSTALL_DIR, wxConvUTF8), "gdb_printers");
#else
#ifdef USE_POSIX_LAYOUT
wxString commdir(wxStandardPaths::Get().GetDataDir() + wxT(INSTALL_DIR));
wxString commdir(clStandardPaths::Get().GetDataDir() + wxT(INSTALL_DIR));
printersInstallDir = wxFileName(commdir, "gdb_printers");
#else
printersInstallDir = wxFileName(wxStandardPaths::Get().GetDataDir(), "gdb_printers");
printersInstallDir = wxFileName(clStandardPaths::Get().GetDataDir(), "gdb_printers");
#endif
#endif

Expand Down
2 changes: 1 addition & 1 deletion LiteEditor/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3954,7 +3954,7 @@ void clMainFrame::CompleteInitialization()

// Load debuggers (*must* be after the plugins)
#ifdef USE_POSIX_LAYOUT
wxString plugdir(wxStandardPaths::Get().GetDataDir() + wxT(PLUGINS_DIR));
wxString plugdir(clStandardPaths::Get().GetDataDir() + wxT(PLUGINS_DIR));
DebuggerMgr::Get().Initialize(this, EnvironmentConfig::Instance(), plugdir);
#else
DebuggerMgr::Get().Initialize(this, EnvironmentConfig::Instance(), ManagerST::Get()->GetInstallDir());
Expand Down
10 changes: 5 additions & 5 deletions LiteEditor/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,7 @@ wxString Manager::GetProjectExecutionCommand(const wxString& projectName, wxStri
wd = bldConf->GetWorkingDirectory();
wd = ExpandVariables(wd, GetProject(projectName), clMainFrame::Get()->GetMainBook()->GetActiveEditor());

wxFileName fnCodeliteTerminal(wxStandardPaths::Get().GetExecutablePath());
wxFileName fnCodeliteTerminal(clStandardPaths::Get().GetExecutablePath());
fnCodeliteTerminal.SetFullName("codelite-terminal");

wxString title;
Expand Down Expand Up @@ -1537,7 +1537,7 @@ wxString Manager::GetProjectExecutionCommand(const wxString& projectName, wxStri
wxString command;
if(bldConf->GetPauseWhenExecEnds()) {
wxString ld_lib_path;
wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
wxFileName exePath(clStandardPaths::Get().GetExecutablePath());
wxFileName exeWrapper(exePath.GetPath(), wxT("codelite_exec"));

if(wxGetEnv(wxT("LD_LIBRARY_PATH"), &ld_lib_path) && ld_lib_path.IsEmpty() == false) {
Expand Down Expand Up @@ -3232,7 +3232,7 @@ void Manager::DoRestartCodeLite()
// the codelite_launcher application is located where the codelite executable is
// to properly shoutdown codelite. We first need to close the codelite_indexer process
restartCodeLiteCommand << wxT("\"") << m_codeliteLauncher.GetFullPath() << wxT("\" ") << wxT(" --name=\"")
<< wxStandardPaths::Get().GetExecutablePath() << wxT("\"");
<< clStandardPaths::Get().GetExecutablePath() << wxT("\"");

wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, wxID_EXIT);
clMainFrame::Get()->GetEventHandler()->ProcessEvent(event);
Expand All @@ -3241,7 +3241,7 @@ void Manager::DoRestartCodeLite()

#elif defined(__WXGTK__)
// The Shell is our friend
restartCodeLiteCommand << wxStandardPaths::Get().GetExecutablePath();
restartCodeLiteCommand << clStandardPaths::Get().GetExecutablePath();

// Restore the original working dir and any paramters
for(int i = 1; i < wxTheApp->argc; i++) {
Expand All @@ -3256,7 +3256,7 @@ void Manager::DoRestartCodeLite()
#else // OSX

// on OSX, we use the open command
wxFileName bundlePath(wxStandardPaths::Get().GetExecutablePath());
wxFileName bundlePath(clStandardPaths::Get().GetExecutablePath());
bundlePath.RemoveLastDir();
bundlePath.RemoveLastDir();
wxString bundlePathStr = bundlePath.GetPath();
Expand Down
2 changes: 1 addition & 1 deletion MemCheck/valgrindprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ wxString ValgrindMemcheckProcessor::GetExecutionCommand(const wxString & origina
m_outputLogFileName = wxFileName(clCxxWorkspaceST::Get()->GetPrivateFolder(),
"valgrind.memcheck.log.xml").GetFullPath();
else
m_outputLogFileName = wxFileName(wxStandardPaths::Get().GetTempDir(),
m_outputLogFileName = wxFileName(clStandardPaths::Get().GetTempDir(),
"valgrind.memcheck.log.xml").GetFullPath();
}

Expand Down
2 changes: 1 addition & 1 deletion Plugin/EclipseCXXThemeImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ wxFileName EclipseCXXThemeImporter::ToEclipseXML(const wxFileName& codeliteXml,
}
eclipseXML << "</colorTheme>\n";
wxString xmlFile;
xmlFile << wxStandardPaths::Get().GetTempDir() << "/"
xmlFile << clStandardPaths::Get().GetTempDir() << "/"
<< "eclipse-theme-" << id << ".xml";
FileUtils::WriteFileContent(xmlFile, eclipseXML);
return wxFileName(xmlFile);
Expand Down
4 changes: 2 additions & 2 deletions Plugin/bitmap_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ BitmapLoader::BitmapLoader()
fn = wxFileName(bitmapPath, zipname);
#else
#ifdef USE_POSIX_LAYOUT
wxString bitmapPath(wxStandardPaths::Get().GetDataDir() + wxT(INSTALL_DIR));
wxString bitmapPath(clStandardPaths::Get().GetDataDir() + wxT(INSTALL_DIR));
fn = wxFileName(bitmapPath, zipname);
#else
fn = wxFileName(wxStandardPaths::Get().GetDataDir(), zipname);
fn = wxFileName(clStandardPaths::Get().GetDataDir(), zipname);
#endif
#endif

Expand Down
6 changes: 3 additions & 3 deletions Plugin/globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,7 @@ IProcess* LaunchTerminal(const wxString& title, bool forDebugger, IProcessCallba

#else
wxString command;
wxFileName fnCodeliteTerminal(wxStandardPaths::Get().GetExecutablePath());
wxFileName fnCodeliteTerminal(clStandardPaths::Get().GetExecutablePath());

#if defined(__WXMAC__)
command << "/usr/bin/open \"" << fnCodeliteTerminal.GetPath(true) << "codelite-terminal.app\" --args ";
Expand Down Expand Up @@ -1764,7 +1764,7 @@ wxString MakeExecInShellCommand(const wxString& cmd, const wxString& wd, bool wa
wxString title(cmd);

OptionsConfigPtr opts = EditorConfigST::Get()->GetOptions();
wxFileName fnCodeliteTerminal(wxStandardPaths::Get().GetExecutablePath());
wxFileName fnCodeliteTerminal(clStandardPaths::Get().GetExecutablePath());
fnCodeliteTerminal.SetFullName("codelite-terminal");

// change directory to the working directory
Expand Down Expand Up @@ -1797,7 +1797,7 @@ wxString MakeExecInShellCommand(const wxString& cmd, const wxString& wd, bool wa
// build the command
wxString command;
wxString ld_lib_path;
wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
wxFileName exePath(clStandardPaths::Get().GetExecutablePath());
wxFileName exeWrapper(exePath.GetPath(), wxT("codelite_exec"));

if(wxGetEnv(wxT("LD_LIBRARY_PATH"), &ld_lib_path) && ld_lib_path.IsEmpty() == false) {
Expand Down
4 changes: 2 additions & 2 deletions Plugin/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ const wxString CLEAN_PROJECT_PREFIX = _("----------Cleaning project:[ ");
#ifdef __WXGTK__
#define TERMINAL_CMD \
wxString::Format(wxT("%s/codelite_xterm '$(TITLE)' '$(CMD)'"), \
wxFileName(wxStandardPaths::Get().GetExecutablePath()).GetPath().c_str())
wxFileName(clStandardPaths::Get().GetExecutablePath()).GetPath().c_str())
#elif defined(__WXMAC__)
#define TERMINAL_CMD wxString::Format(wxT("%s/OpenTerm '$(CMD)'"), wxStandardPaths::Get().GetDataDir().c_str())
#define TERMINAL_CMD wxString::Format(wxT("%s/OpenTerm '$(CMD)'"), clStandardPaths::Get().GetDataDir().c_str())
#else
const wxString TERMINAL_CMD = wxT("");
#endif
Expand Down
2 changes: 1 addition & 1 deletion Plugin/pipedprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void PipedProcess::Terminate()
{
#ifdef __WXGTK__
wxString cmd;
wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
wxFileName exePath(clStandardPaths::Get().GetExecutablePath());
wxFileName script(exePath.GetPath(), wxT("codelite_kill_children"));
cmd << wxT("/bin/sh -f ") << script.GetFullPath() << wxT(" ") << GetPid();
wxExecute(cmd, wxEXEC_ASYNC);
Expand Down
7 changes: 4 additions & 3 deletions SpellChecker/IHunSpell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#include <wx/log.h>

#ifndef WX_PRECOMP
#include "wx/wx.h"
Expand Down Expand Up @@ -91,21 +92,21 @@ bool IHunSpell::InitEngine()
wxFileName fna(aff);

if(!fna.FileExists()) {
::wxMessageBox(_("Could not find aff file!"));
wxLogMessage(_("Could not find aff file!"));
return false;
}
wxFileName fnd(dict);

if(!fnd.FileExists()) {
::wxMessageBox(_("Could not find dictionary file!"));
wxLogMessage(_("Could not find dictionary file!"));
return false;
}
// so far ok, init engine
m_pSpell = Hunspell_create(affBuffer, dicBuffer);

return true;

::wxMessageBox(_("Could not initialize spelling engine!"));
wxLogMessage(_("Could not initialize spelling engine!"));
return false;
}
// ------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion SpellChecker/spellcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void SpellCheck::Init()

if(m_pEngine) {
LoadSettings();
wxString userDictPath = wxStandardPaths::Get().GetUserDataDir();
wxString userDictPath = clStandardPaths::Get().GetUserDataDir();
userDictPath << wxFILE_SEP_PATH << wxT("spellcheck") << wxFILE_SEP_PATH;

if(!wxFileName::DirExists(userDictPath)) wxFileName::Mkdir(userDictPath);
Expand Down
4 changes: 2 additions & 2 deletions codelitephp/PHPParser/php_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ wxString GetResourceDirectory()
fn.AppendDir("resources");
#else
#ifdef USE_POSIX_LAYOUT
fn = wxFileName(wxStandardPaths::Get().GetDataDir() + wxT(PLUGINS_DIR));
fn = wxFileName(clStandardPaths::Get().GetDataDir() + wxT(PLUGINS_DIR));
#else
fn = wxFileName(wxStandardPaths::Get().GetExecutablePath());
fn = wxFileName(clStandardPaths::Get().GetExecutablePath());
fn.AppendDir("plugins");
#endif
fn.AppendDir("resources");
Expand Down

0 comments on commit 7e4ee85

Please sign in to comment.