35 #include <wx/mimetype.h> 36 #include <wx/tokenzr.h> 37 #include <wx/filename.h> 46 wxString browser =
m_common_settings->Read( wxT(
"PdfBrowserName" ), wxEmptyString );
68 wxFileTypeInfo( wxT(
"text/html" ),
71 wxT(
"html document (from KiCad)" ),
73 wxT(
"html" ),wxNullPtr ),
75 wxFileTypeInfo( wxT(
"application/sch" ),
77 wxT(
"eeschema -p %s" ),
78 wxT(
"sch document (from KiCad)" ),
80 wxT(
"SCH" ), wxNullPtr ),
88 const wxString& aDocName,
89 const wxPathList* aPaths)
92 wxString docname, fullfilename;
98 static const wxChar* url_header[] = {
106 for(
unsigned ii = 0; ii <
DIM(url_header); ii++ )
108 if( aDocName.First( url_header[ii] ) == 0 )
110 wxURI uri( aDocName );
111 wxLaunchDefaultBrowser( uri.BuildURI() );
126 if( wxIsAbsolutePath( aDocName ) || aPaths == NULL)
127 fullfilename = aDocName;
132 else if( wxFileName::FileExists( aDocName ) )
133 fullfilename = aDocName;
136 fullfilename = aPaths->FindValidPath( aDocName );
139 wxString mask( wxT(
"*" ) ), extension;
143 extension = wxT(
".*" );
146 if( wxIsWild( fullfilename ) )
149 wxPathOnly( fullfilename ),
157 if( fullfilename.IsEmpty() )
161 if( !wxFileExists( fullfilename ) )
163 msg.Printf( _(
"Doc File \"%s\" not found" ),
GetChars( aDocName ) );
168 wxFileName currentFileName( fullfilename );
170 wxString file_ext = currentFileName.GetExt();
172 if( file_ext.Lower() == wxT(
"pdf" ) )
174 success =
OpenPDF( fullfilename );
179 wxFileType* filetype;
182 filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( file_ext );
188 filetype =
mimeDatabase->GetFileTypeFromExtension( file_ext );
195 wxFileType::MessageParameters params( fullfilename, type );
197 success = filetype->GetOpenCommand( &command, params );
206 msg.Printf( _(
"Unknown MIME type for doc file \"%s\"" ),
GetChars( fullfilename ) );
214 int KeyWordOk(
const wxString& KeyList,
const wxString& Database )
216 wxString KeysCopy, DataList;
218 if( KeyList.IsEmpty() )
221 KeysCopy = KeyList; KeysCopy.MakeUpper();
222 DataList = Database; DataList.MakeUpper();
224 wxStringTokenizer Token( KeysCopy, wxT(
" \n\r" ) );
226 while( Token.HasMoreTokens() )
228 wxString Key = Token.GetNextToken();
231 wxStringTokenizer Data( DataList, wxT(
" \n\r" ) );
233 while( Data.HasMoreTokens() )
235 wxString word = Data.GetNextToken();
#define DIM(x)
of elements in an array
int ProcessExecute(const wxString &aCommandLine, int aFlags, wxProcess *callback)
Function ProcessExecute runs a child process.
#define WIN_STRING_DIR_SEP
This file is part of the common library TODO brief description.
This file is part of the common library.
#define UNIX_STRING_DIR_SEP
VTBL_ENTRY const wxString & GetPdfBrowserName() const
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, const wxPathList *aPaths)
Function GetAssociatedDocument open a document (file) with the suitable browser.
VTBL_ENTRY void WritePdfBrowserInfos()
Function WritePdfBrowserInfos saves the PDF browser choice to the common configuration.
static wxMimeTypesManager * mimeDatabase
bool m_use_system_pdf_browser
true to use the selected PDF browser, if exists, or false to use the default
This file contains miscellaneous commonly used macros and functions.
static const wxFileTypeInfo EDAfallbacks[]
int KeyWordOk(const wxString &KeyList, const wxString &Database)
Function KeyWordOk searches aKeyList for any words found in aDatabase.
VTBL_ENTRY void SetPdfBrowserName(const wxString &aFileName)
wxString EDA_FILE_SELECTOR(const wxString &aTitle, const wxString &aPath, const wxString &aFileName, const wxString &aExtension, const wxString &aWildcard, wxWindow *aParent, int aStyle, const bool aKeepWorkingDirectory, const wxPoint &aPosition, wxString *aMruPath)
Function EDA_FILE_SELECTOR.
wxConfigBase * m_common_settings
Configuration settings common to all KiCad program modules, like as in $HOME/.kicad_common.
VTBL_ENTRY void ReadPdfBrowserInfos()
Function ReadPdfBrowserInfos reads the PDF browser choice from the common configuration.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
bool OpenPDF(const wxString &file)
Function OpenPDF run the PDF viewer and display a PDF file.