}
-void wxMimeTypesManagerImpl::LoadGnomeDataFromKeyFile(const wxString& filename)
+void wxMimeTypesManagerImpl::LoadGnomeDataFromKeyFile(const wxString& filename,
+ const wxArrayString& dirs)
{
wxTextFile textfile(filename);
#if defined(__WXGTK20__) && wxUSE_UNICODE
wxString sTmp(pc);
if (sTmp.Contains(wxT("=")) )
{
+ // GNOME 1:
if (sTmp.Contains( wxT("icon-filename=") ) )
{
curIconFile = sTmp.AfterFirst(wxT('='));
}
+ // GNOME 2:
+ else if (sTmp.Contains( wxT("icon_filename=") ) )
+ {
+ curIconFile = sTmp.AfterFirst(wxT('='));
+ if (!wxFileExists(curIconFile))
+ {
+ size_t nDirs = dirs.GetCount();
+ for (size_t nDir = 0; nDir < nDirs; nDir++)
+ {
+ wxString newFile;
+ newFile.Printf(wxT("%s/pixmaps/document-icons/%s.png"),
+ dirs[nDir].c_str(),
+ curIconFile.c_str());
+ if (wxFileExists(newFile))
+ curIconFile = newFile;
+ }
+ }
+ }
else //: some other field,
{
//may contain lines like this (RH7)
}
-void wxMimeTypesManagerImpl::LoadGnomeMimeFilesFromDir(const wxString& dirbase)
+void wxMimeTypesManagerImpl::LoadGnomeMimeFilesFromDir(
+ const wxString& dirbase, const wxArrayString& dirs)
{
wxASSERT_MSG( !!dirbase && !wxEndsWithPathSeparator(dirbase),
_T("base directory shouldn't end with a slash") );
cont = dir.GetFirst(&filename, _T("*.keys"), wxDIR_FILES);
while ( cont )
{
- LoadGnomeDataFromKeyFile(dirname + filename);
+ LoadGnomeDataFromKeyFile(dirname + filename, dirs);
cont = dir.GetNext(&filename);
}
void wxMimeTypesManagerImpl::GetGnomeMimeInfo(const wxString& sExtraDir)
{
-
wxArrayString dirs;
dirs.Add(wxT("/usr/share"));
dirs.Add(wxT("/usr/local/share"));
size_t nDirs = dirs.GetCount();
for ( size_t nDir = 0; nDir < nDirs; nDir++ )
{
- LoadGnomeMimeFilesFromDir(dirs[nDir]);
+ LoadGnomeMimeFilesFromDir(dirs[nDir], dirs);
}
}
wxMimeTextFile file;
if ( !file.Open(dirbase + filename) ) return;
+ wxLogTrace(TRACE_MIME, wxT("loading KDE file %s"),
+ (dirbase+filename).c_str());
+
wxMimeTypeCommands * entry = new wxMimeTypeCommands;
wxArrayString sExts;
wxString mimetype, mime_desc, strIcon;
if ( nIndex != wxNOT_FOUND )
{
strIcon = file.GetCmd(nIndex);
+ wxLogTrace(TRACE_MIME, wxT(" icon %s"), strIcon.c_str());
//it could be the real path, but more often a short name
if (!wxFileExists(strIcon))
{
if (wxFileExists(icondirs[nDir] + strIcon))
{
strIcon.Prepend(icondirs[nDir]);
+ wxLogTrace(TRACE_MIME, wxT(" iconfile %s"), strIcon.c_str());
break;
}
}
if ( !dir.IsOpened() )
return;
+ wxLogTrace(TRACE_MIME, wxT("--- Loading from KDE directory %s ---"),
+ dirname.c_str());
+
dirname += _T('/');
wxString filename;
else if ( strLHS == wxT("exts") ) {
strExtensions = strRHS;
}
- else {
+ else if ( strLHS != _T("icon") )
+ {
// this one is simply ignored: it usually refers to Netscape
// built in icons which are useless for us anyhow
- if ( strLHS != _T("icon") )
- {
- wxLogWarning(_("Unknown field in file %s, line %d: '%s'."),
- strFileName.c_str(), nLine + 1, strLHS.c_str());
- }
+ }
+ else if ( !strLHS.StartsWith(_T("x-")) )
+ {
+ // we suppose that all fields starting with "X-" are
+ // unregistered extensions according to the standard practice,
+ // but it may be worth telling the user about other junk in
+ // his mime.types file
+ wxLogWarning(_("Unknown field in file %s, line %d: '%s'."),
+ strFileName.c_str(), nLine + 1, strLHS.c_str());
}
if ( !entryEnded ) {