#include "wx/defs.h"
 #endif
 
-#if wxUSE_FILE && wxUSE_TEXTFILE
+#if wxUSE_MIMETYPE && wxUSE_FILE && wxUSE_TEXTFILE
 
 #ifndef WX_PRECOMP
   #include "wx/string.h"
 
     wxString GetVerb (size_t i)
     {
-        if (i < 0) return wxEmptyString;
         if (i > GetCount() ) return wxEmptyString;
         wxString sTmp = Item(i).BeforeFirst(wxT('='));
         return sTmp;
 
     wxString GetCmd (size_t i)
     {
-        if (i < 0) return wxEmptyString;
         if (i > GetCount() ) return wxEmptyString;
         wxString sTmp = Item(i).AfterFirst(wxT('='));
         return sTmp;
 
     wxString GetVerb (size_t i)
     {
-        if (i < 0) return wxEmptyString;
         if (i > GetLineCount() ) return wxEmptyString;
         wxString sTmp = GetLine(i).BeforeFirst(wxT('='));
         return sTmp;
 
     wxString GetCmd (size_t i)
     {
-        if (i < 0) return wxEmptyString;
         if (i > GetLineCount() ) return wxEmptyString;
         wxString sTmp = GetLine(i).AfterFirst(wxT('='));
         return sTmp;
 //  a) for "brief" format:
 //      <mime type>  <space separated list of extensions>
 //  b) for "expanded" format:
-//      type=<mime type> \ 
-//      desc="<description>" \ 
+//      type=<mime type> BACKSLASH
+//      desc="<description>" BACKSLASH
 //      exts="<comma separated list of extensions>"
 //
+// (where BACKSLASH is a literal '\\' which we can't put here because cpp
+// misinterprets it)
+//
 // We try to autodetect the format of mime.types: if a non-comment line starts
 // with "type=" we assume the second format, otherwise the first one.
 
     return wxFileType::ExpandCommand(sTmp, params);
 }
 
-bool wxFileTypeImpl::GetIcon(wxIcon *icon, wxString *iconFile /*= NULL */,
-                 int *iconIndex /*= NULL*/) const
+bool wxFileTypeImpl::GetIcon(wxIcon *icon,
+                             wxString *iconFile /*= NULL */,
+                             int *iconIndex /*= NULL*/) const
 
 {
+#if wxUSE_GUI
     wxString sTmp;
     size_t i = 0;
     while ( (i < m_index.GetCount() ) && sTmp.IsEmpty() )
-        {
-            sTmp = m_manager->m_aIcons[m_index[i]];
-            i ++;
-        }
+    {
+        sTmp = m_manager->m_aIcons[m_index[i]];
+        i ++;
+    }
     if ( sTmp.IsEmpty () ) return FALSE;
 
     wxIcon icn;
         icn = wxIcon(sTmp, wxBITMAP_TYPE_ANY);
 
     if ( icn.Ok() )
-      {
-      *icon = icn;
-      if (iconFile) *iconFile = sTmp;
-      if (iconIndex) *iconIndex = 0;
-      return TRUE;
-      }
-        return FALSE;
+    {
+        *icon = icn;
+        if (iconFile) *iconFile = sTmp;
+        if (iconIndex) *iconIndex = 0;
+        return TRUE;
     }
+#endif // wxUSE_GUI
+
+    return FALSE;
+}
 
 
 bool
     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();
                 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 ) {
         // the flags and field values on the current line
         bool needsterminal = FALSE,
              copiousoutput = FALSE;
-        wxMimeArrayString *entry;
+        wxMimeArrayString *entry = NULL; // suppress compiler warning
 
         wxString strType,
                  strOpenCmd,
         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
 }
 
 #endif
-  // wxUSE_FILE && wxUSE_TEXTFILE
+  // wxUSE_MIMETYPE && wxUSE_FILE && wxUSE_TEXTFILE