Give new footprint libraries a dummy name in the file dialog

If they don't have a dummy name, then GTK will display the regex
for the extension in the dialog.

Fixes https://gitlab.com/kicad/code/kicad/issues/5365
This commit is contained in:
Ian McInerney 2020-09-02 00:08:57 +01:00
parent 8bdf25d3e2
commit 4ca7993382
2 changed files with 15 additions and 18 deletions

View File

@ -884,6 +884,10 @@ bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename,
} }
else else
{ {
// Ensure the file has a dummy name, otherwise GTK will display the regex from the filter
if( aFilename.GetName().empty() )
aFilename.SetName( "Library" );
wxString dir = Prj().IsNullProject() ? aFilename.GetFullPath() : Prj().GetProjectPath(); wxString dir = Prj().IsNullProject() ? aFilename.GetFullPath() : Prj().GetProjectPath();
wxFileDialog dlg( this, prompt, dir, aFilename.GetFullName(), wxFileDialog dlg( this, prompt, dir, aFilename.GetFullName(),

View File

@ -391,7 +391,7 @@ wxString PCB_BASE_EDIT_FRAME::CreateNewLibrary( const wxString& aLibName,
fn = initialPath; fn = initialPath;
if( !LibraryFileBrowser( false, fn, if( !LibraryFileBrowser( false, fn,
KiCadFootprintLibPathWildcard(), KiCadFootprintLibPathExtension) ) KiCadFootprintLibPathWildcard(), KiCadFootprintLibPathExtension ) )
{ {
return wxEmptyString; return wxEmptyString;
} }
@ -413,15 +413,15 @@ wxString PCB_BASE_EDIT_FRAME::CreateNewLibrary( const wxString& aLibName,
} }
// We can save fp libs only using IO_MGR::KICAD_SEXP format (.pretty libraries) // We can save fp libs only using IO_MGR::KICAD_SEXP format (.pretty libraries)
IO_MGR::PCB_FILE_T piType = IO_MGR::KICAD_SEXP; IO_MGR::PCB_FILE_T piType = IO_MGR::KICAD_SEXP;
wxString libPath = fn.GetFullPath(); wxString libPath = fn.GetFullPath();
try try
{ {
PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) ); PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) );
bool writable = false; bool writable = false;
bool exists = false; bool exists = false;
try try
{ {
@ -488,8 +488,8 @@ bool PCB_BASE_EDIT_FRAME::AddLibrary( const wxString& aFilename )
if( libName.IsEmpty() ) if( libName.IsEmpty() )
return false; return false;
bool saveInGlobalTable = false; bool saveInGlobalTable = false;
bool saveInProjectTable = false; bool saveInProjectTable = false;
if( Prj().IsNullProject() ) if( Prj().IsNullProject() )
{ {
@ -505,16 +505,9 @@ bool PCB_BASE_EDIT_FRAME::AddLibrary( const wxString& aFilename )
switch( SelectSingleOption( this, _( "Select Library Table" ), switch( SelectSingleOption( this, _( "Select Library Table" ),
_( "Choose the Library Table to add the library to:" ), libTableNames ) ) _( "Choose the Library Table to add the library to:" ), libTableNames ) )
{ {
case 0: case 0: saveInGlobalTable = true; break;
saveInGlobalTable = true; case 1: saveInProjectTable = true; break;
break; default: return false;
case 1:
saveInProjectTable = true;
break;
default:
return false;
} }
} }