Commit 4a39fcdd authored by Dick Hollenbeck's avatar Dick Hollenbeck

single_top.c logic, improved OpenProjectFiles() documentation.

parent 8fc1e382
...@@ -353,76 +353,54 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp ) ...@@ -353,76 +353,54 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
if( argc > 1 ) if( argc > 1 )
{ {
/*
gerbview handles multiple project data files, i.e. gerber files on
cmd line. Others currently do not, they handle only one. For common
code simplicity we simply pass all the arguments in however, each
program module can do with them what they want, ignore, complain
whatever. We don't establish policy here, as this is a multi-purpose
launcher.
*/
#if defined(TOP_FRAME) && TOP_FRAME==GERBER_FRAME_TYPE std::vector<wxString> argSet;
// gerbview handles multiple project data files, i.e. gerber files on cmd line.
std::vector<wxString> fileSet;
// Load all files specified on the command line.
for( int i=1; i<argc; ++i ) for( int i=1; i<argc; ++i )
{ {
wxFileName fn( App().argv[i] ); argSet.push_back( App().argv[i] );
if( fn.FileExists() )
fileSet.push_back( App().argv[i] );
}
wxFileName fn( fileSet[0] );
if( fn.GetPath().size() )
{
// wxSetWorkingDirectory does not like empty paths
wxSetWorkingDirectory( fn.GetPath() );
// @todo: setting CWD is taboo in a multi-project environment
}
// Use the KIWAY_PLAYER::OpenProjectFiles() API function:
if( !frame->OpenProjectFiles( fileSet ) )
{
// OpenProjectFiles() API asks that it report failure to the UI.
// Nothing further to say here.
// Fail the process startup if the file could not be opened,
// although this is an optional choice, one that can be reversed
// also in the KIFACE specific OpenProjectFiles() return value.
return false;
} }
#else // special attention to the first argument: argv[1] (==argSet[0])
wxFileName argv1( argSet[0] );
wxFileName fn( argv[1] );
if( !fn.IsOk() ) if( argc == 2 )
{ {
return false;
}
#if defined(PGM_DATA_FILE_EXT) #if defined(PGM_DATA_FILE_EXT)
// PGM_DATA_FILE_EXT is different for each compile, it may come from CMake // PGM_DATA_FILE_EXT is different for each compile, it may come
// on the compiler command line, or not. // from CMake on the compiler command line, often does not.
if( !fn.GetExt() ) // This facillity is mostly useful only for those program modules
fn.SetExt( wxT( PGM_DATA_FILE_EXT ) ); // supporting a single argv[1].
if( !argv1.GetExt() )
argv1.SetExt( wxT( PGM_DATA_FILE_EXT ) );
argSet[0] = argv1.GetFullPath();
#endif #endif
if( !Pgm().LockFile( argSet[0] ) )
if( !Pgm().LockFile( fn.GetFullPath() ) ) {
{ wxLogSysError( _( "This file is already open." ) );
wxLogSysError( _( "This file is already open." ) ); return false;
return false; }
} }
if( fn.GetPath().size() ) // @todo: setting CWD is taboo in a multi-project environment, this
// will not be possible soon.
if( argv1.GetPath().size() ) // path only
{ {
// wxSetWorkingDirectory does not like empty paths // wxSetWorkingDirectory() does not like empty paths
wxSetWorkingDirectory( fn.GetPath() ); wxSetWorkingDirectory( argv1.GetPath() );
// @todo: setting CWD is taboo in a multi-project environment
} }
// Use the KIWAY_PLAYER::OpenProjectFiles() API function: // Use the KIWAY_PLAYER::OpenProjectFiles() API function:
if( !frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) ) ) if( !frame->OpenProjectFiles( argSet ) )
{ {
// OpenProjectFiles() API asks that it report failure to the UI. // OpenProjectFiles() API asks that it report failure to the UI.
// Nothing further to say here. // Nothing further to say here.
...@@ -432,7 +410,6 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp ) ...@@ -432,7 +410,6 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
// also in the KIFACE specific OpenProjectFiles() return value. // also in the KIFACE specific OpenProjectFiles() return value.
return false; return false;
} }
#endif
} }
else else
{ {
......
...@@ -129,8 +129,15 @@ public: ...@@ -129,8 +129,15 @@ public:
* KIWAY_PLAYER is precluded. * KIWAY_PLAYER is precluded.
* <p> * <p>
* Each derived class should handle this in a way specific to its needs. * Each derived class should handle this in a way specific to its needs.
* No prompting is done inside here for any file or project. There is no * No prompting is done inside here for any file or project. There should be
* need to call this with aFileList which is empty. * need to call this with aFileList which is empty. However, calling it with
* a single filename which does not exist should indicate to the implementor
* that a new session is being started and that the given name is the desired
* name for the data file at time of save.
* <p>
* Therefore, one of the first things an implementation should do is test for
* existence of the first file in the list, and if it does not exist, treat
* it as a new session, possibly with a UI notification to that effect.
* <p> * <p>
* After loading the window should update its Title as part of this operation. * After loading the window should update its Title as part of this operation.
* If the KIWAY_PLAYER needs to, it can load the *.pro file as part of this operation. * If the KIWAY_PLAYER needs to, it can load the *.pro file as part of this operation.
......
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