kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #14532
Re: Config file relocation (new patch)
On 09/02/2014 11:50 AM, Moses McKnight wrote:
On 09/02/2014 11:36 AM, Wayne Stambaugh wrote:
On 8/31/2014 8:35 PM, Moses McKnight wrote:
On 08/31/2014 11:07 AM, jp charras wrote:
Le 31/08/2014 13:59, Moses McKnight a écrit :
<snip>
Moses,
I don't think it's necessary to copy the old files. Most of the
configuration set up is fairly trivial. If you've been using KiCad for
any length of time, there probably is a lot of cruft in the config files
that is no longer used. If we are going to make this change, I
recommend moving fp-lib-table there as well. Splitting up the KiCad
configuration files in multiple places will only confuse users. I also
recommend migrating windows over to config files instead of using the
registry. The global fp-lib-table file is alread in the %APPDATA%/kicad
folder on windows. I'm sure there will be some grumbling but it's much
easier for developers have someone send a config file than digging
around the windows registry.
Wayne
Ok, I can add that to my patch and re-send it if you want me to. I haven't
looked into what it would take to move the fp-lib-table, but I should be able to
move the windows config to %APPDATA%/kicad in a few minutes of work.
Ok, I've attached another patch against BZR 5112 which puts the fp-lib-table in
~/.config/kicad on linux, and should put all the config files in %APPDATA%/kicad
in windows. This seems to work fine in Linux, and when my WinXP vm finally gets
kicad compiled I'll test there as well.
I did not actually use the %APPDATA% environment variable - since the code for
the fp-lib-table just used wxStandardPaths::Get().GetUserConfigDir(), I did
likewise. I also removed the code that checks the environment variable
XDG_CONFIG_HOME in linux because that variable is not even set on the Ubuntu or
Linux Mint installs I have.
Thanks,
Moses
=== modified file 'bitmap2component/bitmap2cmp_gui.cpp'
--- bitmap2component/bitmap2cmp_gui.cpp 2014-08-22 10:24:14 +0000
+++ bitmap2component/bitmap2cmp_gui.cpp 2014-08-31 00:15:30 +0000
@@ -77,7 +77,7 @@
wxString m_ConvertedFileName;
wxSize m_frameSize;
wxPoint m_framePos;
- wxConfig* m_config;
+ wxConfigBase* m_config;
public:
BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent );
@@ -147,7 +147,7 @@
SetKiway( this, aKiway );
int tmp;
- m_config = new wxConfig();
+ m_config = GetNewConfig( Pgm().App().GetAppName() );
m_config->Read( KEYWORD_FRAME_POSX, & m_framePos.x, -1 );
m_config->Read( KEYWORD_FRAME_POSY, & m_framePos.y, -1 );
m_config->Read( KEYWORD_FRAME_SIZEX, & m_frameSize.x, -1 );
=== modified file 'common/bin_mod.cpp'
--- common/bin_mod.cpp 2014-09-02 16:44:53 +0000
+++ common/bin_mod.cpp 2014-09-02 19:43:42 +0000
@@ -1,8 +1,9 @@
-#include <wx/config.h>
+//#include <wx/config.h>
#include <bin_mod.h>
#include <online_help.h>
+#include <common.h>
BIN_MOD::BIN_MOD( const char* aName ) :
@@ -15,7 +16,7 @@
void BIN_MOD::Init()
{
// do an OS specific wxConfig instantiation, using the bin_mod (EXE/DLL/DSO) name.
- m_config = new wxConfig( wxString::FromUTF8( m_name ) );
+ m_config = GetNewConfig( wxString::FromUTF8( m_name ) );
m_history.Load( *m_config );
=== modified file 'common/common.cpp'
--- common/common.cpp 2014-08-05 09:39:42 +0000
+++ common/common.cpp 2014-09-02 19:22:58 +0000
@@ -39,6 +39,9 @@
#include <base_units.h>
#include <wx/process.h>
+#include <wx/config.h>
+#include <wx/utils.h>
+#include <wx/stdpaths.h>
/**
@@ -289,3 +292,35 @@
#endif
}
+wxConfigBase* GetNewConfig( const wxString& aProgName )
+{
+ wxConfigBase* cfg = 0;
+ // under Windows we prefer to use the native implementation but can be forced
+ // to use the file-based one
+#if defined(__WXOS2__) && wxUSE_CONFIG_NATIVE
+ cfg = new wxConfig( aProgName );
+#else // either we're under Unix or wish to always use config files
+ wxFileName configname;
+ wxString envstr;
+
+ // From the wxWidgets wxStandardPaths::GetUserConfigDir() help:
+ // Unix: ~ (the home directory)
+ // Windows: "C:\Documents and Settings\username\Application Data"
+ // Mac: ~/Library/Preferences
+ configname.AssignDir( wxStandardPaths::Get().GetUserConfigDir() );
+
+#if !defined(__WINDOWS__)
+ configname.AppendDir( wxT( ".config" ) );
+#endif
+
+ configname.AppendDir( wxT( "kicad" ) );
+ configname.SetFullName( aProgName );
+ if ( !configname.DirExists() )
+ {
+ configname.Mkdir( configname.GetPath(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
+ }
+ cfg = new wxFileConfig( wxT(""), wxT(""), configname.GetFullPath() );
+#endif
+ return cfg;
+}
+
=== modified file 'common/fp_lib_table.cpp'
--- common/fp_lib_table.cpp 2014-05-18 15:16:59 +0000
+++ common/fp_lib_table.cpp 2014-09-02 18:45:42 +0000
@@ -733,13 +733,16 @@
{
wxFileName fn;
- // This is possibly problematic with an uncertain wxApp title, which is now
- // the case. We'll need a better technique soon.
+ // From the wxWidgets wxStandardPaths::GetUserConfigDir() help:
+ // Unix: ~ (the home directory)
+ // Windows: "C:\Documents and Settings\username\Application Data"
+ // Mac: ~/Library/Preferences
fn.SetPath( wxStandardPaths::Get().GetUserConfigDir() );
-#if defined( __WINDOWS__ )
+#if !defined( __WINDOWS__ )
+ fn.AppendDir( wxT( ".config" ) );
+#endif
fn.AppendDir( wxT( "kicad" ) );
-#endif
fn.SetName( global_tbl_name );
=== modified file 'common/pgm_base.cpp'
--- common/pgm_base.cpp 2014-09-02 16:44:53 +0000
+++ common/pgm_base.cpp 2014-09-02 19:43:42 +0000
@@ -405,7 +405,8 @@
SetLanguagePath();
// OS specific instantiation of wxConfigBase derivative:
- m_common_settings = new wxConfig( KICAD_COMMON );
+ //m_common_settings = new wxConfig( KICAD_COMMON );
+ m_common_settings = GetNewConfig( KICAD_COMMON );
ReadPdfBrowserInfos(); // needs m_common_settings
=== modified file 'include/common.h'
--- include/common.h 2014-09-02 16:44:53 +0000
+++ include/common.h 2014-09-02 19:43:42 +0000
@@ -612,5 +612,17 @@
/// Put aPriorityPath in front of all paths in the value of aEnvVar.
const wxString PrePendPath( const wxString& aEnvVar, const wxString& aPriorityPath );
+/**
+ * Use this function instead of creating a new wxConfig so we can put config files in
+ * the proper place (/$HOME/.config/kicad/) according to the FreeDesktop specification
+ * at http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
+ * The config object created here should be detroyed by the caller.
+ * @param aProgName is the name of the program calling this function - can be obtained by
+ * calling Pgm().App().GetAppName(). This will be the actual file name of the config file.
+ * @return A pointer to a new wxConfigBase derived object is returned. The caller is in charge
+ * of deleting it.
+ */
+wxConfigBase* GetNewConfig( const wxString& aProgName );
+
#endif // INCLUDE__COMMON_H_
=== modified file 'pcb_calculator/pcb_calculator.h'
--- pcb_calculator/pcb_calculator.h 2014-04-02 13:38:59 +0000
+++ pcb_calculator/pcb_calculator.h 2014-08-31 00:16:47 +0000
@@ -28,7 +28,7 @@
// must be rewritten
wxSize m_FrameSize;
wxPoint m_FramePos;
- wxConfig * m_Config;
+ wxConfigBase* m_Config;
enum TRANSLINE_TYPE_ID m_currTransLineType;
TRANSLINE * m_currTransLine; // a pointer to the active transline
// List of translines: ordered like in dialog menu list
=== modified file 'pcb_calculator/pcb_calculator_frame.cpp'
--- pcb_calculator/pcb_calculator_frame.cpp 2014-05-18 15:16:59 +0000
+++ pcb_calculator/pcb_calculator_frame.cpp 2014-08-31 00:15:20 +0000
@@ -24,6 +24,7 @@
#include <wx/wx.h>
#include <wx/config.h>
+#include <pgm_base.h>
#include <pcb_calculator.h>
#include <UnitSelector.h>
#include <bitmaps.h>
@@ -61,7 +62,7 @@
m_currTransLineType = DEFAULT_TYPE;
m_currAttenuator = NULL;
m_RegulatorListChanged = false;
- m_Config = new wxConfig();
+ m_Config = GetNewConfig( Pgm().App().GetAppName() );
// Populate transline list ordered like in dialog menu list
const static TRANSLINE_TYPE_ID tltype_list[8] =
Follow ups
References