Slightly less hacky way to get the KDE icon theme name.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25814 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -803,14 +803,21 @@ void wxMimeTypesManagerImpl::LoadGnomeMimeFilesFromDir(
|
||||
void wxMimeTypesManagerImpl::GetGnomeMimeInfo(const wxString& sExtraDir)
|
||||
{
|
||||
wxArrayString dirs;
|
||||
dirs.Add(wxT("/opt/gnome/share"));
|
||||
|
||||
wxString gnomedir = wxGetenv( wxT("GNOMEDIR") );;
|
||||
if (!gnomedir.empty())
|
||||
{
|
||||
gnomedir << wxT("/share");
|
||||
dirs.Add( gnomedir );
|
||||
}
|
||||
|
||||
dirs.Add(wxT("/usr/share"));
|
||||
dirs.Add(wxT("/usr/local/share"));
|
||||
|
||||
wxString gnomedir;
|
||||
wxGetHomeDir( &gnomedir );
|
||||
gnomedir += wxT("/.gnome");
|
||||
gnomedir = wxGetHomeDir();
|
||||
gnomedir << wxT("/.gnome");
|
||||
dirs.Add( gnomedir );
|
||||
|
||||
if (!sExtraDir.empty()) dirs.Add( sExtraDir );
|
||||
|
||||
size_t nDirs = dirs.GetCount();
|
||||
@@ -839,12 +846,13 @@ void wxMimeTypesManagerImpl::GetGnomeMimeInfo(const wxString& sExtraDir)
|
||||
// for now write to .kdelnk but should eventually do .desktop instead (in preference??)
|
||||
|
||||
bool wxMimeTypesManagerImpl::CheckKDEDirsExist ( const wxString &sOK, const wxString &sTest )
|
||||
|
||||
{
|
||||
if (sTest.empty())
|
||||
{
|
||||
if (wxDir::Exists(sOK)) return TRUE;
|
||||
else return FALSE;
|
||||
if (wxDir::Exists(sOK))
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -959,8 +967,6 @@ bool wxMimeTypesManagerImpl::WriteKDEMimeFile(int index, bool delete_index)
|
||||
appoutfile.Close ();
|
||||
|
||||
return bTemp;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void wxMimeTypesManagerImpl::LoadKDELinksForMimeSubtype(const wxString& dirbase,
|
||||
@@ -1037,7 +1043,6 @@ void wxMimeTypesManagerImpl::LoadKDELinksForMimeSubtype(const wxString& dirbase,
|
||||
}
|
||||
sExts.Add(mime_extension);
|
||||
|
||||
|
||||
// ok, now we can take care of icon:
|
||||
|
||||
nIndex = file.pIndexOf(_T("Icon="));
|
||||
@@ -1160,35 +1165,47 @@ void wxMimeTypesManagerImpl::GetKDEMimeInfo(const wxString& sExtraDir)
|
||||
wxArrayString dirs;
|
||||
wxArrayString icondirs;
|
||||
|
||||
// the variable KDEDIR is set when KDE is running
|
||||
const wxChar *kdedir = wxGetenv( wxT("KDEDIR") );
|
||||
// the variable $KDEDIR is set when KDE is running
|
||||
wxString kdedir = wxGetenv( wxT("KDEDIR") );
|
||||
|
||||
if (kdedir)
|
||||
if (!kdedir.empty())
|
||||
{
|
||||
// $(KDEDIR)/share/config/kdeglobals holds info
|
||||
// the current icons theme
|
||||
wxFileName configFile( kdedir, wxEmptyString );
|
||||
configFile.AppendDir( wxT("share") );
|
||||
#if 0
|
||||
configFile.AppendDir( wxT("config") );
|
||||
configFile.SetName( wxT("kdeglobals") );
|
||||
|
||||
wxFileConfig config( wxEmptyString, wxEmptyString, configFile.GetFullPath() );
|
||||
wxString theme;
|
||||
config.SetPath( wxT("Icons") );
|
||||
config.Read( wxT("Theme"), theme );
|
||||
|
||||
configFile.RemoveDir( configFile.GetDirCount()-1 );
|
||||
configFile.AppendDir( wxT("icons") );
|
||||
configFile.AppendDir( theme );
|
||||
#else
|
||||
configFile.AppendDir( wxT("icons") );
|
||||
configFile.AppendDir( wxT("crystalsvg") );
|
||||
#endif
|
||||
|
||||
if (!wxDir::Exists(configFile.GetPath()))
|
||||
if (configFile.FileExists())
|
||||
{
|
||||
wxFileConfig config( wxEmptyString, wxEmptyString, configFile.GetFullPath() );
|
||||
// $(KDEDIR)/share/config -> $(KDEDIR)/share
|
||||
configFile.RemoveDir( configFile.GetDirCount()-1 );
|
||||
configFile.AppendDir( wxT("crystal") );
|
||||
// $(KDEDIR)/share/ -> $(KDEDIR)/share/icons
|
||||
configFile.AppendDir( wxT("icons") );
|
||||
|
||||
// Check for entry
|
||||
config.SetPath( wxT("Icons") );
|
||||
wxString theme;
|
||||
if (config.Read( wxT("Theme"), &theme ))
|
||||
configFile.AppendDir( theme );
|
||||
else
|
||||
configFile.AppendDir( wxT("default.kde") );
|
||||
}
|
||||
else
|
||||
{
|
||||
// $(KDEDIR)/share/config -> $(KDEDIR)/share
|
||||
configFile.RemoveDir( configFile.GetDirCount()-1 );
|
||||
// $(KDEDIR)/share/ -> $(KDEDIR)/share/icons
|
||||
configFile.AppendDir( wxT("icons") );
|
||||
// $(KDEDIR)/share/icons -> $(KDEDIR)/share/icons/default.kde
|
||||
configFile.AppendDir( wxT("default.kde") );
|
||||
}
|
||||
|
||||
configFile.SetName( wxEmptyString );
|
||||
|
||||
// Just try a few likely icons theme names
|
||||
|
||||
if (!wxDir::Exists(configFile.GetPath()))
|
||||
{
|
||||
@@ -1196,6 +1213,24 @@ void wxMimeTypesManagerImpl::GetKDEMimeInfo(const wxString& sExtraDir)
|
||||
configFile.AppendDir( wxT("default.kde") );
|
||||
}
|
||||
|
||||
if (!wxDir::Exists(configFile.GetPath()))
|
||||
{
|
||||
configFile.RemoveDir( configFile.GetDirCount()-1 );
|
||||
configFile.AppendDir( wxT("default") );
|
||||
}
|
||||
|
||||
if (!wxDir::Exists(configFile.GetPath()))
|
||||
{
|
||||
configFile.RemoveDir( configFile.GetDirCount()-1 );
|
||||
configFile.AppendDir( wxT("crystalsvg") );
|
||||
}
|
||||
|
||||
if (!wxDir::Exists(configFile.GetPath()))
|
||||
{
|
||||
configFile.RemoveDir( configFile.GetDirCount()-1 );
|
||||
configFile.AppendDir( wxT("crystal") );
|
||||
}
|
||||
|
||||
if (wxDir::Exists(configFile.GetPath()))
|
||||
{
|
||||
configFile.AppendDir( wxT("32x32") );
|
||||
|
Reference in New Issue
Block a user