From 1e8f7f7ba8e746a3173e7ec3b46d5abe6512b851 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 16 Dec 2012 14:48:54 +0100 Subject: [PATCH] Pcbnew: allows pcbnew to open a .kicad_pcb or a .brd file, from the command line. --- pcbnew/pcbnew.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 86e6083424..32fc1e2883 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -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 );