Loading common/CMakeLists.txt +2 −0 Original line number Diff line number Diff line Loading @@ -172,6 +172,7 @@ set( COMMON_SRCS eda_dde.cpp eda_doc.cpp filter_reader.cpp # findkicadhelppath.cpp.notused deprecated, use searchhelpfilefullpath.cpp gestfich.cpp getrunningmicrosecs.cpp grid_tricks.cpp Loading @@ -189,6 +190,7 @@ set( COMMON_SRCS ptree.cpp reporter.cpp richio.cpp searchhelpfilefullpath.cpp search_stack.cpp selcolor.cpp systemdirsappend.cpp Loading common/basicframe.cpp +36 −29 Original line number Diff line number Diff line Loading @@ -271,6 +271,18 @@ wxConfigBase* EDA_BASE_FRAME::config() } const SEARCH_STACK& EDA_BASE_FRAME::sys_search() { return Kiface().KifaceSearch(); } wxString EDA_BASE_FRAME::help_name() { return Kiface().GetHelpFileName(); } void EDA_BASE_FRAME::PrintMsg( const wxString& text ) { SetStatusText( text ); Loading Loading @@ -327,33 +339,28 @@ wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type, void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event ) { wxString msg; const SEARCH_STACK& search = sys_search(); /* We have to get document for beginners, * or the the full specific doc * or the full specific doc * if event id is wxID_INDEX, we want the document for beginners. * else the specific doc file (its name is in Kiface().GetHelpFileName()) * The document for beginners is the same for all KiCad utilities */ if( event.GetId() == wxID_INDEX ) { // Temporarily change the help filename wxString tmp = Kiface().GetHelpFileName(); // Search for "getting_started_in_kicad.pdf" or "Getting_Started_in_KiCad.pdf" Kiface().SetHelpFileName( wxT( "getting_started_in_kicad.pdf" ) ); wxString helpFile = Kiface().GetHelpFile(); wxString helpFile = SearchHelpFileFullPath( search, wxT( "getting_started_in_kicad.pdf" ) ); if( !helpFile ) { // Try to find "Getting_Started_in_KiCad.pdf" Kiface().SetHelpFileName( wxT( "Getting_Started_in_KiCad.pdf" ) ); helpFile = Kiface().GetHelpFile(); } helpFile = SearchHelpFileFullPath( search, wxT( "Getting_Started_in_KiCad.pdf" ) ); if( !helpFile ) { msg.Printf( _( "Help file %s could not be found." ), GetChars( Kiface().GetHelpFileName() ) ); wxString msg = wxString::Format( _( "Help file '%s' could not be found." ), wxT( "getting_started_in_kicad.pdf" ) ); wxMessageBox( msg ); } else Loading @@ -361,36 +368,36 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event ) GetAssociatedDocument( this, helpFile ); } Kiface().SetHelpFileName( tmp ); return; } wxString base_name = help_name(); #if defined ONLINE_HELP_FILES_FORMAT_IS_HTML if( Kiface().GetHtmlHelpController() == NULL ) { Kiface().InitOnLineHelp(); } wxHtmlHelpController* hc = Pgm().GetHtmlHelpController(); wxString helpFile = SearchHelpFileFullPath( search, ); if( Kiface().GetHtmlHelpController() ) if( !!helpFile ) { Kiface().GetHtmlHelpController()->DisplayContents(); Kiface().GetHtmlHelpController()->Display( Kiface().GetHelpFileName() ); } else { msg.Printf( _( "Help file %s could not be found." ), GetChars( Kiface().GetHelpFileName() ) ); wxMessageBox( msg ); hc->UseConfig( Pgm().CommonSettings() ); hc->SetTitleFormat( wxT( "KiCad Help" ) ); hc->AddBook( helpFile ); } hc->DisplayContents(); hc->Display( helpFile ); #elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF wxString helpFile = Kiface().GetHelpFile(); wxString helpFile = SearchHelpFileFullPath( search, base_name ); if( !helpFile ) { msg.Printf( _( "Help file %s could not be found." ), GetChars( Kiface().GetHelpFileName() ) ); wxString msg = wxString::Format( _( "Help file '%s' could not be found." ), GetChars( base_name ) ); wxMessageBox( msg ); } else Loading common/eda_doc.cpp +10 −5 Original line number Diff line number Diff line Loading @@ -64,15 +64,19 @@ bool GetAssociatedDocument( wxFrame* aFrame, const wxPathList* aPaths) { wxString docname, fullfilename, file_ext; wxString docname, fullfilename; wxString msg; wxString command; bool success = false; // Is an internet url static const wxString url_header[3] = { wxT( "http:" ), wxT( "ftp:" ), wxT( "www." ) }; static const wxChar* url_header[3] = { wxT( "http:" ), wxT( "ftp:" ), wxT( "www." ) }; for( int ii = 0; ii < 3; ii++ ) for( unsigned ii = 0; ii < DIM(url_header); ii++ ) { if( aDocName.First( url_header[ii] ) == 0 ) //. seems an internet url { Loading Loading @@ -133,8 +137,9 @@ bool GetAssociatedDocument( wxFrame* aFrame, return false; } wxFileName CurrentFileName( fullfilename ); file_ext = CurrentFileName.GetExt(); wxFileName currentFileName( fullfilename ); wxString file_ext = currentFileName.GetExt(); if( file_ext == wxT( "pdf" ) ) { Loading common/findkicadhelppath.cpp.notused 0 → 100644 +126 −0 Original line number Diff line number Diff line #include <fctsys.h> #include <pgm_base.h> #include <macros.h> #include <gestfich.h> /** * Function FindKicadHelpPath * finds the absolute path for KiCad "help" (or "help/<language>") * Find path kicad/doc/help/xx/ or kicad/doc/help/: * from BinDir * else from environment variable KICAD * else from one of s_HelpPathList * typically c:/kicad/doc/help or /usr/share/kicad/help * or /usr/local/share/kicad/help * (must have kicad in path name) * * xx = iso639-1 language id (2 letters (generic) or 4 letters): * fr = french (or fr_FR) * en = English (or en_GB or en_US ...) * de = deutch * es = spanish * pt = portuguese (or pt_BR ...) * * default = en (if not found = fr) */ wxString FindKicadHelpPath() { bool found = false; wxString bin_dir = Pgm().GetExecutablePath(); if( bin_dir.Last() == '/' ) bin_dir.RemoveLast(); wxString fullPath = bin_dir.BeforeLast( '/' ); // cd .. fullPath += wxT( "/doc/help/" ); wxString localeString = Pgm().GetLocale()->GetCanonicalName(); wxString path_tmp = fullPath; #ifdef __WINDOWS__ path_tmp.MakeLower(); #endif if( path_tmp.Contains( wxT( "kicad" ) ) ) { if( wxDirExists( fullPath ) ) found = true; } // find kicad/help/ from environment variable KICAD if( !found && Pgm().IsKicadEnvVariableDefined() ) { fullPath = Pgm().GetKicadEnvVariable() + wxT( "/doc/help/" ); if( wxDirExists( fullPath ) ) found = true; } if( !found ) { // Possibilities online help const static wxChar* possibilities[] = { #ifdef __WINDOWS__ wxT( "c:/kicad/doc/help/" ), wxT( "d:/kicad/doc/help/" ), wxT( "c:/Program Files/kicad/doc/help/" ), wxT( "d:/Program Files/kicad/doc/help/" ), #else wxT( "/usr/share/doc/kicad/help/" ), wxT( "/usr/local/share/doc/kicad/help/" ), wxT( "/usr/local/kicad/doc/help/" ), // default install for "universal // tarballs" and build for a server // (new) wxT( "/usr/local/kicad/help/" ), // default install for "universal // tarballs" and build for a server // (old) #endif }; for( unsigned i=0; i<DIM(possibilities); ++i ) { fullPath = possibilities[i]; if( wxDirExists( fullPath ) ) { found = true; break; } } } if( found ) { wxString langFullPath = fullPath + localeString + UNIX_STRING_DIR_SEP; if( wxDirExists( langFullPath ) ) return langFullPath; langFullPath = fullPath + localeString.Left( 2 ) + UNIX_STRING_DIR_SEP; if( wxDirExists( langFullPath ) ) return langFullPath; langFullPath = fullPath + wxT( "en/" ); if( wxDirExists( langFullPath ) ) { return langFullPath; } else { langFullPath = fullPath + wxT( "fr/" ); if( wxDirExists( langFullPath ) ) return langFullPath; } return fullPath; } return wxEmptyString; } common/gestfich.cpp +86 −200 Original line number Diff line number Diff line Loading @@ -78,66 +78,6 @@ * like export KICAD=/my_path/kicad if /my_path/kicad is not a default path */ // Path list for online help static wxString s_HelpPathList[] = { #ifdef __WINDOWS__ wxT( "c:/kicad/doc/help/" ), wxT( "d:/kicad/doc/help/" ), wxT( "c:/Program Files/kicad/doc/help/" ), wxT( "d:/Program Files/kicad/doc/help/" ), #else wxT( "/usr/share/doc/kicad/help/" ), wxT( "/usr/local/share/doc/kicad/help/" ), wxT( "/usr/local/kicad/doc/help/" ), // default install for "universal // tarballs" and build for a server // (new) wxT( "/usr/local/kicad/help/" ), // default install for "universal // tarballs" and build for a server // (old) #endif wxT( "end_list" ) // End of list symbol, do not change }; // Path list for KiCad data files static wxString s_KicadDataPathList[] = { #ifdef __WINDOWS__ wxT( "c:/kicad/share/" ), wxT( "d:/kicad/share/" ), wxT( "c:/kicad/" ), wxT( "d:/kicad/" ), wxT( "c:/Program Files/kicad/share/" ), wxT( "d:/Program Files/kicad/share/" ), wxT( "c:/Program Files/kicad/" ), wxT( "d:/Program Files/kicad/" ), #else wxT( "/usr/share/kicad/" ), wxT( "/usr/local/share/kicad/" ), wxT( "/usr/local/kicad/share/" ), // default data path for "universal // tarballs" and build for a server // (new) wxT( "/usr/local/kicad/" ), // default data path for "universal // tarballs" and build for a server // (old) #endif wxT( "end_list" ) // End of list symbol, do not change }; // Path list for KiCad binary files static wxString s_KicadBinaryPathList[] = { #ifdef __WINDOWS__ wxT( "c:/kicad/bin/" ), wxT( "d:/kicad/bin/" ), wxT( "c:/Program Files/kicad/bin/" ), wxT( "d:/Program Files/kicad/bin/" ), #else wxT( "/usr/bin/" ), wxT( "/usr/local/bin/" ), wxT( "/usr/local/kicad/bin/" ), #endif wxT( "end_list" ) // End of list symbol, do not change }; wxString MakeReducedFileName( const wxString& fullfilename, const wxString& default_path, Loading Loading @@ -281,7 +221,7 @@ wxString EDA_FileSelector( const wxString& Title, defaultname, dotted_Ext, Mask, flag, /* open mode wxFD_OPEN, wxFD_SAVE .. */ flag, // open mode wxFD_OPEN, wxFD_SAVE .. Frame, Pos.x, Pos.y ); Loading @@ -292,123 +232,48 @@ wxString EDA_FileSelector( const wxString& Title, } wxString FindKicadHelpPath() { wxString FullPath, LangFullPath, tmp; wxString LocaleString; bool PathFound = false; /* find kicad/help/ */ tmp = Pgm().GetExecutablePath(); if( tmp.Last() == '/' ) tmp.RemoveLast(); FullPath = tmp.BeforeLast( '/' ); // cd .. FullPath += wxT( "/doc/help/" ); LocaleString = Pgm().GetLocale()->GetCanonicalName(); wxString path_tmp = FullPath; #ifdef __WINDOWS__ path_tmp.MakeLower(); #endif if( path_tmp.Contains( wxT( "kicad" ) ) ) { if( wxDirExists( FullPath ) ) PathFound = true; } /* find kicad/help/ from environment variable KICAD */ if( !PathFound && Pgm().IsKicadEnvVariableDefined() ) { FullPath = Pgm().GetKicadEnvVariable() + wxT( "/doc/help/" ); if( wxDirExists( FullPath ) ) PathFound = true; } /* find kicad/help/ from "s_HelpPathList" */ int ii = 0; while( !PathFound ) { FullPath = s_HelpPathList[ii++]; if( FullPath == wxT( "end_list" ) ) break; if( wxDirExists( FullPath ) ) PathFound = true; } if( PathFound ) { LangFullPath = FullPath + LocaleString + UNIX_STRING_DIR_SEP; if( wxDirExists( LangFullPath ) ) return LangFullPath; LangFullPath = FullPath + LocaleString.Left( 2 ) + UNIX_STRING_DIR_SEP; if( wxDirExists( LangFullPath ) ) return LangFullPath; LangFullPath = FullPath + wxT( "en/" ); if( wxDirExists( LangFullPath ) ) { return LangFullPath; } else { LangFullPath = FullPath + wxT( "fr/" ); if( wxDirExists( LangFullPath ) ) return LangFullPath; } return FullPath; } return wxEmptyString; } wxString FindKicadFile( const wxString& shortname ) { wxString FullFileName; // Test the presence of the file in the directory shortname of // the KiCad binary path. wxString fullFileName = Pgm().GetExecutablePath() + shortname; /* Test the presence of the file in the directory shortname of * the KiCad binary path. */ FullFileName = Pgm().GetExecutablePath() + shortname; if( wxFileExists( FullFileName ) ) return FullFileName; if( wxFileExists( fullFileName ) ) return fullFileName; /* Test the presence of the file in the directory shortname * defined by the environment variable KiCad. */ // Test the presence of the file in the directory shortname // defined by the environment variable KiCad. if( Pgm().IsKicadEnvVariableDefined() ) { FullFileName = Pgm().GetKicadEnvVariable() + shortname; fullFileName = Pgm().GetKicadEnvVariable() + shortname; if( wxFileExists( FullFileName ) ) return FullFileName; if( wxFileExists( fullFileName ) ) return fullFileName; } /* find binary file from default path list: * /usr/local/kicad/linux or c:/kicad/winexe * (see s_KicadDataPathList) */ int ii = 0; // find binary file from possibilities list: // /usr/local/kicad/linux or c:/kicad/winexe while( 1 ) { if( s_KicadBinaryPathList[ii] == wxT( "end_list" ) ) break; // Path list for KiCad binary files const static wxChar* possibilities[] = { #ifdef __WINDOWS__ wxT( "c:/kicad/bin/" ), wxT( "d:/kicad/bin/" ), wxT( "c:/Program Files/kicad/bin/" ), wxT( "d:/Program Files/kicad/bin/" ), #else wxT( "/usr/bin/" ), wxT( "/usr/local/bin/" ), wxT( "/usr/local/kicad/bin/" ), #endif }; FullFileName = s_KicadBinaryPathList[ii++] + shortname; for( unsigned i=0; i<DIM(possibilities); ++i ) { fullFileName = possibilities[i] + shortname; if( wxFileExists( FullFileName ) ) return FullFileName; if( wxFileExists( fullFileName ) ) return fullFileName; } return shortname; Loading @@ -418,13 +283,13 @@ wxString FindKicadFile( const wxString& shortname ) int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& param, wxProcess *callback ) { wxString FullFileName; wxString fullFileName; FullFileName = FindKicadFile( ExecFile ); fullFileName = FindKicadFile( ExecFile ); #ifdef __WXMAC__ if( wxFileExists( FullFileName ) || wxDir::Exists( FullFileName ) ) if( wxFileExists( fullFileName ) || wxDir::Exists( fullFileName ) ) { return ProcessExecute( Pgm().GetExecutablePath() + wxT( "/" ) + ExecFile + wxT( " " ) Loading @@ -435,16 +300,16 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para return ProcessExecute( wxT( "/usr/bin/open " ) + param, wxEXEC_ASYNC, callback ); } #else if( wxFileExists( FullFileName ) ) if( wxFileExists( fullFileName ) ) { if( !param.IsEmpty() ) FullFileName += wxT( " " ) + param; fullFileName += wxT( " " ) + param; return ProcessExecute( FullFileName, wxEXEC_ASYNC, callback ); return ProcessExecute( fullFileName, wxEXEC_ASYNC, callback ); } #endif wxString msg; msg.Printf( _( "Command <%s> could not found" ), GetChars( FullFileName ) ); msg.Printf( _( "Command <%s> could not found" ), GetChars( fullFileName ) ); DisplayError( frame, msg, 20 ); return -1; } Loading @@ -452,13 +317,13 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para wxString KicadDatasPath() { bool PathFound = false; bool found = false; wxString data_path; if( Pgm().IsKicadEnvVariableDefined() ) // Path defined by the KICAD environment variable. { data_path = Pgm().GetKicadEnvVariable(); PathFound = true; found = true; } else // Path of executables. { Loading @@ -485,33 +350,56 @@ wxString KicadDatasPath() if( wxDirExists( data_path ) ) { PathFound = true; found = true; } else if( wxDirExists( old_path ) ) { data_path = old_path; PathFound = true; found = true; } } } /* find KiCad from default path list: * /usr/local/kicad/ or c:/kicad/ * (see s_KicadDataPathList) */ int ii = 0; while( !PathFound ) if( !found ) { if( s_KicadDataPathList[ii] == wxT( "end_list" ) ) break; // find KiCad from possibilities list: // /usr/local/kicad/ or c:/kicad/ data_path = s_KicadDataPathList[ii++]; const static wxChar* possibilities[] = { #ifdef __WINDOWS__ wxT( "c:/kicad/share/" ), wxT( "d:/kicad/share/" ), wxT( "c:/kicad/" ), wxT( "d:/kicad/" ), wxT( "c:/Program Files/kicad/share/" ), wxT( "d:/Program Files/kicad/share/" ), wxT( "c:/Program Files/kicad/" ), wxT( "d:/Program Files/kicad/" ), #else wxT( "/usr/share/kicad/" ), wxT( "/usr/local/share/kicad/" ), wxT( "/usr/local/kicad/share/" ), // default data path for "universal // tarballs" and build for a server // (new) wxT( "/usr/local/kicad/" ), // default data path for "universal // tarballs" and build for a server // (old) #endif }; for( unsigned i=0; i<DIM(possibilities); ++i ) { data_path = possibilities[i]; if( wxDirExists( data_path ) ) PathFound = true; { found = true; break; } } } if( PathFound ) if( found ) { data_path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); Loading Loading @@ -569,38 +457,36 @@ bool OpenPDF( const wxString& file ) } success = false; command.Empty(); command.clear(); if( !success ) { #ifndef __WINDOWS__ #if !defined(__WINDOWS__) AddDelimiterString( filename ); /* here is a list of PDF viewers candidates */ const static wxString tries[] = // here is a list of PDF viewers candidates static const wxChar* tries[] = { wxT( "/usr/bin/evince" ), wxT( "/usr/bin/okular" ), wxT( "/usr/bin/gpdf" ), wxT( "/usr/bin/konqueror" ), wxT( "/usr/bin/kpdf" ), wxT( "/usr/bin/xpdf" ), wxT( "/usr/bin/open" ), // BSD and OSX file & dir opener wxT( "/usr/bin/xdg-open" ), // Freedesktop file & dir opener wxT( "" ), }; for( int ii = 0; ; ii++ ) for( unsigned ii = 0; ii<DIM(tries); ii++ ) { if( tries[ii].IsEmpty() ) break; if( wxFileExists( tries[ii] ) ) { command = tries[ii] + wxT( " " ) + filename; command = tries[ii]; command += wxT( ' ' ); command += filename; break; } } #endif } } Loading Loading
common/CMakeLists.txt +2 −0 Original line number Diff line number Diff line Loading @@ -172,6 +172,7 @@ set( COMMON_SRCS eda_dde.cpp eda_doc.cpp filter_reader.cpp # findkicadhelppath.cpp.notused deprecated, use searchhelpfilefullpath.cpp gestfich.cpp getrunningmicrosecs.cpp grid_tricks.cpp Loading @@ -189,6 +190,7 @@ set( COMMON_SRCS ptree.cpp reporter.cpp richio.cpp searchhelpfilefullpath.cpp search_stack.cpp selcolor.cpp systemdirsappend.cpp Loading
common/basicframe.cpp +36 −29 Original line number Diff line number Diff line Loading @@ -271,6 +271,18 @@ wxConfigBase* EDA_BASE_FRAME::config() } const SEARCH_STACK& EDA_BASE_FRAME::sys_search() { return Kiface().KifaceSearch(); } wxString EDA_BASE_FRAME::help_name() { return Kiface().GetHelpFileName(); } void EDA_BASE_FRAME::PrintMsg( const wxString& text ) { SetStatusText( text ); Loading Loading @@ -327,33 +339,28 @@ wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type, void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event ) { wxString msg; const SEARCH_STACK& search = sys_search(); /* We have to get document for beginners, * or the the full specific doc * or the full specific doc * if event id is wxID_INDEX, we want the document for beginners. * else the specific doc file (its name is in Kiface().GetHelpFileName()) * The document for beginners is the same for all KiCad utilities */ if( event.GetId() == wxID_INDEX ) { // Temporarily change the help filename wxString tmp = Kiface().GetHelpFileName(); // Search for "getting_started_in_kicad.pdf" or "Getting_Started_in_KiCad.pdf" Kiface().SetHelpFileName( wxT( "getting_started_in_kicad.pdf" ) ); wxString helpFile = Kiface().GetHelpFile(); wxString helpFile = SearchHelpFileFullPath( search, wxT( "getting_started_in_kicad.pdf" ) ); if( !helpFile ) { // Try to find "Getting_Started_in_KiCad.pdf" Kiface().SetHelpFileName( wxT( "Getting_Started_in_KiCad.pdf" ) ); helpFile = Kiface().GetHelpFile(); } helpFile = SearchHelpFileFullPath( search, wxT( "Getting_Started_in_KiCad.pdf" ) ); if( !helpFile ) { msg.Printf( _( "Help file %s could not be found." ), GetChars( Kiface().GetHelpFileName() ) ); wxString msg = wxString::Format( _( "Help file '%s' could not be found." ), wxT( "getting_started_in_kicad.pdf" ) ); wxMessageBox( msg ); } else Loading @@ -361,36 +368,36 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event ) GetAssociatedDocument( this, helpFile ); } Kiface().SetHelpFileName( tmp ); return; } wxString base_name = help_name(); #if defined ONLINE_HELP_FILES_FORMAT_IS_HTML if( Kiface().GetHtmlHelpController() == NULL ) { Kiface().InitOnLineHelp(); } wxHtmlHelpController* hc = Pgm().GetHtmlHelpController(); wxString helpFile = SearchHelpFileFullPath( search, ); if( Kiface().GetHtmlHelpController() ) if( !!helpFile ) { Kiface().GetHtmlHelpController()->DisplayContents(); Kiface().GetHtmlHelpController()->Display( Kiface().GetHelpFileName() ); } else { msg.Printf( _( "Help file %s could not be found." ), GetChars( Kiface().GetHelpFileName() ) ); wxMessageBox( msg ); hc->UseConfig( Pgm().CommonSettings() ); hc->SetTitleFormat( wxT( "KiCad Help" ) ); hc->AddBook( helpFile ); } hc->DisplayContents(); hc->Display( helpFile ); #elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF wxString helpFile = Kiface().GetHelpFile(); wxString helpFile = SearchHelpFileFullPath( search, base_name ); if( !helpFile ) { msg.Printf( _( "Help file %s could not be found." ), GetChars( Kiface().GetHelpFileName() ) ); wxString msg = wxString::Format( _( "Help file '%s' could not be found." ), GetChars( base_name ) ); wxMessageBox( msg ); } else Loading
common/eda_doc.cpp +10 −5 Original line number Diff line number Diff line Loading @@ -64,15 +64,19 @@ bool GetAssociatedDocument( wxFrame* aFrame, const wxPathList* aPaths) { wxString docname, fullfilename, file_ext; wxString docname, fullfilename; wxString msg; wxString command; bool success = false; // Is an internet url static const wxString url_header[3] = { wxT( "http:" ), wxT( "ftp:" ), wxT( "www." ) }; static const wxChar* url_header[3] = { wxT( "http:" ), wxT( "ftp:" ), wxT( "www." ) }; for( int ii = 0; ii < 3; ii++ ) for( unsigned ii = 0; ii < DIM(url_header); ii++ ) { if( aDocName.First( url_header[ii] ) == 0 ) //. seems an internet url { Loading Loading @@ -133,8 +137,9 @@ bool GetAssociatedDocument( wxFrame* aFrame, return false; } wxFileName CurrentFileName( fullfilename ); file_ext = CurrentFileName.GetExt(); wxFileName currentFileName( fullfilename ); wxString file_ext = currentFileName.GetExt(); if( file_ext == wxT( "pdf" ) ) { Loading
common/findkicadhelppath.cpp.notused 0 → 100644 +126 −0 Original line number Diff line number Diff line #include <fctsys.h> #include <pgm_base.h> #include <macros.h> #include <gestfich.h> /** * Function FindKicadHelpPath * finds the absolute path for KiCad "help" (or "help/<language>") * Find path kicad/doc/help/xx/ or kicad/doc/help/: * from BinDir * else from environment variable KICAD * else from one of s_HelpPathList * typically c:/kicad/doc/help or /usr/share/kicad/help * or /usr/local/share/kicad/help * (must have kicad in path name) * * xx = iso639-1 language id (2 letters (generic) or 4 letters): * fr = french (or fr_FR) * en = English (or en_GB or en_US ...) * de = deutch * es = spanish * pt = portuguese (or pt_BR ...) * * default = en (if not found = fr) */ wxString FindKicadHelpPath() { bool found = false; wxString bin_dir = Pgm().GetExecutablePath(); if( bin_dir.Last() == '/' ) bin_dir.RemoveLast(); wxString fullPath = bin_dir.BeforeLast( '/' ); // cd .. fullPath += wxT( "/doc/help/" ); wxString localeString = Pgm().GetLocale()->GetCanonicalName(); wxString path_tmp = fullPath; #ifdef __WINDOWS__ path_tmp.MakeLower(); #endif if( path_tmp.Contains( wxT( "kicad" ) ) ) { if( wxDirExists( fullPath ) ) found = true; } // find kicad/help/ from environment variable KICAD if( !found && Pgm().IsKicadEnvVariableDefined() ) { fullPath = Pgm().GetKicadEnvVariable() + wxT( "/doc/help/" ); if( wxDirExists( fullPath ) ) found = true; } if( !found ) { // Possibilities online help const static wxChar* possibilities[] = { #ifdef __WINDOWS__ wxT( "c:/kicad/doc/help/" ), wxT( "d:/kicad/doc/help/" ), wxT( "c:/Program Files/kicad/doc/help/" ), wxT( "d:/Program Files/kicad/doc/help/" ), #else wxT( "/usr/share/doc/kicad/help/" ), wxT( "/usr/local/share/doc/kicad/help/" ), wxT( "/usr/local/kicad/doc/help/" ), // default install for "universal // tarballs" and build for a server // (new) wxT( "/usr/local/kicad/help/" ), // default install for "universal // tarballs" and build for a server // (old) #endif }; for( unsigned i=0; i<DIM(possibilities); ++i ) { fullPath = possibilities[i]; if( wxDirExists( fullPath ) ) { found = true; break; } } } if( found ) { wxString langFullPath = fullPath + localeString + UNIX_STRING_DIR_SEP; if( wxDirExists( langFullPath ) ) return langFullPath; langFullPath = fullPath + localeString.Left( 2 ) + UNIX_STRING_DIR_SEP; if( wxDirExists( langFullPath ) ) return langFullPath; langFullPath = fullPath + wxT( "en/" ); if( wxDirExists( langFullPath ) ) { return langFullPath; } else { langFullPath = fullPath + wxT( "fr/" ); if( wxDirExists( langFullPath ) ) return langFullPath; } return fullPath; } return wxEmptyString; }
common/gestfich.cpp +86 −200 Original line number Diff line number Diff line Loading @@ -78,66 +78,6 @@ * like export KICAD=/my_path/kicad if /my_path/kicad is not a default path */ // Path list for online help static wxString s_HelpPathList[] = { #ifdef __WINDOWS__ wxT( "c:/kicad/doc/help/" ), wxT( "d:/kicad/doc/help/" ), wxT( "c:/Program Files/kicad/doc/help/" ), wxT( "d:/Program Files/kicad/doc/help/" ), #else wxT( "/usr/share/doc/kicad/help/" ), wxT( "/usr/local/share/doc/kicad/help/" ), wxT( "/usr/local/kicad/doc/help/" ), // default install for "universal // tarballs" and build for a server // (new) wxT( "/usr/local/kicad/help/" ), // default install for "universal // tarballs" and build for a server // (old) #endif wxT( "end_list" ) // End of list symbol, do not change }; // Path list for KiCad data files static wxString s_KicadDataPathList[] = { #ifdef __WINDOWS__ wxT( "c:/kicad/share/" ), wxT( "d:/kicad/share/" ), wxT( "c:/kicad/" ), wxT( "d:/kicad/" ), wxT( "c:/Program Files/kicad/share/" ), wxT( "d:/Program Files/kicad/share/" ), wxT( "c:/Program Files/kicad/" ), wxT( "d:/Program Files/kicad/" ), #else wxT( "/usr/share/kicad/" ), wxT( "/usr/local/share/kicad/" ), wxT( "/usr/local/kicad/share/" ), // default data path for "universal // tarballs" and build for a server // (new) wxT( "/usr/local/kicad/" ), // default data path for "universal // tarballs" and build for a server // (old) #endif wxT( "end_list" ) // End of list symbol, do not change }; // Path list for KiCad binary files static wxString s_KicadBinaryPathList[] = { #ifdef __WINDOWS__ wxT( "c:/kicad/bin/" ), wxT( "d:/kicad/bin/" ), wxT( "c:/Program Files/kicad/bin/" ), wxT( "d:/Program Files/kicad/bin/" ), #else wxT( "/usr/bin/" ), wxT( "/usr/local/bin/" ), wxT( "/usr/local/kicad/bin/" ), #endif wxT( "end_list" ) // End of list symbol, do not change }; wxString MakeReducedFileName( const wxString& fullfilename, const wxString& default_path, Loading Loading @@ -281,7 +221,7 @@ wxString EDA_FileSelector( const wxString& Title, defaultname, dotted_Ext, Mask, flag, /* open mode wxFD_OPEN, wxFD_SAVE .. */ flag, // open mode wxFD_OPEN, wxFD_SAVE .. Frame, Pos.x, Pos.y ); Loading @@ -292,123 +232,48 @@ wxString EDA_FileSelector( const wxString& Title, } wxString FindKicadHelpPath() { wxString FullPath, LangFullPath, tmp; wxString LocaleString; bool PathFound = false; /* find kicad/help/ */ tmp = Pgm().GetExecutablePath(); if( tmp.Last() == '/' ) tmp.RemoveLast(); FullPath = tmp.BeforeLast( '/' ); // cd .. FullPath += wxT( "/doc/help/" ); LocaleString = Pgm().GetLocale()->GetCanonicalName(); wxString path_tmp = FullPath; #ifdef __WINDOWS__ path_tmp.MakeLower(); #endif if( path_tmp.Contains( wxT( "kicad" ) ) ) { if( wxDirExists( FullPath ) ) PathFound = true; } /* find kicad/help/ from environment variable KICAD */ if( !PathFound && Pgm().IsKicadEnvVariableDefined() ) { FullPath = Pgm().GetKicadEnvVariable() + wxT( "/doc/help/" ); if( wxDirExists( FullPath ) ) PathFound = true; } /* find kicad/help/ from "s_HelpPathList" */ int ii = 0; while( !PathFound ) { FullPath = s_HelpPathList[ii++]; if( FullPath == wxT( "end_list" ) ) break; if( wxDirExists( FullPath ) ) PathFound = true; } if( PathFound ) { LangFullPath = FullPath + LocaleString + UNIX_STRING_DIR_SEP; if( wxDirExists( LangFullPath ) ) return LangFullPath; LangFullPath = FullPath + LocaleString.Left( 2 ) + UNIX_STRING_DIR_SEP; if( wxDirExists( LangFullPath ) ) return LangFullPath; LangFullPath = FullPath + wxT( "en/" ); if( wxDirExists( LangFullPath ) ) { return LangFullPath; } else { LangFullPath = FullPath + wxT( "fr/" ); if( wxDirExists( LangFullPath ) ) return LangFullPath; } return FullPath; } return wxEmptyString; } wxString FindKicadFile( const wxString& shortname ) { wxString FullFileName; // Test the presence of the file in the directory shortname of // the KiCad binary path. wxString fullFileName = Pgm().GetExecutablePath() + shortname; /* Test the presence of the file in the directory shortname of * the KiCad binary path. */ FullFileName = Pgm().GetExecutablePath() + shortname; if( wxFileExists( FullFileName ) ) return FullFileName; if( wxFileExists( fullFileName ) ) return fullFileName; /* Test the presence of the file in the directory shortname * defined by the environment variable KiCad. */ // Test the presence of the file in the directory shortname // defined by the environment variable KiCad. if( Pgm().IsKicadEnvVariableDefined() ) { FullFileName = Pgm().GetKicadEnvVariable() + shortname; fullFileName = Pgm().GetKicadEnvVariable() + shortname; if( wxFileExists( FullFileName ) ) return FullFileName; if( wxFileExists( fullFileName ) ) return fullFileName; } /* find binary file from default path list: * /usr/local/kicad/linux or c:/kicad/winexe * (see s_KicadDataPathList) */ int ii = 0; // find binary file from possibilities list: // /usr/local/kicad/linux or c:/kicad/winexe while( 1 ) { if( s_KicadBinaryPathList[ii] == wxT( "end_list" ) ) break; // Path list for KiCad binary files const static wxChar* possibilities[] = { #ifdef __WINDOWS__ wxT( "c:/kicad/bin/" ), wxT( "d:/kicad/bin/" ), wxT( "c:/Program Files/kicad/bin/" ), wxT( "d:/Program Files/kicad/bin/" ), #else wxT( "/usr/bin/" ), wxT( "/usr/local/bin/" ), wxT( "/usr/local/kicad/bin/" ), #endif }; FullFileName = s_KicadBinaryPathList[ii++] + shortname; for( unsigned i=0; i<DIM(possibilities); ++i ) { fullFileName = possibilities[i] + shortname; if( wxFileExists( FullFileName ) ) return FullFileName; if( wxFileExists( fullFileName ) ) return fullFileName; } return shortname; Loading @@ -418,13 +283,13 @@ wxString FindKicadFile( const wxString& shortname ) int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& param, wxProcess *callback ) { wxString FullFileName; wxString fullFileName; FullFileName = FindKicadFile( ExecFile ); fullFileName = FindKicadFile( ExecFile ); #ifdef __WXMAC__ if( wxFileExists( FullFileName ) || wxDir::Exists( FullFileName ) ) if( wxFileExists( fullFileName ) || wxDir::Exists( fullFileName ) ) { return ProcessExecute( Pgm().GetExecutablePath() + wxT( "/" ) + ExecFile + wxT( " " ) Loading @@ -435,16 +300,16 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para return ProcessExecute( wxT( "/usr/bin/open " ) + param, wxEXEC_ASYNC, callback ); } #else if( wxFileExists( FullFileName ) ) if( wxFileExists( fullFileName ) ) { if( !param.IsEmpty() ) FullFileName += wxT( " " ) + param; fullFileName += wxT( " " ) + param; return ProcessExecute( FullFileName, wxEXEC_ASYNC, callback ); return ProcessExecute( fullFileName, wxEXEC_ASYNC, callback ); } #endif wxString msg; msg.Printf( _( "Command <%s> could not found" ), GetChars( FullFileName ) ); msg.Printf( _( "Command <%s> could not found" ), GetChars( fullFileName ) ); DisplayError( frame, msg, 20 ); return -1; } Loading @@ -452,13 +317,13 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para wxString KicadDatasPath() { bool PathFound = false; bool found = false; wxString data_path; if( Pgm().IsKicadEnvVariableDefined() ) // Path defined by the KICAD environment variable. { data_path = Pgm().GetKicadEnvVariable(); PathFound = true; found = true; } else // Path of executables. { Loading @@ -485,33 +350,56 @@ wxString KicadDatasPath() if( wxDirExists( data_path ) ) { PathFound = true; found = true; } else if( wxDirExists( old_path ) ) { data_path = old_path; PathFound = true; found = true; } } } /* find KiCad from default path list: * /usr/local/kicad/ or c:/kicad/ * (see s_KicadDataPathList) */ int ii = 0; while( !PathFound ) if( !found ) { if( s_KicadDataPathList[ii] == wxT( "end_list" ) ) break; // find KiCad from possibilities list: // /usr/local/kicad/ or c:/kicad/ data_path = s_KicadDataPathList[ii++]; const static wxChar* possibilities[] = { #ifdef __WINDOWS__ wxT( "c:/kicad/share/" ), wxT( "d:/kicad/share/" ), wxT( "c:/kicad/" ), wxT( "d:/kicad/" ), wxT( "c:/Program Files/kicad/share/" ), wxT( "d:/Program Files/kicad/share/" ), wxT( "c:/Program Files/kicad/" ), wxT( "d:/Program Files/kicad/" ), #else wxT( "/usr/share/kicad/" ), wxT( "/usr/local/share/kicad/" ), wxT( "/usr/local/kicad/share/" ), // default data path for "universal // tarballs" and build for a server // (new) wxT( "/usr/local/kicad/" ), // default data path for "universal // tarballs" and build for a server // (old) #endif }; for( unsigned i=0; i<DIM(possibilities); ++i ) { data_path = possibilities[i]; if( wxDirExists( data_path ) ) PathFound = true; { found = true; break; } } } if( PathFound ) if( found ) { data_path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); Loading Loading @@ -569,38 +457,36 @@ bool OpenPDF( const wxString& file ) } success = false; command.Empty(); command.clear(); if( !success ) { #ifndef __WINDOWS__ #if !defined(__WINDOWS__) AddDelimiterString( filename ); /* here is a list of PDF viewers candidates */ const static wxString tries[] = // here is a list of PDF viewers candidates static const wxChar* tries[] = { wxT( "/usr/bin/evince" ), wxT( "/usr/bin/okular" ), wxT( "/usr/bin/gpdf" ), wxT( "/usr/bin/konqueror" ), wxT( "/usr/bin/kpdf" ), wxT( "/usr/bin/xpdf" ), wxT( "/usr/bin/open" ), // BSD and OSX file & dir opener wxT( "/usr/bin/xdg-open" ), // Freedesktop file & dir opener wxT( "" ), }; for( int ii = 0; ; ii++ ) for( unsigned ii = 0; ii<DIM(tries); ii++ ) { if( tries[ii].IsEmpty() ) break; if( wxFileExists( tries[ii] ) ) { command = tries[ii] + wxT( " " ) + filename; command = tries[ii]; command += wxT( ' ' ); command += filename; break; } } #endif } } Loading