From 09eff7243a6e8e37d9615df7b951ffa3c03c0ae2 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Wed, 19 Jan 2022 16:08:29 +0100 Subject: 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. --- fluid/Fl_Function_Type.cxx | 14 +++++++------- fluid/alignment_panel.fl | 23 ++++++++++++++--------- fluid/fluid.cxx | 2 +- 3 files changed, 22 insertions(+), 17 deletions(-) (limited to 'fluid') diff --git a/fluid/Fl_Function_Type.cxx b/fluid/Fl_Function_Type.cxx index 3c728863e..f51570d92 100644 --- a/fluid/Fl_Function_Type.cxx +++ b/fluid/Fl_Function_Type.cxx @@ -1530,7 +1530,7 @@ static void load_comments_preset(Fl_Preferences &menu) { "FLTK/Header" }; int i; menu.set("n", 5); - Fl_Preferences db(Fl_Preferences::USER, "fltk.org", "fluid_comments"); + Fl_Preferences db(Fl_Preferences::USER_L, "fltk.org", "fluid_comments"); for (i=0; i<5; i++) { menu.set(Fl_Preferences::Name(i), predefined_comment[i]); db.set(predefined_comment[i], comment_text[i]); @@ -1545,7 +1545,7 @@ void Fl_Comment_Type::open() { const char *text = name(); { int i=0, n=0; - Fl_Preferences menu(Fl_Preferences::USER, "fltk.org", "fluid_comments_menu"); + Fl_Preferences menu(Fl_Preferences::USER_L, "fltk.org", "fluid_comments_menu"); comment_predefined->clear(); comment_predefined->add("_Edit/Add current comment..."); comment_predefined->add("_Edit/Remove last selection..."); @@ -1583,9 +1583,9 @@ void Fl_Comment_Type::open() { char *name = fl_strdup(xname); for (char*s=name;*s;s++) if (*s==':') *s = ';'; int n; - Fl_Preferences db(Fl_Preferences::USER, "fltk.org", "fluid_comments"); + Fl_Preferences db(Fl_Preferences::USER_L, "fltk.org", "fluid_comments"); db.set(name, comment_input->buffer()->text()); - Fl_Preferences menu(Fl_Preferences::USER, "fltk.org", "fluid_comments_menu"); + Fl_Preferences menu(Fl_Preferences::USER_L, "fltk.org", "fluid_comments_menu"); menu.get("n", n, 0); menu.set(Fl_Preferences::Name(n), name); menu.set("n", ++n); @@ -1599,10 +1599,10 @@ void Fl_Comment_Type::open() { } else if (fl_choice("Are you sure that you want to delete the entry\n" "\"%s\"\nfrom the database?", "Cancel", "Delete", NULL, itempath)) { - Fl_Preferences db(Fl_Preferences::USER, "fltk.org", "fluid_comments"); + Fl_Preferences db(Fl_Preferences::USER_L, "fltk.org", "fluid_comments"); db.deleteEntry(itempath); comment_predefined->remove(last_selected_item); - Fl_Preferences menu(Fl_Preferences::USER, "fltk.org", "fluid_comments_menu"); + Fl_Preferences menu(Fl_Preferences::USER_L, "fltk.org", "fluid_comments_menu"); int i, n; for (i=4, n=0; isize(); i++) { const Fl_Menu_Item *mi = comment_predefined->menu()+i; @@ -1617,7 +1617,7 @@ void Fl_Comment_Type::open() { // load the selected comment from the database if (comment_predefined->item_pathname(itempath, 255)==0) { if (itempath[0]=='/') memmove(itempath, itempath+1, 255); - Fl_Preferences db(Fl_Preferences::USER, "fltk.org", "fluid_comments"); + Fl_Preferences db(Fl_Preferences::USER_L, "fltk.org", "fluid_comments"); char *text; db.get(itempath, text, "(no text found in data base)"); comment_input->buffer()->text(text); diff --git a/fluid/alignment_panel.fl b/fluid/alignment_panel.fl index 716ebcca3..af64ecb73 100644 --- a/fluid/alignment_panel.fl +++ b/fluid/alignment_panel.fl @@ -1,5 +1,10 @@ # data file for the Fltk User Interface Designer (fluid) version 1.0400 +i18n_type 1 +i18n_include {} +i18n_conditional FLTK_GETTEXT_FOUND +i18n_function gettext +i18n_static_function gettext_noop header_name {.h} code_name {.cxx} comment {// @@ -35,7 +40,7 @@ decl {\#include } {public local decl {\#include } {public local } -decl {\#include } {selected public local +decl {\#include } {public local } decl {\#include } {private global @@ -323,7 +328,7 @@ Function {make_shell_window()} {open tooltip {save the design to the .fl file before running the command} xywh {82 39 136 19} down_box DOWN_BOX labelsize 12 } Fl_Check_Button shell_writecode_button { - label {save source code} + label {save source code} selected tooltip {generate the source code and header file before running the command} xywh {82 59 120 19} down_box DOWN_BOX labelsize 12 } Fl_Check_Button shell_writemsgs_button { @@ -524,11 +529,11 @@ wShowZoomFactor->value(opt[Fl::OPTION_SHOW_SCALING][mode]);} {} } Function {readPrefs()} { - comment {read all preferences and refresh the GUI} private return_type void + comment {read all preferences and refresh the GUI} open private return_type void } { code {// read all preferences and refresh the GUI { - Fl_Preferences prefs(Fl_Preferences::SYSTEM, "fltk.org", "fltk"); + Fl_Preferences prefs(Fl_Preferences::SYSTEM_L, "fltk.org", "fltk"); Fl_Preferences opt_prefs(prefs, "options"); opt_prefs.get("ArrowFocus", opt[Fl::OPTION_ARROW_FOCUS][1], 2); opt_prefs.get("VisibleFocus", opt[Fl::OPTION_VISIBLE_FOCUS][1], 2); @@ -539,7 +544,7 @@ Function {readPrefs()} { opt_prefs.get("ShowZoomFactor", opt[Fl::OPTION_SHOW_SCALING ][1], 2); } { - Fl_Preferences prefs(Fl_Preferences::USER, "fltk.org", "fltk"); + Fl_Preferences prefs(Fl_Preferences::USER_L, "fltk.org", "fltk"); Fl_Preferences opt_prefs(prefs, "options"); opt_prefs.get("ArrowFocus", opt[Fl::OPTION_ARROW_FOCUS][0], 2); opt_prefs.get("VisibleFocus", opt[Fl::OPTION_VISIBLE_FOCUS][0], 2); @@ -553,11 +558,11 @@ refreshUI();} {} } Function {writePrefs()} { - comment {write all preferences using the array} private return_type void + comment {write all preferences using the array} open private return_type void } { code {// write all preferences using the array { - Fl_Preferences prefs(Fl_Preferences::SYSTEM, "fltk.org", "fltk"); + Fl_Preferences prefs(Fl_Preferences::SYSTEM_L, "fltk.org", "fltk"); Fl_Preferences opt_prefs(prefs, "options"); if (opt[Fl::OPTION_ARROW_FOCUS][1]==2) opt_prefs.deleteEntry("ArrowFocus"); else opt_prefs.set("ArrowFocus", opt[Fl::OPTION_ARROW_FOCUS][1]); @@ -575,7 +580,7 @@ Function {writePrefs()} { else opt_prefs.set("ShowZoomFactor", opt[Fl::OPTION_SHOW_SCALING][1]); } { - Fl_Preferences prefs(Fl_Preferences::USER, "fltk.org", "fltk"); + Fl_Preferences prefs(Fl_Preferences::USER_L, "fltk.org", "fltk"); Fl_Preferences opt_prefs(prefs, "options"); if (opt[Fl::OPTION_ARROW_FOCUS][0]==2) opt_prefs.deleteEntry("ArrowFocus"); else opt_prefs.set("ArrowFocus", opt[Fl::OPTION_ARROW_FOCUS][0]); @@ -594,7 +599,7 @@ Function {writePrefs()} { }} {} } -Function {show_global_settings_window()} {return_type void +Function {show_global_settings_window()} {open return_type void } { code {if (!global_settings_window) make_global_settings_window(); diff --git a/fluid/fluid.cxx b/fluid/fluid.cxx index 1ed1ad93b..aa0b2ee19 100644 --- a/fluid/fluid.cxx +++ b/fluid/fluid.cxx @@ -72,7 +72,7 @@ Fl_Menu_Bar *main_menubar = NULL; Fl_Window *main_window; /// Fluid application preferences, allways accessible, will be flushed when app closes. -Fl_Preferences fluid_prefs(Fl_Preferences::USER, "fltk.org", "fluid"); +Fl_Preferences fluid_prefs(Fl_Preferences::USER_L, "fltk.org", "fluid"); /// Align widget position and size when designing, saved in app preferences and project file. int gridx = 5; -- cgit v1.2.3