]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormPreferences.C
More pref work from Angus
[lyx.git] / src / frontends / xforms / FormPreferences.C
index 6ea7d22e4264c313d4294b000449d4ec4317874b..6ac12145236f04e6fe809dbb869405ad5c03384a 100644 (file)
@@ -2,6 +2,7 @@
  * FormPreferences Interface Class Implementation
  */
 
+#include <utility>
 #include <config.h>
 
 #include FORMS_H_LOCATION
@@ -10,6 +11,7 @@
 #pragma implementation
 #endif
 
+#include "Lsstream.h"
 #include "FormPreferences.h"
 #include "form_preferences.h"
 #include "input_validators.h"
@@ -23,6 +25,9 @@
 #include "support/FileInfo.h"
 #include "support/filetools.h"
 #include "lyx_gui_misc.h"
+#include "lyxlex.h"
+#include "input_validators.h"
+#include "xform_helpers.h" // formatted()
 #include "xform_macros.h"
 
 #ifdef SIGC_CXX_NAMESPACES
@@ -30,17 +35,30 @@ using SigC::slot;
 #endif
 
 using std::find;
+using std::getline;
+using std::istream;
+using std::pair;
 using std::vector;
 
+extern string fmt(char const * fmtstr ...);
 extern Languages languages;
 
+typedef pair<string, FormPreferences::RGB> X11Colour;
+
+static vector<X11Colour> colourDB;
+static string const colourFile = "/usr/lib/X11/rgb.txt";
+
+
 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
        : FormBaseBI(lv, d, _("Preferences"), new PreferencesPolicy),
-         dialog_(0), outputs_tab_(0), look_n_feel_tab_(0), inputs_tab_(0),
-         usage_tab_(0), colours_(0), inputs_misc_(0), interface_(0),
-         language_(0), lnf_misc_(0), outputs_misc_(0), paths_(0), printer_(0),
-         screen_fonts_(0), spellchecker_(0),
-         combo_default_lang(0), combo_kbmap_1(0), combo_kbmap_2(0)
+         dialog_(0),
+         converters_tab_(0), inputs_tab_(0), look_n_feel_tab_(0),
+         outputs_tab_(0),  usage_tab_(0),
+         colours_(0), converters_(0), formats_(0), inputs_misc_(0),
+         interface_(0), language_(0), lnf_misc_(0), outputs_misc_(0),
+         paths_(0), printer_(0), screen_fonts_(0), spellchecker_(0),
+         combo_default_lang(0), combo_kbmap_1(0), combo_kbmap_2(0),
+         feedbackObj(0)
 {
        // let the dialog be shown
        // This is a permanent connection so we won't bother
@@ -55,11 +73,15 @@ FormPreferences::~FormPreferences()
        delete combo_kbmap_1;
        delete combo_kbmap_2;
 
-       delete look_n_feel_tab_;
+       delete converters_tab_;
        delete inputs_tab_;
+       delete look_n_feel_tab_;
        delete outputs_tab_;
        delete usage_tab_;
+
        delete colours_;
+       delete converters_;
+       delete formats_;
        delete inputs_misc_;
        delete interface_;
        delete language_;
@@ -70,8 +92,8 @@ FormPreferences::~FormPreferences()
        delete screen_fonts_;
        delete spellchecker_;
 
-       // Must be last to be deleted, or we'll get a SIGSEGV.
-       // Something to do with the Timer mechanism.
+       // Must delete dialog last or we'll end up with a SIGSEGV trying to
+       // access dialog_->timer_feedback in feedbackPost().
        delete dialog_;
 }
 
@@ -90,15 +112,6 @@ void FormPreferences::ok()
 }
 
 
-void FormPreferences::restore()
-{
-       update();
-// if I add an error message line to the dialog it'll have to be controlled
-// within input().  I don't need it yet so I'll leave it commented out.
-//     bc_.valid(input(0));
-}
-
-
 void FormPreferences::hide()
 {
        // We need to hide the active tabfolder otherwise we get a
@@ -128,14 +141,17 @@ void FormPreferences::build()
        minh_ = form()->h;
 
        // build the tab folders
-       outputs_tab_ = build_outer_tab();
+       converters_tab_ = build_outer_tab();
        look_n_feel_tab_ = build_outer_tab();
        inputs_tab_ = build_outer_tab();
+       outputs_tab_ = build_outer_tab();
        usage_tab_ = build_outer_tab();
 
        // build actual tabfolder contents
        // these will become nested tabfolders
        buildColours();
+       buildConverters();
+       buildFormats();
        buildInputsMisc();
        buildInterface();
        buildLanguage();
@@ -150,15 +166,18 @@ void FormPreferences::build()
        fl_addto_tabfolder(dialog_->tabfolder_prefs,
                           _("Look and Feel"),
                           look_n_feel_tab_->form);
+       fl_addto_tabfolder(dialog_->tabfolder_prefs,
+                          _("Usage"),
+                          usage_tab_->form);
+       fl_addto_tabfolder(dialog_->tabfolder_prefs,
+                          _("Converters"),
+                          converters_tab_->form);
        fl_addto_tabfolder(dialog_->tabfolder_prefs,
                           _("Inputs"),
                           inputs_tab_->form);
        fl_addto_tabfolder(dialog_->tabfolder_prefs,
                           _("Outputs"),
                           outputs_tab_->form);
-       fl_addto_tabfolder(dialog_->tabfolder_prefs,
-                          _("Usage"),
-                          usage_tab_->form);
 
        // now build the nested tabfolders
        // Starting with look and feel
@@ -175,6 +194,14 @@ void FormPreferences::build()
                           _("Misc"),
                           lnf_misc_->form);
 
+       // then build converters
+       fl_addto_tabfolder(converters_tab_->tabfolder_outer,
+                          _("Formats"),
+                          formats_->form);
+       fl_addto_tabfolder(converters_tab_->tabfolder_outer,
+                          _("Converters"),
+                          converters_->form);
+
        // then build inputs
        // Paths should probably go in a few outer_tab called Files
        fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
@@ -215,6 +242,8 @@ void FormPreferences::apply()
        // and other stuff which may cost us a lot on slower/high-load machines.
 
        applyColours();
+       applyConverters();
+       applyFormats();
        applyInputsMisc();
        applyInterface();
        applyLanguage();
