wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser() now returns empty string on abort.

GITHUB_PLUGIN uses redirected URL to remove one HTTP hit time.
This commit is contained in:
Dick Hollenbeck 2013-11-11 19:14:17 -06:00
parent 5821d4bc48
commit dc138512b9
3 changed files with 41 additions and 21 deletions

View File

@ -503,11 +503,12 @@ public:
wxDC* aDC = NULL );
/**
* SelectFootprintFromLibBrowser
* Launch the footprint viewer to select the name of a footprint to load.
* @return the selected footprint name
* Function SelectFootprintFromLibBrowser
* launches the footprint viewer to select the name of a footprint to load.
*
* @return the selected footprint name or an empty string if no selection was made.
*/
wxString SelectFootprintFromLibBrowser( void );
wxString SelectFootprintFromLibBrowser();
/**
* Function GetFootprintLibraryTable

View File

@ -36,8 +36,10 @@
remote pretty libraries. If you want to support writing to the repo, then you
could use the above API.
@todo: Derive this PLUGIN from KICAD_PLUGIN so we can use its FootprintSave().
@todo:
Derive this PLUGIN from KICAD_PLUGIN so we can use its FootprintSave().
Support local footprints if they are present in an optional directory.
Possibly cache the zip file locally. Use HTTP's "have changed" or whatever it is called.
*/
#ifdef WIN32
@ -53,7 +55,6 @@
#include <wx/zipstrm.h>
#include <wx/mstream.h>
#include <wx/uri.h>
//#include <wx/strconv.h>
#include <fctsys.h>
// Under Windows Mingw/msys, avhttp.hpp should be included after fctsys.h
@ -247,10 +248,24 @@ bool GITHUB_PLUGIN::repoURL_zipURL( const wxString& aRepoURL, string* aZipURL )
// goal: "https://github.com/liftoff-sr/pretty_footprints/archive/master.zip"
wxString zip_url( wxT( "https://" ) );
#if 0 // Github issues a redirect for this "master.zip". i.e.
// "https://github.com/liftoff-sr/pretty_footprints/archive/master.zip"
// would be redirected to:
// "https://codeload.github.com/liftoff-sr/pretty_footprints/zip/master"
// The alternate code path below uses the redirected URL on first attempt
// to save one HTTP GET hit. avhttp does the redirect behind the scenes normally.
zip_url += repo.GetServer();
zip_url += repo.GetPath();
zip_url += wxT( '/' );
zip_url += wxT( "archive/master.zip" );
#else
zip_url += wxT( "codeload.github.com" );
zip_url += repo.GetPath();
zip_url += wxT( '/' );
zip_url += wxT( "zip/master" );
#endif
*aZipURL = zip_url.utf8_str();
return true;

View File

@ -110,13 +110,12 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
return true;
}
/*
* Launch the footprint viewer to select the name of a footprint to load.
* return the selected footprint name
*/
wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void )
wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser()
{
wxString fpname;
wxString fpid;
wxSemaphore semaphore( 0, 1 );
// Close the current Lib browser, if opened, and open a new one, in "modal" mode:
@ -135,17 +134,22 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void )
wxMilliSleep( 50 );
}
fpname = viewer->GetSelectedFootprint();
if( !!fpname )
{
#if !defined( USE_FP_LIB_TABLE )
// Returns the full fp name, i.e. the lib name and th fp name,
// Returns the full fp name, i.e. the lib name and the fp name,
// separated by a '/' (/ is now an illegal char in fp names)
fpname = viewer->GetSelectedLibraryFullName() + wxT( "/" ) + viewer->GetSelectedFootprint();
fpid = viewer->GetSelectedLibraryFullName() + wxT( "/" ) + fpname;
#else
fpname = viewer->GetSelectedLibrary() + wxT( ":" ) + viewer->GetSelectedFootprint();
fpid = viewer->GetSelectedLibrary() + wxT( ":" ) + fpname;
#endif
}
viewer->Destroy();
return fpname;
return fpid;
}