Fix theme loading on non-Windows.

This commit is contained in:
Jordan Woyak 2013-01-16 20:22:00 -06:00
parent 196c2867ad
commit 178b1b3862
2 changed files with 17 additions and 3 deletions

View File

@ -595,7 +595,13 @@ void CConfigMain::CreateGUIControls()
// theme selection
auto const theme_selection = new wxChoice(DisplayPage, wxID_ANY);
CFileSearch cfs(CFileSearch::XStringVector(1, "*"), CFileSearch::XStringVector(1, File::GetUserPath(D_THEMES_IDX)));
CFileSearch::XStringVector theme_dirs;
theme_dirs.push_back(File::GetUserPath(D_THEMES_IDX));
#if !defined(_WIN32)
theme_dirs.push_back(SHARED_USER_DIR THEMES_DIR);
#endif
CFileSearch cfs(CFileSearch::XStringVector(1, "*"), theme_dirs);
auto const& sv = cfs.GetFileNames();
std::for_each(sv.begin(), sv.end(), [theme_selection](const std::string& filename)
{
@ -603,7 +609,8 @@ void CConfigMain::CreateGUIControls()
SplitPath(filename, NULL, &name, &ext);
name += ext;
theme_selection->Append(name);
if (-1 == theme_selection->FindString(name))
theme_selection->Append(name);
if (SConfig::GetInstance().m_LocalCoreStartupParameter.theme_name == name)
theme_selection->SetSelection(theme_selection->GetCount() - 1);

View File

@ -495,7 +495,14 @@ void CFrame::RecreateToolbar()
void CFrame::InitBitmaps()
{
wxString dir(File::GetUserPath(D_THEMES_IDX) + SConfig::GetInstance().m_LocalCoreStartupParameter.theme_name + "/");
std::string theme(SConfig::GetInstance().m_LocalCoreStartupParameter.theme_name + "/");
std::string dir(File::GetUserPath(D_THEMES_IDX) + theme);
#if !defined(_WIN32)
// If theme does not exist in user's dir load from shared directory
if (!File::Exists(dir))
dir = SHARED_USER_DIR THEMES_DIR "/" + theme;
#endif
m_Bitmaps[Toolbar_FileOpen].LoadFile(dir + "open.png", wxBITMAP_TYPE_PNG);
m_Bitmaps[Toolbar_Refresh].LoadFile(dir + "refresh.png", wxBITMAP_TYPE_PNG);