@@ -229,30 +258,43 @@ void FormPreferences::apply()
 
 void FormPreferences::feedback( FL_OBJECT * ob )
 {
-       if( ob->form->fdui == colours_ )
-               feedbackColours( ob );
-       if( ob->form->fdui == inputs_misc_ )
-               feedbackInputsMisc( ob );
-       if( ob->form->fdui == interface_ )
-               feedbackInterface( ob );
-       if( ob->form->fdui == language_ )
-               feedbackLanguage( ob );
-       if( ob->form->fdui == lnf_misc_ )
-               feedbackLnFmisc( ob );
-       if( ob->form->fdui == outputs_misc_ )
-               feedbackOutputsMisc( ob );
-       if( ob->form->fdui == paths_ )
-               feedbackPaths( ob );
-       if( ob->form->fdui == printer_ )
-               feedbackPrinter( ob );
-       if( ob->form->fdui == screen_fonts_ )
-               feedbackScreenFonts( ob );
-       if( ob->form->fdui == spellchecker_ )
-               feedbackSpellChecker( ob );
-}
-
-
-bool FormPreferences::input(FL_OBJECT * ob, long data)
+       string str;
+
+       if( ob->form->fdui == colours_ ) {
+               str = feedbackColours( ob );
+       } else if( ob->form->fdui == converters_ ) {
+               str = feedbackConverters( ob );
+       } else if( ob->form->fdui == formats_ ) {
+               str = feedbackFormats( ob );
+       } else if( ob->form->fdui == inputs_misc_ ) {
+               str = feedbackInputsMisc( ob );
+       } else if( ob->form->fdui == interface_ ) {
+               str = feedbackInterface( ob );
+       } else if( ob->form->fdui == language_ ) {
+               str = feedbackLanguage( ob );
+       } else if( ob->form->fdui == lnf_misc_ ) {
+               str = feedbackLnFmisc( ob );
+       } else if( ob->form->fdui == outputs_misc_ ) {
+               str = feedbackOutputsMisc( ob );
+       } else if( ob->form->fdui == paths_ ) {
+               str = feedbackPaths( ob );
+       } else if( ob->form->fdui == printer_ ) {
+               str = feedbackPrinter( ob );
+       } else if( ob->form->fdui == screen_fonts_ ) {
+               str = feedbackScreenFonts( ob );
+       } else if( ob->form->fdui == spellchecker_ ) {
+               str = feedbackSpellChecker( ob );
+       }
+
+       str = formatted( str, dialog_->text_warning->w-10,
+                        FL_SMALL_SIZE, FL_NORMAL_STYLE );
+
+       fl_set_object_label(dialog_->text_warning, str.c_str());
+       fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+}
+
+
+bool FormPreferences::input(FL_OBJECT * ob, long)
 {
        bool activate = true;
 
@@ -260,30 +302,21 @@ bool FormPreferences::input(FL_OBJECT * ob, long data)
        // some totally ridiculous value somewhere.  Change activate to suit.
        // comments before each test describe what is _valid_
 
-       State cb = static_cast<State>( data );
-       switch( cb ) {
-       case LANGUAGE:
+       if( ob->form->fdui == colours_ ) {
+               if( ! inputColours( ob ) )
+                       activate = false;
+       } else if( ob->form->fdui == language_ ) {
                if( ! inputLanguage( ob ) )
                        activate = false;
-               break;
-
-       case PATHS:
+       } else if( ob->form->fdui == paths_ ) {
                if( ! inputPaths( ob ) )
                        activate = false;
-               break;
-
-       case SCREENFONTS:
+       } else if( ob->form->fdui == screen_fonts_ ) {
                if( ! inputScreenFonts() )
                        activate = false;
-               break;
-
-       case SPELLCHECKER:
+       } else if( ob->form->fdui == spellchecker_ ) {
                if( ! inputSpellChecker( ob ) )
                        activate = false;
-               break;
-
-       default:
-               break;
        }
 
        return activate;
@@ -296,6 +329,8 @@ void FormPreferences::update()
     
        // read lyxrc entries
        updateColours();
+       updateConverters();
+       updateFormats();
        updateInputsMisc();
        updateInterface();
        updateLanguage();
@@ -308,7 +343,7 @@ void FormPreferences::update()
 }
 
 
-void FormPreferences::applyColours()
+void FormPreferences::applyColours() const
 {
 }
 
@@ -316,11 +351,220 @@ void FormPreferences::applyColours()
 void FormPreferences::buildColours()
 {
        colours_ = build_colours();
+
+       FL_OBJECT *obj;
+       obj = colours_->valslider_red;
+       fl_set_slider_bounds(obj, 0, 255);
+       fl_set_slider_precision(obj, 0);
+       fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
+       
+       obj = colours_->valslider_green;
+       fl_set_slider_bounds(obj, 0, 255);
+       fl_set_slider_precision(obj, 0);
+       fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
+       
+       obj = colours_->valslider_blue;
+       fl_set_slider_bounds(obj, 0, 255);
+       fl_set_slider_precision(obj, 0);
+       fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
+
+       fl_set_object_color(colours_->button_colour,
+                           FL_FREE_COL4, FL_FREE_COL4);
+       
+       fl_set_input_return(colours_->input_name, FL_RETURN_END_CHANGED);
+
+       if( ColoursLoadBrowser(colourFile) )
+               fl_set_input(colours_->input_name, colourFile.c_str());
+       else
+               fl_set_input(colours_->input_name, N_("No file found"));
+
+       // deactivate the browse button because it isn't implemented
+       fl_deactivate_object(colours_->button_browse);
+       fl_set_object_lcol(colours_->button_browse, FL_INACTIVE);
+}
+
+
+string FormPreferences::feedbackColours( FL_OBJECT const * const ) const
+{
+       return string();
+}
+
+
+bool FormPreferences::inputColours( FL_OBJECT const * const ob )
+{
+       bool activate = true;
+       
+       if( ob == colours_->browser_x11 ) {
+               int i = fl_get_browser(colours_->browser_x11);
+               if( i > 0) {
+                       ColoursUpdateBrowser(i-1);
+               }
+
+       } else if( ob == colours_->valslider_red
+                  || ob == colours_->valslider_green
+                  || ob == colours_->valslider_blue ) {
+               ColoursUpdateRGB();
+
+       } else if( ob == colours_->input_name) {
+               string file = fl_get_input(colours_->input_name);
+               if( ColoursLoadBrowser(file) )
+                       fl_set_input(colours_->input_name, file.c_str());
+               else if( ColoursLoadBrowser(colourFile) )
+                       fl_set_input(colours_->input_name, colourFile.c_str());
+               else
+                       fl_set_input(colours_->input_name, N_("No file found"));
+       }
+
+       return activate;
+}
+
+
+bool FormPreferences::ColoursLoadBrowser( string const & filename )
+{
+       LyXLex lex(0, 0);
+
+       if (!lex.setFile(filename))
+               return false;
+
+       istream & is = lex.getStream();
+       string line;
+
+       vector<RGB> cols;
+       vector<string> names;
+       
+       while( 1 ) {
+               getline( is, line );
+               if( line.empty() )
+                       break;
+
+               if( line[0] != '!' ) {
+                       RGB col;
+                       string name;
+                       
+                       istringstream iss(line);
+                       iss >> col.r >> col.g >> col.b;
+                       while( iss.good() ) {
+                               string next;
+                               iss >> next;
+                               if( !name.empty() ) name += " ";
+                               name += next;
+                       }
+
+                       // remove redundant entries on the fly
+                       bool add = cols.empty();
+                       if( !add ) {
+                               vector<RGB>::const_iterator it =
+                                       find( cols.begin(), cols.end(), col );
+                               add = (it == cols.end());
+                       }
+                       
+                       if ( add ) {
+                               name = lowercase( name );
+                               if( name == "gray0" )   name = "black";
+                               if( name == "gray100" ) name = "white";
+
+                               if( name == "black" || name == "white" ) {
+                                       cols.insert(cols.begin(), col);
+                                       names.insert(names.begin(), name);
+                               } else {
+                                       cols.push_back(col);
+                                       names.push_back(name);
+                               }
+                       }
+               }
+       }
+
+       vector<string>::iterator sit = names.begin();
+       for( vector<RGB>::const_iterator iit = cols.begin();
+            iit != cols.end(); ++iit, ++sit ) {
+               colourDB.push_back( X11Colour(*sit, *iit) );
+       }
+       
+       FL_OBJECT * colbr = colours_->browser_x11;
+       fl_freeze_form(colours_->form);
+       fl_clear_browser( colbr );
+
+       for( vector<X11Colour>::const_iterator cit = colourDB.begin();
+            cit != colourDB.end(); ++cit ) {
+               string name = (*cit).first;
+               //RGB col     = (*cit).second;
+               //name += "  (" + tostr(col.r) + ", " + tostr(col.g) +
+               //      ", " + tostr(col.b) + ")";
+               fl_addto_browser(colbr, name.c_str());
+       }
+
+       fl_set_browser_topline(colbr, 1);
+       fl_select_browser_line(colbr, 1);
+       ColoursUpdateBrowser(0);
+       fl_unfreeze_form(colours_->form);
+       
+       return true;
+}
+
+
+int FormPreferences::ColoursSearchEntry(RGB const & col ) const
+{
+       int mindiff = 0x7fffffff;
+       vector<X11Colour>::const_iterator mincit = colourDB.begin();
+
+       for( vector<X11Colour>::const_iterator cit = colourDB.begin();
+            cit != colourDB.end(); ++cit ) {
+               RGB colDB = (*cit).second;
+               RGB diff;
+               diff.r = col.r - colDB.r;
+               diff.g = col.g - colDB.g;
+               diff.b = col.b - colDB.b;
+
+               int d = (2 * (diff.r * diff.r) +
+                        3 * (diff.g * diff.g) +
+                            (diff.b * diff.b));
+
+               if( mindiff > d ) {
+                       mindiff = d;
+                       mincit = cit;
+               }
+       }
+       return static_cast<int>(mincit - colourDB.begin());
+}
+
+
+void FormPreferences::ColoursUpdateBrowser( int i )
+{
+       fl_freeze_form(colours_->form);
+
+       RGB col = colourDB[i].second;
+    
+       fl_mapcolor(FL_FREE_COL4+i, col.r, col.g, col.b);
+       fl_mapcolor(FL_FREE_COL4,   col.r, col.g, col.b);
+       fl_set_slider_value(colours_->valslider_red,   col.r);
+       fl_set_slider_value(colours_->valslider_green, col.g);
+       fl_set_slider_value(colours_->valslider_blue,  col.b);
+       fl_redraw_object(colours_->button_colour);
+
+       fl_unfreeze_form(colours_->form);
 }
 
 
-void FormPreferences::feedbackColours( FL_OBJECT const * const )
+void FormPreferences::ColoursUpdateRGB()
 {
+       fl_freeze_form(colours_->form);
+
+       RGB col;
+       col.r = int(fl_get_slider_value(colours_->valslider_red));
+       col.g = int(fl_get_slider_value(colours_->valslider_green));
+       col.b = int(fl_get_slider_value(colours_->valslider_blue));
+    
+       fl_mapcolor(FL_FREE_COL4, col.r, col.g, col.b);
+       fl_redraw_object(colours_->button_colour);
+
+       int i = ColoursSearchEntry( col );
+       // change topline only if necessary
+       // int top = fl_get_browser_topline(colours_->browser_x11);
+       // if(i < top || i > (top+15))
+       fl_set_browser_topline(colours_->browser_x11, i-5);
+       fl_select_browser_line(colours_->browser_x11, i + 1);
+
+       fl_unfreeze_form(colours_->form);
 }
 
 
@@ -329,7 +573,67 @@ void FormPreferences::updateColours()
 }
 
 
