]> git.saurik.com Git - wxWidgets.git/blobdiff - src/unix/mimetype.cpp
Now scaling doesn't scale GetTextExtent() anymore. This
[wxWidgets.git] / src / unix / mimetype.cpp
index 23c23a983ed135ce36e1d8bfa95b3ac26b1a49d8..6d34ebc91c7c5b545a3a981c79bc197fff69f915 100644 (file)
@@ -529,7 +529,8 @@ bool wxMimeTypesManagerImpl::WriteGnomeMimeFile(int index, bool delete_index)
 }
 
 
-void wxMimeTypesManagerImpl::LoadGnomeDataFromKeyFile(const wxString& filename)
+void wxMimeTypesManagerImpl::LoadGnomeDataFromKeyFile(const wxString& filename,
+                                                      const wxArrayString& dirs)
 {
     wxTextFile textfile(filename);
 #if defined(__WXGTK20__) && wxUSE_UNICODE
@@ -564,10 +565,29 @@ void wxMimeTypesManagerImpl::LoadGnomeDataFromKeyFile(const wxString& filename)
             wxString sTmp(pc);
             if (sTmp.Contains(wxT("=")) )
             {
+                // GNOME 1:
                 if (sTmp.Contains( wxT("icon-filename=") ) )
                 {
                     curIconFile = sTmp.AfterFirst(wxT('='));
                 }
+                // GNOME 2:
+                else if (sTmp.Contains( wxT("icon_filename=") ) )
+                {
+                    curIconFile = sTmp.AfterFirst(wxT('='));
+                    if (!wxFileExists(curIconFile))
+                    {
+                        size_t nDirs = dirs.GetCount();
+                        for (size_t nDir = 0; nDir < nDirs; nDir++)
+                        {
+                            wxString newFile;
+                            newFile.Printf(wxT("%s/pixmaps/document-icons/%s.png"),
+                                           dirs[nDir].c_str(),
+                                           curIconFile.c_str());
+                            if (wxFileExists(newFile))
+                                curIconFile = newFile;
+                        }
+                    }
+                }
                 else //: some other field,
                 {
                     //may contain lines like this (RH7)
@@ -711,7 +731,8 @@ void wxMimeTypesManagerImpl::LoadGnomeMimeTypesFromMimeFile(const wxString& file
 }
 
 
-void wxMimeTypesManagerImpl::LoadGnomeMimeFilesFromDir(const wxString& dirbase)
+void wxMimeTypesManagerImpl::LoadGnomeMimeFilesFromDir(
+                      const wxString& dirbase, const wxArrayString& dirs)
 {
     wxASSERT_MSG( !!dirbase && !wxEndsWithPathSeparator(dirbase),
                   _T("base directory shouldn't end with a slash") );
@@ -741,7 +762,7 @@ void wxMimeTypesManagerImpl::LoadGnomeMimeFilesFromDir(const wxString& dirbase)
     cont = dir.GetFirst(&filename, _T("*.keys"), wxDIR_FILES);
     while ( cont )
     {
-        LoadGnomeDataFromKeyFile(dirname + filename);
+        LoadGnomeDataFromKeyFile(dirname + filename, dirs);
 
         cont = dir.GetNext(&filename);
     }
@@ -752,7 +773,6 @@ void wxMimeTypesManagerImpl::LoadGnomeMimeFilesFromDir(const wxString& dirbase)
 
 void wxMimeTypesManagerImpl::GetGnomeMimeInfo(const wxString& sExtraDir)
 {
-
     wxArrayString dirs;
     dirs.Add(wxT("/usr/share"));
     dirs.Add(wxT("/usr/local/share"));
@@ -766,7 +786,7 @@ void wxMimeTypesManagerImpl::GetGnomeMimeInfo(const wxString& sExtraDir)
     size_t nDirs = dirs.GetCount();
     for ( size_t nDir = 0; nDir < nDirs; nDir++ )
     {
-        LoadGnomeMimeFilesFromDir(dirs[nDir]);
+        LoadGnomeMimeFilesFromDir(dirs[nDir], dirs);
     }
 }
 
@@ -921,6 +941,9 @@ void wxMimeTypesManagerImpl::LoadKDELinksForMimeSubtype(const wxString& dirbase,
     wxMimeTextFile file;
     if ( !file.Open(dirbase + filename) ) return;
 
+    wxLogTrace(TRACE_MIME, wxT("loading KDE file %s"),
+                           (dirbase+filename).c_str());
+    
     wxMimeTypeCommands * entry = new wxMimeTypeCommands;
     wxArrayString sExts;
     wxString mimetype, mime_desc, strIcon;
@@ -991,6 +1014,7 @@ void wxMimeTypesManagerImpl::LoadKDELinksForMimeSubtype(const wxString& dirbase,
     if ( nIndex != wxNOT_FOUND )
     {
         strIcon = file.GetCmd(nIndex);
+        wxLogTrace(TRACE_MIME, wxT("  icon %s"), strIcon.c_str());
         //it could be the real path, but more often a short name
         if (!wxFileExists(strIcon))
         {
@@ -1004,6 +1028,7 @@ void wxMimeTypesManagerImpl::LoadKDELinksForMimeSubtype(const wxString& dirbase,
                     if (wxFileExists(icondirs[nDir] + strIcon))
                     {
                         strIcon.Prepend(icondirs[nDir]);
+                        wxLogTrace(TRACE_MIME, wxT("  iconfile %s"), strIcon.c_str());
                         break;
                     }
             }
@@ -1042,6 +1067,9 @@ void wxMimeTypesManagerImpl::LoadKDELinksForMimeType(const wxString& dirbase,
     if ( !dir.IsOpened() )
         return;
 
+    wxLogTrace(TRACE_MIME, wxT("--- Loading from KDE directory %s  ---"),
+                           dirname.c_str());
+    
     dirname += _T('/');
 
     wxString filename;