X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4010aae119296f675b2bd48c38f795712ce41bec..acd32ffcdb319f162633c20e0202db3f8542998a:/src/unix/mimetype.cpp diff --git a/src/unix/mimetype.cpp b/src/unix/mimetype.cpp index 9467a8c1b4..52820e306d 100644 --- a/src/unix/mimetype.cpp +++ b/src/unix/mimetype.cpp @@ -267,7 +267,7 @@ void wxMimeTypesManagerImpl::LoadXDGGlobs(const wxString& filename) ext.Remove( 0, 2 ); wxArrayString exts; exts.Add( ext ); - + AddToMimeData(mime, wxEmptyString, NULL, exts, wxEmptyString, true ); } } @@ -527,7 +527,7 @@ void wxMimeTypesManagerImpl::Initialize(int mailcapStyles, #ifdef __VMS // XDG tables are never installed on OpenVMS return; -#endif +#else // Read MIME type - extension associations LoadXDGGlobs( "/usr/share/mime/globs" ); @@ -603,7 +603,6 @@ void wxMimeTypesManagerImpl::Initialize(int mailcapStyles, { if (textfile.GetLine(i).Find(wxT("=")) != wxNOT_FOUND) { - wxString mimeType = textfile.GetVerb(i); wxString desktopFile = textfile.GetCmd(i); if (deskTopFilesSeen.Index(desktopFile) == wxNOT_FOUND) @@ -627,6 +626,7 @@ void wxMimeTypesManagerImpl::Initialize(int mailcapStyles, } } } +#endif } // clear data so you can read another group of WM files @@ -718,16 +718,35 @@ int wxMimeTypesManagerImpl::AddToMimeData(const wxString& strType, int nIndex = m_aTypes.Index(mimeType); if ( nIndex == wxNOT_FOUND ) { - // new file type - m_aTypes.Add(mimeType); - m_aIcons.Add(strIcon); - m_aEntries.Add(entry ? entry : new wxMimeTypeCommands); + // We put MIME types containing "application" at the end, so that + // if the MIME type for the extention "htm" is searched for, it will + // rather find "text/html" than "application/x-mozilla-bookmarks". + if (mimeType.Find( "application" ) == 0) + { + // new file type + m_aTypes.Add(mimeType); + m_aIcons.Add(strIcon); + m_aEntries.Add(entry ? entry : new wxMimeTypeCommands); - // change nIndex so we can use it below to add the extensions - m_aExtensions.Add(wxEmptyString); - nIndex = m_aExtensions.size() - 1; + // change nIndex so we can use it below to add the extensions + m_aExtensions.Add(wxEmptyString); + nIndex = m_aExtensions.size() - 1; - m_aDescriptions.Add(strDesc); + m_aDescriptions.Add(strDesc); + } + else + { + // new file type + m_aTypes.Insert(mimeType,0); + m_aIcons.Insert(strIcon,0); + m_aEntries.Insert(entry ? entry : new wxMimeTypeCommands,0); + + // change nIndex so we can use it below to add the extensions + m_aExtensions.Insert(wxEmptyString,0); + nIndex = 0; + + m_aDescriptions.Insert(strDesc,0); + } } else // yes, we already have it { @@ -825,7 +844,7 @@ wxFileType * wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& ex // found wxFileType *fileType = new wxFileType; fileType->m_impl->Init(this, n); - + return fileType; } }