-void FormPreferences::applyInputsMisc()
+void FormPreferences::applyConverters() const
+{
+}
+
+
+void FormPreferences::buildConverters()
+{
+       converters_ = build_converters();
+
+}
+
+
+string FormPreferences::feedbackConverters( FL_OBJECT const * const ) const
+{
+       return string();
+}
+
+
+void FormPreferences::updateConverters()
+{
+}
+
+
+void FormPreferences::applyFormats() const
+{
+}
+
+
+void FormPreferences::buildFormats()
+{
+       formats_ = build_formats();
+
+       fl_set_input_return(formats_->input_format, FL_RETURN_CHANGED);
+       fl_set_input_return(formats_->input_viewer, FL_RETURN_CHANGED);
+       fl_set_input_return(formats_->input_gui_name, FL_RETURN_CHANGED);
+       fl_set_input_return(formats_->input_extension, FL_RETURN_CHANGED);
+
+       fl_set_input_filter(formats_->input_format, fl_lowercase_filter);
+}
+
+
+string FormPreferences::feedbackFormats( FL_OBJECT const * const ) const
+{
+       string str;
+
+       return str;
+}
+
+
+bool FormPreferences::inputFormats( FL_OBJECT const * const )
+{
+       return true;
+}
+
+
+void FormPreferences::updateFormats()
+{
+}
+
+
+void FormPreferences::applyInputsMisc() const
 {
        lyxrc.date_insert_format = fl_get_input(inputs_misc_->input_date_format);
 }
