Loading kicad/dialogs/dialog_template_selector.cpp +15 −10 Original line number Original line Diff line number Diff line Loading @@ -191,23 +191,28 @@ void DIALOG_TEMPLATE_SELECTOR::AddPage( const wxString& aTitle, wxFileName& aPat // Get a list of files under the template path to include as choices... // Get a list of files under the template path to include as choices... wxArrayString files; wxArrayString files; wxDir dir, sub; wxDir dir; if ( dir.Open( aPath.GetPath() ) ) wxString path = aPath.GetFullPath(); // caller ensures this ends with file separator. if( dir.Open( path ) ) { { wxString filename; wxDir sub_dir; bool cont = dir.GetFirst( &filename, wxEmptyString, wxDIR_FILES | wxDIR_DIRS ); wxString sub_name; bool cont = dir.GetFirst( &sub_name, wxEmptyString, wxDIR_DIRS ); while( cont ) while( cont ) { { if( sub.Open( aPath.GetPathWithSep() + filename ) ) wxString sub_full = path + sub_name; if( sub_dir.Open( sub_full ) ) { { files.Add( filename ); files.Add( sub_name ); PROJECT_TEMPLATE* pt = new PROJECT_TEMPLATE( aPath.GetPathWithSep() + filename ); PROJECT_TEMPLATE* pt = new PROJECT_TEMPLATE( sub_full ); AddTemplate( m_notebook->GetPageCount() - 1, pt ); AddTemplate( m_notebook->GetPageCount() - 1, pt ); } } cont = dir.GetNext( &filename ); cont = dir.GetNext( &sub_name ); } } } } } } kicad/prjconfig.cpp +15 −7 Original line number Original line Diff line number Diff line Loading @@ -78,11 +78,12 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, boo { { wxString kicadEnv; wxString kicadEnv; wxGetEnv( wxT( "KICAD"), &kicadEnv ); wxGetEnv( wxT( "KICAD"), &kicadEnv ); templatePath = kicadEnv + SEP() + wxT("template") + SEP(); templatePath = kicadEnv + SEP() + wxT("template") + SEP(); } } else else { { wxFileName templatePath = wxPathOnly(wxStandardPaths::Get().GetExecutablePath()) + templatePath = wxPathOnly(wxStandardPaths::Get().GetExecutablePath()) + SEP() + wxT( ".." ) + SEP() + wxT( "share" ) + SEP() + wxT( "template" ) + SEP(); SEP() + wxT( ".." ) + SEP() + wxT( "share" ) + SEP() + wxT( "template" ) + SEP(); } } Loading @@ -98,11 +99,16 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, boo // if there is // if there is wxString envStr; wxString envStr; wxGetEnv( wxT( "KICAD_PTEMPLATES" ), &envStr ); wxGetEnv( wxT( "KICAD_PTEMPLATES" ), &envStr ); wxFileName envPath = envStr; if( envStr != wxEmptyString ) if( envStr ) { { wxChar sep = SEP(); if( !envStr.EndsWith( &sep ) ) envStr += sep; wxFileName envPath = envStr; wxFileName envPath = envStr; ps->AddPage( _( "Portable Templates" ), envPath ); ps->AddPage( _( "Portable Templates" ), envPath ); } } Loading Loading @@ -256,6 +262,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event ) SetTitle( title ); SetTitle( title ); UpdateFileHistory( m_ProjectFileName.GetFullPath() ); UpdateFileHistory( m_ProjectFileName.GetFullPath() ); m_LeftWin->ReCreateTreePrj(); m_LeftWin->ReCreateTreePrj(); #ifdef KICAD_USE_FILES_WATCHER #ifdef KICAD_USE_FILES_WATCHER // Rebuild the list of watched paths. // Rebuild the list of watched paths. // however this is possible only when the main loop event handler is running, // however this is possible only when the main loop event handler is running, Loading @@ -263,6 +270,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event ) wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS ); wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS ); wxPostEvent( this, cmd); wxPostEvent( this, cmd); #endif #endif wxString msg; wxString msg; msg.Format( _( "Working dir: <%s>\nProject: <%s>\n" ), msg.Format( _( "Working dir: <%s>\nProject: <%s>\n" ), GetChars( m_ProjectFileName.GetPath() ), GetChars( m_ProjectFileName.GetPath() ), Loading kicad/project_template.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -96,7 +96,7 @@ wxStandardPaths::GetExecutableDir()/../share/template/ wxStandardPaths::GetExecutableDir()/../share/template/ wxStandardPaths::GetUserDataDir()/templates/ wxStandardPaths::GetUserDataDir()/templates/ wxGetEnv(wxT("KICAD_TEMPLATES")) wxGetEnv(wxT("KICAD_PTEMPLATES")) wxGetEnv(wxT("KICAD"))/template/ wxGetEnv(wxT("KICAD"))/template/ */ */ Loading Loading
kicad/dialogs/dialog_template_selector.cpp +15 −10 Original line number Original line Diff line number Diff line Loading @@ -191,23 +191,28 @@ void DIALOG_TEMPLATE_SELECTOR::AddPage( const wxString& aTitle, wxFileName& aPat // Get a list of files under the template path to include as choices... // Get a list of files under the template path to include as choices... wxArrayString files; wxArrayString files; wxDir dir, sub; wxDir dir; if ( dir.Open( aPath.GetPath() ) ) wxString path = aPath.GetFullPath(); // caller ensures this ends with file separator. if( dir.Open( path ) ) { { wxString filename; wxDir sub_dir; bool cont = dir.GetFirst( &filename, wxEmptyString, wxDIR_FILES | wxDIR_DIRS ); wxString sub_name; bool cont = dir.GetFirst( &sub_name, wxEmptyString, wxDIR_DIRS ); while( cont ) while( cont ) { { if( sub.Open( aPath.GetPathWithSep() + filename ) ) wxString sub_full = path + sub_name; if( sub_dir.Open( sub_full ) ) { { files.Add( filename ); files.Add( sub_name ); PROJECT_TEMPLATE* pt = new PROJECT_TEMPLATE( aPath.GetPathWithSep() + filename ); PROJECT_TEMPLATE* pt = new PROJECT_TEMPLATE( sub_full ); AddTemplate( m_notebook->GetPageCount() - 1, pt ); AddTemplate( m_notebook->GetPageCount() - 1, pt ); } } cont = dir.GetNext( &filename ); cont = dir.GetNext( &sub_name ); } } } } } }
kicad/prjconfig.cpp +15 −7 Original line number Original line Diff line number Diff line Loading @@ -78,11 +78,12 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, boo { { wxString kicadEnv; wxString kicadEnv; wxGetEnv( wxT( "KICAD"), &kicadEnv ); wxGetEnv( wxT( "KICAD"), &kicadEnv ); templatePath = kicadEnv + SEP() + wxT("template") + SEP(); templatePath = kicadEnv + SEP() + wxT("template") + SEP(); } } else else { { wxFileName templatePath = wxPathOnly(wxStandardPaths::Get().GetExecutablePath()) + templatePath = wxPathOnly(wxStandardPaths::Get().GetExecutablePath()) + SEP() + wxT( ".." ) + SEP() + wxT( "share" ) + SEP() + wxT( "template" ) + SEP(); SEP() + wxT( ".." ) + SEP() + wxT( "share" ) + SEP() + wxT( "template" ) + SEP(); } } Loading @@ -98,11 +99,16 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, boo // if there is // if there is wxString envStr; wxString envStr; wxGetEnv( wxT( "KICAD_PTEMPLATES" ), &envStr ); wxGetEnv( wxT( "KICAD_PTEMPLATES" ), &envStr ); wxFileName envPath = envStr; if( envStr != wxEmptyString ) if( envStr ) { { wxChar sep = SEP(); if( !envStr.EndsWith( &sep ) ) envStr += sep; wxFileName envPath = envStr; wxFileName envPath = envStr; ps->AddPage( _( "Portable Templates" ), envPath ); ps->AddPage( _( "Portable Templates" ), envPath ); } } Loading Loading @@ -256,6 +262,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event ) SetTitle( title ); SetTitle( title ); UpdateFileHistory( m_ProjectFileName.GetFullPath() ); UpdateFileHistory( m_ProjectFileName.GetFullPath() ); m_LeftWin->ReCreateTreePrj(); m_LeftWin->ReCreateTreePrj(); #ifdef KICAD_USE_FILES_WATCHER #ifdef KICAD_USE_FILES_WATCHER // Rebuild the list of watched paths. // Rebuild the list of watched paths. // however this is possible only when the main loop event handler is running, // however this is possible only when the main loop event handler is running, Loading @@ -263,6 +270,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event ) wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS ); wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS ); wxPostEvent( this, cmd); wxPostEvent( this, cmd); #endif #endif wxString msg; wxString msg; msg.Format( _( "Working dir: <%s>\nProject: <%s>\n" ), msg.Format( _( "Working dir: <%s>\nProject: <%s>\n" ), GetChars( m_ProjectFileName.GetPath() ), GetChars( m_ProjectFileName.GetPath() ), Loading
kicad/project_template.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -96,7 +96,7 @@ wxStandardPaths::GetExecutableDir()/../share/template/ wxStandardPaths::GetExecutableDir()/../share/template/ wxStandardPaths::GetUserDataDir()/templates/ wxStandardPaths::GetUserDataDir()/templates/ wxGetEnv(wxT("KICAD_TEMPLATES")) wxGetEnv(wxT("KICAD_PTEMPLATES")) wxGetEnv(wxT("KICAD"))/template/ wxGetEnv(wxT("KICAD"))/template/ */ */ Loading