]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormPreferences.C
some mods I had in my local tree, mostly small stuff, perhaps minus the the Makefile...
[lyx.git] / src / frontends / xforms / FormPreferences.C
index 0f2a087a5612a4966728cef78594fe75b62b62de..d43c4ef22d9314a1dccc8ca95c50d305ae4f02e5 100644 (file)
@@ -37,6 +37,7 @@
 #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 "input_validators.h"
@@ -68,7 +69,7 @@ Converters local_converters;
 
 
 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
-       : FormBaseBI(lv, d, _("Preferences")),
+       : FormBaseBI(lv, d, _("Preferences"), false),
          warningPosted(false),
          colors_(*this), converters_(*this), inputs_misc_(*this),
          formats_(*this), interface_(*this), language_(*this), 
@@ -83,24 +84,6 @@ FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
 }
 
 
-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();
-}
-
-
 void FormPreferences::redraw()
 {
        if (!(form() && form()->visible))
@@ -392,7 +375,7 @@ void FormPreferences::update()
 
 
 FormPreferences::Colors::Colors(FormPreferences & p)
-       : parent_(p)
+       : modifiedXformsPrefs(false), parent_(p)
 {}
 
 
@@ -956,8 +939,8 @@ FD_form_converters const * FormPreferences::Converters::dialog()
 void FormPreferences::Converters::apply() const
 {
        converters = local_converters;
-       converters.Update(formats);
-       converters.BuildGraph();
+       converters.update(formats);
+       converters.buildGraph();
 }
 
 
@@ -1022,7 +1005,7 @@ bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
                return Add();
 
        } else if (ob == dialog_->button_delete) {
-               return Delete();
+               return erase();
        }
 
        return true;
@@ -1032,14 +1015,14 @@ bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
 void FormPreferences::Converters::update()
 {
        local_converters = converters;
-       local_converters.Update(local_formats);
+       local_converters.update(local_formats);
        UpdateBrowser();
 }
 
 
 void FormPreferences::Converters::UpdateBrowser()
 {
-       local_converters.Sort();
+       local_converters.sort();
 
        fl_freeze_form(dialog_->form);
        fl_clear_browser(dialog_->browser_all);
@@ -1061,10 +1044,10 @@ bool FormPreferences::Converters::Add()
        string const command = fl_get_input(dialog_->input_converter);
        string const flags = fl_get_input(dialog_->input_flags);
 
-       Converter const * old = local_converters.GetConverter(from, to);
-       local_converters.Add(from, to, command, flags);
+       Converter const * old = local_converters.getConverter(from, to);
+       local_converters.add(from, to, command, flags);
        if (!old) {
-               local_converters.UpdateLast(local_formats);
+               local_converters.updateLast(local_formats);
                UpdateBrowser();
        }
        setEnabled(dialog_->button_add, false);
@@ -1080,14 +1063,14 @@ bool FormPreferences::Converters::Browser()
 
        fl_freeze_form(dialog_->form);
 
-       Converter const & c = local_converters.Get(i-1);
-       int j = local_formats.GetNumber(c.from);
+       Converter const & c = local_converters.get(i - 1);
+       int j = local_formats.getNumber(c.from);
        if (j >= 0)
-               fl_set_choice(dialog_->choice_from, j+1);
+               fl_set_choice(dialog_->choice_from, j + 1);
 
-       j = local_formats.GetNumber(c.to);
+       j = local_formats.getNumber(c.to);
        if (j >= 0)
-               fl_set_choice(dialog_->choice_to, j+1);
+               fl_set_choice(dialog_->choice_to, j + 1);
 
        fl_set_input(dialog_->input_converter, c.command.c_str());
        fl_set_input(dialog_->input_flags, c.flags.c_str());
@@ -1103,12 +1086,12 @@ bool FormPreferences::Converters::Browser()
 }
 
 
-bool FormPreferences::Converters::Delete()
+bool FormPreferences::Converters::erase()
 {
        string const from = GetFrom();
        string const to = GetTo();
 
-       local_converters.Delete(from, to);
+       local_converters.erase(from, to);
        UpdateBrowser();
        return true;
 }
@@ -1118,7 +1101,7 @@ bool FormPreferences::Converters::Input()
 {
        string const from = GetFrom();
        string const to = GetTo();
-       int const sel = local_converters.GetNumber(from, to);
+       int const sel = local_converters.getNumber(from, to);
        
        fl_freeze_form(dialog_->form);
 
@@ -1156,7 +1139,7 @@ string const FormPreferences::Converters::GetFrom() const
                fl_get_choice(dialog_->choice_from);
 
        if (i > 0 && i <= local_formats.size())
-               return local_formats.Get(i-1).name();
+               return local_formats.get(i - 1).name();
        else {
                lyxerr << "FormPreferences::Converters::GetFrom: No choice!"
                       << endl;
@@ -1171,7 +1154,7 @@ string const FormPreferences::Converters::GetTo() const
                fl_get_choice(dialog_->choice_to);
 
        if (i > 0 && i <= local_formats.size())
-               return local_formats.Get(i-1).name();
+               return local_formats.get(i - 1).name();
        else {
                lyxerr << "FormPreferences::Converters::GetTo: No choice!"
                       << endl;
@@ -1288,7 +1271,7 @@ bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
                return Add();
 
        } else if (ob == dialog_->button_delete) {
-               return Delete();
+               return erase();
        }
 
        return false;
@@ -1304,7 +1287,7 @@ void FormPreferences::Formats::update()
 
 void FormPreferences::Formats::UpdateBrowser()
 {
-       local_formats.Sort();
+       local_formats.sort();
 
        fl_freeze_form(dialog_->form);
        fl_deselect_browser(dialog_->browser_all);
@@ -1319,7 +1302,7 @@ void FormPreferences::Formats::UpdateBrowser()
 
        // Mustn't forget to update the Formats available to the converters_
        parent_.converters_.UpdateChoices();
-       local_converters.Update(local_formats);
+       local_converters.update(local_formats);
 }
 
 
@@ -1331,10 +1314,10 @@ bool FormPreferences::Formats::Add()
        string const shortcut =  fl_get_input(dialog_->input_shrtcut);
        string const viewer =  fl_get_input(dialog_->input_viewer);
 
-       Format const * old = local_formats.GetFormat(name);
+       Format const * old = local_formats.getFormat(name);
        string const old_prettyname = old ? old->prettyname() : string();
-       local_formats.Add(name, extension, prettyname, shortcut);
-       local_formats.SetViewer(name, viewer);
+       local_formats.add(name, extension, prettyname, shortcut);
+       local_formats.setViewer(name, viewer);
        if (!old || prettyname != old_prettyname) {
                UpdateBrowser();
                if (old)
@@ -1353,7 +1336,7 @@ bool FormPreferences::Formats::Browser()
 
        fl_freeze_form(dialog_->form);
 
-       Format const & f = local_formats.Get(i-1);
+       Format const & f = local_formats.get(i - 1);
 
        fl_set_input(dialog_->input_format, f.name().c_str());
        fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
@@ -1372,17 +1355,17 @@ bool FormPreferences::Formats::Browser()
 }
 
 
-bool FormPreferences::Formats::Delete()
+bool FormPreferences::Formats::erase()
 {
        string const name = fl_get_input(dialog_->input_format);
 
-       if (local_converters.FormatIsUsed(name)) {
+       if (local_converters.formatIsUsed(name)) {
                parent_.printWarning(_("Cannot remove a Format used by a Converter. Remove the converter first."));
                setEnabled(dialog_->button_delete, false);
                return false;
        }
 
-       local_formats.Delete(name);
+       local_formats.erase(name);
        UpdateBrowser();
        return true;
 }
@@ -1391,7 +1374,7 @@ bool FormPreferences::Formats::Delete()
 bool FormPreferences::Formats::Input()
 {
        string const name = fl_get_input(dialog_->input_format);
-       int const sel = local_formats.GetNumber(name);
+       int const sel = local_formats.getNumber(name);
        fl_freeze_form(dialog_->form);
 
        if (sel < 0) {
@@ -1780,7 +1763,7 @@ void FormPreferences::Language::update()
        fl_set_button(dialog_->check_use_kbmap,
                      lyxrc.use_kbmap);
 
-       combo_default_lang->select_text(lyxrc.default_language);
+       combo_default_lang->select(lyxrc.default_language);
 
        if (lyxrc.use_kbmap) {
                fl_set_input(dialog_->input_kbmap1,
@@ -1845,6 +1828,8 @@ void FormPreferences::LnFmisc::apply() const
        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.autosave = static_cast<unsigned int>
                (fl_get_counter_value(dialog_->counter_autosave));
        lyxrc.wheel_jump = static_cast<unsigned int>
@@ -1870,6 +1855,7 @@ void FormPreferences::LnFmisc::build()
        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);
 }
 
@@ -1891,6 +1877,8 @@ FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
                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)
@@ -1910,6 +1898,8 @@ void FormPreferences::LnFmisc::update()
        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_counter_value(dialog_->counter_autosave, lyxrc.autosave);
        fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
 }
@@ -1938,6 +1928,7 @@ 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);
 }
 
 
@@ -1951,6 +1942,7 @@ void FormPreferences::OutputsMisc::build()
        fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_ascii_roff,   FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_checktex,     FL_RETURN_CHANGED);