@@ -351,15 +655,14 @@ void FormPreferences::buildInputsMisc()
 }
 
 
-void FormPreferences::feedbackInputsMisc( FL_OBJECT const * const ob )
+string FormPreferences::feedbackInputsMisc( FL_OBJECT const * const ob ) const
 {
        string str;
 
        if( ob == inputs_misc_->input_date_format )
-               str = lyxrc.getFeedback( LyXRC::RC_DATE_INSERT_FORMAT );
+               str = lyxrc.getDescription( LyXRC::RC_DATE_INSERT_FORMAT );
 
-       fl_set_object_label(dialog_->text_warning, str.c_str());
-       fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+       return str;
 }
 
 
@@ -370,7 +673,7 @@ void FormPreferences::updateInputsMisc()
 }
 
 
-void FormPreferences::applyInterface()
+void FormPreferences::applyInterface() const
 {
        lyxrc.popup_font_name =
                fl_get_input(interface_->input_popup_font);
@@ -418,25 +721,24 @@ void FormPreferences::buildInterface()
 
 
 
-void FormPreferences::feedbackInterface( FL_OBJECT const * const ob )
+string FormPreferences::feedbackInterface( FL_OBJECT const * const ob ) const
 {
        string str;
 
        if( ob == interface_->input_popup_font )
-               str = lyxrc.getFeedback( LyXRC::RC_SCREEN_FONT_POPUP );
+               str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_POPUP );
        else if ( ob == interface_->input_menu_font )
-               str = lyxrc.getFeedback( LyXRC::RC_SCREEN_FONT_MENU );
+               str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_MENU );
        else if ( ob == interface_->input_popup_encoding )
-               str = lyxrc.getFeedback( LyXRC::RC_SCREEN_FONT_ENCODING_MENU );
+               str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ENCODING_MENU );
        else if ( ob == interface_->input_bind_file )
-               str = lyxrc.getFeedback( LyXRC::RC_BINDFILE );
+               str = lyxrc.getDescription( LyXRC::RC_BINDFILE );
        else if ( ob == interface_->input_ui_file )
-               str = lyxrc.getFeedback( LyXRC::RC_UIFILE );
+               str = lyxrc.getDescription( LyXRC::RC_UIFILE );
        else if ( ob == interface_->check_override_x_dead_keys )
-               str = lyxrc.getFeedback( LyXRC::RC_OVERRIDE_X_DEADKEYS );
+               str = lyxrc.getDescription( LyXRC::RC_OVERRIDE_X_DEADKEYS );
 
-       fl_set_object_label(dialog_->text_warning, str.c_str());
-       fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+       return str;
 }
 
 
@@ -457,7 +759,7 @@ void FormPreferences::updateInterface()
 }
 
 
-void FormPreferences::applyLanguage()
+void FormPreferences::applyLanguage() const
 {
        lyxrc.default_language = combo_default_lang->getline();
 
@@ -496,32 +798,37 @@ void FormPreferences::buildLanguage()
        fl_set_input_return(language_->input_command_end, FL_RETURN_CHANGED);
 
        // The default_language is a combo-box and has to be inserted manually
+       fl_freeze_form(language_->form);
        fl_addto_form(language_->form);
 
        FL_OBJECT * obj = language_->choice_default_lang;
+       fl_deactivate_object(language_->choice_default_lang);
        combo_default_lang = new Combox(FL_COMBOX_DROPLIST);
        combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400);
        combo_default_lang->shortcut("#L",1);
        combo_default_lang->setcallback(ComboLanguageCB, this);
-       addLanguages( *combo_default_lang );
+       LanguagesAdd( *combo_default_lang );
        
        // ditto kbmap_1
        obj = language_->choice_kbmap_1;
+       fl_deactivate_object(language_->choice_kbmap_1);
        combo_kbmap_1 = new Combox(FL_COMBOX_DROPLIST);
        combo_kbmap_1->add(obj->x, obj->y, obj->w, obj->h, 400);
        combo_kbmap_1->shortcut("#1",1);
        combo_kbmap_1->setcallback(ComboLanguageCB, this);
-       addLanguages( *combo_kbmap_1 );
+       LanguagesAdd( *combo_kbmap_1 );
        
        // ditto kbmap_2
        obj = language_->choice_kbmap_2;
+       fl_deactivate_object(language_->choice_kbmap_2);
        combo_kbmap_2 = new Combox(FL_COMBOX_DROPLIST);
        combo_kbmap_2->add(obj->x, obj->y, obj->w, obj->h, 400);
        combo_kbmap_2->shortcut("#2",1);
        combo_kbmap_2->setcallback(ComboLanguageCB, this);
-       addLanguages( *combo_kbmap_2 );
+       LanguagesAdd( *combo_kbmap_2 );
 
        fl_end_form();
+       fl_unfreeze_form(language_->form);
 
        // set up the feedback mechanism
        fl_addto_form(language_->form);
@@ -529,10 +836,11 @@ void FormPreferences::buildLanguage()
        setPostHandler( language_->input_package );
        setPostHandler( language_->check_use_kbmap );
 
-       // these 3 should be replaced by the appropriate combox call
-       // setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_default_lang) );
-       // setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_1) );
-       // setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_2) );
+       // This is safe, as nothing is done to the pointer, other than
+       // to use its address in a block-if statement.
+       //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_default_lang) );
+       //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_1) );
+       //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_2) );
 
        setPostHandler( language_->check_rtl_support );
        setPostHandler( language_->check_mark_foreign );
@@ -545,44 +853,34 @@ void FormPreferences::buildLanguage()
 }
 
 
