]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/mimecmn.cpp
check the week day for consistency in ParseFormat() (replaces patch 788052)
[wxWidgets.git] / src / common / mimecmn.cpp
index 6523cce38272276b5123d75a8bb341a1a0d48180..1510e92b2fabf6311bd493f55de7e48ecc1e35f2 100644 (file)
 
 #if wxUSE_MIMETYPE
 
-#ifndef WX_PRECOMP
-    #include "wx/module.h"
-#endif
-// this one is needed for MSVC5
-#include "wx/module.h"
-
 #ifndef WX_PRECOMP
   #include "wx/string.h"
-  #if wxUSE_GUI
-    #include "wx/icon.h"
-  #endif
 #endif //WX_PRECOMP
 
+#include "wx/module.h"
 #include "wx/log.h"
 #include "wx/file.h"
+#include "wx/iconloc.h"
 #include "wx/intl.h"
 #include "wx/dynarray.h"
 #include "wx/confbase.h"
@@ -269,33 +262,41 @@ bool wxFileType::GetMimeTypes(wxArrayString& mimeTypes) const
     return m_impl->GetMimeTypes(mimeTypes);
 }
 
-bool wxFileType::GetIcon(wxIcon *icon,
-                         wxString *iconFile,
-                         int *iconIndex) const
+bool wxFileType::GetIcon(wxIconLocation *iconLoc) const
 {
     if ( m_info )
     {
-        if ( iconFile )
-            *iconFile = m_info->GetIconFile();
-        if ( iconIndex )
-            *iconIndex = m_info->GetIconIndex();
-
-#if wxUSE_GUI
-        if ( icon && !m_info->GetIconFile().empty() )
+        if ( iconLoc )
         {
-            // FIXME: what about the index?
-            icon->LoadFile(m_info->GetIconFile());
+            iconLoc->SetFileName(m_info->GetIconFile());
+#ifdef __WXMSW__
+            iconLoc->SetIndex(m_info->GetIconIndex());
+#endif // __WXMSW__
         }
-#endif // wxUSE_GUI
 
         return TRUE;
     }
 
-#if defined(__WXMSW__) || defined(__UNIX__)
-    return m_impl->GetIcon(icon, iconFile, iconIndex);
-#else
-    return m_impl->GetIcon(icon);
-#endif
+    return m_impl->GetIcon(iconLoc);
+}
+
+bool
+wxFileType::GetIcon(wxIconLocation *iconloc,
+                    const MessageParameters& params) const
+{
+    if ( !GetIcon(iconloc) )
+    {
+        return false;
+    }
+
+    // we may have "%s" in the icon location string, at least under Windows, so
+    // expand this
+    if ( iconloc )
+    {
+        iconloc->SetFileName(ExpandCommand(iconloc->GetFileName(), params));
+    }
+
+    return true;
 }
 
 bool wxFileType::GetDescription(wxString *desc) const
@@ -537,11 +538,11 @@ wxMimeTypesManager::GetFileTypeFromMimeType(const wxString& mimeType)
     EnsureImpl();
     wxFileType *ft = m_impl->GetFileTypeFromMimeType(mimeType);
 
-    if ( ft ) {
+    if ( !ft ) {
         // check the fallbacks
         //
-        // TODO linear search is potentially slow, perhaps we should use a sorted
-        //      array?
+        // TODO linear search is potentially slow, perhaps we should use a
+        //      sorted array?
         size_t count = m_fallbacks.GetCount();
         for ( size_t n = 0; n < count; n++ ) {
             if ( wxMimeTypesManager::IsOfType(mimeType,