Commit 87e5b6b8 authored by jean-pierre charras's avatar jean-pierre charras

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

parent 4352edda
......@@ -105,11 +105,13 @@ bool EDA_APP::OnInit()
{
wxFileName fn;
PCB_EDIT_FRAME* frame = NULL;
wxString msg;
#ifdef KICAD_SCRIPTING
if ( !pcbnewInitPythonScripting() )
{
return false;
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
wxSetWorkingDirectory( fn.GetPath() );
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 );
......
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