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:
parent
805f26b316
commit
25d599ae91
@ -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
|
||||
have wxFont::GetInternalFont while 2.4 must have it because of binary
|
||||
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
|
||||
|
||||
|
@ -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);
|
||||
#if defined(__WXGTK20__) && wxUSE_UNICODE
|
||||
@ -564,10 +565,29 @@ void wxMimeTypesManagerImpl::LoadGnomeDataFromKeyFile(const wxString& filename)
|
||||
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)
|
||||
@ -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),
|
||||
_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);
|
||||
while ( cont )
|
||||
{
|
||||
LoadGnomeDataFromKeyFile(dirname + filename);
|
||||
LoadGnomeDataFromKeyFile(dirname + filename, dirs);
|
||||
|
||||
cont = dir.GetNext(&filename);
|
||||
}
|
||||
@ -752,7 +773,6 @@ void wxMimeTypesManagerImpl::LoadGnomeMimeFilesFromDir(const wxString& dirbase)
|
||||
|
||||
void wxMimeTypesManagerImpl::GetGnomeMimeInfo(const wxString& sExtraDir)
|
||||
{
|
||||
|
||||
wxArrayString dirs;
|
||||
dirs.Add(wxT("/usr/share"));
|
||||
dirs.Add(wxT("/usr/local/share"));
|
||||
@ -766,7 +786,7 @@ void wxMimeTypesManagerImpl::GetGnomeMimeInfo(const wxString& sExtraDir)
|
||||
size_t nDirs = dirs.GetCount();
|
||||
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;
|
||||
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;
|
||||
@ -991,6 +1014,7 @@ void wxMimeTypesManagerImpl::LoadKDELinksForMimeSubtype(const wxString& dirbase,
|
||||
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))
|
||||
{
|
||||
@ -1004,6 +1028,7 @@ void wxMimeTypesManagerImpl::LoadKDELinksForMimeSubtype(const wxString& dirbase,
|
||||
if (wxFileExists(icondirs[nDir] + strIcon))
|
||||
{
|
||||
strIcon.Prepend(icondirs[nDir]);
|
||||
wxLogTrace(TRACE_MIME, wxT(" iconfile %s"), strIcon.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1042,6 +1067,9 @@ void wxMimeTypesManagerImpl::LoadKDELinksForMimeType(const wxString& dirbase,
|
||||
if ( !dir.IsOpened() )
|
||||
return;
|
||||
|
||||
wxLogTrace(TRACE_MIME, wxT("--- Loading from KDE directory %s ---"),
|
||||
dirname.c_str());
|
||||
|
||||
dirname += _T('/');
|
||||
|
||||
wxString filename;
|
||||
|
Loading…
Reference in New Issue
Block a user