summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Preferences.cxx54
-rw-r--r--src/filename_absolute.cxx1
2 files changed, 41 insertions, 14 deletions
diff --git a/src/Fl_Preferences.cxx b/src/Fl_Preferences.cxx
index 93b29db45..c7a47881f 100644
--- a/src/Fl_Preferences.cxx
+++ b/src/Fl_Preferences.cxx
@@ -233,7 +233,9 @@ Fl_Preferences::Root Fl_Preferences::filename( char *buffer, size_t buffer_size,
<tt>\<null\>/Library/Preferences/\$(vendor)/\$(application).prefs</tt>,
which would silently fail to create a preference file.
- \param[in] root can be \c USER_L or \c SYSTEM_L for user specific or system wide preferences
+ \param[in] root can be \c USER_L or \c SYSTEM_L for user specific or system
+ wide preferences, add the CLEAR flag to start with a clean set of
+ preferences instead of reading them from the database
\param[in] vendor unique text describing the company or author of this file, must be a valid filepath segment
\param[in] application unique text describing the application, must be a valid filepath segment
@@ -246,19 +248,41 @@ Fl_Preferences::Fl_Preferences( Root root, const char *vendor, const char *appli
}
/**
- \brief Use this constructor to create or read a preference file at an
- arbitrary position in the file system.
+ \brief Deprecated: Use this constructor to create or read a preference file at an
+ arbitrary position in the file system.
+
+ This constructor should no longer be used because the generated database uses
+ the current locale, making it impossible to exchange floating point settings
+ between machines with different language settings.
- The file name is generated in the form <tt>\$(path)/\$(application).prefs</tt>.
- If \p application is \c NULL, \p path is taken literally as the file path and name.
+ Use `Fl_Preferences(path, vendor, application, C_LOCALE)` in new projects and
+ `Fl_Preferences(path, vendor, application, 0)` if you must keep backward
+ compatibility.
- \param[in] path path to the directory that contains the preference file
- \param[in] vendor unique text describing the company or author of this file, must be a valid filepath segment
- \param[in] application unique text describing the application, must be a valid filepath segment
+ \see Fl_Preferences( const char *path, const char *vendor, const char *application, Root flags )
*/
Fl_Preferences::Fl_Preferences( const char *path, const char *vendor, const char *application ) {
node = new Node( "." );
- rootNode = new RootNode( this, path, vendor, application );
+ rootNode = new RootNode( this, path, vendor, application, (Root)0 );
+ node->setRoot(rootNode);
+}
+
+/**
+ \brief Use this constructor to create or read a preference file at an
+ arbitrary position in the file system.
+
+ The file name is generated in the form <tt>\$(path)/\$(application).prefs</tt>.
+ If \p application is \c NULL, \p path is taken literally as the file path and name.
+
+ \param[in] path path to the directory that contains the preference file
+ \param[in] vendor unique text describing the company or author of this file, must be a valid filepath segment
+ \param[in] application unique text describing the application, must be a valid filename or NULL
+ \param[in] set C_LOCALE to make the preferences file independent of the current locale,
+ add the CLEAR flag to start with a clean set of preferences instead of reading from the database
+ */
+Fl_Preferences::Fl_Preferences( const char *path, const char *vendor, const char *application, Root flags ) {
+ node = new Node( "." );
+ rootNode = new RootNode( this, path, vendor, application, flags );
node->setRoot(rootNode);
}
@@ -1168,23 +1192,24 @@ Fl_Preferences::RootNode::RootNode( Fl_Preferences *prefs, Root root, const char
filename_(0L),
vendor_(0L),
application_(0L),
- root_type_(root)
+ root_type_((Root)(root & ~CLEAR))
{
char *filename = Fl::system_driver()->preference_rootnode(prefs, root, vendor, application);
filename_ = filename ? fl_strdup(filename) : 0L;
vendor_ = fl_strdup(vendor);
application_ = fl_strdup(application);
- read();
+ if ( (root & CLEAR) == 0 )
+ read();
}
// create the root node
// - construct the name of the file that will hold our preferences
-Fl_Preferences::RootNode::RootNode( Fl_Preferences *prefs, const char *path, const char *vendor, const char *application )
+Fl_Preferences::RootNode::RootNode( Fl_Preferences *prefs, const char *path, const char *vendor, const char *application, Root flags )
: prefs_(prefs),
filename_(0L),
vendor_(0L),
application_(0L),
- root_type_(Fl_Preferences::USER)
+ root_type_( (Root)(USER | (flags & C_LOCALE) ))
{
if (!vendor)
@@ -1199,7 +1224,8 @@ Fl_Preferences::RootNode::RootNode( Fl_Preferences *prefs, const char *path, con
}
vendor_ = fl_strdup(vendor);
application_ = fl_strdup(application);
- read();
+ if ( (flags & CLEAR) == 0 )
+ read();
}
// create a root node that exists only on RAM and can not be read or written to
diff --git a/src/filename_absolute.cxx b/src/filename_absolute.cxx
index 70b86fcf7..0d0155df1 100644
--- a/src/filename_absolute.cxx
+++ b/src/filename_absolute.cxx
@@ -367,3 +367,4 @@ Fl_String fl_getcwd() {
fl_getcwd(buffer, FL_PATH_MAX);
return Fl_String(buffer);
}
+