|
|
|
@ -54,21 +54,15 @@ void WinEDA_App::WritePdfBrowserInfos() |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Mime type extensions
|
|
|
|
// Mime type extensions (PDF files are not considered here)
|
|
|
|
static wxMimeTypesManager* mimeDatabase; |
|
|
|
static const wxFileTypeInfo EDAfallbacks[] = |
|
|
|
{ |
|
|
|
wxFileTypeInfo( wxT( "text/pdf" ), |
|
|
|
wxT( "xpdf %s" ), |
|
|
|
wxT( "xpdf -p %s" ), |
|
|
|
wxT( "pdf document (from Kicad)" ), |
|
|
|
wxT( "pdf" ), wxT( "PDF" ), NULL ), |
|
|
|
|
|
|
|
wxFileTypeInfo( wxT( "text/html" ), |
|
|
|
wxT( "wxhtml %s" ), |
|
|
|
wxT( "wxhtml %s" ), |
|
|
|
wxT( "html document (from Kicad)" ), |
|
|
|
wxT( "htm" ), wxT( "html" ), NULL ), |
|
|
|
wxT( "htm" ), wxT( "html" ),NULL ), |
|
|
|
|
|
|
|
wxFileTypeInfo( wxT( "application/sch" ), |
|
|
|
wxT( "eeschema %s" ), |
|
|
|
@ -95,7 +89,7 @@ bool GetAssociatedDocument( wxFrame* frame, const wxString& LibPath, |
|
|
|
* if DocName is starting by http: or ftp: or www. the default internet browser is launched |
|
|
|
*/ |
|
|
|
{ |
|
|
|
wxString docpath, fullfilename; |
|
|
|
wxString docpath, fullfilename, file_ext; |
|
|
|
wxString Line; |
|
|
|
wxString command; |
|
|
|
bool success = FALSE; |
|
|
|
@ -158,22 +152,27 @@ bool GetAssociatedDocument( wxFrame* frame, const wxString& LibPath, |
|
|
|
return FALSE; |
|
|
|
} |
|
|
|
|
|
|
|
/* Try to launch some browser (usefull under linux) */ |
|
|
|
g_EDA_Appl->ReadPdfBrowserInfos(); |
|
|
|
if( g_EDA_Appl->m_PdfBrowserIsDefault ) |
|
|
|
wxFileName CurrentFileName( fullfilename ); |
|
|
|
file_ext = CurrentFileName.GetExt(); |
|
|
|
|
|
|
|
if( file_ext == wxT( "pdf" ) ) |
|
|
|
{ |
|
|
|
success = OpenPDF( fullfilename ); |
|
|
|
return success; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Try to launch some browser (usefull under linux) */ |
|
|
|
wxFileType* filetype; |
|
|
|
wxFileName CurrentFileName( fullfilename ); |
|
|
|
|
|
|
|
wxString ext, type; |
|
|
|
ext = CurrentFileName.GetExt(); |
|
|
|
filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( ext ); |
|
|
|
wxString type; |
|
|
|
filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( file_ext ); |
|
|
|
|
|
|
|
if( !filetype ) // 2ieme tentative
|
|
|
|
{ |
|
|
|
mimeDatabase = new wxMimeTypesManager; |
|
|
|
mimeDatabase->AddFallbacks( EDAfallbacks ); |
|
|
|
filetype = mimeDatabase->GetFileTypeFromExtension( ext ); |
|
|
|
filetype = mimeDatabase->GetFileTypeFromExtension( file_ext ); |
|
|
|
delete mimeDatabase; |
|
|
|
mimeDatabase = NULL; |
|
|
|
} |
|
|
|
@ -185,57 +184,15 @@ bool GetAssociatedDocument( wxFrame* frame, const wxString& LibPath, |
|
|
|
success = filetype->GetOpenCommand( &command, params ); |
|
|
|
delete filetype; |
|
|
|
if( success ) |
|
|
|
ProcessExecute( command ); |
|
|
|
success = ProcessExecute( command ); |
|
|
|
} |
|
|
|
|
|
|
|
if( !success ) |
|
|
|
{ |
|
|
|
#ifdef __LINUX__
|
|
|
|
if( ext == wxT( "pdf" ) ) |
|
|
|
{ |
|
|
|
success = TRUE; command.Empty(); |
|
|
|
if( wxFileExists( wxT( "/usr/bin/kpdf" ) ) ) |
|
|
|
command = wxT( "kpdf " ) + fullfilename; |
|
|
|
else if( wxFileExists( wxT( "/usr/bin/konqueror" ) ) ) |
|
|
|
command = wxT( "konqueror " ) + fullfilename; |
|
|
|
else if( wxFileExists( wxT( "/usr/bin/gpdf" ) ) ) |
|
|
|
command = wxT( "gpdf " ) + fullfilename; |
|
|
|
if( wxFileExists( wxT( "/usr/bin/xpdf" ) ) ) |
|
|
|
command = wxT( "xpdf " ) + fullfilename; |
|
|
|
if( command.IsEmpty() ) // not started
|
|
|
|
{ |
|
|
|
DisplayError( frame, |
|
|
|
_( " Cannot find the PDF viewer (kpdf, gpdf, konqueror or xpdf) in /usr/bin/" ) ); |
|
|
|
success = FALSE; |
|
|
|
} |
|
|
|
else |
|
|
|
ProcessExecute( command ); |
|
|
|
} |
|
|
|
else |
|
|
|
#endif
|
|
|
|
{ |
|
|
|
Line.Printf( _( "Unknown MIME type for Doc File [%s] (%s)" ), |
|
|
|
fullfilename.GetData(), ext.GetData() ); |
|
|
|
DisplayError( frame, Line ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
command = g_EDA_Appl->m_PdfBrowser; |
|
|
|
if( wxFileExists( command ) ) |
|
|
|
{ |
|
|
|
success = TRUE; |
|
|
|
AddDelimiterString( fullfilename ); |
|
|
|
command += wxT( " " ) + fullfilename; |
|
|
|
ProcessExecute( command ); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Line.Printf( _( "Cannot find Pdf viewer %s" ), command.GetData() ); |
|
|
|
Line.Printf( _( "Unknown MIME type for Doc File [%s]" ), |
|
|
|
fullfilename.GetData() ); |
|
|
|
DisplayError( frame, Line ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return success; |
|
|
|
} |
|
|
|
|