From 4ca7993382dde89c6d7ad931f2d30c39679b3006 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Wed, 2 Sep 2020 00:08:57 +0100 Subject: [PATCH] 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 --- common/eda_draw_frame.cpp | 4 ++++ pcbnew/footprint_libraries_utils.cpp | 29 +++++++++++----------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index ca3285115f..335310c86c 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -884,6 +884,10 @@ bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename, } 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(); wxFileDialog dlg( this, prompt, dir, aFilename.GetFullName(), diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index 61ed6ecba0..b945f18a2b 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -391,7 +391,7 @@ wxString PCB_BASE_EDIT_FRAME::CreateNewLibrary( const wxString& aLibName, fn = initialPath; if( !LibraryFileBrowser( false, fn, - KiCadFootprintLibPathWildcard(), KiCadFootprintLibPathExtension) ) + KiCadFootprintLibPathWildcard(), KiCadFootprintLibPathExtension ) ) { 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) - IO_MGR::PCB_FILE_T piType = IO_MGR::KICAD_SEXP; - wxString libPath = fn.GetFullPath(); + IO_MGR::PCB_FILE_T piType = IO_MGR::KICAD_SEXP; + wxString libPath = fn.GetFullPath(); try { - PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) ); + PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) ); - bool writable = false; - bool exists = false; + bool writable = false; + bool exists = false; try { @@ -488,8 +488,8 @@ bool PCB_BASE_EDIT_FRAME::AddLibrary( const wxString& aFilename ) if( libName.IsEmpty() ) return false; - bool saveInGlobalTable = false; - bool saveInProjectTable = false; + bool saveInGlobalTable = false; + bool saveInProjectTable = false; if( Prj().IsNullProject() ) { @@ -505,16 +505,9 @@ bool PCB_BASE_EDIT_FRAME::AddLibrary( const wxString& aFilename ) switch( SelectSingleOption( this, _( "Select Library Table" ), _( "Choose the Library Table to add the library to:" ), libTableNames ) ) { - case 0: - saveInGlobalTable = true; - break; - - case 1: - saveInProjectTable = true; - break; - - default: - return false; + case 0: saveInGlobalTable = true; break; + case 1: saveInProjectTable = true; break; + default: return false; } }