diff options
| author | Matthias Melcher <github@matthiasm.com> | 2022-01-19 16:08:29 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-19 16:08:29 +0100 |
| commit | 09eff7243a6e8e37d9615df7b951ffa3c03c0ae2 (patch) | |
| tree | 513b39c92f1f6a9d0f0ca7f9a1488f298f7a068e /test/preferences.fl | |
| parent | 793f4b90fac349b096922a6b90ae2731777ac6cf (diff) | |
Fixing and upgrading Fl_Preferences (#374)
* Added filename function to Fl_Preferences
Static function to get filename before opening.
Member to get filename after opening.
Bug fixes for memory mapped preferences.
* ERROR is a macro on Windows, don't use it
* Added Fl_Preferences::dirty().
User can now check if the database will be written
when flushed or destroyed.
Flush returns a crude error code.
* Fl_Preferences::get binary data returns # of bytes read.
* Verified group deletion code
* Fl_Preferences ignores locale.
This will make .prefs files interchangeable
between different computers.
* Updating the Preferences Mode to ignore locale.
* Fixes in docs.
Diffstat (limited to 'test/preferences.fl')
| -rw-r--r-- | test/preferences.fl | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/test/preferences.fl b/test/preferences.fl index e7d5b1756..ef2cc5d1a 100644 --- a/test/preferences.fl +++ b/test/preferences.fl @@ -45,7 +45,7 @@ Function {saveAndCloseWindowCB( Fl_Widget*, void* )} {open private return_type v Fl::delete_widget(myWindow);} {} } -Function {} {open return_type int +Function {} {open selected return_type int } { Fl_Window myWindow { label {My Preferences} @@ -78,7 +78,7 @@ Function {} {open return_type int xywh {0 0 100 20} } MenuItem {} { - label {p.m.} selected + label {p.m.} xywh {0 0 100 20} } } @@ -206,10 +206,32 @@ int intValue; char buffer[80]; double doubleValue; -Fl_Preferences app( Fl_Preferences::USER, project, application ); +char path[ FL_PATH_MAX ]; +Fl_Preferences::Root root = + Fl_Preferences::filename(path, FL_PATH_MAX, Fl_Preferences::USER_L, project, application); +if (root == Fl_Preferences::UNKNOWN_ROOT_TYPE) { + printf("Location of future Preferences file not found.\\n"); +} else { + printf("Preferences file will be located at:\\n%s\\n", path); +} + +Fl_Preferences app( Fl_Preferences::USER_L, project, application ); - char path[ FL_PATH_MAX ]; - app.getUserdataPath( path, sizeof(path) ); + root = app.filename(path, FL_PATH_MAX); + if (root == Fl_Preferences::UNKNOWN_ROOT_TYPE) { + printf("Location of app Preferences file not found.\\n"); + } else if (root == Fl_Preferences::MEMORY) { + printf("App Preferences are memory mapped.\\n"); + } else { + printf("App Preferences file is actually located at:\\n%s\\n", path); + } + + app.getUserdataPath( path, sizeof(path) ); + if (path[0]) { + printf("Preferences user data directory is located at:\\n%s\\n", path); + } else { + printf("Location of Preferences user data directory not found.\\n"); + } Fl_Preferences bed( app, "Bed" ); bed.get( "alarm", buffer, "8:00", 79 ); @@ -278,7 +300,7 @@ Fl_Preferences app( Fl_Preferences::USER, project, application ); Function {writePrefs()} {open return_type void } { - code {Fl_Preferences app( Fl_Preferences::USER, project, application ); + code {Fl_Preferences app( Fl_Preferences::USER_L, project, application ); Fl_Preferences bed( app, "Bed" ); |
