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)
|
void wxMimeTypesManagerImpl::GetGnomeMimeInfo(const wxString& sExtraDir)
|
||||||
{
|
{
|
||||||
wxArrayString dirs;
|
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/share"));
|
||||||
dirs.Add(wxT("/usr/local/share"));
|
dirs.Add(wxT("/usr/local/share"));
|
||||||
|
|
||||||
wxString gnomedir;
|
gnomedir = wxGetHomeDir();
|
||||||
wxGetHomeDir( &gnomedir );
|
gnomedir << wxT("/.gnome");
|
||||||
gnomedir += wxT("/.gnome");
|
|
||||||
dirs.Add( gnomedir );
|
dirs.Add( gnomedir );
|
||||||
|
|
||||||
if (!sExtraDir.empty()) dirs.Add( sExtraDir );
|
if (!sExtraDir.empty()) dirs.Add( sExtraDir );
|
||||||
|
|
||||||
size_t nDirs = dirs.GetCount();
|
size_t nDirs = dirs.GetCount();
|
||||||
@@ -838,13 +845,14 @@ void wxMimeTypesManagerImpl::GetGnomeMimeInfo(const wxString& sExtraDir)
|
|||||||
// kde writing; see http://webcvs.kde.org/cgi-bin/cvsweb.cgi/~checkout~/kdelibs/kio/DESKTOP_ENTRY_STANDARD
|
// kde writing; see http://webcvs.kde.org/cgi-bin/cvsweb.cgi/~checkout~/kdelibs/kio/DESKTOP_ENTRY_STANDARD
|
||||||
// for now write to .kdelnk but should eventually do .desktop instead (in preference??)
|
// for now write to .kdelnk but should eventually do .desktop instead (in preference??)
|
||||||
|
|
||||||
bool wxMimeTypesManagerImpl::CheckKDEDirsExist ( const wxString & sOK, const wxString & sTest )
|
bool wxMimeTypesManagerImpl::CheckKDEDirsExist ( const wxString &sOK, const wxString &sTest )
|
||||||
|
{
|
||||||
{
|
|
||||||
if (sTest.empty())
|
if (sTest.empty())
|
||||||
{
|
{
|
||||||
if (wxDir::Exists(sOK)) return TRUE;
|
if (wxDir::Exists(sOK))
|
||||||
else return FALSE;
|
return TRUE;
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -959,8 +967,6 @@ bool wxMimeTypesManagerImpl::WriteKDEMimeFile(int index, bool delete_index)
|
|||||||
appoutfile.Close ();
|
appoutfile.Close ();
|
||||||
|
|
||||||
return bTemp;
|
return bTemp;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMimeTypesManagerImpl::LoadKDELinksForMimeSubtype(const wxString& dirbase,
|
void wxMimeTypesManagerImpl::LoadKDELinksForMimeSubtype(const wxString& dirbase,
|
||||||
@@ -1037,7 +1043,6 @@ void wxMimeTypesManagerImpl::LoadKDELinksForMimeSubtype(const wxString& dirbase,
|
|||||||
}
|
}
|
||||||
sExts.Add(mime_extension);
|
sExts.Add(mime_extension);
|
||||||
|
|
||||||
|
|
||||||
// ok, now we can take care of icon:
|
// ok, now we can take care of icon:
|
||||||
|
|
||||||
nIndex = file.pIndexOf(_T("Icon="));
|
nIndex = file.pIndexOf(_T("Icon="));
|
||||||
@@ -1160,35 +1165,47 @@ void wxMimeTypesManagerImpl::GetKDEMimeInfo(const wxString& sExtraDir)
|
|||||||
wxArrayString dirs;
|
wxArrayString dirs;
|
||||||
wxArrayString icondirs;
|
wxArrayString icondirs;
|
||||||
|
|
||||||
// the variable KDEDIR is set when KDE is running
|
// the variable $KDEDIR is set when KDE is running
|
||||||
const wxChar *kdedir = wxGetenv( wxT("KDEDIR") );
|
wxString kdedir = wxGetenv( wxT("KDEDIR") );
|
||||||
|
|
||||||
if (kdedir)
|
if (!kdedir.empty())
|
||||||
{
|
{
|
||||||
|
// $(KDEDIR)/share/config/kdeglobals holds info
|
||||||
|
// the current icons theme
|
||||||
wxFileName configFile( kdedir, wxEmptyString );
|
wxFileName configFile( kdedir, wxEmptyString );
|
||||||
configFile.AppendDir( wxT("share") );
|
configFile.AppendDir( wxT("share") );
|
||||||
#if 0
|
|
||||||
configFile.AppendDir( wxT("config") );
|
configFile.AppendDir( wxT("config") );
|
||||||
configFile.SetName( wxT("kdeglobals") );
|
configFile.SetName( wxT("kdeglobals") );
|
||||||
|
|
||||||
wxFileConfig config( wxEmptyString, wxEmptyString, configFile.GetFullPath() );
|
if (configFile.FileExists())
|
||||||
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()))
|
|
||||||
{
|
{
|
||||||
|
wxFileConfig config( wxEmptyString, wxEmptyString, configFile.GetFullPath() );
|
||||||
|
// $(KDEDIR)/share/config -> $(KDEDIR)/share
|
||||||
configFile.RemoveDir( configFile.GetDirCount()-1 );
|
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()))
|
if (!wxDir::Exists(configFile.GetPath()))
|
||||||
{
|
{
|
||||||
@@ -1196,6 +1213,24 @@ void wxMimeTypesManagerImpl::GetKDEMimeInfo(const wxString& sExtraDir)
|
|||||||
configFile.AppendDir( wxT("default.kde") );
|
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()))
|
if (wxDir::Exists(configFile.GetPath()))
|
||||||
{
|
{
|
||||||
configFile.AppendDir( wxT("32x32") );
|
configFile.AppendDir( wxT("32x32") );
|
||||||
@@ -1208,7 +1243,7 @@ void wxMimeTypesManagerImpl::GetKDEMimeInfo(const wxString& sExtraDir)
|
|||||||
dirs.Add(wxGetHomeDir() + wxT("/.kde/share"));
|
dirs.Add(wxGetHomeDir() + wxT("/.kde/share"));
|
||||||
icondirs.Add(wxGetHomeDir() + wxT("/.kde/share/icons/"));
|
icondirs.Add(wxGetHomeDir() + wxT("/.kde/share/icons/"));
|
||||||
|
|
||||||
if ( kdedir )
|
if (kdedir)
|
||||||
{
|
{
|
||||||
dirs.Add( wxString(kdedir) + wxT("/share") );
|
dirs.Add( wxString(kdedir) + wxT("/share") );
|
||||||
icondirs.Add( wxString(kdedir) + wxT("/share/icons/") );
|
icondirs.Add( wxString(kdedir) + wxT("/share/icons/") );
|
||||||
|
Reference in New Issue
Block a user