]> git.saurik.com Git - wxWidgets.git/blobdiff - src/unix/mimetype.cpp
replace use of deprecated GtkPixmap
[wxWidgets.git] / src / unix / mimetype.cpp
index 0a2793f92c6b8e9ed8d677865fd5a29969dfc15a..e2e68bd09a8ffdabfa24dda23e0aeb15e3c4f2f6 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        unix/mimetype.cpp
+// Name:        src/unix/mimetype.cpp
 // Purpose:     classes and functions to manage MIME types
 // Author:      Vadim Zeitlin
 // Modified by:
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
-  #pragma hdrstop
-#endif
-
-#ifndef WX_PRECOMP
-  #include "wx/defs.h"
+    #pragma hdrstop
 #endif
 
 #if wxUSE_MIMETYPE && wxUSE_FILE && wxUSE_TEXTFILE
 
+#include "wx/unix/mimetype.h"
+
 #ifndef WX_PRECOMP
-  #include "wx/string.h"
+    #include "wx/dynarray.h"
+    #include "wx/string.h"
+    #include "wx/intl.h"
+    #include "wx/log.h"
+    #include "wx/utils.h"
 #endif
 
-#include "wx/log.h"
 #include "wx/file.h"
-#include "wx/intl.h"
-#include "wx/dynarray.h"
 #include "wx/confbase.h"
 
 #include "wx/ffile.h"
 #include "wx/textfile.h"
 #include "wx/dir.h"
-#include "wx/utils.h"
 #include "wx/tokenzr.h"
 #include "wx/iconloc.h"
 #include "wx/filename.h"
 
-#include "wx/unix/mimetype.h"
-
-// Not GUI dependent
-#include "wx/gtk/gnome/gvfs.h"
+#if wxUSE_LIBGNOMEVFS
+    // Not GUI dependent
+    #include "wx/gtk/gnome/gvfs.h"
+#endif
 
 // other standard headers
 #include <ctype.h>
@@ -282,7 +280,7 @@ void wxMimeTypesManagerImpl::LoadGnomeDataFromKeyFile(const wxString& filename,
 {
     wxTextFile textfile(filename);
 #if defined(__WXGTK20__) && wxUSE_UNICODE
-    if ( !textfile.Open(wxConvUTF8) )
+    if ( !textfile.Open(wxMBConvUTF8(wxMBConvUTF8::MAP_INVALID_UTF8_TO_OCTAL)) )
 #else
     if ( !textfile.Open() )
 #endif
@@ -311,7 +309,7 @@ void wxMimeTypesManagerImpl::LoadGnomeDataFromKeyFile(const wxString& filename,
 
             wxLogTrace(TRACE_MIME, wxT("--- Reading from Gnome file %s '%s' ---"),
                     filename.c_str(), pc);
-            
+
             // trim trailing space and tab
             while ((*pc == wxT(' ')) || (*pc == wxT('\t')))
                 pc++;
@@ -322,18 +320,18 @@ void wxMimeTypesManagerImpl::LoadGnomeDataFromKeyFile(const wxString& filename,
             {
                 wxString left_of_equal = sTmp.Left( equal_pos );
                 const wxChar *right_of_equal = pc;
-                right_of_equal += equal_pos+1; 
-                
+                right_of_equal += equal_pos+1;
+
                 if (left_of_equal == wxT("icon_filename"))
                 {
                     // GNOME 2:
                     curIconFile = right_of_equal;
-                    
+
                     wxFileName newFile( curIconFile );
                     if (newFile.IsRelative() || newFile.FileExists())
                     {
                         size_t nDirs = search_dirs.GetCount();
-                        
+
                         for (size_t nDir = 0; nDir < nDirs; nDir++)
                         {
                             newFile.SetPath( search_dirs[nDir] );
@@ -1309,7 +1307,7 @@ void wxMimeTypesManagerImpl::InitIfNeeded()
     {
         // set the flag first to prevent recursion
         m_initialized = true;
-    
+
     wxString wm = wxGetenv( wxT("WINDOWMANAGER") );
 
     if (wm.Find( wxT("kde") ) != wxNOT_FOUND)
@@ -1436,7 +1434,7 @@ bool wxMimeTypesManagerImpl::WriteToMimeTypes(int index, bool delete_index)
         nIndex = file.pIndexOf(wxT("#--Netscape"));
         if (nIndex != wxNOT_FOUND)
         {
-            wxASSERT_MSG(false,wxT("Error in .mime.types \nTrying to mix Netscape and Metamail formats\nFile not modiifed"));
+            wxFAIL_MSG(wxT("Error in .mime.types\nTrying to mix Netscape and Metamail formats\nFile not modified"));
             return false;
         }
 
@@ -1503,7 +1501,7 @@ bool wxMimeTypesManagerImpl::WriteToNSMimeTypes(int index, bool delete_index)
             // metamail entreies
             if (file.GetLineCount() > 0)
             {
-                wxASSERT_MSG(false, wxT(".mime.types File not in Netscape format\nNo entries written to\n.mime.types or to .mailcap"));
+                wxFAIL_MSG(wxT(".mime.types File not in Netscape format\nNo entries written to\n.mime.types or to .mailcap"));
                 return false;
             }
 
@@ -1764,7 +1762,7 @@ bool wxMimeTypesManagerImpl::DoAssociation(const wxString& strType,
                                            const wxString& strDesc)
 {
     int nIndex = AddToMimeData(strType, strIcon, entry, strExtensions, strDesc, true);
-    
+
     if ( nIndex == wxNOT_FOUND )
         return false;
 
@@ -2645,6 +2643,8 @@ size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
 
 bool wxMimeTypesManagerImpl::Unassociate(wxFileType *ft)
 {
+    InitIfNeeded();
+
     wxArrayString sMimeTypes;
     ft->GetMimeTypes(sMimeTypes);
 
@@ -2703,4 +2703,3 @@ static bool IsKnownUnimportantField(const wxString& fieldAll)
 
 #endif
   // wxUSE_MIMETYPE && wxUSE_FILE && wxUSE_TEXTFILE
-