-void FormPreferences::addLanguages( Combox & combo )
-{
-       for(Languages::const_iterator cit = languages.begin();
-           cit != languages.end(); cit++) {
-               combo.addto((*cit).second.lang());
-       }
-}
-
-
-void FormPreferences::feedbackLanguage( FL_OBJECT const * const ob )
+string FormPreferences::feedbackLanguage( FL_OBJECT const * const ob ) const
 {
        string str;
 
        if( reinterpret_cast<Combox const *>(ob) == combo_default_lang )
-               str = lyxrc.getFeedback( LyXRC::RC_DEFAULT_LANGUAGE );
+               str = lyxrc.getDescription( LyXRC::RC_DEFAULT_LANGUAGE );
        else if( ob == language_->check_use_kbmap )
-               str = lyxrc.getFeedback( LyXRC::RC_KBMAP );
+               str = lyxrc.getDescription( LyXRC::RC_KBMAP );
        else if( reinterpret_cast<Combox const *>(ob) == combo_kbmap_1)
-               str = lyxrc.getFeedback( LyXRC::RC_KBMAP_PRIMARY );
+               str = lyxrc.getDescription( LyXRC::RC_KBMAP_PRIMARY );
        else if( reinterpret_cast<Combox const *>(ob) == combo_kbmap_2 )
-               str = lyxrc.getFeedback( LyXRC::RC_KBMAP_SECONDARY );
+               str = lyxrc.getDescription( LyXRC::RC_KBMAP_SECONDARY );
        else if( ob == language_->check_rtl_support )
-               str = lyxrc.getFeedback( LyXRC::RC_RTL_SUPPORT );
+               str = lyxrc.getDescription( LyXRC::RC_RTL_SUPPORT );
        else if( ob == language_->check_auto_begin )
-               str = lyxrc.getFeedback( LyXRC::RC_LANGUAGE_AUTO_BEGIN );
+               str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_AUTO_BEGIN );
        else if( ob == language_->check_auto_end )
-               str = lyxrc.getFeedback( LyXRC::RC_LANGUAGE_AUTO_END );
+               str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_AUTO_END );
        else if( ob == language_->check_mark_foreign )
-               str = lyxrc.getFeedback( LyXRC::RC_MARK_FOREIGN_LANGUAGE );
+               str = lyxrc.getDescription( LyXRC::RC_MARK_FOREIGN_LANGUAGE );
        else if( ob == language_->input_package )
-               str = lyxrc.getFeedback( LyXRC::RC_LANGUAGE_PACKAGE );
+               str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_PACKAGE );
        else if( ob == language_->input_command_begin )
-               str = lyxrc.getFeedback( LyXRC::RC_LANGUAGE_COMMAND_BEGIN );
+               str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_COMMAND_BEGIN );
        else if( ob == language_->input_command_end )
-               str = lyxrc.getFeedback( LyXRC::RC_LANGUAGE_COMMAND_END );
+               str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_COMMAND_END );
 
-       fl_set_object_label(dialog_->text_warning, str.c_str());
-       fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+       return str;
 }
 
 
@@ -638,7 +936,16 @@ void FormPreferences::updateLanguage()
 }
 
 
-void FormPreferences::applyLnFmisc()
+void FormPreferences::LanguagesAdd( Combox & combo ) const
+{
+       for(Languages::const_iterator cit = languages.begin();
+           cit != languages.end(); cit++) {
+               combo.addto((*cit).second.lang());
+       }
+}
+
+
+void FormPreferences::applyLnFmisc() const
 {
        lyxrc.show_banner = fl_get_button(lnf_misc_->check_banner);
        lyxrc.auto_region_delete = fl_get_button(lnf_misc_->
@@ -681,29 +988,28 @@ void FormPreferences::buildLnFmisc()
 }
 
 
-void FormPreferences::feedbackLnFmisc( FL_OBJECT const * const ob )
+string FormPreferences::feedbackLnFmisc( FL_OBJECT const * const ob ) const
 {
        string str;
 
        if( ob == lnf_misc_->check_banner )
-               str = lyxrc.getFeedback( LyXRC::RC_SHOW_BANNER );
+               str = lyxrc.getDescription( LyXRC::RC_SHOW_BANNER );
        else if( ob == lnf_misc_->check_auto_region_delete )
-               str = lyxrc.getFeedback( LyXRC::RC_AUTOREGIONDELETE );
+               str = lyxrc.getDescription( LyXRC::RC_AUTOREGIONDELETE );
        else if( ob == lnf_misc_->check_exit_confirm )
-               str = lyxrc.getFeedback( LyXRC::RC_EXIT_CONFIRMATION );
+               str = lyxrc.getDescription( LyXRC::RC_EXIT_CONFIRMATION );
        else if( ob == lnf_misc_->check_display_shortcuts )
-               str = lyxrc.getFeedback( LyXRC::RC_DISPLAY_SHORTCUTS );
+               str = lyxrc.getDescription( LyXRC::RC_DISPLAY_SHORTCUTS );
        else if( ob == lnf_misc_->check_ask_new_file )
-               str = lyxrc.getFeedback( LyXRC::RC_NEW_ASK_FILENAME );
+               str = lyxrc.getDescription( LyXRC::RC_NEW_ASK_FILENAME );
        else if( ob == lnf_misc_->check_cursor_follows_scrollbar )
-               str = lyxrc.getFeedback( LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR );
+               str = lyxrc.getDescription( LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR );
        else if( ob == lnf_misc_->counter_autosave )
-               str = lyxrc.getFeedback( LyXRC::RC_AUTOSAVE );
+               str = lyxrc.getDescription( LyXRC::RC_AUTOSAVE );
        else if( ob == lnf_misc_->counter_wm_jump )
-               str = lyxrc.getFeedback( LyXRC::RC_WHEEL_JUMP );
+               str = lyxrc.getDescription( LyXRC::RC_WHEEL_JUMP );
 
-       fl_set_object_label(dialog_->text_warning, str.c_str());
-       fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+       return str;
 }
 
 void FormPreferences::updateLnFmisc()
@@ -727,7 +1033,7 @@ void FormPreferences::updateLnFmisc()
 }
 
 
-void FormPreferences::applyOutputsMisc()
+void FormPreferences::applyOutputsMisc() const
 {
        lyxrc.ascii_linelen = static_cast<unsigned int>
                (fl_get_counter_value(outputs_misc_->counter_line_len));
@@ -770,23 +1076,22 @@ void FormPreferences::buildOutputsMisc()
 }
 
 
