MIME type manager fixes described earlier on the list:
1. extended wxFileTypeInfo 2. moved handling of fallbacks into wxMimeTypesManager (instead of Impl) 3. added wxMimeTypesManager::Associate() and Unassociate() 4. Unix version only reads the files on demand => much faster startup git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9156 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -44,13 +44,13 @@
|
||||
//#define TEST_EXECUTE
|
||||
//#define TEST_FILE
|
||||
//#define TEST_FILECONF
|
||||
#define TEST_FILENAME
|
||||
//#define TEST_FILENAME
|
||||
//#define TEST_FTP
|
||||
//#define TEST_HASH
|
||||
//#define TEST_LIST
|
||||
//#define TEST_LOG
|
||||
//#define TEST_LONGLONG
|
||||
//#define TEST_MIME
|
||||
#define TEST_MIME
|
||||
//#define TEST_INFO_FUNCTIONS
|
||||
//#define TEST_REGISTRY
|
||||
//#define TEST_SOCKETS
|
||||
@@ -813,6 +813,8 @@ static wxMimeTypesManager g_mimeManager;
|
||||
|
||||
static void TestMimeEnum()
|
||||
{
|
||||
wxPuts(_T("*** Testing wxMimeTypesManager::EnumAllFileTypes() ***\n"));
|
||||
|
||||
wxArrayString mimetypes;
|
||||
|
||||
size_t count = g_mimeManager.EnumAllFileTypes(mimetypes);
|
||||
@@ -908,24 +910,24 @@ static void TestMimeAssociate()
|
||||
{
|
||||
wxPuts(_T("*** Testing creation of filetype association ***\n"));
|
||||
|
||||
wxFileType *ft = g_mimeManager.Associate
|
||||
(
|
||||
_T(".xyz"),
|
||||
_T("application/x-xyz"),
|
||||
_T("XYZFile"), // filetype (MSW only)
|
||||
_T("XYZ File") // description (Unix only)
|
||||
);
|
||||
wxFileTypeInfo ftInfo(
|
||||
_T("application/x-xyz"),
|
||||
_T("xyzview '%s'"), // open cmd
|
||||
_T(""), // print cmd
|
||||
_T("XYZ File") // description
|
||||
_T(".xyz"), // extensions
|
||||
NULL // end of extensions
|
||||
);
|
||||
ftInfo.SetShortDesc(_T("XYZFile")); // used under Win32 only
|
||||
|
||||
wxFileType *ft = g_mimeManager.Associate(ftInfo);
|
||||
if ( !ft )
|
||||
{
|
||||
wxPuts(_T("ERROR: failed to create association!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !ft->SetOpenCommand(_T("myprogram")) )
|
||||
{
|
||||
wxPuts(_T("ERROR: failed to set open command!"));
|
||||
}
|
||||
|
||||
// TODO: read it back
|
||||
delete ft;
|
||||
}
|
||||
}
|
||||
@@ -4089,13 +4091,14 @@ int main(int argc, char **argv)
|
||||
|
||||
#ifdef TEST_MIME
|
||||
wxLog::AddTraceMask(_T("mime"));
|
||||
if ( 0 )
|
||||
if ( 1 )
|
||||
{
|
||||
TestMimeEnum();
|
||||
TestMimeOverride();
|
||||
TestMimeFilename();
|
||||
}
|
||||
TestMimeAssociate();
|
||||
else
|
||||
TestMimeAssociate();
|
||||
#endif // TEST_MIME
|
||||
|
||||
#ifdef TEST_INFO_FUNCTIONS
|
||||
|
Reference in New Issue
Block a user