kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #14579
Re: Config file relocation (patch 5)
Ok, the previous patch actually put the files in
~/Library/Preferences/.config/kicad on OSX, so I added a check for __WXMAC__ so
it does not add the .config directory on OSX. I also did a little cleanup on the
patch - mainly removed the check for OS/2 which I'm pretty sure is not needed
for kicad!
nullset on IRC who did some testing did say he thinks the
~/Library/Preferences/kicad location is fine for the config files.
Moses
On 09/03/2014 12:17 PM, Moses McKnight wrote:
Hi Wayne,
One person on IRC is compiling with the patch to test on OSX. Currently the
files on OSX should go in ~/Library/Preferences/kicad, but from what he said and
also from these links, it looks like that might should be changed to
~/Library/Application Support/kicad. I did figure out an easy way to make the
change if it is decided that is better.
http://stackoverflow.com/questions/15677388/default-location-for-configuration-files-macos
https://developer.apple.com/library/mac/documentation/General/Conceptual/MOSXAppProgrammingGuide/AppRuntime/AppRuntime.html
The install_****_fp-lib-table cmake stuff is in the kicad library repository,
looks like under the template directory.
Moses
On 09/03/2014 09:02 AM, Wayne Stambaugh wrote:
<snip>
Can someone please test this on OSX to make sure it doesn't cause any
issues before we commit it. Also, kicad-install.sh calls `make
install_github_fp-lib-table` to install the global fp-lib-table. I
cannot find the definition of install_github_fp-lib-table in any of the
kicad CMake files. Where ever this is defined, it will need to be
changed to copy the global fp-lib-table to ~/.config/kicad.
Thanks,
Wayne
_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~kicad-developers
More help : https://help.launchpad.net/ListHelp
=== modified file 'bitmap2component/bitmap2cmp_gui.cpp'
--- bitmap2component/bitmap2cmp_gui.cpp 2014-08-22 10:24:14 +0000
+++ bitmap2component/bitmap2cmp_gui.cpp 2014-09-03 02:53:13 +0000
@@ -65,19 +65,19 @@
class BM2CMP_FRAME : public BM2CMP_FRAME_BASE
{
private:
- wxImage m_Pict_Image;
- wxBitmap m_Pict_Bitmap;
- wxImage m_Greyscale_Image;
- wxBitmap m_Greyscale_Bitmap;
- wxImage m_NB_Image;
- wxBitmap m_BN_Bitmap;
- wxSize m_imageDPI; // The initial image resolution. When unknown,
+ wxImage m_Pict_Image;
+ wxBitmap m_Pict_Bitmap;
+ wxImage m_Greyscale_Image;
+ wxBitmap m_Greyscale_Bitmap;
+ wxImage m_NB_Image;
+ wxBitmap m_BN_Bitmap;
+ wxSize m_imageDPI; // The initial image resolution. When unknown,
// set to DEFAULT_DPI x DEFAULT_DPI per Inch
- wxString m_BitmapFileName;
- wxString m_ConvertedFileName;
- wxSize m_frameSize;
- wxPoint m_framePos;
- wxConfig* m_config;
+ wxString m_BitmapFileName;
+ wxString m_ConvertedFileName;
+ wxSize m_frameSize;
+ wxPoint m_framePos;
+ 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-03 02:49:20 +0000
@@ -1,8 +1,7 @@
-
-#include <wx/config.h>
#include <bin_mod.h>
#include <online_help.h>
+#include <common.h>
BIN_MOD::BIN_MOD( const char* aName ) :
@@ -15,7 +14,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-03 18:28:07 +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,29 @@
#endif
}
+wxConfigBase* GetNewConfig( const wxString& aProgName )
+{
+ wxConfigBase* cfg = 0;
+ 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__) && !defined(__WXMAC__)
+ 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() );
+ 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-03 18:20:41 +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__) && !defined(__WXMAC__)
+ 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-03 02:48:32 +0000
@@ -405,7 +405,7 @@
SetLanguagePath();
// OS specific instantiation of wxConfigBase derivative:
- 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-09-03 02:54:22 +0000
@@ -26,9 +26,9 @@
bool m_RegulatorListChanged; // set to true when m_RegulatorList
// was modified, and the corresponging file
// must be rewritten
- wxSize m_FrameSize;
- wxPoint m_FramePos;
- wxConfig * m_Config;
+ wxSize m_FrameSize;
+ wxPoint m_FramePos;
+ 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
-
Fwd: Re: Config file relocation
From: Moses McKnight, 2014-08-31
-
Re: Fwd: Re: Config file relocation
From: jp charras, 2014-08-31
-
Re: Fwd: Re: Config file relocation
From: Moses McKnight, 2014-09-01
-
Re: Fwd: Re: Config file relocation
From: Wayne Stambaugh, 2014-09-02
-
Re: Fwd: Re: Config file relocation
From: Moses McKnight, 2014-09-02
-
Re: Config file relocation (new patch)
From: Moses McKnight, 2014-09-02
-
Re: Config file relocation (new patch)
From: Nick Østergaard, 2014-09-02
-
Re: Config file relocation (new patch)
From: Moses McKnight, 2014-09-03
-
Re: Config file relocation (new patch)
From: Wayne Stambaugh, 2014-09-03
-
Re: Config file relocation (new patch)
From: Moses McKnight, 2014-09-03