X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1457c9030c2e982c019a8f5cd96870276b75028b..3d9fe7b26de338412e6fe34b8a76bfd64d0f265c:/src/unix/mimetype.cpp diff --git a/src/unix/mimetype.cpp b/src/unix/mimetype.cpp index 2332dc12ac..70aaee69b2 100644 --- a/src/unix/mimetype.cpp +++ b/src/unix/mimetype.cpp @@ -51,7 +51,7 @@ #include "wx/defs.h" #endif -#if wxUSE_FILE && wxUSE_TEXTFILE +#if wxUSE_MIMETYPE && wxUSE_FILE && wxUSE_TEXTFILE #ifndef WX_PRECOMP #include "wx/string.h" @@ -119,7 +119,6 @@ public: wxString GetVerb (size_t i) { - if (i < 0) return wxEmptyString; if (i > GetCount() ) return wxEmptyString; wxString sTmp = Item(i).BeforeFirst(wxT('=')); return sTmp; @@ -127,7 +126,6 @@ public: wxString GetCmd (size_t i) { - if (i < 0) return wxEmptyString; if (i > GetCount() ) return wxEmptyString; wxString sTmp = Item(i).AfterFirst(wxT('=')); return sTmp; @@ -197,7 +195,6 @@ public: wxString GetVerb (size_t i) { - if (i < 0) return wxEmptyString; if (i > GetLineCount() ) return wxEmptyString; wxString sTmp = GetLine(i).BeforeFirst(wxT('=')); return sTmp; @@ -205,7 +202,6 @@ public: wxString GetCmd (size_t i) { - if (i < 0) return wxEmptyString; if (i > GetLineCount() ) return wxEmptyString; wxString sTmp = GetLine(i).AfterFirst(wxT('=')); return sTmp; @@ -1242,7 +1238,7 @@ bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions) // overwriteprompt is TRUE, but this is currently ignored as *Associate* has // no overwrite prompt bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt /*= TRUE*/) - { +{ wxArrayString strExtensions; wxString strDesc, strIcon ; @@ -1256,17 +1252,17 @@ bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool size_t i; bool Ok = TRUE; for (i = 0; i < strTypes.GetCount(); i++) - { + { if (!m_manager->DoAssociation (strTypes[i], strIcon, entry, strExtensions, strDesc)) - Ok = FALSE; - } + Ok = FALSE; + } return Ok; - } +} // ignore index on the grouds that we only have one icon in a Unix file bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon /*= wxEmptyString*/, int /*index = 0*/) - { +{ if (strIcon.IsEmpty()) return FALSE; wxArrayString strExtensions; wxString strDesc; @@ -1280,13 +1276,14 @@ bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon /*= wxEmptyString*/, size_t i; bool Ok = TRUE; for (i = 0; i < strTypes.GetCount(); i++) - { + { if (!m_manager->DoAssociation (strTypes[i], strIcon, entry, strExtensions, strDesc)) - Ok = FALSE; - } + Ok = FALSE; + } return Ok; - } +} + // ---------------------------------------------------------------------------- // wxMimeTypesManagerImpl (Unix) // ---------------------------------------------------------------------------- @@ -1361,12 +1358,12 @@ void wxMimeTypesManagerImpl::GetMimeInfo (const wxString& sExtraDir) wxString strHome = wxGetenv(wxT("HOME")); wxArrayString dirs; + dirs.Add ( strHome + wxT("/.") ); dirs.Add ( wxT("/etc/") ); dirs.Add ( wxT("/usr/etc/") ); dirs.Add ( wxT("/usr/local/etc/") ); dirs.Add ( wxT("/etc/mail/") ); dirs.Add ( wxT("/usr/public/lib/") ); - dirs.Add ( strHome + wxT("/.") ); if (!sExtraDir.IsEmpty()) dirs.Add ( sExtraDir + wxT("/") ); size_t nDirs = dirs.GetCount(); @@ -2121,8 +2118,13 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName) strExtensions = strRHS; } else { - wxLogWarning(_("Unknown field in file %s, line %d: '%s'."), - strFileName.c_str(), nLine + 1, strLHS.c_str()); + // 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()); + } } if ( !entryEnded ) { @@ -2531,11 +2533,11 @@ bool wxMimeTypesManagerImpl::Unassociate(wxFileType *ft) else { WriteMimeInfo(nIndex, TRUE ); - m_aTypes.Remove (nIndex); - m_aEntries.Remove (nIndex); - m_aExtensions.Remove (nIndex); - m_aDescriptions.Remove (nIndex); - m_aIcons.Remove (nIndex); + m_aTypes.RemoveAt(nIndex); + m_aEntries.RemoveAt(nIndex); + m_aExtensions.RemoveAt(nIndex); + m_aDescriptions.RemoveAt(nIndex); + m_aIcons.RemoveAt(nIndex); } } // check data integrity @@ -2571,5 +2573,5 @@ static bool IsKnownUnimportantField(const wxString& fieldAll) } #endif - // wxUSE_FILE && wxUSE_TEXTFILE + // wxUSE_MIMETYPE && wxUSE_FILE && wxUSE_TEXTFILE