diff --git a/common/dialogs/dialog_global_lib_table_config.cpp b/common/dialogs/dialog_global_lib_table_config.cpp index 29428e255c..d6b60c503b 100644 --- a/common/dialogs/dialog_global_lib_table_config.cpp +++ b/common/dialogs/dialog_global_lib_table_config.cpp @@ -20,7 +20,11 @@ #include "dialog_global_lib_table_config.h" -#include +#include +#include +#include + +#include DIALOG_GLOBAL_LIB_TABLE_CONFIG::DIALOG_GLOBAL_LIB_TABLE_CONFIG( wxWindow* aParent, @@ -98,14 +102,28 @@ bool DIALOG_GLOBAL_LIB_TABLE_CONFIG::TransferDataToWindow() wxFileName fn = GetGlobalTableFileName(); + SEARCH_STACK ss; + + SystemDirsAppend( &ss ); + + wxString templatePath = + Pgm().GetLocalEnvVariables().at( wxT( "KICAD_TEMPLATE_DIR" ) ).GetValue(); + + if( !templatePath.IsEmpty() ) + ss.AddPaths( templatePath, 0 ); + else + templatePath = wxStandardPaths::Get().GetUserConfigDir(); + + m_filePicker1->SetInitialDirectory( templatePath ); + // Attempt to find the default global file table from the KiCad template folder. - wxString fileName = Kiface().KifaceSearch().FindValidPath( fn.GetName() ); + wxString fileName = ss.FindValidPath( fn.GetName() ); m_defaultFileFound = wxFileName::FileExists( fileName ); if( m_defaultFileFound ) { - m_filePicker1->SetFileName( wxFileName( fileName ) ); + m_filePicker1->SetPath(fileName ); m_filePicker1->Enable( false ); } else diff --git a/common/fp_lib_table.cpp b/common/fp_lib_table.cpp index 7402bd4551..caf21c79be 100644 --- a/common/fp_lib_table.cpp +++ b/common/fp_lib_table.cpp @@ -2,8 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2010-2012 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2012-2016 Wayne Stambaugh - * Copyright (C) 2012-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2012 Wayne Stambaugh + * Copyright (C) 2012-2019 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -30,6 +30,9 @@ #include #include #include +#include +#include +#include #include #include @@ -475,7 +478,17 @@ bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable ) // Attempt to copy the default global file table from the KiCad // template folder to the user's home configuration path. - wxString fileName = Kiface().KifaceSearch().FindValidPath( global_tbl_name ); + SEARCH_STACK ss; + + SystemDirsAppend( &ss ); + + wxString templatePath = + Pgm().GetLocalEnvVariables().at( wxT( "KICAD_TEMPLATE_DIR" ) ).GetValue(); + + if( !templatePath.IsEmpty() ) + ss.AddPaths( templatePath, 0 ); + + wxString fileName = ss.FindValidPath( global_tbl_name ); // The fallback is to create an empty global footprint table for the user to populate. if( fileName.IsEmpty() || !::wxCopyFile( fileName, fn.GetFullPath(), false ) ) diff --git a/eeschema/symbol_lib_table.cpp b/eeschema/symbol_lib_table.cpp index 2fa204b9a2..cb94e0b947 100644 --- a/eeschema/symbol_lib_table.cpp +++ b/eeschema/symbol_lib_table.cpp @@ -1,8 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2016-2017 Wayne Stambaugh - * Copyright (C) 2016-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2019 Wayne Stambaugh + * Copyright (C) 2016-2019 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -25,10 +25,12 @@ #include #include -#include #include #include #include +#include +#include +#include #include #include @@ -489,7 +491,17 @@ bool SYMBOL_LIB_TABLE::LoadGlobalTable( SYMBOL_LIB_TABLE& aTable ) // Attempt to copy the default global file table from the KiCad // template folder to the user's home configuration path. - wxString fileName = Kiface().KifaceSearch().FindValidPath( global_tbl_name ); + SEARCH_STACK ss; + + SystemDirsAppend( &ss ); + + wxString templatePath = + Pgm().GetLocalEnvVariables().at( wxT( "KICAD_TEMPLATE_DIR" ) ).GetValue(); + + if( !templatePath.IsEmpty() ) + ss.AddPaths( templatePath, 0 ); + + wxString fileName = ss.FindValidPath( global_tbl_name ); // The fallback is to create an empty global symbol table for the user to populate. if( fileName.IsEmpty() || !::wxCopyFile( fileName, fn.GetFullPath(), false ) )