Add stub for parsing globs file

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54448 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2008-07-01 09:28:08 +00:00
parent c1d97593ed
commit 05f616efaa
2 changed files with 24 additions and 5 deletions

View File

@@ -84,6 +84,9 @@ protected:
// Scan XDG directory // Scan XDG directory
void LoadXDGAppsFilesFromDir(const wxString& dirname); void LoadXDGAppsFilesFromDir(const wxString& dirname);
// Load XDG globs files
void LoadXDGGlobs(const wxString& filename);
// functions used to do associations // functions used to do associations
virtual int AddToMimeData(const wxString& strType, virtual int AddToMimeData(const wxString& strType,
const wxString& strIcon, const wxString& strIcon,

View File

@@ -16,7 +16,7 @@
#pragma hdrstop #pragma hdrstop
#endif #endif
#if wxUSE_MIMETYPE && wxUSE_FILE && wxUSE_TEXTFILE #if wxUSE_MIMETYPE && wxUSE_FILE
#include "wx/unix/mimetype.h" #include "wx/unix/mimetype.h"
@@ -32,7 +32,6 @@
#include "wx/confbase.h" #include "wx/confbase.h"
#include "wx/ffile.h" #include "wx/ffile.h"
#include "wx/textfile.h"
#include "wx/dir.h" #include "wx/dir.h"
#include "wx/tokenzr.h" #include "wx/tokenzr.h"
#include "wx/iconloc.h" #include "wx/iconloc.h"
@@ -73,7 +72,7 @@ public:
{ {
wxString t = tok.GetNextToken(); wxString t = tok.GetNextToken();
t.MakeLower(); t.MakeLower();
if ((!!t) && (t.Find( "comment" ) != 0) && (t.Find( "generic" ) != 0)) if ((!!t) && (t.Find( "comment" ) != 0) && (t.Find( "#" ) != 0) && (t.Find( "generic" ) != 0))
m_text.Add( t ); m_text.Add( t );
} }
return true; return true;
@@ -248,6 +247,17 @@ void wxMimeTypesManagerImpl::LoadXDGAppsFilesFromDir(const wxString& dirname)
} }
void wxMimeTypesManagerImpl::LoadXDGGlobs(const wxString& filename)
{
wxLogTrace(TRACE_MIME, wxT("loading XDG globs file from %s"), filename.c_str());
wxMimeTextFile file(filename);
if ( !file.Open() )
return;
// Parse it here
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxFileTypeImpl (Unix) // wxFileTypeImpl (Unix)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -494,6 +504,8 @@ void wxMimeTypesManagerImpl::InitIfNeeded()
} }
} }
// read system and user mailcaps and other files // read system and user mailcaps and other files
void wxMimeTypesManagerImpl::Initialize(int mailcapStyles, void wxMimeTypesManagerImpl::Initialize(int mailcapStyles,
const wxString& sExtraDir) const wxString& sExtraDir)
@@ -503,7 +515,10 @@ void wxMimeTypesManagerImpl::Initialize(int mailcapStyles,
return; return;
#endif #endif
// Load desktop files for Gnome, and then override them with the Gnome defaults. // Read MIME type - extension associations
LoadXDGGlobs( "/usr/share/mime/globs" );
// Load desktop files for XDG, and then override them with the defaults.
// We will override them one desktop file at a time, rather // We will override them one desktop file at a time, rather
// than one mime type at a time, but it should be a reasonable // than one mime type at a time, but it should be a reasonable
// heuristic. // heuristic.
@@ -815,6 +830,7 @@ wxFileType * wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mim
// first look for an exact match // first look for an exact match
int index = m_aTypes.Index(mimetype); int index = m_aTypes.Index(mimetype);
if ( index != wxNOT_FOUND ) if ( index != wxNOT_FOUND )
{ {
fileType = new wxFileType; fileType = new wxFileType;
@@ -973,4 +989,4 @@ bool wxMimeTypesManagerImpl::Unassociate(wxFileType *ft)
} }
#endif #endif
// wxUSE_MIMETYPE && wxUSE_FILE && wxUSE_TEXTFILE // wxUSE_MIMETYPE && wxUSE_FILE