fixed loading of GNOME2 mime icons (still not working as desired)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18949 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2003-01-26 20:56:31 +00:00
parent 805f26b316
commit 25d599ae91
2 changed files with 42 additions and 5 deletions

View File

@ -274,3 +274,12 @@ CVS: [RR] wxWindows/src/gtk minifram.cpp,1.29,1.30
When applying, be careful to not pick later revision of font.cpp -- 2.5 doesn't When applying, be careful to not pick later revision of font.cpp -- 2.5 doesn't
have wxFont::GetInternalFont while 2.4 must have it because of binary have wxFont::GetInternalFont while 2.4 must have it because of binary
compatibility! compatibility!
23. Use GNOME2's /usr/share/pixmaps/document-icons in wxMimeTypesManager
Checking in mimetype.cpp;
/pack/cvsroots/wxwindows/wxWindows/src/unix/mimetype.cpp,v <-- mimetype.cpp
new revision: 1.29; previous revision: 1.28
done

View File

@ -529,7 +529,8 @@ bool wxMimeTypesManagerImpl::WriteGnomeMimeFile(int index, bool delete_index)
} }
void wxMimeTypesManagerImpl::LoadGnomeDataFromKeyFile(const wxString& filename) void wxMimeTypesManagerImpl::LoadGnomeDataFromKeyFile(const wxString& filename,
const wxArrayString& dirs)
{ {
wxTextFile textfile(filename); wxTextFile textfile(filename);
#if defined(__WXGTK20__) && wxUSE_UNICODE #if defined(__WXGTK20__) && wxUSE_UNICODE
@ -564,10 +565,29 @@ void wxMimeTypesManagerImpl::LoadGnomeDataFromKeyFile(const wxString& filename)
wxString sTmp(pc); wxString sTmp(pc);
if (sTmp.Contains(wxT("=")) ) if (sTmp.Contains(wxT("=")) )
{ {
// GNOME 1:
if (sTmp.Contains( wxT("icon-filename=") ) ) if (sTmp.Contains( wxT("icon-filename=") ) )
{ {
curIconFile = sTmp.AfterFirst(wxT('=')); 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, else //: some other field,
{ {
//may contain lines like this (RH7) //may contain lines like this (RH7)
@ -711,7 +731,8 @@ void wxMimeTypesManagerImpl::LoadGnomeMimeTypesFromMimeFile(const wxString& file
} }
void wxMimeTypesManagerImpl::LoadGnomeMimeFilesFromDir(const wxString& dirbase) void wxMimeTypesManagerImpl::LoadGnomeMimeFilesFromDir(
const wxString& dirbase, const wxArrayString& dirs)
{ {
wxASSERT_MSG( !!dirbase && !wxEndsWithPathSeparator(dirbase), wxASSERT_MSG( !!dirbase && !wxEndsWithPathSeparator(dirbase),
_T("base directory shouldn't end with a slash") ); _T("base directory shouldn't end with a slash") );
@ -741,7 +762,7 @@ void wxMimeTypesManagerImpl::LoadGnomeMimeFilesFromDir(const wxString& dirbase)
cont = dir.GetFirst(&filename, _T("*.keys"), wxDIR_FILES); cont = dir.GetFirst(&filename, _T("*.keys"), wxDIR_FILES);
while ( cont ) while ( cont )
{ {
LoadGnomeDataFromKeyFile(dirname + filename); LoadGnomeDataFromKeyFile(dirname + filename, dirs);
cont = dir.GetNext(&filename); cont = dir.GetNext(&filename);
} }
@ -752,7 +773,6 @@ void wxMimeTypesManagerImpl::LoadGnomeMimeFilesFromDir(const wxString& dirbase)
void wxMimeTypesManagerImpl::GetGnomeMimeInfo(const wxString& sExtraDir) void wxMimeTypesManagerImpl::GetGnomeMimeInfo(const wxString& sExtraDir)
{ {
wxArrayString dirs; wxArrayString dirs;
dirs.Add(wxT("/usr/share")); dirs.Add(wxT("/usr/share"));
dirs.Add(wxT("/usr/local/share")); dirs.Add(wxT("/usr/local/share"));
@ -766,7 +786,7 @@ void wxMimeTypesManagerImpl::GetGnomeMimeInfo(const wxString& sExtraDir)
size_t nDirs = dirs.GetCount(); size_t nDirs = dirs.GetCount();
for ( size_t nDir = 0; nDir < nDirs; nDir++ ) for ( size_t nDir = 0; nDir < nDirs; nDir++ )
{ {
LoadGnomeMimeFilesFromDir(dirs[nDir]); LoadGnomeMimeFilesFromDir(dirs[nDir], dirs);
} }
} }
@ -921,6 +941,9 @@ void wxMimeTypesManagerImpl::LoadKDELinksForMimeSubtype(const wxString& dirbase,
wxMimeTextFile file; wxMimeTextFile file;
if ( !file.Open(dirbase + filename) ) return; if ( !file.Open(dirbase + filename) ) return;
wxLogTrace(TRACE_MIME, wxT("loading KDE file %s"),
(dirbase+filename).c_str());
wxMimeTypeCommands * entry = new wxMimeTypeCommands; wxMimeTypeCommands * entry = new wxMimeTypeCommands;
wxArrayString sExts; wxArrayString sExts;
wxString mimetype, mime_desc, strIcon; wxString mimetype, mime_desc, strIcon;
@ -991,6 +1014,7 @@ void wxMimeTypesManagerImpl::LoadKDELinksForMimeSubtype(const wxString& dirbase,
if ( nIndex != wxNOT_FOUND ) if ( nIndex != wxNOT_FOUND )
{ {
strIcon = file.GetCmd(nIndex); 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 //it could be the real path, but more often a short name
if (!wxFileExists(strIcon)) if (!wxFileExists(strIcon))
{ {
@ -1004,6 +1028,7 @@ void wxMimeTypesManagerImpl::LoadKDELinksForMimeSubtype(const wxString& dirbase,
if (wxFileExists(icondirs[nDir] + strIcon)) if (wxFileExists(icondirs[nDir] + strIcon))
{ {
strIcon.Prepend(icondirs[nDir]); strIcon.Prepend(icondirs[nDir]);
wxLogTrace(TRACE_MIME, wxT(" iconfile %s"), strIcon.c_str());
break; break;
} }
} }
@ -1042,6 +1067,9 @@ void wxMimeTypesManagerImpl::LoadKDELinksForMimeType(const wxString& dirbase,
if ( !dir.IsOpened() ) if ( !dir.IsOpened() )
return; return;
wxLogTrace(TRACE_MIME, wxT("--- Loading from KDE directory %s ---"),
dirname.c_str());
dirname += _T('/'); dirname += _T('/');
wxString filename; wxString filename;