]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormPreferences.C
Yet more dialog tweaking from Rob.
[lyx.git] / src / frontends / xforms / FormPreferences.C
index 4272c2f82b9c1b916d3338af430a2acc3fdb40d3..b40d8ebbb95bac253f8b2de9f2e26d0ff1031446 100644 (file)
@@ -1,51 +1,57 @@
-/* This file is part of
- * ======================================================
- * 
- *           LyX, The Document Processor
- *      
- *         Copyright 1995 Matthias Ettrich
- *          Copyright 1995-2001 The LyX Team.
+/**
+ * \file FormPreferences.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *======================================================*/
-/* FormPreferences.C
- * FormPreferences Interface Class Implementation
+ * \author Angus Leeming 
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
 
-#include <utility>
-#include <iomanip>
-#include <X11/Xlib.h>
-
-#include FORMS_H_LOCATION
-
-#ifdef __GNUG_
+#ifdef __GNUG__
 #pragma implementation
 #endif
 
-#include "Color.h"
-#include "LColor.h"
-#include "Lsstream.h"
 #include "FormPreferences.h"
-#include "form_preferences.h"
-#include "input_validators.h"
-#include "LyXView.h"
-#include "language.h"
-#include "lyxfunc.h"
-#include "Dialogs.h"
-#include "lyxrc.h"
+#include "forms/form_preferences.h"
+
 #include "combox.h"
-#include "debug.h"
-#include "support/filetools.h"
-#include "support/LAssert.h"
-#include "lyx_gui_misc.h" // idex, scex
-#include "lyxlex.h"
+#include "Color.h"
 #include "input_validators.h"
+#include "forms_gettext.h"
 #include "xforms_helpers.h"
 #include "helper_funcs.h"
+
+#include "buffer.h"
 #include "converter.h"
+#include "debug.h"
+#include "language.h"
+#include "frnt_lang.h"
+#include "lyxlex.h"
+#include "lyxrc.h"
+#include "LColor.h"
+#include "Lsstream.h"
+#include "funcrequest.h"
+
+#include "frontends/LyXView.h"
+#include "frontends/Dialogs.h"
+
 #include "support/lyxfunctional.h"
 #include "support/lyxmanip.h"
+#include "support/filetools.h"
+#include "support/LAssert.h"
+
+#include "graphics/GraphicsCache.h"
+#include "graphics/GraphicsTypes.h"
+
+#include <boost/bind.hpp>
+
+#include FORMS_H_LOCATION
+#include <utility>
+#include <iomanip>
+#include <X11/Xlib.h>
 
 using std::endl;
 using std::pair;
@@ -53,11 +59,11 @@ using std::make_pair;
 using std::max;
 using std::min;
 using std::vector;
-using SigC::slot;
+using std::setw;
+using std::setfill;
 
 extern string system_lyxdir;
 extern string user_lyxdir;
-extern Languages languages;
 
 namespace {
 
@@ -68,37 +74,16 @@ Converters local_converters;
 } // namespace anon
 
 
-FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
-       : FormBaseBI(lv, d, _("Preferences")),
-         warningPosted(false),
+FormPreferences::FormPreferences(LyXView & lv, Dialogs & d)
+       : FormBaseBI(lv, d, _("Preferences"), false),
          colors_(*this), converters_(*this), inputs_misc_(*this),
-         formats_(*this), interface_(*this), language_(*this), 
+         formats_(*this), interface_(*this), language_(*this),
          lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
          printer_(*this), screen_fonts_(*this), spelloptions_(*this)
 {
        // let the dialog be shown
        // This is a permanent connection so we won't bother
        // storing a copy because we won't be disconnecting.
-       d->showPreferences.connect(slot(this, &FormPreferences::show));
-       d->showSpellcheckerPreferences.connect(slot(this, &FormPreferences::showSpellPref));
-}
-
-
-void FormPreferences::connect()
-{
-       fl_set_form_maxsize( dialog_->form, minw_, minh_ );
-
-       FormBaseBI::connect();
-}
-
-
-void FormPreferences::disconnect()
-{
-       // colors_->disconnect();
-       // converters_->disconnect(); //local_converters.Clear();
-       // formats_->disconnect();    //local_formats.Clear();
-
-       FormBaseBI::disconnect();
 }
 
 
@@ -115,19 +100,19 @@ void FormPreferences::redraw()
 
        FL_FORM * form3 = 0;
        if (form2 == converters_tab_->form)
-               form3 = fl_get_active_folder(converters_tab_->tabfolder_outer);
+               form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
 
        else if (form2 == look_n_feel_tab_->form)
-               form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_outer);
+               form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
 
        else if (form2 == inputs_tab_->form)
-               form3 = fl_get_active_folder(inputs_tab_->tabfolder_outer);
+               form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
 
        else if (form2 == outputs_tab_->form)
-               form3 = fl_get_active_folder(outputs_tab_->tabfolder_outer);
+               form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
 
        else if (form2 == lang_opts_tab_->form)
-               form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_outer);
+               form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
 
        if (form3 && form3->visible)
                fl_redraw_form(form3);
@@ -136,16 +121,7 @@ void FormPreferences::redraw()
 
 FL_FORM * FormPreferences::form() const
 {
-       if (dialog_.get()) return dialog_->form;
-       return 0;
-}
-
-
-void FormPreferences::showSpellPref()
-{
-       show();
-       fl_set_folder(dialog_->tabfolder_prefs, lang_opts_tab_->form);
-       fl_set_folder(lang_opts_tab_->tabfolder_outer, spelloptions_.dialog()->form);
+       return dialog_.get() ? dialog_->form : 0;
 }
 
 
@@ -158,40 +134,41 @@ void FormPreferences::ok()
                        AddName(user_lyxdir, "preferences.xform");
                colors_.modifiedXformsPrefs = !XformsColor::write(filename);
        }
-       
-       lv_->getLyXFunc()->dispatch(LFUN_SAVEPREFERENCES);
+
+       lv_.dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
 }
 
 
 void FormPreferences::hide()
 {
        // We need to hide the active tabfolder otherwise we get a
-       // BadDrawable error from X windows and LyX crashes without saving.
-       FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder_prefs);
-       if (outer_form
-           && outer_form->visible) {
-               fl_hide_form(outer_form);
-       }
+       // BadDrawable error from X window and LyX crashes without saving.
+       FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
+       if (inner_form && inner_form->visible)
+               fl_hide_form(inner_form);
        FormBaseDeprecated::hide();
 }
 
 
 void FormPreferences::build()
 {
-       dialog_.reset(build_preferences());
+       dialog_.reset(build_preferences(this));
 
        // Manage the restore, save, apply and cancel/close buttons
        bc().setOK(dialog_->button_ok);
        bc().setApply(dialog_->button_apply);
-       bc().setCancel(dialog_->button_cancel);
+       bc().setCancel(dialog_->button_close);
        bc().setRestore(dialog_->button_restore);
 
+       // Allow the base class to control messages
+       setMessageWidget(dialog_->text_warning);
+
        // build the tab folders
-       converters_tab_.reset(build_outer_tab());
-       look_n_feel_tab_.reset(build_outer_tab());
-       inputs_tab_.reset(build_outer_tab());
-       outputs_tab_.reset(build_outer_tab());
-       lang_opts_tab_.reset(build_outer_tab());
+       converters_tab_.reset(build_preferences_inner_tab(this));
+       look_n_feel_tab_.reset(build_preferences_inner_tab(this));
+       inputs_tab_.reset(build_preferences_inner_tab(this));
+       outputs_tab_.reset(build_preferences_inner_tab(this));
+       lang_opts_tab_.reset(build_preferences_inner_tab(this));
 
        // build actual tabfolder contents
        // these will become nested tabfolders
@@ -216,7 +193,7 @@ void FormPreferences::build()
                           _("Lang Opts"),
                           lang_opts_tab_->form);
        fl_addto_tabfolder(dialog_->tabfolder_prefs,
-                          _("Converters"),
+                          _("Conversion"),
                           converters_tab_->form);
        fl_addto_tabfolder(dialog_->tabfolder_prefs,
                           _("Inputs"),
@@ -227,49 +204,49 @@ void FormPreferences::build()
 
        // now build the nested tabfolders
        // Starting with look and feel
-       fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
+       fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
                           _("Screen Fonts"),
                           screen_fonts_.dialog()->form);
-       fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
+       fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
                           _("Interface"),
                           interface_.dialog()->form);
-       fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
+       fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
                           _("Colors"),
                           colors_.dialog()->form);
-       fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
+       fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
                           _("Misc"),
                           lnf_misc_.dialog()->form);
 
        // then build converters
-       fl_addto_tabfolder(converters_tab_->tabfolder_outer,
+       fl_addto_tabfolder(converters_tab_->tabfolder_inner,
                           _("Formats"),
                           formats_.dialog()->form);
-       fl_addto_tabfolder(converters_tab_->tabfolder_outer,
+       fl_addto_tabfolder(converters_tab_->tabfolder_inner,
                           _("Converters"),
                           converters_.dialog()->form);
 
        // then build inputs
-       // Paths should probably go in a few outer_tab called Files
-       fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
+       // Paths should probably go in a few inner_tab called Files
+       fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
                           _("Paths"),
                           paths_.dialog()->form);
-       fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
+       fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
                           _("Misc"),
                           inputs_misc_.dialog()->form);
 
        // then building outputs
-       fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
+       fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
                           _("Printer"),
                           printer_.dialog()->form);
-       fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
+       fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
                           _("Misc"),
                           outputs_misc_.dialog()->form);
 
        // then building usage
-       fl_addto_tabfolder(lang_opts_tab_->tabfolder_outer,
+       fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
                           _("Spell checker"),
                           spelloptions_.dialog()->form);
-       fl_addto_tabfolder(lang_opts_tab_->tabfolder_outer,
+       fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
                           _("Language"),
                           language_.dialog()->form);
 }
@@ -303,49 +280,43 @@ void FormPreferences::apply()
 }
 
 
-void FormPreferences::feedback(FL_OBJECT * ob)
+string const FormPreferences::getFeedback(FL_OBJECT * ob)
 {
        lyx::Assert(ob);
 
-       string str;
-
-       if (ob->form->fdui == colors_.dialog()) {
-               str = colors_.feedback(ob);
-       } else if (ob->form->fdui == converters_.dialog()) {
-               str = converters_.feedback(ob);
-       } else if (ob->form->fdui == formats_.dialog()) {
-               str = formats_.feedback(ob);
-       } else if (ob->form->fdui == inputs_misc_.dialog()) {
-               str = inputs_misc_.feedback(ob);
-       } else if (ob->form->fdui == interface_.dialog()) {
-               str = interface_.feedback(ob);
-       } else if (ob->form->fdui == language_.dialog()) {
-               str = language_.feedback(ob);
-       } else if (ob->form->fdui == lnf_misc_.dialog()) {
-               str = lnf_misc_.feedback(ob);
-       } else if (ob->form->fdui == outputs_misc_.dialog()) {
-               str = outputs_misc_.feedback(ob);
-       } else if (ob->form->fdui == paths_.dialog()) {
-               str = paths_.feedback(ob);
-       } else if (ob->form->fdui == printer_.dialog()) {
-               str = printer_.feedback(ob);
-       } else if (ob->form->fdui == screen_fonts_.dialog()) {
-               str = screen_fonts_.feedback(ob);
-       } else if (ob->form->fdui == spelloptions_.dialog()) {
-               str = spelloptions_.feedback(ob);
-       }
-
-       str = formatted(_(str), dialog_->text_warning->w-10, FL_SMALL_SIZE);
-
-       fl_set_object_label(dialog_->text_warning, str.c_str());
-       fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+       if (ob->form->fdui == colors_.dialog())
+               return colors_.feedback(ob);
+       if (ob->form->fdui == converters_.dialog())
+               return converters_.feedback(ob);
+       if (ob->form->fdui == formats_.dialog())
+               return formats_.feedback(ob);
+       if (ob->form->fdui == inputs_misc_.dialog())
+               return inputs_misc_.feedback(ob);
+       if (ob->form->fdui == interface_.dialog())
+               return interface_.feedback(ob);
+       if (ob->form->fdui == language_.dialog())
+               return language_.feedback(ob);
+       if (ob->form->fdui == lnf_misc_.dialog())
+               return lnf_misc_.feedback(ob);
+       if (ob->form->fdui == outputs_misc_.dialog())
+               return outputs_misc_.feedback(ob);
+       if (ob->form->fdui == paths_.dialog())
+               return paths_.feedback(ob);
+       if (ob->form->fdui == printer_.dialog())
+               return printer_.feedback(ob);
+       if (ob->form->fdui == screen_fonts_.dialog())
+               return screen_fonts_.feedback(ob);
+       if (ob->form->fdui == spelloptions_.dialog())
+               return spelloptions_.feedback(ob);
+
+       return string();
 }
 
 
 bool FormPreferences::input(FL_OBJECT * ob, long)
 {
        lyx::Assert(ob);
-       
+
        // whatever checks you need to ensure the user hasn't entered
        // some totally ridiculous value somewhere.  Change activate to suit.
        // comments before each test describe what is _valid_
@@ -353,19 +324,20 @@ bool FormPreferences::input(FL_OBJECT * ob, long)
        if (ob->form->fdui == colors_.dialog()) {
                colors_.input(ob);
                return true;
-       } else if (ob->form->fdui == converters_.dialog())
+       }
+       if (ob->form->fdui == converters_.dialog())
                return converters_.input(ob);
-       else if (ob->form->fdui == formats_.dialog())
+       if (ob->form->fdui == formats_.dialog())
                return formats_.input(ob);
-       else if (ob->form->fdui == interface_.dialog())
+       if (ob->form->fdui == interface_.dialog())
                return interface_.input(ob);
-       else if (ob->form->fdui == language_.dialog())
+       if (ob->form->fdui == language_.dialog())
                return language_.input(ob);
-       else if (ob->form->fdui == paths_.dialog())
+       if (ob->form->fdui == paths_.dialog())
                return paths_.input(ob);
-       else if (ob->form->fdui == screen_fonts_.dialog())
+       if (ob->form->fdui == screen_fonts_.dialog())
                return screen_fonts_.input();
-       else if (ob->form->fdui == spelloptions_.dialog())
+       if (ob->form->fdui == spelloptions_.dialog())
                return spelloptions_.input(ob);
 
        return true;
@@ -375,7 +347,7 @@ bool FormPreferences::input(FL_OBJECT * ob, long)
 void FormPreferences::update()
 {
        if (!dialog_.get()) return;
-    
+
        // read lyxrc entries
        colors_.update();
        formats_.update();   // Must be before converters_.update()
@@ -397,7 +369,7 @@ FormPreferences::Colors::Colors(FormPreferences & p)
 {}
 
 
-FD_form_colors const * FormPreferences::Colors::dialog()
+FD_preferences_colors const * FormPreferences::Colors::dialog()
 {
        return dialog_.get();
 }
@@ -423,7 +395,7 @@ void FormPreferences::Colors::apply()
 
        if (modifiedXformsPrefs) {
                for (vector<XformsColor>::const_iterator cit =
-                            xformsColorDB.begin(); 
+                            xformsColorDB.begin();
                     cit != xformsColorDB.end(); ++cit) {
                        fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
 
@@ -443,11 +415,10 @@ void FormPreferences::Colors::apply()
                        if (cit->colorID == GUI_COLOR_CURSOR) {
                                fl_mapcolor(GUI_COLOR_CURSOR,
                                            cit->r, cit->g, cit->b);
-                               fl_set_cursor_color(FL_DEFAULT_CURSOR,
-                                                   GUI_COLOR_CURSOR, FL_WHITE);
+                               setCursorColor(GUI_COLOR_CURSOR);
                        }
                }
-               Dialogs::redrawGUI();
+               parent_.lv_.getDialogs().redrawGUI();
        }
 
        // Now do the same for the LyX LColors...
@@ -458,7 +429,7 @@ void FormPreferences::Colors::apply()
 
                // Create a valid X11 name of the form "#rrggbb"
                string const hexname = X11hexname(cit->color());
-               
+
                if (lcolor.getX11Name(lc) != hexname) {
                        lyxerr[Debug::GUI]
                                << "FormPreferences::Colors::apply: "
@@ -469,7 +440,7 @@ void FormPreferences::Colors::apply()
 
                        string const s = lcolor.getLyXName(lc) + string(" ") +
                                hexname;
-                       parent_.lv_->getLyXFunc()->dispatch(LFUN_SET_COLOR, s);
+                       parent_.lv_.dispatch(FuncRequest(LFUN_SET_COLOR, s));
                }
        }
 }
@@ -477,7 +448,7 @@ void FormPreferences::Colors::apply()
 
 void FormPreferences::Colors::build()
 {
-       dialog_.reset(parent_.build_colors());
+       dialog_.reset(build_preferences_colors(&parent_));
 
        fl_set_object_color(dialog_->button_color,
                            GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
@@ -494,56 +465,55 @@ void FormPreferences::Colors::build()
        fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
        fl_set_slider_step(dialog_->slider_value, 0.01);
        fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
-       
+
        fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
        fl_set_slider_step(dialog_->slider_red, 1.0);
        fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
-       
+
        fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
        fl_set_slider_step(dialog_->slider_green, 1.0);
        fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
-       
+
        fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
        fl_set_slider_step(dialog_->slider_blue, 1.0);
        fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
-       
+
        // set up the feedback mechanism
-       setPreHandler(dialog_->browser_lyx_objs);
-       setPreHandler(dialog_->button_color);
-       setPreHandler(dialog_->button_modify);
-       setPreHandler(dialog_->dial_hue);
-       setPreHandler(dialog_->slider_saturation);
-       setPreHandler(dialog_->slider_value);
-       setPreHandler(dialog_->slider_red);
-       setPreHandler(dialog_->slider_green);
-       setPreHandler(dialog_->slider_blue);
-       setPreHandler(dialog_->button_colorspace);
+       setPrehandler(dialog_->browser_lyx_objs);
+       setPrehandler(dialog_->button_color);
+       setPrehandler(dialog_->button_modify);
+       setPrehandler(dialog_->dial_hue);
+       setPrehandler(dialog_->slider_saturation);
+       setPrehandler(dialog_->slider_value);
+       setPrehandler(dialog_->slider_red);
+       setPrehandler(dialog_->slider_green);
+       setPrehandler(dialog_->slider_blue);
+       setPrehandler(dialog_->radio_rgb);
+       setPrehandler(dialog_->radio_hsv);
 }
 
+
 string const
 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
 {
-       string str;
-
-       if (ob == dialog_->browser_lyx_objs) {
-               str = N_("LyX objects that can be assigned a color.");
+       if (ob == dialog_->browser_lyx_objs)
+               return _("LyX objects that can be assigned a color.");
 
-       } else if (ob == dialog_->button_modify) {
-               str = N_("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
+       if (ob == dialog_->button_modify)
+               return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
 
-       } else if (ob == dialog_->dial_hue ||
-                  ob == dialog_->slider_saturation ||
-                  ob == dialog_->slider_value ||
-                  ob == dialog_->slider_red ||
-                  ob == dialog_->slider_green ||
-                  ob == dialog_->slider_blue) {
-               str = N_("Find a new color.");
+       if (ob == dialog_->dial_hue ||
+                 ob == dialog_->slider_saturation ||
+                 ob == dialog_->slider_value ||
+                 ob == dialog_->slider_red ||
+                 ob == dialog_->slider_green ||
+                 ob == dialog_->slider_blue)
+               return  _("Find a new color.");
 
-       } else if (ob == dialog_->button_colorspace) {
-               str = N_("Toggle between RGB and HSV color spaces.");
-       }
+       if (ob == dialog_->radio_rgb || ob == dialog_->radio_hsv)
+               return _("Toggle between RGB and HSV color spaces.");
 
-       return str;
+       return string();
 }
 
 
@@ -551,7 +521,7 @@ void FormPreferences::Colors::input(FL_OBJECT const * const ob)
 {
        if (ob == dialog_->browser_lyx_objs) {
                InputBrowserLyX();
-               
+
        } else if (ob == dialog_->dial_hue ||
                   ob == dialog_->slider_saturation ||
                   ob == dialog_->slider_value) {
@@ -562,7 +532,8 @@ void FormPreferences::Colors::input(FL_OBJECT const * const ob)
                   ob == dialog_->slider_blue) {
                InputRGB();
 
-       } else if (ob == dialog_->button_colorspace) {
+       } else if (ob == dialog_->radio_rgb ||
+                  ob == dialog_->radio_hsv) {
                SwitchColorSpace();
 
        } else if (ob == dialog_->button_modify) {
@@ -579,7 +550,7 @@ void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
 
        HSVColor hsv(rgb);
        hsv.v += addVal;
-       hsv.v = min( 1.0, max(0.0, hsv.v) );
+       hsv.v = min(1.0, max(0.0, hsv.v));
 
        rgb = RGBColor(hsv);
        fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
@@ -595,7 +566,7 @@ void FormPreferences::Colors::InputBrowserLyX() const
        // Is the choice an Xforms color...
        RGBColor col;
 
-       if( selLyX-1 < xformsColorDB.size() ) {
+       if (selLyX - 1 < xformsColorDB.size()) {
                vector<XformsColor>::size_type const i = selLyX - 1;
                col = xformsColorDB[i].color();
        }
@@ -613,10 +584,10 @@ void FormPreferences::Colors::InputBrowserLyX() const
 
        // Display either RGB or HSV but not both!
        SwitchColorSpace();
-       
+
        // Deactivate the modify button to begin with...
        setEnabled(dialog_->button_modify, false);
-       
+
        fl_unfreeze_form(dialog_->form);
 }
 
@@ -630,13 +601,13 @@ void FormPreferences::Colors::InputHSV()
        int const h = int(hue);
        int const s = int(100.0 * sat);
        int const v = int(100.0 * val);
-       
+
        string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
                tostr(v);
        fl_set_object_label(dialog_->text_color_values, label.c_str());
 
        RGBColor col = HSVColor(hue, sat, val);
-       
+
        fl_freeze_form(dialog_->form);
 
        fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
@@ -653,12 +624,12 @@ void FormPreferences::Colors::InputHSV()
 
        fl_unfreeze_form(dialog_->form);
        if (selLyX < 1) return;
-       
+
        fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
        bool modify = false;
-       
+
        // Is the choice an Xforms color...
-       if( selLyX-1 < xformsColorDB.size() ) {
+       if (selLyX - 1 < xformsColorDB.size()) {
                vector<XformsColor>::size_type const i = selLyX - 1;
                modify = (xformsColorDB[i].color() != col);
        }
@@ -682,7 +653,7 @@ void FormPreferences::Colors::InputRGB()
        string const label = tostr(red) + string(", ") + tostr(green) +
                string(", ") + tostr(blue);
        fl_set_object_label(dialog_->text_color_values, label.c_str());
-               
+
        fl_freeze_form(dialog_->form);
 
        RGBColor col = RGBColor(red, green, blue);
@@ -695,11 +666,11 @@ void FormPreferences::Colors::InputRGB()
 
        fl_unfreeze_form(dialog_->form);
        if (selLyX < 1) return;
-       
+
        bool modify = false;
-       
+
        // Is the choice an Xforms color...
-       if( selLyX-1 < xformsColorDB.size() ) {
+       if (selLyX - 1 < xformsColorDB.size()) {
                vector<XformsColor>::size_type const i = selLyX - 1;
                modify = (xformsColorDB[i].color() != col);
        }
@@ -716,7 +687,8 @@ void FormPreferences::Colors::InputRGB()
 
 void FormPreferences::Colors::LoadBrowserLyX()
 {
-       if (!dialog_->browser_lyx_objs->visible) return;
+       if (!dialog_->browser_lyx_objs->visible)
+               return;
 
        // First, define the modifiable xforms colors
        xformsColorDB.clear();
@@ -732,9 +704,6 @@ void FormPreferences::Colors::LoadBrowserLyX()
        xcol.colorID = FL_BLACK;
        fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
 
-       fl_mapcolor(GUI_COLOR_CURSOR, xcol.r, xcol.g, xcol.b);
-       fl_set_cursor_color(FL_DEFAULT_CURSOR, GUI_COLOR_CURSOR, FL_WHITE);
-
        xformsColorDB.push_back(xcol);
 
        xcol.name = _("GUI selection");
@@ -778,8 +747,7 @@ void FormPreferences::Colors::LoadBrowserLyX()
                               << "\". Set to \"black\"!" << endl;
 
                        string const arg = lcolor.getLyXName(lc) + " black";
-                       parent_.lv_->getLyXFunc()->
-                               dispatch(LFUN_SET_COLOR, arg);
+                       parent_.lv_.dispatch(FuncRequest(LFUN_SET_COLOR, arg));
                        continue;
                }
 
@@ -836,13 +804,14 @@ void FormPreferences::Colors::Modify()
 {
        vector<NamedColor>::size_type const selLyX =
                fl_get_browser(dialog_->browser_lyx_objs);
-       if (selLyX < 1) return;
+       if (selLyX < 1)
+               return;
 
        RGBColor col;
        fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
 
        // Is the choice an Xforms color...
-       if( selLyX-1 < xformsColorDB.size() ) {
+       if (selLyX - 1 < xformsColorDB.size()) {
                vector<XformsColor>::size_type const i = selLyX - 1;
                xformsColorDB[i].r  = col.r;
                xformsColorDB[i].g  = col.g;
@@ -858,23 +827,21 @@ void FormPreferences::Colors::Modify()
        }
 
        fl_freeze_form(dialog_->form);
-       setEnabled(dialog_->button_modify, false);      
+       setEnabled(dialog_->button_modify, false);
        fl_unfreeze_form(dialog_->form);
 }
 
 
 void FormPreferences::Colors::SwitchColorSpace() const
 {
-       bool const pressed = fl_get_button(dialog_->button_colorspace);
+       bool const hsv = fl_get_button(dialog_->radio_hsv);
 
        RGBColor col;
        fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
 
        fl_freeze_form(dialog_->form);
 
-       if (pressed) {
-               fl_set_object_label(dialog_->button_colorspace, _("HSV"));
-
+       if (hsv) {
                fl_hide_object(dialog_->slider_red);
                fl_hide_object(dialog_->slider_blue);
                fl_hide_object(dialog_->slider_green);
@@ -884,13 +851,13 @@ void FormPreferences::Colors::SwitchColorSpace() const
 
                HSVColor hsv = HSVColor(col);
                hsv.h = max(hsv.h, 0.0);
-       
+
                fl_set_dial_value(dialog_->dial_hue, hsv.h);
                fl_set_slider_value(dialog_->slider_saturation, hsv.s);
                fl_set_slider_value(dialog_->slider_value, hsv.v);
 
                col = HSVColor(hsv.h, 1.0, 1.0);
-               col.r = max(col.r,0);
+               col.r = max(col.r, 0);
                fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
                fl_redraw_object(dialog_->dial_hue);
 
@@ -898,15 +865,13 @@ void FormPreferences::Colors::SwitchColorSpace() const
                // Means that toggling from one space to the other has no
                // effect on the final color.
                int const h = int(hsv.h);
-               int const s = int(100*hsv.s);
-               int const v = int(100*hsv.v);
-               string const label = tostr(h) + string(", ") + tostr(s) +
-                       string(", ") + tostr(v);
+               int const s = int(100 * hsv.s);
+               int const v = int(100 * hsv.v);
+               string const label = tostr(h) + ", " + tostr(s) +
+                       ", " + tostr(v);
                fl_set_object_label(dialog_->text_color_values, label.c_str());
-               
-       } else {
-               fl_set_object_label(dialog_->button_colorspace, _("RGB"));
 
+       } else {
                fl_show_object(dialog_->slider_red);
                fl_show_object(dialog_->slider_blue);
                fl_show_object(dialog_->slider_green);
@@ -922,11 +887,11 @@ void FormPreferences::Colors::SwitchColorSpace() const
                int const r = int(col.r);
                int const g = int(col.g);
                int const b = int(col.b);
-               string const label = tostr(r) + string(", ") + tostr(g) +
-                       string(", ") + tostr(b);
+               string const label = tostr(r) + ", " + tostr(g) +
+                       ", " + tostr(b);
                fl_set_object_label(dialog_->text_color_values, label.c_str());
        }
-       
+
        fl_unfreeze_form(dialog_->form);
 }
 
@@ -934,10 +899,10 @@ string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
 {
        ostringstream ostr;
 
-       ostr << "#" << std::setbase(16) << std::setfill('0')
-            << std::setw(2) << col.r
-            << std::setw(2) << col.g
-            << std::setw(2) << col.b;
+       ostr << "#" << std::setbase(16) << setfill('0')
+            << setw(2) << col.r
+            << setw(2) << col.g
+            << setw(2) << col.b;
 
        return ostr.str().c_str();
 }
@@ -948,7 +913,7 @@ FormPreferences::Converters::Converters(FormPreferences & p)
 {}
 
 
-FD_form_converters const * FormPreferences::Converters::dialog()
+FD_preferences_converters const * FormPreferences::Converters::dialog()
 {
        return dialog_.get();
 }
@@ -964,67 +929,77 @@ void FormPreferences::Converters::apply() const
 
 void FormPreferences::Converters::build()
 {
-       dialog_.reset(parent_.build_converters());
+       dialog_.reset(build_preferences_converters(&parent_));
 
        fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
 
        // set up the feedback mechanism
-       setPreHandler(dialog_->browser_all);
-       setPreHandler(dialog_->button_delete);
-       setPreHandler(dialog_->button_add);
-       setPreHandler(dialog_->input_converter);
-       setPreHandler(dialog_->choice_from);
-       setPreHandler(dialog_->choice_to);
-       setPreHandler(dialog_->input_flags);
+       setPrehandler(dialog_->browser_all);
+       setPrehandler(dialog_->button_delete);
+       setPrehandler(dialog_->button_add);
+       setPrehandler(dialog_->input_converter);
+       setPrehandler(dialog_->choice_from);
+       setPrehandler(dialog_->choice_to);
+       setPrehandler(dialog_->input_flags);
 }
 
 
 string const
 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
 {
-       string str;
+       if (ob == dialog_->browser_all)
+               return _("All the currently defined converters known to LyX.");
+
+       if (ob == dialog_->choice_from)
+               return _("Convert \"from\" this format");
 
-       if (ob == dialog_->browser_all) {
-               str = N_("All the currently defined converters known to LyX.");
-       } else if (ob == dialog_->choice_from) {
-               str = N_("Convert \"from\" this format");
-       } else if (ob == dialog_->choice_to) {
-               str = N_("Convert \"to\" this format");
-       } else if (ob == dialog_->input_converter) {
-               str = N_("The conversion command. $$i is the input file name, $$b is the file name without its extension and $$o is the name of the output file.");
-       } else if (ob == dialog_->input_flags) {
-               str = N_("Flags that control the converter behavior");
-       } else if (ob == dialog_->button_delete) {
-               str = N_("Remove the current converter from the list of available converters. Note: you must then \"Apply\" the change.");
-       } else if (ob == dialog_->button_add) {
+       if (ob == dialog_->choice_to)
+               return _("Convert \"to\" this format");
+
+       if (ob == dialog_->input_converter)
+               return _("The conversion command. $$i is the input file name, "
+                        "$$b is the file name without its extension and $$o is "
+                        "the name of the output file. $$s can be used as path to "
+                        "LyX's own collection of conversion scripts.");
+
+       if (ob == dialog_->input_flags)
+               return _("Extra information for the Converter class, whether and "
+                        "how to parse the result, and various other things.");
+
+       if (ob == dialog_->button_delete)
+               return _("Remove the current converter from the list of available "
+                        "converters. Note: you must then \"Apply\" the change.");
+
+       if (ob == dialog_->button_add) {
                if (string(ob->label) == _("Add"))
-                       str = N_("Add the current converter to the list of available converters. Note: you must then \"Apply\" the change.");
+                       return _("Add the current converter to the list of available "
+                                "converters. Note: you must then \"Apply\" the change.");
                else
-                       str = N_("Modify the contents of the current converter. Note: you must then \"Apply\" the change.");
+                       return _("Modify the contents of the current converter. "
+                                "Note: you must then \"Apply\" the change.");
        }
 
-       return str;
+       return string();
 }
 
 
 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
 {
-       if (ob == dialog_->browser_all) {
+       if (ob == dialog_->browser_all)
                return Browser();
 
-       } else if (ob == dialog_->choice_from
+       if (ob == dialog_->choice_from
                   || ob == dialog_->choice_to
                   || ob == dialog_->input_converter
-                  || ob == dialog_->input_flags) {
+                  || ob == dialog_->input_flags)
                return Input();
 
-       } else if (ob == dialog_->button_add) {
+       if (ob == dialog_->button_add)
                return Add();
 
-       } else if (ob == dialog_->button_delete) {
+       if (ob == dialog_->button_delete)
                return erase();
-       }
 
        return true;
 }
@@ -1074,7 +1049,7 @@ bool FormPreferences::Converters::Add()
 }
 
 
-bool FormPreferences::Converters::Browser() 
+bool FormPreferences::Converters::Browser()
 {
        int const i = fl_get_browser(dialog_->browser_all);
        if (i <= 0) return false;
@@ -1098,7 +1073,7 @@ bool FormPreferences::Converters::Browser()
 
        setEnabled(dialog_->button_add,    false);
        setEnabled(dialog_->button_delete, true);
-                               
+
        fl_unfreeze_form(dialog_->form);
        return false;
 }
@@ -1120,12 +1095,12 @@ bool FormPreferences::Converters::Input()
        string const from = GetFrom();
        string const to = GetTo();
        int const sel = local_converters.getNumber(from, to);
-       
+
        fl_freeze_form(dialog_->form);
 
        if (sel < 0) {
                fl_set_object_label(dialog_->button_add, idex(_("Add|#A")));
-               fl_set_button_shortcut(dialog_->button_add, 
+               fl_set_button_shortcut(dialog_->button_add,
                                       scex(_("Add|#A")), 1);
 
                fl_deselect_browser(dialog_->browser_all);
@@ -1134,15 +1109,15 @@ bool FormPreferences::Converters::Input()
        } else {
                fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
                fl_set_button_shortcut(dialog_->button_add,
-                                       scex(_("Modify|#M")), 1);
-               
+                                      scex(_("Modify|#M")), 1);
+
                int top = max(sel-5, 0);
                fl_set_browser_topline(dialog_->browser_all, top);
                fl_select_browser_line(dialog_->browser_all, sel+1);
                setEnabled(dialog_->button_delete, true);
        }
 
-       string const command = strip(fl_get_input(dialog_->input_converter));
+       string const command = rtrim(fl_get_input(dialog_->input_converter));
        bool const enable = !(command.empty() || from == to);
        setEnabled(dialog_->button_add, enable);
 
@@ -1158,11 +1133,9 @@ string const FormPreferences::Converters::GetFrom() const
 
        if (i > 0 && i <= local_formats.size())
                return local_formats.get(i - 1).name();
-       else {
-               lyxerr << "FormPreferences::Converters::GetFrom: No choice!"
-                      << endl;
-               return "???";
-       }
+
+       lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
+       return "???";
 }
 
 
@@ -1173,11 +1146,9 @@ string const FormPreferences::Converters::GetTo() const
 
        if (i > 0 && i <= local_formats.size())
                return local_formats.get(i - 1).name();
-       else {
-               lyxerr << "FormPreferences::Converters::GetTo: No choice!"
-                      << endl;
-               return "???";
-       }
+
+       lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
+       return "???";
 }
 
 
@@ -1202,12 +1173,12 @@ void FormPreferences::Converters::UpdateChoices() const
 }
 
 
-FormPreferences::Formats::Formats( FormPreferences &  p )
+FormPreferences::Formats::Formats(FormPreferences &  p)
        : parent_(p)
 {}
 
 
-FD_form_formats const * FormPreferences::Formats::dialog()
+FD_preferences_formats const * FormPreferences::Formats::dialog()
 {
        return dialog_.get();
 }
@@ -1221,7 +1192,7 @@ void FormPreferences::Formats::apply() const
 
 void FormPreferences::Formats::build()
 {
-       dialog_.reset(parent_.build_formats());
+       dialog_.reset(build_preferences_formats(&parent_));
 
        fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
@@ -1232,65 +1203,73 @@ void FormPreferences::Formats::build()
        fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
 
        // set up the feedback mechanism
-       setPreHandler(dialog_->browser_all);
-       setPreHandler(dialog_->input_format);
-       setPreHandler(dialog_->input_gui_name);
-       setPreHandler(dialog_->button_delete);
-       setPreHandler(dialog_->button_add);
-       setPreHandler(dialog_->input_extension);
-       setPreHandler(dialog_->input_viewer);
-       setPreHandler(dialog_->input_shrtcut);
+       setPrehandler(dialog_->browser_all);
+       setPrehandler(dialog_->input_format);
+       setPrehandler(dialog_->input_gui_name);
+       setPrehandler(dialog_->button_delete);
+       setPrehandler(dialog_->button_add);
+       setPrehandler(dialog_->input_extension);
+       setPrehandler(dialog_->input_viewer);
+       setPrehandler(dialog_->input_shrtcut);
 }
 
 
 string const
 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
 {
-       string str;
+       if (ob == dialog_->browser_all)
+               return  _("All the currently defined formats known to LyX.");
+
+       if (ob == dialog_->input_format)
+               return  _("The format identifier.");
+
+       if (ob == dialog_->input_gui_name)
+               return  _("The format name as it will appear in the menus.");
+
+       if (ob == dialog_->input_shrtcut)
+               return  _("The keyboard accelerator. Use a letter in the GUI name. "
+                         "Case sensitive.");
+
+       if (ob == dialog_->input_extension)
+               return  _("Used to recognize the file. E.g., ps, pdf, tex.");
+
+       if (ob == dialog_->input_viewer)
+               return  _("The command used to launch the viewer application.");
+
+       if (ob == dialog_->button_delete)
+               return  _("Remove the current format from the list of available "
+                         "formats. Note: you must then \"Apply\" the change.");
 
-       if (ob == dialog_->browser_all) {
-               str = N_("All the currently defined formats known to LyX.");
-       } else if (ob == dialog_->input_format) {
-               str = N_("The format identifier.");
-       } else if (ob == dialog_->input_gui_name) {
-               str = N_("The format name as it will appear in the menus.");
-       } else if (ob == dialog_->input_shrtcut) {
-               str = N_("The keyboard accelerator. Use a letter in the GUI name. Case sensitive.");
-       } else if (ob == dialog_->input_extension) {
-               str = N_("Used to recognize the file. E.g., ps, pdf, tex.");
-       } else if (ob == dialog_->input_viewer) {
-               str = N_("The command used to launch the viewer application.");
-       } else if (ob == dialog_->button_delete) {
-               str = N_("Remove the current format from the list of available formats. Note: you must then \"Apply\" the change.");
-       } else if (ob == dialog_->button_add) {
+       if (ob == dialog_->button_add) {
                if (string(ob->label) == _("Add"))
-                       str = N_("Add the current format to the list of available formats. Note: you must then \"Apply\" the change.");
+                       return  _("Add the current format to the list of available "
+                                 "formats. Note: you must then \"Apply\" the change.");
                else
-                       str = N_("Modify the contents of the current format. Note: you must then \"Apply\" the change.");
+                       return  _("Modify the contents of the current format. Note: "
+                                 "you must then \"Apply\" the change.");
        }
 
-       return str;
+       return string();
 }
 
 
 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
 {
-       if (ob == dialog_->browser_all) {
+       if (ob == dialog_->browser_all)
                return Browser();
 
-       } else if (ob == dialog_->input_format
-                  || ob == dialog_->input_gui_name
-                  || ob == dialog_->input_shrtcut
-                  || ob == dialog_->input_extension
-                  || ob == dialog_->input_viewer) {
+       if (ob == dialog_->input_format
+        || ob == dialog_->input_gui_name
+        || ob == dialog_->input_shrtcut
+        || ob == dialog_->input_extension
+        || ob == dialog_->input_viewer)
                return Input();
 
-       } else if (ob == dialog_->button_add) {
+       if (ob == dialog_->button_add)
                return Add();
 
-       } else if (ob == dialog_->button_delete) {
+       if (ob == dialog_->button_delete)
                return erase();
-       }
 
        return false;
 }
@@ -1347,10 +1326,11 @@ bool FormPreferences::Formats::Add()
 }
 
 
-bool FormPreferences::Formats::Browser() 
+bool FormPreferences::Formats::Browser()
 {
        int const i = fl_get_browser(dialog_->browser_all);
-       if (i <= 0) return false;
+       if (i <= 0)
+               return false;
 
        fl_freeze_form(dialog_->form);
 
@@ -1367,7 +1347,7 @@ bool FormPreferences::Formats::Browser()
 
        setEnabled(dialog_->button_add,    false);
        setEnabled(dialog_->button_delete, true);
-                               
+
        fl_unfreeze_form(dialog_->form);
        return false;
 }
@@ -1378,7 +1358,8 @@ bool FormPreferences::Formats::erase()
        string const name = fl_get_input(dialog_->input_format);
 
        if (local_converters.formatIsUsed(name)) {
-               parent_.printWarning(_("Cannot remove a Format used by a Converter. Remove the converter first."));
+               parent_.postWarning(_("Cannot remove a Format used by a Converter. "
+                                     "Remove the converter first."));
                setEnabled(dialog_->button_delete, false);
                return false;
        }
@@ -1397,18 +1378,18 @@ bool FormPreferences::Formats::Input()
 
        if (sel < 0) {
                fl_set_object_label(dialog_->button_add,
-                                    idex(_("Add|#A")));
+                                   idex(_("Add|#A")));
                fl_set_button_shortcut(dialog_->button_add,
-                                       scex(_("Add|#A")), 1);
+                                      scex(_("Add|#A")), 1);
 
                fl_deselect_browser(dialog_->browser_all);
                setEnabled(dialog_->button_delete, false);
 
        } else {
                fl_set_object_label(dialog_->button_add,
-                                    idex(_("Modify|#M")));
+                                   idex(_("Modify|#M")));
                fl_set_button_shortcut(dialog_->button_add,
-                                       scex(_("Modify|#M")), 1);
+                                      scex(_("Modify|#M")), 1);
 
                int const top = max(sel-5, 0);
                fl_set_browser_topline(dialog_->browser_all, top);
@@ -1427,12 +1408,12 @@ bool FormPreferences::Formats::Input()
 }
 
 
-FormPreferences::InputsMisc::InputsMisc( FormPreferences &  p )
+FormPreferences::InputsMisc::InputsMisc(FormPreferences &  p)
        : parent_(p)
 {}
 
 
-FD_form_inputs_misc const * FormPreferences::InputsMisc::dialog()
+FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
 {
        return dialog_.get();
 }
@@ -1447,24 +1428,21 @@ void FormPreferences::InputsMisc::apply() const
 
 void FormPreferences::InputsMisc::build()
 {
-       dialog_.reset(parent_.build_inputs_misc());
+       dialog_.reset(build_preferences_inputs_misc(&parent_));
 
        fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
 
        // set up the feedback mechanism
-       setPreHandler(dialog_->input_date_format);
+       setPrehandler(dialog_->input_date_format);
 }
 
 
 string const
 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
 {
-       string str;
-
        if (ob == dialog_->input_date_format)
-               str = lyxrc.getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
-
-       return str;
+               return lyxrc.getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
+       return string();
 }
 
 
@@ -1475,12 +1453,12 @@ void FormPreferences::InputsMisc::update()
 }
 
 
-FormPreferences::Interface::Interface( FormPreferences &  p )
+FormPreferences::Interface::Interface(FormPreferences &  p)
        : parent_(p)
 {}
 
 
-FD_form_interface const * FormPreferences::Interface::dialog()
+FD_preferences_interface const * FormPreferences::Interface::dialog()
 {
        return dialog_.get();
 }
@@ -1488,11 +1466,11 @@ FD_form_interface const * FormPreferences::Interface::dialog()
 
 void FormPreferences::Interface::apply() const
 {
-       lyxrc.popup_font_name =
-               fl_get_input(dialog_->input_popup_font);
-       lyxrc.menu_font_name = fl_get_input(dialog_->input_menu_font);
-       lyxrc.font_norm_menu =
-               fl_get_input(dialog_->input_popup_encoding);
+       lyxrc.popup_normal_font =
+               fl_get_input(dialog_->input_popup_normal_font);
+       lyxrc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
+       lyxrc.popup_font_encoding =
+               fl_get_input(dialog_->input_popup_font_encoding);
        lyxrc.bind_file = fl_get_input(dialog_->input_bind_file);
        lyxrc.ui_file = fl_get_input(dialog_->input_ui_file);
        lyxrc.override_x_deadkeys =
@@ -1502,45 +1480,42 @@ void FormPreferences::Interface::apply() const
 
 void FormPreferences::Interface::build()
 {
-       dialog_.reset(parent_.build_interface());
+       dialog_.reset(build_preferences_interface(&parent_));
 
-       fl_set_input_return(dialog_->input_popup_font, FL_RETURN_CHANGED);
-       fl_set_input_return(dialog_->input_menu_font, FL_RETURN_CHANGED);
-       fl_set_input_return(dialog_->input_popup_encoding, FL_RETURN_CHANGED);
+       fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
+       fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
+       fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
 
        // set up the feedback mechanism
-       setPreHandler(dialog_->input_popup_font);
-       setPreHandler(dialog_->input_menu_font);
-       setPreHandler(dialog_->input_popup_encoding);
-       setPreHandler(dialog_->input_bind_file);
-       setPreHandler(dialog_->button_bind_file_browse);
-       setPreHandler(dialog_->input_ui_file);
-       setPreHandler(dialog_->button_ui_file_browse);
-       setPreHandler(dialog_->check_override_x_dead_keys);
+       setPrehandler(dialog_->input_popup_normal_font);
+       setPrehandler(dialog_->input_popup_bold_font);
+       setPrehandler(dialog_->input_popup_font_encoding);
+       setPrehandler(dialog_->input_bind_file);
+       setPrehandler(dialog_->button_bind_file_browse);
+       setPrehandler(dialog_->input_ui_file);
+       setPrehandler(dialog_->button_ui_file_browse);
+       setPrehandler(dialog_->check_override_x_dead_keys);
 }
 
 
 string const
 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
 {
-       string str;
-
-       if (ob == dialog_->input_popup_font)
-               str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_POPUP);
-       else if (ob == dialog_->input_menu_font)
-               str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_MENU);
-       else if (ob == dialog_->input_popup_encoding)
-               str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING_MENU);
-       else if (ob == dialog_->input_bind_file)
-               str = lyxrc.getDescription(LyXRC::RC_BINDFILE);
-       else if (ob == dialog_->input_ui_file)
-               str = lyxrc.getDescription(LyXRC::RC_UIFILE);
-       else if (ob == dialog_->check_override_x_dead_keys)
-               str = lyxrc.getDescription(LyXRC::RC_OVERRIDE_X_DEADKEYS);
-
-       return str;
+       if (ob == dialog_->input_popup_normal_font)
+               return lyxrc.getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
+       if (ob == dialog_->input_popup_bold_font)
+               return lyxrc.getDescription(LyXRC::RC_POPUP_BOLD_FONT);
+       if (ob == dialog_->input_popup_font_encoding)
+               return lyxrc.getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
+       if (ob == dialog_->input_bind_file)
+               return lyxrc.getDescription(LyXRC::RC_BINDFILE);
+       if (ob == dialog_->input_ui_file)
+               return lyxrc.getDescription(LyXRC::RC_UIFILE);
+       if (ob == dialog_->check_override_x_dead_keys)
+               return lyxrc.getDescription(LyXRC::RC_OVERRIDE_X_DEADKEYS);
+       return string();
 }
 
 
@@ -1548,41 +1523,41 @@ bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
 {
        if (ob == dialog_->button_bind_file_browse) {
                string dir  = AddName(system_lyxdir, "bind");
-               string name = N_("Sys Bind");
+               string name = _("Sys Bind|#S#s");
                pair<string,string> dir1(name, dir);
 
                dir = AddName(user_lyxdir, "bind");
-               name = N_("User Bind");
+               name = _("User Bind|#U#u");
                pair<string,string> dir2(name, dir);
 
                parent_.browse(dialog_->input_bind_file,
-                              N_("Bind file"), "*.bind", dir1, dir2);
-               
+                              _("Bind file"), "*.bind", dir1, dir2);
+
        } else if (ob == dialog_->button_ui_file_browse) {
                string dir  = AddName(system_lyxdir, "ui");
-               string name = N_("Sys UI");
+               string name = _("Sys UI|#S#s");
                pair<string,string> dir1(name, dir);
 
                dir = AddName(user_lyxdir, "ui");
-               name = N_("User UI");
+               name = _("User UI|#U#u");
                pair<string,string> dir2(name, dir);
 
                parent_.browse(dialog_->input_ui_file,
-                              N_("UI file"), "*.ui", dir1, dir2);
+                              _("UI file"), "*.ui", dir1, dir2);
        }
-       
+
        return true;
 }
 
 
 void FormPreferences::Interface::update()
 {
-       fl_set_input(dialog_->input_popup_font,
-                    lyxrc.popup_font_name.c_str());
-       fl_set_input(dialog_->input_menu_font,
-                    lyxrc.menu_font_name.c_str());
-       fl_set_input(dialog_->input_popup_encoding,
-                    lyxrc.font_norm_menu.c_str());
+       fl_set_input(dialog_->input_popup_normal_font,
+                    lyxrc.popup_normal_font.c_str());
+       fl_set_input(dialog_->input_popup_bold_font,
+                    lyxrc.popup_bold_font.c_str());
+       fl_set_input(dialog_->input_popup_font_encoding,
+                    lyxrc.popup_font_encoding.c_str());
        fl_set_input(dialog_->input_bind_file,
                     lyxrc.bind_file.c_str());
        fl_set_input(dialog_->input_ui_file,
@@ -1592,12 +1567,12 @@ void FormPreferences::Interface::update()
 }
 
 
-FormPreferences::Language::Language( FormPreferences &  p )
+FormPreferences::Language::Language(FormPreferences &  p)
        : parent_(p)
 {}
 
 
-FD_form_language const * FormPreferences::Language::dialog()
+FD_preferences_language const * FormPreferences::Language::dialog()
 {
        return dialog_.get();
 }
@@ -1605,7 +1580,8 @@ FD_form_language const * FormPreferences::Language::dialog()
 
 void FormPreferences::Language::apply()
 {
-       lyxrc.default_language = combo_default_lang->getline();
+       int const pos = combo_default_lang->get();
+       lyxrc.default_language = lang_[pos-1];
 
        int button = fl_get_button(dialog_->check_use_kbmap);
        string const name_1 = fl_get_input(dialog_->input_kbmap1);
@@ -1618,7 +1594,7 @@ void FormPreferences::Language::apply()
                lyxrc.primary_kbmap = name_1;
                lyxrc.secondary_kbmap = name_2;
        }
-       
+
        button = fl_get_button(dialog_->check_rtl_support);
        lyxrc.rtl_support = static_cast<bool>(button);
 
@@ -1648,12 +1624,16 @@ void FormPreferences::Language::apply()
 
 void FormPreferences::Language::build()
 {
-       dialog_.reset(parent_.build_language());
+       dialog_.reset(build_preferences_language(&parent_));
 
        fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
 
+       // Store the lang identifiers for later
+       vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
+       lang_ = getSecond(langs);
+
        // The default_language is a combo-box and has to be inserted manually
        fl_freeze_form(dialog_->form);
        fl_addto_form(dialog_->form);
@@ -1662,40 +1642,42 @@ void FormPreferences::Language::build()
        fl_deactivate_object(dialog_->choice_default_lang);
        combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
        combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400,
-                               parent_.lang_opts_tab_->tabfolder_outer,
+                               parent_.lang_opts_tab_->tabfolder_inner,
                                parent_.dialog_->tabfolder_prefs);
        combo_default_lang->shortcut("#L",1);
        combo_default_lang->setcallback(ComboCB, &parent_);
 
-       for (Languages::const_iterator cit = languages.begin();
-           cit != languages.end(); ++cit) {
-               combo_default_lang->addto(cit->second.lang());
+       vector<frnt::LanguagePair>::const_iterator lit  = langs.begin();
+       vector<frnt::LanguagePair>::const_iterator lend = langs.end();
+       for (; lit != lend; ++lit) {
+               combo_default_lang->addto(lit->first);
        }
+       combo_default_lang->select(1);
 
        fl_end_form();
        fl_unfreeze_form(dialog_->form);
 
        // set up the feedback mechanism
-       setPreHandler(dialog_->input_package);
-       setPreHandler(dialog_->check_use_kbmap);
+       setPrehandler(dialog_->input_package);
+       setPrehandler(dialog_->check_use_kbmap);
 
        // This is safe, as nothing is done to the pointer, other than
        // to use its address in a block-if statement.
        // No it's not! Leads to crash.
-       // setPreHandler(
-       //              reinterpret_cast<FL_OBJECT *>(combo_default_lang),
+       // setPrehandler(
+       //              reinterpret_cast<FL_OBJECT *>(combo_default_lang),
        //              C_FormPreferencesFeedbackCB);
 
-       setPreHandler(dialog_->input_kbmap1);
-       setPreHandler(dialog_->input_kbmap2);
-       setPreHandler(dialog_->check_rtl_support);
-       setPreHandler(dialog_->check_mark_foreign);
-       setPreHandler(dialog_->check_auto_begin);
-       setPreHandler(dialog_->check_auto_end);
-       setPreHandler(dialog_->check_use_babel);
-       setPreHandler(dialog_->check_global_options);
-       setPreHandler(dialog_->input_command_begin);
-       setPreHandler(dialog_->input_command_end);
+       setPrehandler(dialog_->input_kbmap1);
+       setPrehandler(dialog_->input_kbmap2);
+       setPrehandler(dialog_->check_rtl_support);
+       setPrehandler(dialog_->check_mark_foreign);
+       setPrehandler(dialog_->check_auto_begin);
+       setPrehandler(dialog_->check_auto_end);
+       setPrehandler(dialog_->check_use_babel);
+       setPrehandler(dialog_->check_global_options);
+       setPrehandler(dialog_->input_command_begin);
+       setPrehandler(dialog_->input_command_end);
 
        // Activate/Deactivate the input fields dependent on the state of the
        // buttons.
@@ -1706,36 +1688,33 @@ void FormPreferences::Language::build()
 string const
 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
 {
-       string str;
-
        if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
-               str = lyxrc.getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
-       else if (ob == dialog_->check_use_kbmap)
-               str = lyxrc.getDescription(LyXRC::RC_KBMAP);
-       else if (ob == dialog_->input_kbmap1)
-               str = lyxrc.getDescription(LyXRC::RC_KBMAP_PRIMARY);
-       else if (ob == dialog_->input_kbmap2)
-               str = lyxrc.getDescription(LyXRC::RC_KBMAP_SECONDARY);
-       else if (ob == dialog_->check_rtl_support)
-               str = lyxrc.getDescription(LyXRC::RC_RTL_SUPPORT);
-       else if (ob == dialog_->check_mark_foreign)
-               str = lyxrc.getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
-       else if (ob == dialog_->check_auto_begin)
-               str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
-       else if (ob == dialog_->check_auto_end)
-               str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
-       else if (ob == dialog_->check_use_babel)
-               str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
-       else if (ob == dialog_->check_global_options)
-               str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
-       else if (ob == dialog_->input_package)
-               str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
-       else if (ob == dialog_->input_command_begin)
-               str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
-       else if (ob == dialog_->input_command_end)
-               str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
-
-       return str;
+               return lyxrc.getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
+       if (ob == dialog_->check_use_kbmap)
+               return lyxrc.getDescription(LyXRC::RC_KBMAP);
+       if (ob == dialog_->input_kbmap1)
+               return lyxrc.getDescription(LyXRC::RC_KBMAP_PRIMARY);
+       if (ob == dialog_->input_kbmap2)
+               return lyxrc.getDescription(LyXRC::RC_KBMAP_SECONDARY);
+       if (ob == dialog_->check_rtl_support)
+               return lyxrc.getDescription(LyXRC::RC_RTL_SUPPORT);
+       if (ob == dialog_->check_mark_foreign)
+               return lyxrc.getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
+       if (ob == dialog_->check_auto_begin)
+               return lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
+       if (ob == dialog_->check_auto_end)
+               return lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
+       if (ob == dialog_->check_use_babel)
+               return lyxrc.getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
+       if (ob == dialog_->check_global_options)
+               return lyxrc.getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
+       if (ob == dialog_->input_package)
+               return lyxrc.getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
+       if (ob == dialog_->input_command_begin)
+               return lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
+       if (ob == dialog_->input_command_end)
+               return lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
+       return string();
 }
 
 
@@ -1756,20 +1735,18 @@ bool FormPreferences::Language::input(FL_OBJECT const * const ob)
 
        if (ob == dialog_->button_kbmap1_browse) {
                string const dir  = AddName(system_lyxdir, "kbd");
-               string const name = N_("Key maps");
+               string const name = _("Key maps|#K#k");
                pair<string, string> dir1(name, dir);
 
                parent_.browse(dialog_->input_kbmap1,
-                              N_("Keyboard map"), "*.kmap", dir1,
-                              make_pair(string(), string()));
+                              _("Keyboard map"), "*.kmap", dir1);
        } else if (ob == dialog_->button_kbmap2_browse) {
                string const dir  = AddName(system_lyxdir, "kbd");
-               string const name = N_("Key maps");
+               string const name = _("Key maps|#K#k");
                pair<string, string> dir1(name, dir);
 
                parent_.browse(dialog_->input_kbmap2,
-                              N_("Keyboard map"), "*.kmap", dir1,
-                              make_pair(string(), string()));
+                              _("Keyboard map"), "*.kmap", dir1);
        }
 
        return activate;
@@ -1781,7 +1758,8 @@ void FormPreferences::Language::update()
        fl_set_button(dialog_->check_use_kbmap,
                      lyxrc.use_kbmap);
 
-       combo_default_lang->select(lyxrc.default_language);
+       int const pos = int(findPos(lang_, lyxrc.default_language));
+       combo_default_lang->select(pos + 1);
 
        if (lyxrc.use_kbmap) {
                fl_set_input(dialog_->input_kbmap1,
@@ -1792,7 +1770,7 @@ void FormPreferences::Language::update()
                fl_set_input(dialog_->input_kbmap1, "");
                fl_set_input(dialog_->input_kbmap2, "");
        }
-       
+
        fl_set_button(dialog_->check_rtl_support, lyxrc.rtl_support);
        fl_set_button(dialog_->check_mark_foreign,
                      lyxrc.mark_foreign_language);
@@ -1817,19 +1795,19 @@ void FormPreferences::Language::update()
 
 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
 {
-    FormPreferences * pre = static_cast<FormPreferences*>(v);
-    // 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));
+       FormPreferences * pre = static_cast<FormPreferences*>(v);
+       // 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));
 }
 
 
-FormPreferences::LnFmisc::LnFmisc( FormPreferences &  p )
+FormPreferences::LnFmisc::LnFmisc(FormPreferences &  p)
        : parent_(p)
 {}
 
 
-FD_form_lnf_misc const * FormPreferences::LnFmisc::dialog()
+FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
 {
        return dialog_.get();
 }
@@ -1837,27 +1815,43 @@ FD_form_lnf_misc const * FormPreferences::LnFmisc::dialog()
 
 void FormPreferences::LnFmisc::apply() const
 {
-       lyxrc.show_banner = fl_get_button(dialog_->check_banner);
        lyxrc.auto_region_delete =
                fl_get_button(dialog_->check_auto_region_delete);
-       lyxrc.exit_confirmation = fl_get_button(dialog_->check_exit_confirm);
-       lyxrc.display_shortcuts =
-               fl_get_button(dialog_->check_display_shrtcuts);
-       lyxrc.new_ask_filename = fl_get_button(dialog_->check_ask_new_file);
        lyxrc.cursor_follows_scrollbar =
                fl_get_button(dialog_->check_cursor_follows_scrollbar);
        lyxrc.dialogs_iconify_with_main =
                fl_get_button(dialog_->check_dialogs_iconify_with_main);
+       lyxrc.preview = fl_get_button(dialog_->check_preview_latex);
        lyxrc.autosave = static_cast<unsigned int>
                (fl_get_counter_value(dialog_->counter_autosave));
        lyxrc.wheel_jump = static_cast<unsigned int>
                (fl_get_counter_value(dialog_->counter_wm_jump));
+
+       // See FIXME below
+       // grfx::DisplayType old_value = lyxrc.display_graphics;
+       switch (fl_get_choice(dialog_->choice_display)) {
+               case 4: lyxrc.display_graphics = grfx::NoDisplay; break;
+               case 3: lyxrc.display_graphics = grfx::ColorDisplay; break;
+               case 2: lyxrc.display_graphics = grfx::GrayscaleDisplay; break;
+               case 1: lyxrc.display_graphics = grfx::MonochromeDisplay; break;
+               default: lyxrc.display_graphics = grfx::ColorDisplay; break;
+       }
+
+#ifdef WITH_WARNINGS
+#warning FIXME!! The graphics cache no longer has a changeDisplay method.
+#endif
+#if 0
+       if (old_value != lyxrc.display_graphics) {
+               grfx::GCache & gc = grfx::GCache::get();
+               gc.changeDisplay();
+       }
+#endif
 }
 
 
 void FormPreferences::LnFmisc::build()
 {
-       dialog_.reset(parent_.build_lnf_misc());
+       dialog_.reset(build_preferences_lnf_misc(&parent_));
 
        fl_set_counter_step(dialog_->counter_autosave, 1, 10);
        fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
@@ -1866,69 +1860,67 @@ void FormPreferences::LnFmisc::build()
        fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
 
        // set up the feedback mechanism
-       setPreHandler(dialog_->check_banner);
-       setPreHandler(dialog_->check_auto_region_delete);
-       setPreHandler(dialog_->check_exit_confirm);
-       setPreHandler(dialog_->check_display_shrtcuts);
-       setPreHandler(dialog_->counter_autosave);
-       setPreHandler(dialog_->check_ask_new_file);
-       setPreHandler(dialog_->check_cursor_follows_scrollbar);
-       setPreHandler(dialog_->check_dialogs_iconify_with_main);
-       setPreHandler(dialog_->counter_wm_jump);
+       setPrehandler(dialog_->check_auto_region_delete);
+       setPrehandler(dialog_->counter_autosave);
+       setPrehandler(dialog_->check_cursor_follows_scrollbar);
+       setPrehandler(dialog_->check_dialogs_iconify_with_main);
+       setPrehandler(dialog_->check_preview_latex);
+       setPrehandler(dialog_->counter_wm_jump);
+       
+       fl_addto_choice(dialog_->choice_display, _("Monochrome|Grayscale|Color|Do not display"));
 }
 
 
 string const
 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
 {
-       string str;
-
-       if (ob == dialog_->check_banner)
-               str = lyxrc.getDescription(LyXRC::RC_SHOW_BANNER);
-       else if (ob == dialog_->check_auto_region_delete)
-               str = lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
-       else if (ob == dialog_->check_exit_confirm)
-               str = lyxrc.getDescription(LyXRC::RC_EXIT_CONFIRMATION);
-       else if (ob == dialog_->check_display_shrtcuts)
-               str = lyxrc.getDescription(LyXRC::RC_DISPLAY_SHORTCUTS);
-       else if (ob == dialog_->check_ask_new_file)
-               str = lyxrc.getDescription(LyXRC::RC_NEW_ASK_FILENAME);
-       else if (ob == dialog_->check_cursor_follows_scrollbar)
-               str = lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
-       else if (ob == dialog_->check_dialogs_iconify_with_main)
-               str = lyxrc.getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
-       else if (ob == dialog_->counter_autosave)
-               str = lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
-       else if (ob == dialog_->counter_wm_jump)
-               str = lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
-
-       return str;
+       if (ob == dialog_->check_auto_region_delete)
+               return lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
+       if (ob == dialog_->check_cursor_follows_scrollbar)
+               return lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
+       if (ob == dialog_->check_dialogs_iconify_with_main)
+               return lyxrc.getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
+       if (ob == dialog_->check_preview_latex)
+               return lyxrc.getDescription(LyXRC::RC_PREVIEW);
+       if (ob == dialog_->counter_autosave)
+               return lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
+       if (ob == dialog_->counter_wm_jump)
+               return lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
+       if (ob == dialog_->choice_display)
+               return lyxrc.getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
+       return string();
 }
 
 
 void FormPreferences::LnFmisc::update()
 {
-       fl_set_button(dialog_->check_banner, lyxrc.show_banner);
-       fl_set_button(dialog_->check_auto_region_delete, 
+       fl_set_button(dialog_->check_auto_region_delete,
                      lyxrc.auto_region_delete);
-       fl_set_button(dialog_->check_exit_confirm, lyxrc.exit_confirmation);
-       fl_set_button(dialog_->check_display_shrtcuts, lyxrc.display_shortcuts);
-       fl_set_button(dialog_->check_ask_new_file, lyxrc.new_ask_filename);
        fl_set_button(dialog_->check_cursor_follows_scrollbar,
                      lyxrc.cursor_follows_scrollbar);
        fl_set_button(dialog_->check_dialogs_iconify_with_main,
                      lyxrc.dialogs_iconify_with_main);
+       fl_set_button(dialog_->check_preview_latex,
+                     lyxrc.preview);
        fl_set_counter_value(dialog_->counter_autosave, lyxrc.autosave);
        fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
+
+       switch (lyxrc.display_graphics) {
+               case grfx::NoDisplay:           fl_set_choice(dialog_->choice_display, 4); break;
+               case grfx::ColorDisplay:        fl_set_choice(dialog_->choice_display, 3); break;
+               case grfx::GrayscaleDisplay:    fl_set_choice(dialog_->choice_display, 2); break;
+               case grfx::MonochromeDisplay:   fl_set_choice(dialog_->choice_display, 1); break;
+               default:                        fl_set_choice(dialog_->choice_display, 3); break;
+       }
 }
 
 
-FormPreferences::OutputsMisc::OutputsMisc( FormPreferences &  p )
+FormPreferences::OutputsMisc::OutputsMisc(FormPreferences &  p)
        : parent_(p)
 {}
 
 
-FD_form_outputs_misc const * FormPreferences::OutputsMisc::dialog()
+FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
 {
        return dialog_.get();
 }
@@ -1947,12 +1939,13 @@ void FormPreferences::OutputsMisc::apply() const
        lyxrc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
        lyxrc.chktex_command = fl_get_input(dialog_->input_checktex);
        lyxrc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
+       lyxrc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
 }
 
 
 void FormPreferences::OutputsMisc::build()
 {
-       dialog_.reset(parent_.build_outputs_misc());
+       dialog_.reset(build_preferences_outputs_misc(&parent_));
 
        fl_set_counter_step(dialog_->counter_line_len, 1, 10);
 
@@ -1963,37 +1956,37 @@ void FormPreferences::OutputsMisc::build()
        fl_set_input_return(dialog_->input_paperoption,  FL_RETURN_CHANGED);
 
        fl_addto_choice(dialog_->choice_default_papersize,
-                       _(" default | US letter | legal | executive | A3 | A4 | A5 | B5 "));
+                       _(" default | US letter | US legal | US executive | A3 | A4 | A5 | B5 "));
 
        // set up the feedback mechanism
-       setPreHandler(dialog_->counter_line_len);
-       setPreHandler(dialog_->input_tex_encoding);
-       setPreHandler(dialog_->choice_default_papersize);
-       setPreHandler(dialog_->input_ascii_roff);
-       setPreHandler(dialog_->input_checktex);
-       setPreHandler(dialog_->input_paperoption);
+       setPrehandler(dialog_->counter_line_len);
+       setPrehandler(dialog_->input_tex_encoding);
+       setPrehandler(dialog_->choice_default_papersize);
+       setPrehandler(dialog_->input_ascii_roff);
+       setPrehandler(dialog_->input_checktex);
+       setPrehandler(dialog_->input_paperoption);
+       setPrehandler(dialog_->check_autoreset_classopt);
 }
 
 
 string const
 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
 {
-       string str;
-
        if (ob == dialog_->counter_line_len)
-               str = lyxrc.getDescription(LyXRC::RC_ASCII_LINELEN);
-       else if (ob == dialog_->input_tex_encoding)
-               str = lyxrc.getDescription(LyXRC::RC_FONT_ENCODING);
-       else if (ob == dialog_->input_ascii_roff)
-               str = lyxrc.getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
-       else if (ob == dialog_->input_checktex)
-               str = lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
-       else if (ob == dialog_->choice_default_papersize)
-               str = lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
-       else if (ob == dialog_->input_paperoption)
-               str = lyxrc.getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
-
-       return str;
+               return lyxrc.getDescription(LyXRC::RC_ASCII_LINELEN);
+       if (ob == dialog_->input_tex_encoding)
+               return lyxrc.getDescription(LyXRC::RC_FONT_ENCODING);
+       if (ob == dialog_->input_ascii_roff)
+               return lyxrc.getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
+       if (ob == dialog_->input_checktex)
+               return lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
+       if (ob == dialog_->choice_default_papersize)
+               return lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
+       if (ob == dialog_->input_paperoption)
+               return lyxrc.getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
+       if (ob == dialog_->check_autoreset_classopt)
+               return lyxrc.getDescription(LyXRC::RC_AUTORESET_OPTIONS);
+       return string();
 }
 
 
@@ -2010,16 +2003,19 @@ void FormPreferences::OutputsMisc::update()
        fl_set_input(dialog_->input_checktex,
                     lyxrc.chktex_command.c_str());
        fl_set_input(dialog_->input_paperoption,
-                     lyxrc.view_dvi_paper_option.c_str());
+                    lyxrc.view_dvi_paper_option.c_str());
+       fl_set_button(dialog_->check_autoreset_classopt,
+                     lyxrc.auto_reset_options);
+
 }
 
 
-FormPreferences::Paths::Paths( FormPreferences &  p )
+FormPreferences::Paths::Paths(FormPreferences &  p)
        : parent_(p)
 {}
 
 
-FD_form_paths const * FormPreferences::Paths::dialog()
+FD_preferences_paths const * FormPreferences::Paths::dialog()
 {
        return dialog_.get();
 }
@@ -2032,7 +2028,8 @@ void FormPreferences::Paths::apply()
 
        int button = fl_get_button(dialog_->check_use_temp_dir);
        string str  = fl_get_input(dialog_->input_temp_dir);
-       if (!button) str.erase();
+       if (!button)
+               str.erase();
 
        lyxrc.use_tempdir = button;
        lyxrc.tempdir_path = str;
@@ -2040,7 +2037,7 @@ void FormPreferences::Paths::apply()
        button = fl_get_button(dialog_->check_last_files);
        str = fl_get_input(dialog_->input_lastfiles);
        if (!button) str.erase();
-       
+
        lyxrc.check_lastfiles = button;
        lyxrc.lastfiles = str;
        lyxrc.num_lastfiles = static_cast<unsigned int>
@@ -2048,7 +2045,8 @@ void FormPreferences::Paths::apply()
 
        button = fl_get_button(dialog_->check_make_backups);
        str = fl_get_input(dialog_->input_backup_path);
-       if (!button) str.erase();
+       if (!button)
+               str.erase();
 
        lyxrc.make_backup = button;
        lyxrc.backupdir_path = str;
@@ -2062,7 +2060,7 @@ void FormPreferences::Paths::apply()
 
 void FormPreferences::Paths::build()
 {
-       dialog_.reset(parent_.build_paths());
+       dialog_.reset(build_preferences_paths(&parent_));
 
        fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
@@ -2073,54 +2071,50 @@ void FormPreferences::Paths::build()
        fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
 
        // set up the feedback mechanism
-       setPreHandler(dialog_->input_default_path);
-       setPreHandler(dialog_->counter_lastfiles);
-       setPreHandler(dialog_->input_template_path);
-       setPreHandler(dialog_->check_last_files);
-       setPreHandler(dialog_->input_lastfiles);
-       setPreHandler(dialog_->check_make_backups);
-       setPreHandler(dialog_->input_backup_path);
-       setPreHandler(dialog_->input_serverpipe);
-       setPreHandler(dialog_->input_temp_dir);
-       setPreHandler(dialog_->check_use_temp_dir);
+       setPrehandler(dialog_->input_default_path);
+       setPrehandler(dialog_->counter_lastfiles);
+       setPrehandler(dialog_->input_template_path);
+       setPrehandler(dialog_->check_last_files);
+       setPrehandler(dialog_->input_lastfiles);
+       setPrehandler(dialog_->check_make_backups);
+       setPrehandler(dialog_->input_backup_path);
+       setPrehandler(dialog_->input_serverpipe);
+       setPrehandler(dialog_->input_temp_dir);
+       setPrehandler(dialog_->check_use_temp_dir);
 }
 
 
 string const
 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
 {
-       string str;
-
        if (ob == dialog_->input_default_path)
-               str = lyxrc.getDescription(LyXRC::RC_DOCUMENTPATH);
-       else if (ob == dialog_->input_template_path)
-               str = lyxrc.getDescription(LyXRC::RC_TEMPLATEPATH);
-       else if (ob == dialog_->check_use_temp_dir)
-               str = lyxrc.getDescription(LyXRC::RC_USETEMPDIR);
-       else if (ob == dialog_->input_temp_dir)
-               str = lyxrc.getDescription(LyXRC::RC_TEMPDIRPATH);
-       else if (ob == dialog_->check_last_files)
-               str = lyxrc.getDescription(LyXRC::RC_CHECKLASTFILES);
-       else if (ob == dialog_->input_lastfiles)
-               str = lyxrc.getDescription(LyXRC::RC_LASTFILES);
-       else if (ob == dialog_->counter_lastfiles)
-               str = lyxrc.getDescription(LyXRC::RC_NUMLASTFILES);
-       else if (ob == dialog_->check_make_backups)
-               str = lyxrc.getDescription(LyXRC::RC_MAKE_BACKUP);
-       else if (ob == dialog_->input_backup_path)
-               str = lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH);
-       else if (ob == dialog_->input_serverpipe) {
-               str = lyxrc.getDescription(LyXRC::RC_SERVERPIPE);
-       }
-
-       return str;
+               return lyxrc.getDescription(LyXRC::RC_DOCUMENTPATH);
+       if (ob == dialog_->input_template_path)
+               return lyxrc.getDescription(LyXRC::RC_TEMPLATEPATH);
+       if (ob == dialog_->check_use_temp_dir)
+               return lyxrc.getDescription(LyXRC::RC_USETEMPDIR);
+       if (ob == dialog_->input_temp_dir)
+               return lyxrc.getDescription(LyXRC::RC_TEMPDIRPATH);
+       if (ob == dialog_->check_last_files)
+               return lyxrc.getDescription(LyXRC::RC_CHECKLASTFILES);
+       if (ob == dialog_->input_lastfiles)
+               return lyxrc.getDescription(LyXRC::RC_LASTFILES);
+       if (ob == dialog_->counter_lastfiles)
+               return lyxrc.getDescription(LyXRC::RC_NUMLASTFILES);
+       if (ob == dialog_->check_make_backups)
+               return lyxrc.getDescription(LyXRC::RC_MAKE_BACKUP);
+       if (ob == dialog_->input_backup_path)
+               return lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH);
+       if (ob == dialog_->input_serverpipe)
+               return lyxrc.getDescription(LyXRC::RC_SERVERPIPE);
+       return string();
 }
 
 
 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
 {
        bool activate = true;
-       
+
        // !ob if function is called from Paths::update() to de/activate
        // objects,
        // otherwise the function is called by an xforms CB via input().
@@ -2141,16 +2135,16 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
 
        if (!ob || ob == dialog_->input_default_path) {
                string const name = fl_get_input(dialog_->input_default_path);
-               if (!RWInfo::WriteableDir(name)) {
-                       parent_.printWarning(RWInfo::ErrorMessage());
+               if (!name.empty() && !RWInfo::WriteableDir(name)) {
+                       parent_.postWarning(RWInfo::ErrorMessage());
                        return false;
                }
        }
 
        if (!ob || ob == dialog_->input_template_path) {
                string const name = fl_get_input(dialog_->input_template_path);
-               if (!RWInfo::ReadableDir(name)) {
-                       parent_.printWarning(RWInfo::ErrorMessage());
+               if (!name.empty() && !RWInfo::ReadableDir(name)) {
+                       parent_.postWarning(RWInfo::ErrorMessage());
                        return false;
                }
        }
@@ -2160,7 +2154,7 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
                if (fl_get_button(dialog_->check_make_backups)
                    && !name.empty()
                    && !RWInfo::WriteableDir(name)) {
-                       parent_.printWarning(RWInfo::ErrorMessage());
+                       parent_.postWarning(RWInfo::ErrorMessage());
                        return false;
                }
        }
@@ -2170,7 +2164,7 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
                if (fl_get_button(dialog_->check_make_backups)
                    && !name.empty()
                    && !RWInfo::WriteableDir(name)) {
-                       parent_.printWarning(RWInfo::ErrorMessage());
+                       parent_.postWarning(RWInfo::ErrorMessage());
                        return false;
                }
        }
@@ -2180,7 +2174,7 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
                if (fl_get_button(dialog_->check_last_files)
                    && !name.empty()
                    && !RWInfo::WriteableFile(name)) {
-                       parent_.printWarning(RWInfo::ErrorMessage());
+                       parent_.postWarning(RWInfo::ErrorMessage());
                        return false;
                }
        }
@@ -2191,11 +2185,11 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
                        // strip off the extension
                        string const str = ChangeExtension(name, "");
                        if (!RWInfo::WriteableFile(str + ".in")) {
-                               parent_.printWarning(RWInfo::ErrorMessage());
+                               parent_.postWarning(RWInfo::ErrorMessage());
                                return false;
                        }
                        if (!RWInfo::WriteableFile(str + ".out")) {
-                               parent_.printWarning(RWInfo::ErrorMessage());
+                               parent_.postWarning(RWInfo::ErrorMessage());
                                return false;
                        }
                }
@@ -2203,37 +2197,26 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
 
        if (ob == dialog_->button_default_path_browse) {
                parent_.browse(dialog_->input_default_path,
-                              N_("Default path"), string(),
-                              make_pair(string(), string()),
-                              make_pair(string(), string()));
+                              _("Default path"), string());
        } else if (ob == dialog_->button_template_path_browse) {
                parent_.browse(dialog_->input_template_path,
-                              N_("Template path"), string(),
-                              make_pair(string(), string()),
-                              make_pair(string(), string()));
+                              _("Template path"), string());
        } else if (ob == dialog_->button_temp_dir_browse) {
                parent_.browse(dialog_->input_temp_dir,
-                              N_("Temp dir"), string(),
-                              make_pair(string(), string()),
-                              make_pair(string(), string()));
+                              _("Temp dir"), string());
        } else if (ob == dialog_->button_lastfiles_browse) {
-               pair<string, string> dir(_("User"), user_lyxdir);
+               pair<string, string> dir(_("User|#U#u"), user_lyxdir);
 
                parent_.browse(dialog_->input_lastfiles,
-                              N_("Lastfiles"), string(), dir,
-                              make_pair(string(), string()));
+                              _("Lastfiles"), string(), dir);
        } else if (ob == dialog_->button_backup_path_browse) {
                parent_.browse(dialog_->input_backup_path,
-                              N_("Backup path"), string(),
-                              make_pair(string(), string()),
-                              make_pair(string(), string()));
+                              _("Backup path"), string());
        } else if (ob == dialog_->button_serverpipe_browse) {
                parent_.browse(dialog_->input_serverpipe,
-                              N_("LyX Server pipes"), string(),
-                              make_pair(string(), string()),
-                              make_pair(string(), string()));
+                              _("LyX Server pipes"), string());
        }
-       
+
        return activate;
 }
 
@@ -2246,24 +2229,27 @@ void FormPreferences::Paths::update()
                     lyxrc.template_path.c_str());
 
        string str;
-       if (lyxrc.make_backup) str = lyxrc.backupdir_path;
+       if (lyxrc.make_backup)
+               str = lyxrc.backupdir_path;
 
        fl_set_button(dialog_->check_make_backups,
                      lyxrc.make_backup);
        fl_set_input(dialog_->input_backup_path, str.c_str());
 
        str.erase();
-       if (lyxrc.use_tempdir) str = lyxrc.tempdir_path;
+       if (lyxrc.use_tempdir)
+               str = lyxrc.tempdir_path;
 
        fl_set_button(dialog_->check_use_temp_dir,
                      lyxrc.use_tempdir);
        fl_set_input(dialog_->input_temp_dir, str.c_str());
 
        str.erase();
-       if (lyxrc.check_lastfiles) str = lyxrc.lastfiles;
+       if (lyxrc.check_lastfiles)
+               str = lyxrc.lastfiles;
 
        fl_set_button(dialog_->check_last_files,
-                     lyxrc.check_lastfiles);           
+                     lyxrc.check_lastfiles);
        fl_set_input(dialog_->input_lastfiles, str.c_str());
        fl_set_counter_value(dialog_->counter_lastfiles,
                             lyxrc.num_lastfiles);
@@ -2281,7 +2267,7 @@ FormPreferences::Printer::Printer(FormPreferences &  p)
 {}
 
 
-FD_form_printer const * FormPreferences::Printer::dialog()
+FD_preferences_printer const * FormPreferences::Printer::dialog()
 {
        return dialog_.get();
 }
@@ -2318,52 +2304,49 @@ void FormPreferences::Printer::apply() const
 string const
 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
 {
-       string str;
-
        if (ob == dialog_->input_command)
-               str = lyxrc.getDescription(LyXRC::RC_PRINT_COMMAND);
-       else if (ob == dialog_->check_adapt_output)
-               str = lyxrc.getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
-       else if (ob == dialog_->input_to_printer)
-               str = lyxrc.getDescription(LyXRC::RC_PRINTTOPRINTER);
-       else if (ob == dialog_->input_to_file)
-               str = lyxrc.getDescription(LyXRC::RC_PRINTTOFILE);
-       else if (ob == dialog_->input_file_extension)
-               str = lyxrc.getDescription(LyXRC::RC_PRINTFILEEXTENSION);
-       else if (ob == dialog_->input_extra_options)
-               str = lyxrc.getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
-       else if (ob == dialog_->input_spool_command)
-               str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
-       else if (ob == dialog_->input_spool_prefix)
-               str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
-       else if (ob == dialog_->input_name)
-               str = lyxrc.getDescription(LyXRC::RC_PRINTER);
-       else if (ob == dialog_->input_even_pages)
-               str = lyxrc.getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
-       else if (ob == dialog_->input_odd_pages)
-               str = lyxrc.getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
-       else if (ob == dialog_->input_page_range)
-               str = lyxrc.getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
-       else if (ob == dialog_->input_reverse)
-               str = lyxrc.getDescription(LyXRC::RC_PRINTREVERSEFLAG);
-       else if (ob == dialog_->input_landscape)
-               str = lyxrc.getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
-       else if (ob == dialog_->input_copies)
-               str = lyxrc.getDescription(LyXRC::RC_PRINTCOPIESFLAG);
-       else if (ob == dialog_->input_collated)
-               str = lyxrc.getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
-       else if (ob == dialog_->input_paper_type)
-               str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERFLAG);
-       else if (ob == dialog_->input_paper_size)
-               str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
-
-       return str;
+               return lyxrc.getDescription(LyXRC::RC_PRINT_COMMAND);
+       if (ob == dialog_->check_adapt_output)
+               return lyxrc.getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
+       if (ob == dialog_->input_to_printer)
+               return lyxrc.getDescription(LyXRC::RC_PRINTTOPRINTER);
+       if (ob == dialog_->input_to_file)
+               return lyxrc.getDescription(LyXRC::RC_PRINTTOFILE);
+       if (ob == dialog_->input_file_extension)
+               return lyxrc.getDescription(LyXRC::RC_PRINTFILEEXTENSION);
+       if (ob == dialog_->input_extra_options)
+               return lyxrc.getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
+       if (ob == dialog_->input_spool_command)
+               return lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
+       if (ob == dialog_->input_spool_prefix)
+               return lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
+       if (ob == dialog_->input_name)
+               return lyxrc.getDescription(LyXRC::RC_PRINTER);
+       if (ob == dialog_->input_even_pages)
+               return lyxrc.getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
+       if (ob == dialog_->input_odd_pages)
+               return lyxrc.getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
+       if (ob == dialog_->input_page_range)
+               return lyxrc.getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
+       if (ob == dialog_->input_reverse)
+               return lyxrc.getDescription(LyXRC::RC_PRINTREVERSEFLAG);
+       if (ob == dialog_->input_landscape)
+               return lyxrc.getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
+       if (ob == dialog_->input_copies)
+               return lyxrc.getDescription(LyXRC::RC_PRINTCOPIESFLAG);
+       if (ob == dialog_->input_collated)
+               return lyxrc.getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
+       if (ob == dialog_->input_paper_type)
+               return lyxrc.getDescription(LyXRC::RC_PRINTPAPERFLAG);
+       if (ob == dialog_->input_paper_size)
+               return lyxrc.getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
+       return string();
 }
 
 
 void FormPreferences::Printer::build()
 {
-       dialog_.reset(parent_.build_printer());
+       dialog_.reset(build_preferences_printer(&parent_));
 
        fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
@@ -2384,24 +2367,24 @@ void FormPreferences::Printer::build()
        fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
 
        // set up the feedback mechanism
-       setPreHandler(dialog_->input_command);
-       setPreHandler(dialog_->input_page_range);
-       setPreHandler(dialog_->input_copies);
-       setPreHandler(dialog_->input_reverse);
-       setPreHandler(dialog_->input_to_printer);
-       setPreHandler(dialog_->input_file_extension);
-       setPreHandler(dialog_->input_spool_command);
-       setPreHandler(dialog_->input_paper_type);
-       setPreHandler(dialog_->input_even_pages);
-       setPreHandler(dialog_->input_odd_pages);
-       setPreHandler(dialog_->input_collated);
-       setPreHandler(dialog_->input_landscape);
-       setPreHandler(dialog_->input_to_file);
-       setPreHandler(dialog_->input_extra_options);
-       setPreHandler(dialog_->input_spool_prefix);
-       setPreHandler(dialog_->input_paper_size);
-       setPreHandler(dialog_->input_name);
-       setPreHandler(dialog_->check_adapt_output);
+       setPrehandler(dialog_->input_command);
+       setPrehandler(dialog_->input_page_range);
+       setPrehandler(dialog_->input_copies);
+       setPrehandler(dialog_->input_reverse);
+       setPrehandler(dialog_->input_to_printer);
+       setPrehandler(dialog_->input_file_extension);
+       setPrehandler(dialog_->input_spool_command);
+       setPrehandler(dialog_->input_paper_type);
+       setPrehandler(dialog_->input_even_pages);
+       setPrehandler(dialog_->input_odd_pages);
+       setPrehandler(dialog_->input_collated);
+       setPrehandler(dialog_->input_landscape);
+       setPrehandler(dialog_->input_to_file);
+       setPrehandler(dialog_->input_extra_options);
+       setPrehandler(dialog_->input_spool_prefix);
+       setPrehandler(dialog_->input_paper_size);
+       setPrehandler(dialog_->input_name);
+       setPrehandler(dialog_->check_adapt_output);
 }
 
 
@@ -2446,12 +2429,12 @@ void FormPreferences::Printer::update()
 }
 
 
-FormPreferences::ScreenFonts::ScreenFonts( FormPreferences &  p )
+FormPreferences::ScreenFonts::ScreenFonts(FormPreferences &  p)
        : parent_(p)
 {}
 
 
-FD_form_screen_fonts const * FormPreferences::ScreenFonts::dialog()
+FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
 {
        return dialog_.get();
 }
@@ -2504,7 +2487,7 @@ void FormPreferences::ScreenFonts::apply() const
                changed = true;
                lyxrc.dpi = ivalue;
        }
-       
+
        double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
        if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
                changed = true;
@@ -2568,14 +2551,14 @@ void FormPreferences::ScreenFonts::apply() const
        if (changed) {
                // Now update the buffers
                // Can anything below here affect the redraw process?
-               parent_.lv_->getLyXFunc()->dispatch(LFUN_SCREEN_FONT_UPDATE);
+               parent_.lv_.dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
        }
 }
 
 
 void FormPreferences::ScreenFonts::build()
 {
-       dialog_.reset(parent_.build_screen_fonts());
+       dialog_.reset(build_preferences_screen_fonts(&parent_));
 
        fl_set_counter_step(dialog_->counter_zoom, 1, 10);
        fl_set_counter_step(dialog_->counter_dpi,  1, 10);
@@ -2609,46 +2592,44 @@ void FormPreferences::ScreenFonts::build()
        fl_set_input_filter(dialog_->input_huger,    fl_unsigned_float_filter);
 
        // set up the feedback mechanism
-       setPreHandler(dialog_->input_roman);
-       setPreHandler(dialog_->input_sans);
-       setPreHandler(dialog_->input_typewriter);
-       setPreHandler(dialog_->counter_zoom);
-       setPreHandler(dialog_->counter_dpi);
-       setPreHandler(dialog_->check_scalable);
-       setPreHandler(dialog_->input_screen_encoding);
-       setPreHandler(dialog_->input_tiny);
-       setPreHandler(dialog_->input_script);
-       setPreHandler(dialog_->input_footnote);
-       setPreHandler(dialog_->input_small);
-       setPreHandler(dialog_->input_large);
-       setPreHandler(dialog_->input_larger);
-       setPreHandler(dialog_->input_largest);
-       setPreHandler(dialog_->input_normal);
-       setPreHandler(dialog_->input_huge);
-       setPreHandler(dialog_->input_huger);
+       setPrehandler(dialog_->input_roman);
+       setPrehandler(dialog_->input_sans);
+       setPrehandler(dialog_->input_typewriter);
+       setPrehandler(dialog_->counter_zoom);
+       setPrehandler(dialog_->counter_dpi);
+       setPrehandler(dialog_->check_scalable);
+       setPrehandler(dialog_->input_screen_encoding);
+       setPrehandler(dialog_->input_tiny);
+       setPrehandler(dialog_->input_script);
+       setPrehandler(dialog_->input_footnote);
+       setPrehandler(dialog_->input_small);
+       setPrehandler(dialog_->input_large);
+       setPrehandler(dialog_->input_larger);
+       setPrehandler(dialog_->input_largest);
+       setPrehandler(dialog_->input_normal);
+       setPrehandler(dialog_->input_huge);
+       setPrehandler(dialog_->input_huger);
 }
 
-       
+
 string const
 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
 {
-       string str;
-
        if (ob == dialog_->input_roman)
-               str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
-       else if (ob == dialog_->input_sans)
-               str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SANS);
-       else if (ob == dialog_->input_typewriter)
-               str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
-       else if (ob == dialog_->check_scalable)
-               str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
-       else if (ob == dialog_->input_screen_encoding)
-               str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
-       else if (ob == dialog_->counter_zoom)
-               str = lyxrc.getDescription(LyXRC::RC_SCREEN_ZOOM);
-       else if (ob == dialog_->counter_dpi) 
-               str = lyxrc.getDescription(LyXRC::RC_SCREEN_DPI);
-       else if (ob == dialog_->input_tiny
+               return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
+       if (ob == dialog_->input_sans)
+               return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SANS);
+       if (ob == dialog_->input_typewriter)
+               return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
+       if (ob == dialog_->check_scalable)
+               return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
+       if (ob == dialog_->input_screen_encoding)
+               return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
+       if (ob == dialog_->counter_zoom)
+               return lyxrc.getDescription(LyXRC::RC_SCREEN_ZOOM);
+       if (ob == dialog_->counter_dpi)
+               return lyxrc.getDescription(LyXRC::RC_SCREEN_DPI);
+       if (ob == dialog_->input_tiny
                 || ob == dialog_->input_script
                 || ob == dialog_->input_footnote
                 || ob == dialog_->input_small
@@ -2659,9 +2640,8 @@ FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
                 || ob == dialog_->input_normal
                 || ob == dialog_->input_huge
                 || ob == dialog_->input_huger)
-               str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
-
-       return str;
+               return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
+       return string();
 }
 
 
@@ -2683,10 +2663,10 @@ bool FormPreferences::ScreenFonts::input()
            || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
            || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
                activate = false;
-               str = N_("Fonts must be positive!");
+               str = _("Fonts must be positive!");
 
-       // Fontsizes -- tiny < script < footnote etc.
        } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
+                  // Fontsizes -- tiny < script < footnote etc.
                   strToDbl(fl_get_input(dialog_->input_script)) ||
                   strToDbl(fl_get_input(dialog_->input_script)) >
                   strToDbl(fl_get_input(dialog_->input_footnote)) ||
@@ -2706,12 +2686,12 @@ bool FormPreferences::ScreenFonts::input()
                   strToDbl(fl_get_input(dialog_->input_huger))) {
                activate = false;
 
-               str = N_("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
+               str = _("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
        }
 
        if (!activate)
-               parent_.printWarning(str);
-       
+               parent_.postWarning(str);
+
        return activate;
 }
 
@@ -2754,12 +2734,12 @@ void FormPreferences::ScreenFonts::update()
 
 
 
-FormPreferences::SpellOptions::SpellOptions( FormPreferences &  p )
+FormPreferences::SpellOptions::SpellOptions(FormPreferences &  p)
        : parent_(p)
 {}
 
 
-FD_form_spelloptions const * FormPreferences::SpellOptions::dialog()
+FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
 {
        return dialog_.get();
 }
@@ -2769,8 +2749,8 @@ void FormPreferences::SpellOptions::apply()
 {
 
        string choice = fl_get_choice_text(dialog_->choice_spell_command);
-       choice = strip(frontStrip(choice));
-       
+       choice = trim(choice);
+
        lyxrc.isp_command = choice;
 
 #if 0
@@ -2801,7 +2781,7 @@ void FormPreferences::SpellOptions::apply()
                choice = fl_get_input(dialog_->input_escape_chars);
                if (button && choice.empty()) button = 0;
                if (!button) choice.erase();
-       
+
                lyxrc.isp_use_esc_chars = static_cast<bool>(button);
                lyxrc.isp_esc_chars = choice;
 
@@ -2830,57 +2810,50 @@ void FormPreferences::SpellOptions::apply()
 
 void FormPreferences::SpellOptions::build()
 {
-       dialog_.reset(parent_.build_spelloptions());
+       dialog_.reset(build_preferences_spelloptions(&parent_));
 
        fl_addto_choice(dialog_->choice_spell_command,
-#if 0
-                       _(" none | ispell | aspell "));
-#else
                        _(" ispell | aspell "));
-#endif
        fl_set_input_return(dialog_->input_alt_lang,      FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_escape_chars,  FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
 
        // set up the feedback mechanism
-       setPreHandler(dialog_->choice_spell_command);
-       setPreHandler(dialog_->check_alt_lang);
-       setPreHandler(dialog_->input_alt_lang);
-       setPreHandler(dialog_->check_escape_chars);
-       setPreHandler(dialog_->input_escape_chars);
-       setPreHandler(dialog_->check_personal_dict);
-       setPreHandler(dialog_->input_personal_dict);
-       setPreHandler(dialog_->button_personal_dict);
-       setPreHandler(dialog_->check_compound_words);
-       setPreHandler(dialog_->check_input_enc);
+       setPrehandler(dialog_->choice_spell_command);
+       setPrehandler(dialog_->check_alt_lang);
+       setPrehandler(dialog_->input_alt_lang);
+       setPrehandler(dialog_->check_escape_chars);
+       setPrehandler(dialog_->input_escape_chars);
+       setPrehandler(dialog_->check_personal_dict);
+       setPrehandler(dialog_->input_personal_dict);
+       setPrehandler(dialog_->button_personal_dict);
+       setPrehandler(dialog_->check_compound_words);
+       setPrehandler(dialog_->check_input_enc);
 }
 
 
 string const
 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
 {
-       string str;
-
        if (ob == dialog_->choice_spell_command)
-               str = lyxrc.getDescription(LyXRC::RC_SPELL_COMMAND);
-       else if (ob == dialog_->check_alt_lang)
-               str = lyxrc.getDescription(LyXRC::RC_USE_ALT_LANG);
-       else if (ob == dialog_->input_alt_lang)
-               str = lyxrc.getDescription(LyXRC::RC_ALT_LANG);
-       else if (ob == dialog_->check_escape_chars)
-               str = lyxrc.getDescription(LyXRC::RC_USE_ESC_CHARS);
-       else if (ob == dialog_->input_escape_chars)
-               str = lyxrc.getDescription(LyXRC::RC_ESC_CHARS);
-       else if (ob == dialog_->check_personal_dict)
-               str = lyxrc.getDescription(LyXRC::RC_USE_PERS_DICT);
-       else if (ob == dialog_->input_personal_dict)
-               str = lyxrc.getDescription(LyXRC::RC_PERS_DICT);
-       else if (ob == dialog_->check_compound_words)
-               str = lyxrc.getDescription(LyXRC::RC_ACCEPT_COMPOUND);
-       else if (ob == dialog_->check_input_enc)
-               str = lyxrc.getDescription(LyXRC::RC_USE_INP_ENC);
-
-       return str;
+               return lyxrc.getDescription(LyXRC::RC_SPELL_COMMAND);
+       if (ob == dialog_->check_alt_lang)
+               return lyxrc.getDescription(LyXRC::RC_USE_ALT_LANG);
+       if (ob == dialog_->input_alt_lang)
+               return lyxrc.getDescription(LyXRC::RC_ALT_LANG);
+       if (ob == dialog_->check_escape_chars)
+               return lyxrc.getDescription(LyXRC::RC_USE_ESC_CHARS);
+       if (ob == dialog_->input_escape_chars)
+               return lyxrc.getDescription(LyXRC::RC_ESC_CHARS);
+       if (ob == dialog_->check_personal_dict)
+               return lyxrc.getDescription(LyXRC::RC_USE_PERS_DICT);
+       if (ob == dialog_->input_personal_dict)
+               return lyxrc.getDescription(LyXRC::RC_PERS_DICT);
+       if (ob == dialog_->check_compound_words)
+               return lyxrc.getDescription(LyXRC::RC_ACCEPT_COMPOUND);
+       if (ob == dialog_->check_input_enc)
+               return lyxrc.getDescription(LyXRC::RC_USE_INP_ENC);
+       return string();
 }
 
 
@@ -2930,11 +2903,9 @@ bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
 
        if (ob == dialog_->button_personal_dict) {
                parent_.browse(dialog_->input_personal_dict,
-                              N_("Personal dictionary"), "*.ispell",
-                              make_pair(string(), string()),
-                              make_pair(string(), string()));
+                              _("Personal dictionary"), "*.ispell");
        }
-       
+
        return true; // All input is valid!
 }
 
@@ -2956,23 +2927,26 @@ void FormPreferences::SpellOptions::update()
                choice = 2;
 #endif
        fl_set_choice(dialog_->choice_spell_command, choice);
-       
+
        string str;
-       if (lyxrc.isp_use_alt_lang) str = lyxrc.isp_alt_lang;
+       if (lyxrc.isp_use_alt_lang)
+               str = lyxrc.isp_alt_lang;
 
        fl_set_button(dialog_->check_alt_lang,
                      lyxrc.isp_use_alt_lang);
        fl_set_input(dialog_->input_alt_lang, str.c_str());
-       
+
        str.erase();
-       if (lyxrc.isp_use_esc_chars) str = lyxrc.isp_esc_chars;
+       if (lyxrc.isp_use_esc_chars)
+               str = lyxrc.isp_esc_chars;
 
        fl_set_button(dialog_->check_escape_chars,
                      lyxrc.isp_use_esc_chars);
        fl_set_input(dialog_->input_escape_chars, str.c_str());
 
        str.erase();
-       if (lyxrc.isp_use_pers_dict) str = lyxrc.isp_pers_dict;
+       if (lyxrc.isp_use_pers_dict)
+               str = lyxrc.isp_pers_dict;
 
        fl_set_button(dialog_->check_personal_dict,
                      lyxrc.isp_use_pers_dict);
@@ -2989,21 +2963,9 @@ void FormPreferences::SpellOptions::update()
 }
 
 
-void FormPreferences::printWarning(string const & warning)
-{
-       warningPosted = true;
-
-       string str = _("WARNING!") + string(" ") + warning;
-       str = formatted(str, dialog_->text_warning->w-10, FL_SMALL_SIZE);
-
-       fl_set_object_label(dialog_->text_warning, str.c_str());
-       fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
-}
-
-
 void FormPreferences::browse(FL_OBJECT * inpt,
                             string const & title,
-                            string const & pattern, 
+                            string const & pattern,
                             pair<string,string> const & dir1,
                             pair<string,string> const & dir2)
 {
@@ -3012,7 +2974,7 @@ void FormPreferences::browse(FL_OBJECT * inpt,
 
        // Show the file browser dialog
        string const new_filename =
-               browseFile(lv_, filename, title, pattern, dir1, dir2);
+               browseFile(&lv_, filename, title, pattern, dir1, dir2);
 
        // Save the filename to the dialog
        if (new_filename != filename && !new_filename.empty()) {
@@ -3020,59 +2982,3 @@ void FormPreferences::browse(FL_OBJECT * inpt,
                input(inpt, 0);
        }
 }
-
-
-// C function wrapper, required by xforms.
-extern "C" int C_FormPreferencesFeedbackCB(FL_OBJECT * ob, int event,
-                                          FL_Coord mx, FL_Coord my,
-                                          int key, void * xev)
-{
-       return FormPreferences::FeedbackCB(ob, event, mx, my, key, xev);
-}
-
-int FormPreferences::FeedbackCB(FL_OBJECT * ob, int event,
-                               FL_Coord, FL_Coord, int, void *)
-{
-       // Note that the return value is important in the pre-emptive handler.
-       // Don't return anything other than 0.
-
-       lyx::Assert(ob);
-       // Don't Assert this one, as it can happen quite reasonably when things
-       // are being deleted in the d-tor.
-       //Assert(ob->form);
-       if (!ob->form) return 0;
-
-       FormPreferences * pre =
-               static_cast<FormPreferences*>(ob->form->u_vdata);
-       pre->Feedback(ob, event);
-       return 0;
-}
-
-
-// preemptive handler for feedback messages
-void FormPreferences::Feedback(FL_OBJECT * ob, int event)
-{
-       lyx::Assert(ob);
-
-       switch (event) {
-       case FL_ENTER:
-               warningPosted = false;
-               feedback(ob);
-               break;
-
-       case FL_LEAVE:
-               if (!warningPosted)
-                       fl_set_object_label(dialog_->text_warning, "");
-               break;
-
-       default:
-               break;
-       }
-}
-
-
-void FormPreferences::setPreHandler(FL_OBJECT * ob)
-{
-       lyx::Assert(ob);
-       fl_set_object_prehandler(ob, C_FormPreferencesFeedbackCB);
-}