-void FormPreferences::feedbackOutputsMisc(FL_OBJECT const * const ob )
+string FormPreferences::feedbackOutputsMisc(FL_OBJECT const * const ob ) const
 {
        string str;
 
        if( ob == outputs_misc_->counter_line_len )
-               str = lyxrc.getFeedback( LyXRC::RC_ASCII_LINELEN );
+               str = lyxrc.getDescription( LyXRC::RC_ASCII_LINELEN );
        else if( ob == outputs_misc_->input_tex_encoding )
-               str = lyxrc.getFeedback( LyXRC::RC_FONT_ENCODING );
+               str = lyxrc.getDescription( LyXRC::RC_FONT_ENCODING );
        else if( ob == outputs_misc_->input_ascii_roff )
-               str = lyxrc.getFeedback( LyXRC::RC_ASCIIROFF_COMMAND );
+               str = lyxrc.getDescription( LyXRC::RC_ASCIIROFF_COMMAND );
        else if( ob == outputs_misc_->input_checktex )
-               str = lyxrc.getFeedback( LyXRC::RC_CHKTEX_COMMAND );
+               str = lyxrc.getDescription( LyXRC::RC_CHKTEX_COMMAND );
        else if( ob == outputs_misc_->choice_default_papersize )
-               str = lyxrc.getFeedback( LyXRC::RC_DEFAULT_PAPERSIZE );
+               str = lyxrc.getDescription( LyXRC::RC_DEFAULT_PAPERSIZE );
 
-       fl_set_object_label(dialog_->text_warning, str.c_str());
-       fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+       return str;
 }
 
 
@@ -890,32 +1195,32 @@ void FormPreferences::buildPaths()
 }
 
 
-void FormPreferences::feedbackPaths( FL_OBJECT const * const ob )
+string FormPreferences::feedbackPaths( FL_OBJECT const * const ob ) const
 {
        string str;
+
        if( ob == paths_->input_default_path )
-               str = lyxrc.getFeedback( LyXRC::RC_DOCUMENTPATH );
+               str = lyxrc.getDescription( LyXRC::RC_DOCUMENTPATH );
        else if ( ob == paths_->input_template_path )
-               str = lyxrc.getFeedback( LyXRC::RC_TEMPLATEPATH );
+               str = lyxrc.getDescription( LyXRC::RC_TEMPLATEPATH );
        else if ( ob == paths_->check_use_temp_dir )
-               str = lyxrc.getFeedback( LyXRC::RC_USETEMPDIR );
+               str = lyxrc.getDescription( LyXRC::RC_USETEMPDIR );
        else if ( ob == paths_->input_temp_dir )
-               str = lyxrc.getFeedback( LyXRC::RC_TEMPDIRPATH );
+               str = lyxrc.getDescription( LyXRC::RC_TEMPDIRPATH );
        else if ( ob == paths_->check_last_files )
-               str = lyxrc.getFeedback( LyXRC::RC_CHECKLASTFILES );
+               str = lyxrc.getDescription( LyXRC::RC_CHECKLASTFILES );
        else if ( ob == paths_->input_lastfiles )
-               str = lyxrc.getFeedback( LyXRC::RC_LASTFILES );
+               str = lyxrc.getDescription( LyXRC::RC_LASTFILES );
        else if ( ob == paths_->counter_lastfiles )
-               str = lyxrc.getFeedback( LyXRC::RC_NUMLASTFILES );
+               str = lyxrc.getDescription( LyXRC::RC_NUMLASTFILES );
        else if ( ob == paths_->check_make_backups )
-               str = lyxrc.getFeedback( LyXRC::RC_MAKE_BACKUP );
+               str = lyxrc.getDescription( LyXRC::RC_MAKE_BACKUP );
        else if ( ob == paths_->input_backup_path )
-               str = lyxrc.getFeedback( LyXRC::RC_BACKUPDIR_PATH );
+               str = lyxrc.getDescription( LyXRC::RC_BACKUPDIR_PATH );
        else if ( ob == paths_->input_serverpipe )
-               str = lyxrc.getFeedback( LyXRC::RC_SERVERPIPE );
-       
-       fl_set_object_label(dialog_->text_warning, str.c_str());
-       fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+               str = lyxrc.getDescription( LyXRC::RC_SERVERPIPE );
+
+       return str;
 }
 
 
@@ -1047,7 +1352,7 @@ void FormPreferences::updatePaths()
 }
 
 
-void FormPreferences::applyPrinter()
+void FormPreferences::applyPrinter() const
 {
        lyxrc.print_adapt_output = fl_get_button(printer_->check_adapt_output);
        lyxrc.print_command = fl_get_input(printer_->input_command);
@@ -1075,49 +1380,48 @@ void FormPreferences::applyPrinter()
 }
 
 
-void FormPreferences::feedbackPrinter( FL_OBJECT const * const ob )
+string FormPreferences::feedbackPrinter( FL_OBJECT const * const ob ) const
 {
        string str;
 
        if( ob == printer_->input_command )
-               str = lyxrc.getFeedback( LyXRC::RC_PRINT_COMMAND );
+               str = lyxrc.getDescription( LyXRC::RC_PRINT_COMMAND );
        else if( ob == printer_->check_adapt_output )
-               str = lyxrc.getFeedback( LyXRC::RC_PRINT_ADAPTOUTPUT );
+               str = lyxrc.getDescription( LyXRC::RC_PRINT_ADAPTOUTPUT );
        else if( ob == printer_->input_to_printer )
-               str = lyxrc.getFeedback( LyXRC::RC_PRINTTOPRINTER );
+               str = lyxrc.getDescription( LyXRC::RC_PRINTTOPRINTER );
        else if( ob == printer_->input_to_file )
-               str = lyxrc.getFeedback( LyXRC::RC_PRINTTOFILE );
+               str = lyxrc.getDescription( LyXRC::RC_PRINTTOFILE );
        else if( ob == printer_->input_file_extension )
-               str = lyxrc.getFeedback( LyXRC::RC_PRINTFILEEXTENSION );
+               str = lyxrc.getDescription( LyXRC::RC_PRINTFILEEXTENSION );
        else if( ob == printer_->input_extra_options )
-               str = lyxrc.getFeedback( LyXRC::RC_PRINTEXSTRAOPTIONS );
+               str = lyxrc.getDescription( LyXRC::RC_PRINTEXSTRAOPTIONS );
        else if( ob == printer_->input_spool_command )
-               str = lyxrc.getFeedback( LyXRC::RC_PRINTSPOOL_COMMAND );
+               str = lyxrc.getDescription( LyXRC::RC_PRINTSPOOL_COMMAND );
        else if( ob == printer_->input_spool_prefix )
-               str = lyxrc.getFeedback( LyXRC::RC_PRINTSPOOL_PRINTERPREFIX );
+               str = lyxrc.getDescription( LyXRC::RC_PRINTSPOOL_PRINTERPREFIX );
        else if( ob == printer_->input_name )
-               str = lyxrc.getFeedback( LyXRC::RC_PRINTER );
+               str = lyxrc.getDescription( LyXRC::RC_PRINTER );
        else if( ob == printer_->input_even_pages )
-               str = lyxrc.getFeedback( LyXRC::RC_PRINTEVENPAGEFLAG );
+               str = lyxrc.getDescription( LyXRC::RC_PRINTEVENPAGEFLAG );
        else if( ob == printer_->input_odd_pages )
-               str = lyxrc.getFeedback( LyXRC::RC_PRINTODDPAGEFLAG );
+               str = lyxrc.getDescription( LyXRC::RC_PRINTODDPAGEFLAG );
        else if( ob == printer_->input_page_range )
-               str = lyxrc.getFeedback( LyXRC::RC_PRINTPAGERANGEFLAG );
+               str = lyxrc.getDescription( LyXRC::RC_PRINTPAGERANGEFLAG );
        else if( ob == printer_->input_reverse )
-               str = lyxrc.getFeedback( LyXRC::RC_PRINTREVERSEFLAG );
+               str = lyxrc.getDescription( LyXRC::RC_PRINTREVERSEFLAG );
        else if( ob == printer_->input_landscape )
-               str = lyxrc.getFeedback( LyXRC::RC_PRINTLANDSCAPEFLAG );
+               str = lyxrc.getDescription( LyXRC::RC_PRINTLANDSCAPEFLAG );
        else if( ob == printer_->input_copies )
-               str = lyxrc.getFeedback( LyXRC::RC_PRINTCOLLCOPIESFLAG );
+               str = lyxrc.getDescription( LyXRC::RC_PRINTCOLLCOPIESFLAG );
        else if( ob == printer_->input_collated )
-               str = lyxrc.getFeedback( LyXRC::RC_PRINTCOPIESFLAG );
+               str = lyxrc.getDescription( LyXRC::RC_PRINTCOPIESFLAG );
        else if( ob == printer_->input_paper_type )
-               str = lyxrc.getFeedback( LyXRC::RC_PRINTPAPERFLAG );
+               str = lyxrc.getDescription( LyXRC::RC_PRINTPAPERFLAG );
        else if( ob == printer_->input_paper_size )
-               str = lyxrc.getFeedback( LyXRC::RC_PRINTPAPERDIMENSIONFLAG );
-       
-       fl_set_object_label(dialog_->text_warning, str.c_str());
-       fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+               str = lyxrc.getDescription( LyXRC::RC_PRINTPAPERDIMENSIONFLAG );
+
+       return str;
 }
 
 
@@ -1210,7 +1514,7 @@ void FormPreferences::updatePrinter()
 }
 
 
-void FormPreferences::applyScreenFonts()
+void FormPreferences::applyScreenFonts() const
 {
        bool changed = false;
 
@@ -1349,6 +1653,27 @@ void FormPreferences::buildScreenFonts()
        fl_set_input_return(screen_fonts_->input_huge, FL_RETURN_CHANGED);
        fl_set_input_return(screen_fonts_->input_huger, FL_RETURN_CHANGED);
 
+       fl_set_input_filter(screen_fonts_->input_tiny,
+                           fl_unsigned_int_filter);
+       fl_set_input_filter(screen_fonts_->input_script,
+                           fl_unsigned_int_filter);
+       fl_set_input_filter(screen_fonts_->input_footnote,
+                           fl_unsigned_int_filter);
+       fl_set_input_filter(screen_fonts_->input_small,
+                           fl_unsigned_int_filter);
+       fl_set_input_filter(screen_fonts_->input_normal,
+                           fl_unsigned_int_filter);
+       fl_set_input_filter(screen_fonts_->input_large,
+                           fl_unsigned_int_filter);
+       fl_set_input_filter(screen_fonts_->input_larger,
+                           fl_unsigned_int_filter);
+       fl_set_input_filter(screen_fonts_->input_largest,
+                           fl_unsigned_int_filter);
+       fl_set_input_filter(screen_fonts_->input_huge,
+                           fl_unsigned_int_filter);
+       fl_set_input_filter(screen_fonts_->input_huger,
+                           fl_unsigned_int_filter);
+
        // set up the feedback mechanism
        fl_addto_form(screen_fonts_->form);
 
@@ -1374,24 +1699,24 @@ void FormPreferences::buildScreenFonts()
 }
 
        
-void FormPreferences::feedbackScreenFonts(FL_OBJECT const * const ob )
+string FormPreferences::feedbackScreenFonts(FL_OBJECT const * const ob ) const
 {
        string str;
 
        if( ob == screen_fonts_->input_roman )
-               str = lyxrc.getFeedback( LyXRC::RC_SCREEN_FONT_ROMAN );
+               str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ROMAN );
        else if( ob == screen_fonts_->input_sans )
-               str = lyxrc.getFeedback( LyXRC::RC_SCREEN_FONT_SANS );
+               str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SANS );
        else if( ob == screen_fonts_->input_typewriter )
-               str = lyxrc.getFeedback( LyXRC::RC_SCREEN_FONT_TYPEWRITER );
+               str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_TYPEWRITER );
        else if( ob == screen_fonts_->check_scalable )
-               str = lyxrc.getFeedback( LyXRC::RC_SCREEN_FONT_SCALABLE );
+               str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SCALABLE );
        else if( ob == screen_fonts_->input_screen_encoding )
-               str = lyxrc.getFeedback( LyXRC::RC_SCREEN_FONT_ENCODING );
+               str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ENCODING );
        else if( ob == screen_fonts_->counter_zoom )
-               str = lyxrc.getFeedback( LyXRC::RC_SCREEN_ZOOM );
+               str = lyxrc.getDescription( LyXRC::RC_SCREEN_ZOOM );
        else if( ob == screen_fonts_->counter_dpi ) 
-               str = lyxrc.getFeedback( LyXRC::RC_SCREEN_DPI );
+               str = lyxrc.getDescription( LyXRC::RC_SCREEN_DPI );
        else if( ob == screen_fonts_->input_tiny
                 || ob == screen_fonts_->input_script
                 || ob == screen_fonts_->input_footnote
@@ -1403,10 +1728,9 @@ void FormPreferences::feedbackScreenFonts(FL_OBJECT const * const ob )
                 || ob == screen_fonts_->input_normal
                 || ob == screen_fonts_->input_huge
                 || ob == screen_fonts_->input_huger )
-               str = lyxrc.getFeedback( LyXRC::RC_SCREEN_FONT_SIZES );
+               str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SIZES );
 
-       fl_set_object_label(dialog_->text_warning, str.c_str());
-       fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+       return str;
 }
 
 
@@ -1605,30 +1929,30 @@ void FormPreferences::buildSpellchecker()
 }
 
 
