Commit 5b3c5861 authored by stambaughw's avatar stambaughw

More search path, compiler warning, and bug fixes.

Added template subdirectory to library search path list.
Removed PARAM_CFG_BASE empty destructor to prevent GCC warning.
Set timeout to 0 on DisplayInfo call to prevent debug assertion in eeschema/files-io.cpp.
Declare PARAM_CFG_ARRAY for future project file object implementation.
Removed unnecessary COMMON_GLOBL definition in gr_basic.h and param_config.h.
parent 0706234d
...@@ -105,7 +105,8 @@ void DisplayInfo( wxWindow* parent, const wxString& text, int displaytime ) ...@@ -105,7 +105,8 @@ void DisplayInfo( wxWindow* parent, const wxString& text, int displaytime )
dialog = new WinEDA_MessageDialog( parent, text, _( "Info:" ), dialog = new WinEDA_MessageDialog( parent, text, _( "Info:" ),
wxOK | wxICON_INFORMATION, displaytime ); wxOK | wxICON_INFORMATION, displaytime );
dialog->ShowModal(); dialog->Destroy(); dialog->ShowModal();
dialog->Destroy();
} }
......
...@@ -528,14 +528,21 @@ void WinEDA_App::SetDefaultSearchPaths( void ) ...@@ -528,14 +528,21 @@ void WinEDA_App::SetDefaultSearchPaths( void )
} }
else else
{ {
/* Build schematic, PCB, and 3D module library file search path /* Add schematic library file path to search path list. */
* list based on the known existing default search paths. */
fn.Clear(); fn.Clear();
fn.SetPath( m_searchPaths[i] ); fn.SetPath( m_searchPaths[i] );
fn.AppendDir( wxT( "library") ); fn.AppendDir( wxT( "library") );
wxLogDebug( wxT( "Checking if search path <%s> exists." ), if( fn.IsDirReadable() )
{
wxLogDebug( wxT( "Adding <%s> to library search path list" ),
fn.GetPath().c_str() ); fn.GetPath().c_str() );
m_libSearchPaths.Add( fn.GetPath() );
}
/* Add kicad template file path to search path list. */
fn.RemoveLastDir();
fn.AppendDir( wxT( "template" ) );
if( fn.IsDirReadable() ) if( fn.IsDirReadable() )
{ {
...@@ -543,6 +550,8 @@ void WinEDA_App::SetDefaultSearchPaths( void ) ...@@ -543,6 +550,8 @@ void WinEDA_App::SetDefaultSearchPaths( void )
fn.GetPath().c_str() ); fn.GetPath().c_str() );
m_libSearchPaths.Add( fn.GetPath() ); m_libSearchPaths.Add( fn.GetPath() );
} }
/* Add PCB library file path to search path list. */
fn.RemoveLastDir(); fn.RemoveLastDir();
fn.AppendDir( wxT( "modules" ) ); fn.AppendDir( wxT( "modules" ) );
...@@ -552,6 +561,8 @@ void WinEDA_App::SetDefaultSearchPaths( void ) ...@@ -552,6 +561,8 @@ void WinEDA_App::SetDefaultSearchPaths( void )
fn.GetPath().c_str() ); fn.GetPath().c_str() );
m_libSearchPaths.Add( fn.GetPath() ); m_libSearchPaths.Add( fn.GetPath() );
} }
/* Add 3D module library file path to search path list. */
fn.AppendDir( wxT( "packages3d" ) ); fn.AppendDir( wxT( "packages3d" ) );
if( fn.IsDirReadable() ) if( fn.IsDirReadable() )
......
...@@ -447,48 +447,6 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, ...@@ -447,48 +447,6 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile,
} }
/****************************************************/
void SetRealLibraryPath( const wxString& shortlibname )
/****************************************************/
/* met a jour le chemin des librairies g_RealLibDirBuffer (global)
* a partir de UserLibDirBuffer (global):
* Si UserLibDirBuffer non vide g_RealLibDirBuffer = g_UserLibDirBuffer.
* Sinon si variable d'environnement KICAD definie (KICAD = chemin pour kicad),
* g_UserLibDirBuffer = <KICAD>/shortlibname;
* Sinon g_UserLibDirBuffer = <Chemin des binaires>../shortlibname/
* Sinon g_UserLibDirBuffer = /usr/share/kicad/shortlibname/
*
* Remarque:
* Les \ sont remplaces par / (a la mode Unix)
*/
{
bool PathFound = FALSE;
if( !g_UserLibDirBuffer.IsEmpty() ) // Chemin impose par la configuration
{
g_RealLibDirBuffer = g_UserLibDirBuffer;
PathFound = TRUE;
}
else
{
g_RealLibDirBuffer = ReturnKicadDatasPath();
if( wxGetApp().m_Env_Defined ) // Chemin impose par la variable d'environnement
{
PathFound = TRUE;
}
g_RealLibDirBuffer += shortlibname;
if( wxDirExists( g_RealLibDirBuffer ) )
PathFound = TRUE;
}
g_RealLibDirBuffer.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
if( g_RealLibDirBuffer.Last() != '/' )
g_RealLibDirBuffer += UNIX_STRING_DIR_SEP;
}
/***********************************/ /***********************************/
wxString ReturnKicadDatasPath() wxString ReturnKicadDatasPath()
/***********************************/ /***********************************/
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
#include "gestfich.h" #include "gestfich.h"
#include "wxstruct.h" #include "wxstruct.h"
#include <wx/apptrait.h>
#include <wx/stdpaths.h>
wxString g_CommonSectionTag( wxT( "[common]" ) ); wxString g_CommonSectionTag( wxT( "[common]" ) );
wxString g_SchematicSectionTag( wxT( "[eeschema]" ) ); wxString g_SchematicSectionTag( wxT( "[eeschema]" ) );
...@@ -597,14 +600,21 @@ wxString ReturnHotkeyConfigFilePath( int choice ) ...@@ -597,14 +600,21 @@ wxString ReturnHotkeyConfigFilePath( int choice )
*/ */
{ {
wxString path; wxString path;
wxAppTraits* traits = wxGetApp().GetTraits();
switch( choice ) switch( choice )
{ {
case 0: case 0:
path = wxGetHomeDir() + wxT( "/" ); path = traits->GetStandardPaths().GetUserConfigDir() +
break; wxFileName::GetPathSeparator();
case 1: case 1:
/* TODO: This is broken under a normal Poxis system. Users
* generally do no have write permissions to this path
* and there is no provision for prompting for the root
* password. Suggest we remove this unless someone has
* a workable solution (Wayne).
*/
path = ReturnKicadDatasPath() + wxT( "template/" ); path = ReturnKicadDatasPath() + wxT( "template/" );
break; break;
......
...@@ -11,12 +11,19 @@ ...@@ -11,12 +11,19 @@
#include "wxstruct.h" #include "wxstruct.h"
#include "param_config.h" #include "param_config.h"
#include <wx/apptrait.h>
#include <wx/stdpaths.h>
#define CONFIG_VERSION 1 #define CONFIG_VERSION 1
#define FORCE_LOCAL_CONFIG true #define FORCE_LOCAL_CONFIG true
#include <wx/arrimpl.cpp>
WX_DEFINE_OBJARRAY( PARAM_CFG_ARRAY );
/** /**
* Cree ou recree la configuration locale de kicad (filename.pro) * Cree ou recree la configuration locale de kicad (filename.pro)
* initialise: * initialise:
...@@ -93,13 +100,22 @@ bool WinEDA_App::ReCreatePrjConfig( const wxString& fileName, ...@@ -93,13 +100,22 @@ bool WinEDA_App::ReCreatePrjConfig( const wxString& fileName,
} }
} }
defaultFileName = m_libSearchPaths.FindValidPath( wxT( "kicad.pro" ) );
defaultFileName = ReturnKicadDatasPath() + wxT( "template/kicad" ) + if( !defaultFileName )
wxT( "." ) + ProjectFileExtension; {
wxLogDebug( wxT( "Template file <kicad.pro> not found." ) );
fn = wxFileName( GetTraits()->GetStandardPaths().GetDocumentsDir(),
wxT( "kicad" ), ProjectFileExtension );
}
else
{
fn = defaultFileName;
}
// Create new project file using the default name. // Create new project file using the default name.
m_ProjectConfig = new wxFileConfig( wxEmptyString, wxEmptyString, m_ProjectConfig = new wxFileConfig( wxEmptyString, wxEmptyString,
wxEmptyString, defaultFileName ); wxEmptyString, fn.GetFullPath() );
m_ProjectConfig->DontCreateOnDemand(); m_ProjectConfig->DontCreateOnDemand();
return false; return false;
......
...@@ -75,7 +75,6 @@ bool WinEDA_App::OnInit() ...@@ -75,7 +75,6 @@ bool WinEDA_App::OnInit()
GetSettings(); // read current setup GetSettings(); // read current setup
wxSetWorkingDirectory( currCWD ); // mofifie par GetSetting wxSetWorkingDirectory( currCWD ); // mofifie par GetSetting
SetRealLibraryPath( wxT( "modules" ) );
if( argc > 1 ) if( argc > 1 )
{ {
......
...@@ -124,7 +124,6 @@ void KiConfigCvpcbFrame::Update() ...@@ -124,7 +124,6 @@ void KiConfigCvpcbFrame::Update()
if( msg != g_UserLibDirBuffer ) if( msg != g_UserLibDirBuffer )
{ {
g_UserLibDirBuffer = m_LibDirCtrl->GetValue(); g_UserLibDirBuffer = m_LibDirCtrl->GetValue();
SetRealLibraryPath( wxT( "modules" ) );
listlib(); listlib();
m_Parent->BuildFootprintListBox(); m_Parent->BuildFootprintListBox();
} }
......
...@@ -146,7 +146,6 @@ void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event ) ...@@ -146,7 +146,6 @@ void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event )
// Set new default path lib // Set new default path lib
g_UserLibDirBuffer = m_LibDirCtrl->GetValue(); g_UserLibDirBuffer = m_LibDirCtrl->GetValue();
SetRealLibraryPath( wxT( "library" ) ); // set real path lib
// Set new active lib list // Set new active lib list
if( m_LibListChanged ) if( m_LibListChanged )
......
...@@ -80,19 +80,16 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, ...@@ -80,19 +80,16 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName,
FullFileName = FileName; FullFileName = FileName;
if( ( FullFileName.IsEmpty() ) && !IsNew ) if( ( FullFileName.IsEmpty() ) && !IsNew )
{ {
wxString mask = wxT( "*." ) + SchematicFileExtension; wxFileDialog dlg( this, _( "Open Schematic" ), wxEmptyString,
FullFileName = EDA_FileSelector( _( "Schematic files:" ), wxEmptyString, SchematicFileWildcard,
wxEmptyString, /* Chemin par defaut */ wxFD_OPEN | wxFD_FILE_MUST_EXIST );
wxEmptyString, /* nom fichier par defaut */
SchematicFileExtension, /* extension par defaut */ if( dlg.ShowModal() == wxID_CANCEL )
mask, /* Masque d'affichage */
this,
wxFD_OPEN,
TRUE
);
if( FullFileName.IsEmpty() )
return 0; return 0;
FullFileName = dlg.GetPath();
} }
if( g_RootSheet ) if( g_RootSheet )
{ {
SAFE_DELETE( g_RootSheet ); SAFE_DELETE( g_RootSheet );
...@@ -175,12 +172,13 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, ...@@ -175,12 +172,13 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName,
LibCacheExist = TRUE; LibCacheExist = TRUE;
} }
if( !wxFileExists( g_RootSheet->m_AssociatedScreen->m_FileName ) && !LibCacheExist ) // Nouveau projet prpbablement if( !wxFileExists( g_RootSheet->m_AssociatedScreen->m_FileName )
&& !LibCacheExist )
{ {
Zoom_Automatique( FALSE ); Zoom_Automatique( FALSE );
msg.Printf( _( "File <%s> not found." ), msg.Printf( _( "File <%s> not found." ),
g_RootSheet->m_AssociatedScreen->m_FileName.GetData() ); g_RootSheet->m_AssociatedScreen->m_FileName.GetData() );
DisplayInfo( this, msg, 20 ); DisplayInfo( this, msg, 0 );
return -1; return -1;
} }
......
...@@ -80,14 +80,6 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, ...@@ -80,14 +80,6 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile,
const wxString& param = wxEmptyString ); const wxString& param = wxEmptyString );
void AddDelimiterString( wxString& string ); void AddDelimiterString( wxString& string );
void SetRealLibraryPath( const wxString& shortlibname ); /* met a jour
* le chemin des librairies RealLibDirBuffer (global)
* a partir de UserLibDirBuffer (global):
* Si UserLibDirBuffer non vide RealLibDirBuffer = UserLibDirBuffer.
* Sinon si variable d'environnement KICAD definie (KICAD = chemin pour kicad),
* UserLibDirBuffer = <KICAD>/shortlibname;
* Sinon UserLibDirBuffer = <Chemin des binaires>../shortlibname/
*/
wxString FindKicadHelpPath(); wxString FindKicadHelpPath();
/* Find absolute path for kicad/help (or kicad/help/<language>) */ /* Find absolute path for kicad/help (or kicad/help/<language>) */
......
...@@ -5,10 +5,6 @@ ...@@ -5,10 +5,6 @@
#ifndef GR_BASIC #ifndef GR_BASIC
#define GR_BASIC #define GR_BASIC
#ifndef COMMON_GLOBL
#define COMMON_GLOBL extern
#endif
#include "colors.h" #include "colors.h"
......
...@@ -8,10 +8,7 @@ ...@@ -8,10 +8,7 @@
#include "wx/confbase.h" #include "wx/confbase.h"
#include "wx/fileconf.h" #include "wx/fileconf.h"
#include <wx/dynarray.h>
#ifndef COMMON_GLOBL
# define COMMON_GLOBL extern
#endif
/* definifition des types de parametre des files de configuration */ /* definifition des types de parametre des files de configuration */
...@@ -40,7 +37,6 @@ public: ...@@ -40,7 +37,6 @@ public:
public: public:
PARAM_CFG_BASE( const wxChar* ident, const paramcfg_id type, const wxChar* group = NULL ); PARAM_CFG_BASE( const wxChar* ident, const paramcfg_id type, const wxChar* group = NULL );
~PARAM_CFG_BASE() { };
/** ReadParam /** ReadParam
* read the value of parameter thi stored in aConfig * read the value of parameter thi stored in aConfig
...@@ -209,5 +205,6 @@ public: ...@@ -209,5 +205,6 @@ public:
virtual void SaveParam( wxConfigBase* aConfig ); virtual void SaveParam( wxConfigBase* aConfig );
}; };
WX_DECLARE_OBJARRAY( PARAM_CFG_BASE, PARAM_CFG_ARRAY );
#endif /* __PARAM_CONFIG_H__ */ #endif /* __PARAM_CONFIG_H__ */
...@@ -25,23 +25,20 @@ static const wxString BoardFileNameEntry( wxT( "BoardNm" ) ); ...@@ -25,23 +25,20 @@ static const wxString BoardFileNameEntry( wxT( "BoardNm" ) );
void WinEDA_MainFrame::CreateNewProject( const wxString PrjFullFileName ) void WinEDA_MainFrame::CreateNewProject( const wxString PrjFullFileName )
{ {
wxFileName fn; wxString tmp;
wxFileName newProjectName = PrjFullFileName; wxFileName newProjectName = PrjFullFileName;
// Init default config filename // Init default config filename
fn.SetPath( ReturnKicadDatasPath() ); tmp = wxGetApp().GetLibraryPathList().FindValidPath( wxT( "kicad.pro" ) );
fn.AppendDir( wxT( "template" ) );
fn.SetName( wxT( "kicad" ) );
fn.SetExt( ProjectFileExtension );
if( !fn.FileExists() ) if( !wxFileName::FileExists( tmp ) )
{ {
DisplayInfo( NULL, _( "Template file not found " ) + fn.GetFullPath() ); DisplayInfo( NULL, _( "Project template file <kicad.pro> not found " ) );
return; return;
} }
else else
{ {
wxCopyFile( fn.GetFullPath(), PrjFullFileName ); wxCopyFile( tmp, PrjFullFileName );
} }
m_SchematicRootFileName = wxFileName( newProjectName.GetName(), m_SchematicRootFileName = wxFileName( newProjectName.GetName(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment