]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormPreferences.C
Introduce LFUN_PRINT.
[lyx.git] / src / frontends / xforms / FormPreferences.C
index 852ce0e4de6b2b51a956ca9e02dbf1e326aa06e1..db10c7371eb01f89e805eadc63e3e96cfbfd279b 100644 (file)
@@ -5,68 +5,56 @@
  *
  * \author Angus Leeming
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
-#include "ControlPrefs.h"
 #include "FormPreferences.h"
 #include "forms/form_preferences.h"
-#include "xformsBC.h"
-#include "ButtonController.h"
 
 #include "FormColorpicker.h"
-#include "Color.h"
-#include "input_validators.h"
 #include "forms_gettext.h"
+#include "input_validators.h"
+#include "xformsBC.h"
 #include "xforms_helpers.h"
-#include "helper_funcs.h" // getSecond
+
+#include "controllers/ControlPrefs.h"
+#include "controllers/frnt_lang.h"
+#include "controllers/helper_funcs.h" // getSecond
 
 #include "buffer.h"
 #include "converter.h"
 #include "format.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 "author.h"
+#include "lyxfont.h"
 
 #include "support/lstrings.h"
-#include "support/lyxfunctional.h"
-#include "support/lyxmanip.h"
 #include "support/tostr.h"
+#include "support/path_defines.h"
 #include "support/filetools.h"
-#include "support/LAssert.h"
-
-#include "graphics/GraphicsCache.h"
-#include "graphics/GraphicsTypes.h"
-
-#include <boost/bind.hpp>
 
 #include "lyx_forms.h"
 #include "combox.h"
 
-#include <utility>
 #include <iomanip>
-#include <X11/Xlib.h>
+
+using lyx::support::AddName;
+using lyx::support::ChangeExtension;
+using lyx::support::rtrim;
+using lyx::support::strToDbl;
+using lyx::support::trim;
+using lyx::support::user_lyxdir;
 
 using std::endl;
-using std::pair;
 using std::make_pair;
 using std::max;
 using std::min;
-using std::vector;
-using std::setw;
-using std::setfill;
 
-extern string user_lyxdir;
+using std::pair;
+using std::vector;
+using std::string;
 
-using namespace lyx::support;
 
 namespace {
 
@@ -92,17 +80,6 @@ pair<string,string> parseFontName(string const & name)
 }
 
 
-string const X11hexname(RGBColor const & col)
-{
-       ostringstream ostr;
-
-       ostr << '#' << std::setbase(16) << setfill('0')
-            << setw(2) << col.r
-            << setw(2) << col.g
-            << setw(2) << col.b;
-
-       return STRCONV(ostr.str());
-}
 
 #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
 bool const scalableTabfolders = false;
@@ -330,7 +307,7 @@ void FormPreferences::apply()
        // The "Save" button has been pressed.
        if (controller().isClosing() && colors_.modifiedXformsPrefs) {
                string const filename =
-                       AddName(user_lyxdir, "preferences.xform");
+                       AddName(user_lyxdir(), "preferences.xform");
                colors_.modifiedXformsPrefs = !XformsColor::write(filename);
        }
 }
@@ -338,7 +315,7 @@ void FormPreferences::apply()
 
 string const FormPreferences::getFeedback(FL_OBJECT * ob)
 {
-       Assert(ob);
+       BOOST_ASSERT(ob);
 
        if (ob->form->fdui == colors_.dialog())
                return colors_.feedback(ob);
@@ -371,7 +348,7 @@ string const FormPreferences::getFeedback(FL_OBJECT * ob)
 
 ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long)
 {
-       Assert(ob);
+       BOOST_ASSERT(ob);
 
        bool valid = true;
 
@@ -484,7 +461,7 @@ void FormPreferences::Colors::apply()
        // Now do the same for the LyX LColors...
        for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
             cit != lyxColorDB.end(); ++cit) {
-               LColor::color lc = lcolor.getFromGUIName(cit->getname());
+               LColor::color lc = lcolor.getFromLyXName(cit->lyxname);
                if (lc == LColor::inherit) continue;
 
                // Create a valid X11 name of the form "#rrggbb"
@@ -596,25 +573,29 @@ void FormPreferences::Colors::LoadBrowserLyX()
        xformsColorDB.clear();
        XformsColor xcol;
 
-       xcol.name = _("GUI background");
+       xcol.lyxname = "GUI background";
+       xcol.guiname = _("GUI background");
        xcol.colorID = FL_COL1;
        fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
 
        xformsColorDB.push_back(xcol);
 
-       xcol.name = _("GUI text");
+       xcol.lyxname = "GUI text";
+       xcol.guiname = _("GUI text");
        xcol.colorID = FL_BLACK;
        fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
 
        xformsColorDB.push_back(xcol);
 
-       xcol.name = _("GUI selection");
+       xcol.lyxname = "GUI selection";
+       xcol.guiname = _("GUI selection");
        xcol.colorID = FL_YELLOW;
        fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
 
        xformsColorDB.push_back(xcol);
 
-       xcol.name = _("GUI pointer");
+       xcol.lyxname = "GUI pointer";
+       xcol.guiname = _("GUI pointer");
        xcol.colorID = GUI_COLOR_CURSOR;
        fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
 
@@ -663,7 +644,7 @@ void FormPreferences::Colors::LoadBrowserLyX()
                }
 
                // Finally, push the color onto the database
-               NamedColor ncol(lcolor.getGUIName(lc), col);
+               NamedColor ncol(lcolor.getLyXName(lc), lcolor.getGUIName(lc), col);
                lyxColorDB.push_back(ncol);
        }
 
@@ -673,11 +654,11 @@ void FormPreferences::Colors::LoadBrowserLyX()
        fl_clear_browser(colbr);
        for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
             cit != xformsColorDB.end(); ++cit) {
-               fl_addto_browser(colbr, cit->getname().c_str());
+               fl_addto_browser(colbr, cit->guiname.c_str());
        }
        for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
             cit != lyxColorDB.end(); ++cit) {
-               fl_addto_browser(colbr, cit->getname().c_str());
+               fl_addto_browser(colbr, cit->guiname.c_str());
        }
 
        // just to be safe...
@@ -1844,17 +1825,10 @@ void FormPreferences::Paths::apply(LyXRC & rc)
 {
        rc.document_path = fl_get_input(dialog_->input_default_path);
        rc.template_path = fl_get_input(dialog_->input_template_path);
+       rc.tempdir_path  = fl_get_input(dialog_->input_temp_dir);
 
-       int button = fl_get_button(dialog_->check_use_temp_dir);
-       string str  = fl_get_input(dialog_->input_temp_dir);
-       if (!button)
-               str.erase();
-
-       rc.use_tempdir = button;
-       rc.tempdir_path = str;
-
-       button = fl_get_button(dialog_->check_last_files);
-       str = fl_get_input(dialog_->input_lastfiles);
+       int button = fl_get_button(dialog_->check_last_files);
+       string str = fl_get_input(dialog_->input_lastfiles);
        if (!button) str.erase();
 
        rc.check_lastfiles = button;
@@ -1899,7 +1873,6 @@ void FormPreferences::Paths::build()
        setPrehandler(dialog_->input_backup_path);
        setPrehandler(dialog_->input_serverpipe);
        setPrehandler(dialog_->input_temp_dir);
-       setPrehandler(dialog_->check_use_temp_dir);
 }
 
 
@@ -1910,8 +1883,6 @@ FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
                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)
@@ -1937,11 +1908,6 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
        // !ob if function is called from Paths::update() to de/activate
        // objects,
        // otherwise the function is called by an xforms CB via input().
-       if (!ob || ob == dialog_->check_use_temp_dir) {
-               bool const enable = fl_get_button(dialog_->check_use_temp_dir);
-               setEnabled(dialog_->input_temp_dir, enable);
-       }
-
        if (!ob || ob == dialog_->check_last_files) {
                bool const enable = fl_get_button(dialog_->check_last_files);
                setEnabled(dialog_->input_lastfiles, enable);
@@ -2065,13 +2031,7 @@ void FormPreferences::Paths::update(LyXRC const & rc)
                      rc.make_backup);
        fl_set_input(dialog_->input_backup_path, str.c_str());
 
-       str.erase();
-       if (rc.use_tempdir)
-               str = rc.tempdir_path;
-
-       fl_set_button(dialog_->check_use_temp_dir,
-                     rc.use_tempdir);
-       fl_set_input(dialog_->input_temp_dir, str.c_str());
+       fl_set_input(dialog_->input_temp_dir, rc.tempdir_path.c_str());
 
        str.erase();
        if (rc.check_lastfiles)