-void FormPreferences::feedbackSpellChecker( FL_OBJECT const * const ob )
+string FormPreferences::feedbackSpellChecker( FL_OBJECT const * const ob ) const
 {
        string str;
+
        if( ob == spellchecker_->choice_spell_command )
-               str = lyxrc.getFeedback( LyXRC::RC_SPELL_COMMAND );
+               str = lyxrc.getDescription( LyXRC::RC_SPELL_COMMAND );
        else if( ob == spellchecker_->check_alt_lang )
-               str = lyxrc.getFeedback( LyXRC::RC_USE_ALT_LANG );
+               str = lyxrc.getDescription( LyXRC::RC_USE_ALT_LANG );
        else if( ob == spellchecker_->input_alt_lang )
-               str = lyxrc.getFeedback( LyXRC::RC_ALT_LANG );
+               str = lyxrc.getDescription( LyXRC::RC_ALT_LANG );
        else if( ob == spellchecker_->check_escape_chars )
-               str = lyxrc.getFeedback( LyXRC::RC_USE_ESC_CHARS );
+               str = lyxrc.getDescription( LyXRC::RC_USE_ESC_CHARS );
        else if( ob == spellchecker_->input_escape_chars )
-               str = lyxrc.getFeedback( LyXRC::RC_ESC_CHARS );
+               str = lyxrc.getDescription( LyXRC::RC_ESC_CHARS );
        else if( ob == spellchecker_->check_personal_dict )
-               str = lyxrc.getFeedback( LyXRC::RC_USE_PERS_DICT );
+               str = lyxrc.getDescription( LyXRC::RC_USE_PERS_DICT );
        else if( ob == spellchecker_->input_personal_dict )
-               str = lyxrc.getFeedback( LyXRC::RC_PERS_DICT );
+               str = lyxrc.getDescription( LyXRC::RC_PERS_DICT );
        else if( ob == spellchecker_->check_compound_words )
-               str = lyxrc.getFeedback( LyXRC::RC_ACCEPT_COMPOUND );
+               str = lyxrc.getDescription( LyXRC::RC_ACCEPT_COMPOUND );
        else if( ob == spellchecker_->check_input_enc )
-               str = lyxrc.getFeedback( LyXRC::RC_USE_INP_ENC );
+               str = lyxrc.getDescription( LyXRC::RC_USE_INP_ENC );
 
-       fl_set_object_label(dialog_->text_warning, str.c_str());
-       fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+       return str;
 }
 
 
@@ -1693,7 +2017,7 @@ bool FormPreferences::inputSpellChecker( FL_OBJECT const * const ob )
                }
        }
        
-       return true; // all input is valid!
+       return true; // All input is valid!
 }
 
 
@@ -1864,58 +2188,60 @@ bool FormPreferences::WriteableFile( string const & name, string const & suffix
 void FormPreferences::ComboLanguageCB(int, void * v, Combox * combox)
 {
     FormPreferences * pre = static_cast<FormPreferences*>(v);
-    pre->bc_.valid( pre->input( reinterpret_cast<FL_OBJECT *>(combox),
-                               FormPreferences::LANGUAGE ) );
+    // This is safe, as nothing is done to the pointer, other than
+    // to use its address in a block-if statement.
+    pre->bc_.valid( pre->input( reinterpret_cast<FL_OBJECT *>(combox), 0 ));
 }
 
 
 // C functions for the timer callback used to give the user feedback
 C_GENERICCB(FormPreferences, FeedbackCB)
-extern "C" int C_FormPreferencesFeedbackPost(FL_OBJECT * ob, int event,
-                                            FL_Coord mx, FL_Coord my, 
-                                            int key, void * xev)
+
+void FormPreferences::FeedbackCB(FL_OBJECT * ob, long)
 {
        FormPreferences * pre =
                static_cast<FormPreferences*>(ob->form->u_vdata);
-       return pre->FeedbackPost(ob, event, mx, my, key, xev);
+       pre->feedback( pre->feedbackObj );
 }
 
-
-void FormPreferences::FeedbackCB(FL_OBJECT *, long data)
+extern "C" int C_FormPreferencesFeedbackPost(FL_OBJECT * ob, int event,
+                                            FL_Coord, FL_Coord, int, void *)
 {
-       FL_OBJECT * ob = reinterpret_cast<FL_OBJECT*>(data);
+       // can occur when form is being deleted. This seems an easier fix than
+       // a call "fl_set_object_posthandler(ob, 0)" for each and every object
+       // in the destructor.
+       if( !ob->form ) return 0;
+
        FormPreferences * pre =
                static_cast<FormPreferences*>(ob->form->u_vdata);
-       pre->feedback( ob );
+       pre->feedbackPost(ob, event);
+       return 0;
 }
 
+
 // post_handler for feedback messages
-int FormPreferences::FeedbackPost(FL_OBJECT *ob, int event,
-                FL_Coord, FL_Coord, int, void *)
+void FormPreferences::feedbackPost(FL_OBJECT *ob, int event)
 {
-       FL_OBJECT * timer_feedback = reinterpret_cast<FL_OBJECT *>(ob->u_cdata);
-       
        // We do not test for empty help here, since this can never happen
        if(event == FL_ENTER){
-               fl_set_object_callback(timer_feedback,
+               // Used as a placeholder for ob, so that we don't have to
+               // a horrible reinterpret_cast to long and pass it as an
+               // argument in fl_set_object_callback.
+               feedbackObj = ob;
+               fl_set_object_callback(dialog_->timer_feedback,
                                       C_FormPreferencesFeedbackCB,
-                                      reinterpret_cast<long>(ob));
-               fl_set_timer(timer_feedback, 0.5);
+                                      0);
+               fl_set_timer(dialog_->timer_feedback, 0.5);
        }
        else if(event != FL_MOTION){
-               fl_set_timer(timer_feedback, 0);
-
-               FormPreferences * pre =
-                       static_cast<FormPreferences*>(ob->form->u_vdata);
-
-               fl_set_object_label(pre->dialog_->text_warning, "");
+               fl_set_timer(dialog_->timer_feedback, 0);
+               feedbackObj = 0;
+               fl_set_object_label(dialog_->text_warning, "");
        }
-       return 0;
 }
 
 
 void FormPreferences::setPostHandler( FL_OBJECT * ob ) const
 {
-       ob->u_cdata = reinterpret_cast<char *>(dialog_->timer_feedback);
        fl_set_object_posthandler(ob, C_FormPreferencesFeedbackPost);
 }