This method used to work in 2.8 but was unimplemented in 2.9.
Restore more or less the old implementation using the data that we already
have in wxMimeTypesManager anyhow.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68563
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
OSX:
- Implement wxRegion::Equal() (Dr.Acula).
OSX:
- Implement wxRegion::Equal() (Dr.Acula).
+- Implement wxFileType::GetOpenCommand().
- wxGetOsVersion() now returns more sensible version numbers, e.g. 10 and 6
for OS X 10.6.
- wxGetOsVersion() now returns more sensible version numbers, e.g. 10 and 6
for OS X 10.6.
bool GetMimeTypes(const wxString& uti, wxArrayString& mimeTypes);
bool GetIcon(const wxString& uti, wxIconLocation *iconLoc);
bool GetDescription(const wxString& uti, wxString *desc);
bool GetMimeTypes(const wxString& uti, wxArrayString& mimeTypes);
bool GetIcon(const wxString& uti, wxIconLocation *iconLoc);
bool GetDescription(const wxString& uti, wxString *desc);
+ bool GetApplication(const wxString& uti, wxString *command);
// Structure to represent file types
typedef struct FileTypeData
// Structure to represent file types
typedef struct FileTypeData
wxArrayString extensions;
wxArrayString mimeTypes;
wxIconLocation iconLoc;
wxArrayString extensions;
wxArrayString mimeTypes;
wxIconLocation iconLoc;
wxString description;
}
FileTypeInfo;
wxString description;
}
FileTypeInfo;
bool GetMimeTypes(wxArrayString& mimeTypes) const ;
bool GetIcon(wxIconLocation *iconLoc) const ;
bool GetDescription(wxString *desc) const ;
bool GetMimeTypes(wxArrayString& mimeTypes) const ;
bool GetIcon(wxIconLocation *iconLoc) const ;
bool GetDescription(wxString *desc) const ;
+ bool GetOpenCommand(wxString *openCmd, const wxFileType::MessageParameters& params) const;
// These functions are only stubs on Mac OS X
// These functions are only stubs on Mac OS X
- bool GetOpenCommand(wxString *openCmd, const wxFileType::MessageParameters& params) const;
bool GetPrintCommand(wxString *printCmd, const wxFileType::MessageParameters& params) const;
size_t GetAllCommands(wxArrayString *verbs, wxArrayString *commands, const wxFileType::MessageParameters& params) const;
bool SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt = TRUE);
bool GetPrintCommand(wxString *printCmd, const wxFileType::MessageParameters& params) const;
size_t GetAllCommands(wxArrayString *verbs, wxArrayString *commands, const wxFileType::MessageParameters& params) const;
bool SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt = TRUE);
- // Get a all the document type data in this bundle
+ // Also get the open command while we have the bundle
+ wxCFStringRef cfsAppPath(CFURLCopyFileSystemPath(appUrl, kCFURLPOSIXPathStyle));
+ m_utiMap[ uti ].application = cfsAppPath.AsString();
+
+ // Get all the document type data in this bundle
CFTypeRef docTypeData;
docTypeData = CFBundleGetValueForInfoDictionaryKey( bundle, docTypesKey );
CFTypeRef docTypeData;
docTypeData = CFBundleGetValueForInfoDictionaryKey( bundle, docTypesKey );
+bool wxMimeTypesManagerImpl::GetApplication(const wxString& uti, wxString *command)
+{
+ const UtiMap::const_iterator itr = m_utiMap.find( uti );
+
+ if( itr == m_utiMap.end() )
+ {
+ command->clear();
+ return false;
+ }
+
+ *command = itr->second.application;
+ return true;
+}
/////////////////////////////////////////////////////////////////////////////
// The remaining functionality has not yet been implemented for OS X
/////////////////////////////////////////////////////////////////////////////
// The remaining functionality has not yet been implemented for OS X
return m_manager->GetDescription( m_uti, desc );
}
return m_manager->GetDescription( m_uti, desc );
}
-bool wxFileTypeImpl::GetOpenCommand(wxString *WXUNUSED(openCmd), const wxFileType::MessageParameters& WXUNUSED(params)) const
+
+// Helper function for GetOpenCommand(): returns the string surrounded by
+// (singly) quotes if it contains spaces.
+wxString QuoteIfNecessary(const wxString& path)
+{
+ wxString result(path);
+
+ if ( path.find(' ') != wxString::npos )
+ {
+ result.insert(0, "'");
+ result.append("'");
+ }
+
+ return result;
+}
+
+} // anonymous namespace
+
+bool wxFileTypeImpl::GetOpenCommand(wxString *openCmd, const wxFileType::MessageParameters& params) const
+{
+ wxString application;
+ if ( !m_manager->GetApplication(m_uti, &application) )
+ return false;
+
+ *openCmd << QuoteIfNecessary(application)
+ << ' ' << QuoteIfNecessary(params.GetFileName());
+
+ return true;
}
bool wxFileTypeImpl::GetPrintCommand(wxString *WXUNUSED(printCmd), const wxFileType::MessageParameters& WXUNUSED(params)) const
}
bool wxFileTypeImpl::GetPrintCommand(wxString *WXUNUSED(printCmd), const wxFileType::MessageParameters& WXUNUSED(params)) const