Pcbnew: allows pcbnew to open a .kicad_pcb or a .brd file, from the command line.

This commit is contained in:
jean-pierre charras 2012-12-16 14:48:54 +01:00
parent 4352eddadb
commit 87e5b6b874
1 changed files with 12 additions and 10 deletions

View File

@ -105,10 +105,12 @@ bool EDA_APP::OnInit()
{
wxFileName fn;
PCB_EDIT_FRAME* frame = NULL;
wxString msg;
#ifdef KICAD_SCRIPTING
if ( !pcbnewInitPythonScripting() )
{
wxMessageBox( wxT( "pcbnewInitPythonScripting() fails" ) );
return false;
}
#endif
@ -129,12 +131,13 @@ bool EDA_APP::OnInit()
{
fn = argv[1];
if( fn.GetExt() != PcbFileExtension )
if( fn.GetExt() != PcbFileExtension && fn.GetExt() != LegacyPcbFileExtension )
{
wxLogDebug( wxT( "Pcbnew file <%s> has the wrong extension. \
msg.Printf( _( "Pcbnew file <%s> has a wrong extension.\n\
Changing extension to .%s." ), GetChars( fn.GetFullPath() ),
GetChars( PcbFileExtension ) );
fn.SetExt( PcbFileExtension );
wxMessageBox( msg );
}
if( fn.IsOk() && fn.DirExists() )
@ -177,7 +180,7 @@ Changing extension to .%s." ), GetChars( fn.GetFullPath() ),
* However, because legacy board files are named *.brd,
* and new files are named *.kicad_pcb,
* for all previous projects ( before 2012, december 14 ),
* becuse KiCad manager ask to load a .kicad_pcb file
* because KiCad manager ask to load a .kicad_pcb file
* if this file does not exist, it is certainly useful
* to test if a legacy file is existing,
* under the same name, and therefore if the user want to load it
@ -196,10 +199,9 @@ Changing extension to .%s." ), GetChars( fn.GetFullPath() ),
fn_legacy.SetExt( LegacyPcbFileExtension );
if( fn_legacy.FileExists() )
{
wxString msg;
msg.Printf( _( "File <%s> does not exist.\n"
"However a legacy file <%s> exists.\nDo you want to load it?\n"
"It will be saved under the new file format" ),
msg.Printf( _( "File <%s> does not exist.\n\
However a legacy file <%s> exists.\nDo you want to load it?\n\
It will be saved under the new file format" ),
GetChars( fn.GetFullPath() ),
GetChars( fn_legacy.GetFullPath() ) );
if( IsOK( frame, msg ) )
@ -217,13 +219,13 @@ Changing extension to .%s." ), GetChars( fn.GetFullPath() ),
if( ! file_exists )
{ // File does not exists: prepare an empty board
if( ! fn.GetPath().IsEmpty() )
wxSetWorkingDirectory( fn.GetPath() );
frame->GetBoard()->SetFileName( fn.GetFullPath( wxPATH_UNIX ) );
frame->UpdateTitle();
frame->UpdateFileHistory( frame->GetBoard()->GetFileName() );
frame->OnModify(); // Ready to save the new empty board
wxString msg;
msg.Printf( _( "File <%s> does not exist.\nThis is normal for a new project" ),
GetChars( frame->GetBoard()->GetFileName() ) );
wxMessageBox( msg );