Add wxFileType::GetExpandedCommand()

This new method allows to get the command expanded with the given file name
for commands other than "Open" and "Print".

Closes #17367.
This commit is contained in:
Troels Knakkergaard
2016-03-05 03:09:59 +01:00
committed by Vadim Zeitlin
parent 6ea8ba1e9c
commit cda7209101
10 changed files with 69 additions and 28 deletions

View File

@@ -50,6 +50,7 @@
#include "wx/sizer.h"
#endif
#include "wx/filename.h"
#include "wx/txtstrm.h"
#include "wx/numdlg.h"
#include "wx/textdlg.h"
@@ -1078,7 +1079,7 @@ void MyFrame::OnFileExec(wxCommandEvent& WXUNUSED(event))
if ( !AskUserForFileName() )
return;
wxString ext = gs_lastFile.AfterLast(wxT('.'));
wxString ext = wxFileName(gs_lastFile).GetExt();
wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(ext);
if ( !ft )
{
@@ -1088,8 +1089,15 @@ void MyFrame::OnFileExec(wxCommandEvent& WXUNUSED(event))
}
wxString cmd;
bool ok = ft->GetOpenCommand(&cmd,
wxFileType::MessageParameters(gs_lastFile));
bool ok = false;
const wxFileType::MessageParameters params(gs_lastFile);
#ifdef __WXMSW__
// try editor, for instance Notepad if extension is .xml
cmd = ft->GetExpandedCommand(wxT("edit"), params);
ok = !cmd.empty();
#endif
if (!ok) // else try viewer
ok = ft->GetOpenCommand(&cmd, params);
delete ft;
if ( !ok )
{