+       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 "));
@@ -1961,6 +1953,7 @@ void FormPreferences::OutputsMisc::build()
        setPreHandler(dialog_->choice_default_papersize);
        setPreHandler(dialog_->input_ascii_roff);
        setPreHandler(dialog_->input_checktex);
+       setPreHandler(dialog_->input_paperoption);
 }
 
 
@@ -1979,6 +1972,8 @@ FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
                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;
 }
@@ -1996,6 +1991,8 @@ void FormPreferences::OutputsMisc::update()
                     lyxrc.ascii_roff_command.c_str());
        fl_set_input(dialog_->input_checktex,
                     lyxrc.chktex_command.c_str());
+       fl_set_input(dialog_->input_paperoption,
+                     lyxrc.view_dvi_paper_option.c_str());
 }
 
 
@@ -2758,6 +2755,7 @@ void FormPreferences::SpellOptions::apply()
        
        lyxrc.isp_command = choice;
 
+#if 0
        // If spell checker == "none", all other input set to off.
        if (fl_get_choice(dialog_->choice_spell_command) == 1) {
                lyxrc.isp_use_alt_lang = false;
@@ -2772,6 +2770,7 @@ void FormPreferences::SpellOptions::apply()
                lyxrc.isp_accept_compound = false;
                lyxrc.isp_use_input_encoding = false;
        } else {
+#else
                int button = fl_get_button(dialog_->check_alt_lang);
                choice = fl_get_input(dialog_->input_alt_lang);
                if (button && choice.empty()) button = 0;
@@ -2801,7 +2800,10 @@ void FormPreferences::SpellOptions::apply()
 
                button = fl_get_button(dialog_->check_input_enc);
                lyxrc.isp_use_input_encoding = static_cast<bool>(button);
+#endif
+#if 0
        }
+#endif
 
        // Reset view
        update();
@@ -2813,7 +2815,11 @@ void FormPreferences::SpellOptions::build()
        dialog_.reset(parent_.build_spelloptions());
 
        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);
@@ -2866,6 +2872,7 @@ bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
        // objects,
        // otherwise the function is called by an xforms CB via input().
 
+#if 0
        // If spell checker == "none", disable all input.
        if (!ob || ob == dialog_->choice_spell_command) {
                if (fl_get_choice(dialog_->choice_spell_command) == 1) {
@@ -2886,6 +2893,7 @@ bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
                        fl_activate_object(dialog_->check_input_enc);
                }
        }
+#endif
 
        if (!ob || ob == dialog_->check_alt_lang) {
                bool const enable = fl_get_button(dialog_->check_alt_lang);
@@ -2916,12 +2924,19 @@ bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
 void FormPreferences::SpellOptions::update()
 {
        int choice = 1;
+#if 0
        if (lyxrc.isp_command == "none")
                choice = 1;
        else if (lyxrc.isp_command == "ispell")
                choice = 2;
        else if (lyxrc.isp_command == "aspell")
                choice = 3;
+#else
+       if (lyxrc.isp_command == "ispell")
+               choice = 1;
+       else if (lyxrc.isp_command == "aspell")
+               choice = 2;
+#endif
        fl_set_choice(dialog_->choice_spell_command, choice);
        
        string str;
@@ -2990,13 +3005,20 @@ void FormPreferences::browse(FL_OBJECT * inpt,
 
 
 // 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);
+extern "C" {
+       
+       static
+       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 *)
 {