]> git.lyx.org Git - features.git/blob - src/frontends/xforms/FormPreferences.C
(J��rgen Spitzm��ller): implement a BrowseDir capablility in the File Dialog.
[features.git] / src / frontends / xforms / FormPreferences.C
1 /**
2  * \file FormPreferences.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "ControlPrefs.h"
18 #include "FormPreferences.h"
19 #include "forms/form_preferences.h"
20 #include "xformsBC.h"
21
22 #include "combox.h"
23 #include "Color.h"
24 #include "input_validators.h"
25 #include "forms_gettext.h"
26 #include "xforms_helpers.h"
27 #include "helper_funcs.h" // getSecond
28
29 #include "buffer.h"
30 #include "converter.h"
31 #include "debug.h"
32 #include "language.h"
33 #include "frnt_lang.h"
34 #include "lyxlex.h"
35 #include "lyxrc.h"
36 #include "LColor.h"
37 #include "Lsstream.h"
38 #include "funcrequest.h"
39
40 #include "support/lyxfunctional.h"
41 #include "support/lyxmanip.h"
42 #include "support/filetools.h"
43 #include "support/LAssert.h"
44
45 #include "graphics/GraphicsCache.h"
46 #include "graphics/GraphicsTypes.h"
47
48 #include <boost/bind.hpp>
49
50 #include FORMS_H_LOCATION
51 #include <utility>
52 #include <iomanip>
53 #include <X11/Xlib.h>
54
55 using std::endl;
56 using std::pair;
57 using std::make_pair;
58 using std::max;
59 using std::min;
60 using std::vector;
61 using std::setw;
62 using std::setfill;
63
64 extern string system_lyxdir;
65 extern string user_lyxdir;
66
67 namespace {
68
69 // These should probably go inside the class definition...
70 Formats    local_formats;
71 Converters local_converters;
72
73 string makeFontName(string const & family, string const & foundry)
74 {
75         if (foundry.empty())
76                 return family;
77         return family + ',' + foundry;
78 }
79
80
81 pair<string,string> parseFontName(string const & name)
82 {
83         string::size_type const idx = name.find(',');
84         if (idx == string::npos)
85                 return make_pair(name, string());
86         return make_pair(name.substr(0, idx),
87                          name.substr(idx+1));
88 }
89
90
91 } // namespace anon
92
93
94 typedef FormCB<ControlPrefs, FormDB<FD_preferences> > base_class;
95
96 FormPreferences::FormPreferences()
97         : base_class(_("Preferences"), false),
98           colors_(*this), converters_(*this), inputs_misc_(*this),
99           formats_(*this), interface_(*this), language_(*this),
100           lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
101           printer_(*this), screen_fonts_(*this), spelloptions_(*this)
102 {
103 }
104
105
106 void FormPreferences::redraw()
107 {
108         if (!(form() && form()->visible))
109                 return;
110         fl_redraw_form(form());
111
112         FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
113         if (!(form2 && form2->visible))
114                 return;
115         fl_redraw_form(form2);
116
117         FL_FORM * form3 = 0;
118         if (form2 == converters_tab_->form)
119                 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
120
121         else if (form2 == look_n_feel_tab_->form)
122                 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
123
124         else if (form2 == inputs_tab_->form)
125                 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
126
127         else if (form2 == outputs_tab_->form)
128                 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
129
130         else if (form2 == lang_opts_tab_->form)
131                 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
132
133         if (form3 && form3->visible)
134                 fl_redraw_form(form3);
135 }
136
137
138 void FormPreferences::hide()
139 {
140         // We need to hide the active tabfolder otherwise we get a
141         // BadDrawable error from X window and LyX crashes without saving.
142         FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
143         if (inner_form && inner_form->visible)
144                 fl_hide_form(inner_form);
145         FormBase::hide();
146 }
147
148
149 void FormPreferences::build()
150 {
151         dialog_.reset(build_preferences(this));
152
153         // Manage the restore, save, apply and cancel/close buttons
154         bc().setOK(dialog_->button_ok);
155         bc().setApply(dialog_->button_apply);
156         bc().setCancel(dialog_->button_close);
157         bc().setRestore(dialog_->button_restore);
158
159         // Allow the base class to control messages
160         setMessageWidget(dialog_->text_warning);
161
162         // build the tab folders
163         converters_tab_.reset(build_preferences_inner_tab(this));
164         look_n_feel_tab_.reset(build_preferences_inner_tab(this));
165         inputs_tab_.reset(build_preferences_inner_tab(this));
166         outputs_tab_.reset(build_preferences_inner_tab(this));
167         lang_opts_tab_.reset(build_preferences_inner_tab(this));
168
169         // build actual tabfolder contents
170         // these will become nested tabfolders
171         colors_.build();
172         converters_.build();
173         formats_.build();
174         inputs_misc_.build();
175         interface_.build();
176         language_.build();
177         lnf_misc_.build();
178         outputs_misc_.build();
179         paths_.build();
180         printer_.build();
181         screen_fonts_.build();
182         spelloptions_.build();
183
184         // Now add them to the tabfolder
185         fl_addto_tabfolder(dialog_->tabfolder_prefs,
186                            _("Look & Feel"),
187                            look_n_feel_tab_->form);
188         fl_addto_tabfolder(dialog_->tabfolder_prefs,
189                            _("Lang Opts"),
190                            lang_opts_tab_->form);
191         fl_addto_tabfolder(dialog_->tabfolder_prefs,
192                            _("Conversion"),
193                            converters_tab_->form);
194         fl_addto_tabfolder(dialog_->tabfolder_prefs,
195                            _("Inputs"),
196                            inputs_tab_->form);
197         fl_addto_tabfolder(dialog_->tabfolder_prefs,
198                            _("Outputs"),
199                            outputs_tab_->form);
200
201         // now build the nested tabfolders
202         // Starting with look and feel
203         fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
204                            _("Screen Fonts"),
205                            screen_fonts_.dialog()->form);
206         fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
207                            _("Interface"),
208                            interface_.dialog()->form);
209         fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
210                            _("Colors"),
211                            colors_.dialog()->form);
212         fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
213                            _("Misc"),
214                            lnf_misc_.dialog()->form);
215
216         // then build converters
217         fl_addto_tabfolder(converters_tab_->tabfolder_inner,
218                            _("Formats"),
219                            formats_.dialog()->form);
220         fl_addto_tabfolder(converters_tab_->tabfolder_inner,
221                            _("Converters"),
222                            converters_.dialog()->form);
223
224         // then build inputs
225         // Paths should probably go in a few inner_tab called Files
226         fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
227                            _("Paths"),
228                            paths_.dialog()->form);
229         fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
230                            _("Misc"),
231                            inputs_misc_.dialog()->form);
232
233         // then building outputs
234         fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
235                            _("Printer"),
236                            printer_.dialog()->form);
237         fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
238                            _("Misc"),
239                            outputs_misc_.dialog()->form);
240
241         // then building usage
242         fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
243                            _("Spell checker"),
244                            spelloptions_.dialog()->form);
245         fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
246                            _("Language"),
247                            language_.dialog()->form);
248
249         // work-around xforms bug re update of folder->x, folder->y coords.
250         setPrehandler(look_n_feel_tab_->tabfolder_inner);
251         setPrehandler(converters_tab_->tabfolder_inner);
252         setPrehandler(inputs_tab_->tabfolder_inner);
253         setPrehandler(outputs_tab_->tabfolder_inner);
254         setPrehandler(lang_opts_tab_->tabfolder_inner);
255 }
256
257
258 void FormPreferences::apply()
259 {
260         // set the new lyxrc entries
261         // many of these need to trigger other functions when the assignment
262         // is made.  For example, screen zoom and font types.  These could be
263         // handled either by signals/slots in lyxrc or just directly call the
264         // associated functions here.
265         // There are other problems with this scheme.  We really should check
266         // what we copy to make sure that it really is necessary to do things
267         // like update the screen fonts because that flushes the textcache
268         // and other stuff which may cost us a lot on slower/high-load
269         // machines.
270
271         LyXRC & rc(controller().rc());
272
273         colors_.apply();
274         formats_.apply();    // Must be before converters_.apply()
275         converters_.apply();
276         inputs_misc_.apply(rc);
277         interface_.apply(rc);
278         language_.apply(rc);
279         lnf_misc_.apply(rc);
280         outputs_misc_.apply(rc);
281         paths_.apply(rc);
282         printer_.apply(rc);
283         screen_fonts_.apply(rc);
284         spelloptions_.apply(rc);
285
286         // The "Save" button has been pressed.
287         if (controller().isClosing() && colors_.modifiedXformsPrefs) {
288                 string const filename =
289                         AddName(user_lyxdir, "preferences.xform");
290                 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
291         }
292 }
293
294
295 string const FormPreferences::getFeedback(FL_OBJECT * ob)
296 {
297         lyx::Assert(ob);
298
299         if (ob->form->fdui == colors_.dialog())
300                 return colors_.feedback(ob);
301         if (ob->form->fdui == converters_.dialog())
302                 return converters_.feedback(ob);
303         if (ob->form->fdui == formats_.dialog())
304                 return formats_.feedback(ob);
305         if (ob->form->fdui == inputs_misc_.dialog())
306                 return inputs_misc_.feedback(ob);
307         if (ob->form->fdui == interface_.dialog())
308                 return interface_.feedback(ob);
309         if (ob->form->fdui == language_.dialog())
310                 return language_.feedback(ob);
311         if (ob->form->fdui == lnf_misc_.dialog())
312                 return lnf_misc_.feedback(ob);
313         if (ob->form->fdui == outputs_misc_.dialog())
314                 return outputs_misc_.feedback(ob);
315         if (ob->form->fdui == paths_.dialog())
316                 return paths_.feedback(ob);
317         if (ob->form->fdui == printer_.dialog())
318                 return printer_.feedback(ob);
319         if (ob->form->fdui == screen_fonts_.dialog())
320                 return screen_fonts_.feedback(ob);
321         if (ob->form->fdui == spelloptions_.dialog())
322                 return spelloptions_.feedback(ob);
323
324         return string();
325 }
326
327
328 ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long)
329 {
330         lyx::Assert(ob);
331
332         bool valid = true;
333
334         // whatever checks you need to ensure the user hasn't entered
335         // some totally ridiculous value somewhere.  Change activate to suit.
336         // comments before each test describe what is _valid_
337
338         if (ob->form->fdui == colors_.dialog()) {
339                 colors_.input(ob);
340         } else if (ob->form->fdui == converters_.dialog()) {
341                 valid = converters_.input(ob);
342         } else if (ob->form->fdui == formats_.dialog()) {
343                 valid = formats_.input(ob);
344         } else if  (ob->form->fdui == interface_.dialog()) {
345                 valid = interface_.input(ob);
346         } else if  (ob->form->fdui == language_.dialog()) {
347                 valid = language_.input(ob);
348         } else if  (ob->form->fdui == paths_.dialog()) {
349                 valid = paths_.input(ob);
350         } else if  (ob->form->fdui == screen_fonts_.dialog()) {
351                 valid = screen_fonts_.input();
352         } else if  (ob->form->fdui == spelloptions_.dialog()) {
353                 valid = spelloptions_.input(ob);
354         }
355
356         return valid ? ButtonPolicy::SMI_VALID : ButtonPolicy::SMI_INVALID;
357 }
358
359
360 void FormPreferences::update()
361 {
362         if (!dialog_.get()) return;
363
364         LyXRC const & rc(controller().rc());
365
366         // read lyxrc entries
367         colors_.update();
368         formats_.update();   // Must be before converters_.update()
369         converters_.update();
370         inputs_misc_.update(rc);
371         interface_.update(rc);
372         language_.update(rc);
373         lnf_misc_.update(rc);
374         outputs_misc_.update(rc);
375         paths_.update(rc);
376         printer_.update(rc);
377         screen_fonts_.update(rc);
378         spelloptions_.update(rc);
379 }
380
381
382 FormPreferences::Colors::Colors(FormPreferences & p)
383         : modifiedXformsPrefs(false), parent_(p)
384 {}
385
386
387 FD_preferences_colors const * FormPreferences::Colors::dialog()
388 {
389         return dialog_.get();
390 }
391
392
393 void FormPreferences::Colors::apply()
394 {
395         bool modifiedText = false;
396         bool modifiedBackground = false;
397
398         for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
399              cit != xformsColorDB.end(); ++cit) {
400                 RGBColor col;
401                 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
402                 if (col != cit->color()) {
403                         modifiedXformsPrefs = true;
404                         if (cit->colorID == FL_BLACK)
405                                 modifiedText = true;
406                         if (cit->colorID == FL_COL1)
407                                 modifiedBackground = true;
408                 }
409         }
410
411         if (modifiedXformsPrefs) {
412                 for (vector<XformsColor>::const_iterator cit =
413                              xformsColorDB.begin();
414                      cit != xformsColorDB.end(); ++cit) {
415                         fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
416
417                         if (modifiedText && cit->colorID == FL_BLACK) {
418                                 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
419                         }
420
421                         if (modifiedBackground && cit->colorID == FL_COL1) {
422                                 AdjustVal(FL_MCOL,      FL_COL1, 0.1);
423                                 AdjustVal(FL_TOP_BCOL,  FL_COL1, 0.1);
424                                 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
425
426                                 AdjustVal(FL_RIGHT_BCOL,  FL_COL1, -0.5);
427                                 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
428                         }
429
430                         if (cit->colorID == GUI_COLOR_CURSOR) {
431                                 fl_mapcolor(GUI_COLOR_CURSOR,
432                                             cit->r, cit->g, cit->b);
433                                 setCursorColor(GUI_COLOR_CURSOR);
434                         }
435                 }
436                 parent_.controller().redrawGUI();
437         }
438
439         // Now do the same for the LyX LColors...
440         for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
441              cit != lyxColorDB.end(); ++cit) {
442                 LColor::color lc = lcolor.getFromGUIName(cit->getname());
443                 if (lc == LColor::inherit) continue;
444
445                 // Create a valid X11 name of the form "#rrggbb"
446                 string const hexname = X11hexname(cit->color());
447
448                 if (lcolor.getX11Name(lc) != hexname) {
449                         lyxerr[Debug::GUI]
450                                 << "FormPreferences::Colors::apply: "
451                                 << "resetting LColor " << lcolor.getGUIName(lc)
452                                 << " from \"" << lcolor.getX11Name(lc)
453                                 << "\" to \"" << hexname << "\"."
454                                 << endl;
455
456                         parent_.controller().setColor(lc, hexname);
457                 }
458         }
459 }
460
461
462 void FormPreferences::Colors::build()
463 {
464         dialog_.reset(build_preferences_colors(&parent_));
465
466         fl_set_object_color(dialog_->button_color,
467                             GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
468
469         fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
470         fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
471         fl_set_dial_step(dialog_->dial_hue, 1.0);
472         fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
473
474         fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
475         fl_set_slider_step(dialog_->slider_saturation, 0.01);
476         fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
477
478         fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
479         fl_set_slider_step(dialog_->slider_value, 0.01);
480         fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
481
482         fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
483         fl_set_slider_step(dialog_->slider_red, 1.0);
484         fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
485
486         fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
487         fl_set_slider_step(dialog_->slider_green, 1.0);
488         fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
489
490         fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
491         fl_set_slider_step(dialog_->slider_blue, 1.0);
492         fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
493
494         // set up the feedback mechanism
495         setPrehandler(dialog_->browser_lyx_objs);
496         setPrehandler(dialog_->button_color);
497         setPrehandler(dialog_->button_modify);
498         setPrehandler(dialog_->dial_hue);
499         setPrehandler(dialog_->slider_saturation);
500         setPrehandler(dialog_->slider_value);
501         setPrehandler(dialog_->slider_red);
502         setPrehandler(dialog_->slider_green);
503         setPrehandler(dialog_->slider_blue);
504         setPrehandler(dialog_->radio_rgb);
505         setPrehandler(dialog_->radio_hsv);
506 }
507
508
509 string const
510 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
511 {
512         if (ob == dialog_->browser_lyx_objs)
513                 return _("LyX objects that can be assigned a color.");
514
515         if (ob == dialog_->button_modify)
516                 return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
517
518         if (ob == dialog_->dial_hue ||
519                   ob == dialog_->slider_saturation ||
520                   ob == dialog_->slider_value ||
521                   ob == dialog_->slider_red ||
522                   ob == dialog_->slider_green ||
523                   ob == dialog_->slider_blue)
524                 return  _("Find a new color.");
525
526         if (ob == dialog_->radio_rgb || ob == dialog_->radio_hsv)
527                 return _("Toggle between RGB and HSV color spaces.");
528
529         return string();
530 }
531
532
533 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
534 {
535         if (ob == dialog_->browser_lyx_objs) {
536                 InputBrowserLyX();
537
538         } else if (ob == dialog_->dial_hue ||
539                    ob == dialog_->slider_saturation ||
540                    ob == dialog_->slider_value) {
541                 InputHSV();
542
543         } else if (ob == dialog_->slider_red ||
544                    ob == dialog_->slider_green ||
545                    ob == dialog_->slider_blue) {
546                 InputRGB();
547
548         } else if (ob == dialog_->radio_rgb ||
549                    ob == dialog_->radio_hsv) {
550                 SwitchColorSpace();
551
552         } else if (ob == dialog_->button_modify) {
553                 Modify();
554         }
555 }
556
557
558 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
559                                         double addVal) const
560 {
561         RGBColor rgb;
562         fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
563
564         HSVColor hsv(rgb);
565         hsv.v += addVal;
566         hsv.v = min(1.0, max(0.0, hsv.v));
567
568         rgb = RGBColor(hsv);
569         fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
570 }
571
572
573 void FormPreferences::Colors::InputBrowserLyX() const
574 {
575         vector<NamedColor>::size_type const selLyX =
576                 fl_get_browser(dialog_->browser_lyx_objs);
577         if (selLyX < 1) return;
578
579         // Is the choice an Xforms color...
580         RGBColor col;
581
582         if (selLyX - 1 < xformsColorDB.size()) {
583                 vector<XformsColor>::size_type const i = selLyX - 1;
584                 col = xformsColorDB[i].color();
585         }
586         // or a LyX Logical color?
587         else {
588                 vector<NamedColor>::size_type const i = selLyX - 1 -
589                         xformsColorDB.size();
590                 col = lyxColorDB[i].color();
591         }
592
593         fl_freeze_form(dialog_->form);
594
595         fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
596         fl_redraw_object(dialog_->button_color);
597
598         // Display either RGB or HSV but not both!
599         SwitchColorSpace();
600
601         // Deactivate the modify button to begin with...
602         setEnabled(dialog_->button_modify, false);
603
604         fl_unfreeze_form(dialog_->form);
605 }
606
607
608 void FormPreferences::Colors::InputHSV()
609 {
610         double const hue = fl_get_dial_value(dialog_->dial_hue);
611         double const sat = fl_get_slider_value(dialog_->slider_saturation);
612         double const val = fl_get_slider_value(dialog_->slider_value);
613
614         int const h = int(hue);
615         int const s = int(100.0 * sat);
616         int const v = int(100.0 * val);
617
618         string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
619                 tostr(v);
620         fl_set_object_label(dialog_->text_color_values, label.c_str());
621
622         RGBColor col = HSVColor(hue, sat, val);
623
624         fl_freeze_form(dialog_->form);
625
626         fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
627         fl_redraw_object(dialog_->button_color);
628
629         col = HSVColor(hue, 1.0, 1.0);
630         col.r = max(col.r, 0);
631         fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
632         fl_redraw_object(dialog_->dial_hue);
633
634         // Ascertain whether to activate the Modify button.
635         vector<NamedColor>::size_type const selLyX =
636                 fl_get_browser(dialog_->browser_lyx_objs);
637
638         fl_unfreeze_form(dialog_->form);
639         if (selLyX < 1) return;
640
641         fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
642         bool modify = false;
643
644         // Is the choice an Xforms color...
645         if (selLyX - 1 < xformsColorDB.size()) {
646                 vector<XformsColor>::size_type const i = selLyX - 1;
647                 modify = (xformsColorDB[i].color() != col);
648         }
649         // or a LyX Logical color?
650         else {
651                 vector<NamedColor>::size_type const i = selLyX - 1 -
652                         xformsColorDB.size();
653                 modify = (lyxColorDB[i].color() != col);
654         }
655
656         setEnabled(dialog_->button_modify, modify);
657 }
658
659
660 void FormPreferences::Colors::InputRGB()
661 {
662         int const red   = int(fl_get_slider_value(dialog_->slider_red));
663         int const green = int(fl_get_slider_value(dialog_->slider_green));
664         int const blue  = int(fl_get_slider_value(dialog_->slider_blue));
665
666         string const label = tostr(red) + string(", ") + tostr(green) +
667                 string(", ") + tostr(blue);
668         fl_set_object_label(dialog_->text_color_values, label.c_str());
669
670         fl_freeze_form(dialog_->form);
671
672         RGBColor col = RGBColor(red, green, blue);
673         fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
674         fl_redraw_object(dialog_->button_color);
675
676         // Ascertain whether to activate the Modify button.
677         vector<NamedColor>::size_type const selLyX =
678                 fl_get_browser(dialog_->browser_lyx_objs);
679
680         fl_unfreeze_form(dialog_->form);
681         if (selLyX < 1) return;
682
683         bool modify = false;
684
685         // Is the choice an Xforms color...
686         if (selLyX - 1 < xformsColorDB.size()) {
687                 vector<XformsColor>::size_type const i = selLyX - 1;
688                 modify = (xformsColorDB[i].color() != col);
689         }
690         // or a LyX Logical color?
691         else {
692                 vector<NamedColor>::size_type const i = selLyX - 1 -
693                         xformsColorDB.size();
694                 modify = (lyxColorDB[i].color() != col);
695         }
696
697         setEnabled(dialog_->button_modify, modify);
698 }
699
700
701 void FormPreferences::Colors::LoadBrowserLyX()
702 {
703         if (!dialog_->browser_lyx_objs->visible)
704                 return;
705
706         // First, define the modifiable xforms colors
707         xformsColorDB.clear();
708         XformsColor xcol;
709
710         xcol.name = _("GUI background");
711         xcol.colorID = FL_COL1;
712         fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
713
714         xformsColorDB.push_back(xcol);
715
716         xcol.name = _("GUI text");
717         xcol.colorID = FL_BLACK;
718         fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
719
720         xformsColorDB.push_back(xcol);
721
722         xcol.name = _("GUI selection");
723         xcol.colorID = FL_YELLOW;
724         fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
725
726         xformsColorDB.push_back(xcol);
727
728         xcol.name = _("GUI pointer");
729         xcol.colorID = GUI_COLOR_CURSOR;
730         fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
731
732         xformsColorDB.push_back(xcol);
733
734         // Now create the the LyX LColors database
735         lyxColorDB.clear();
736         for (int i=0; i<LColor::ignore; ++i) {
737                 LColor::color lc = static_cast<LColor::color>(i);
738                 if (lc == LColor::none
739                     || lc == LColor::black
740                     || lc == LColor::white
741                     || lc == LColor::red
742                     || lc == LColor::green
743                     || lc == LColor::blue
744                     || lc == LColor::cyan
745                     || lc == LColor::magenta
746                     || lc == LColor::yellow
747                     || lc == LColor::inherit
748                     || lc == LColor::ignore) continue;
749
750                 string const name = lcolor.getX11Name(lc);
751                 Display * display = fl_get_display();;
752                 Colormap const colormap = fl_state[fl_get_vclass()].colormap;
753                 XColor xcol, ccol;
754
755                 if (XLookupColor(display, colormap, name.c_str(), &xcol, &ccol)
756                     == 0) {
757                         lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
758                                << "LColor " << lcolor.getLyXName(lc)
759                                << ": X can't find color \"" << name
760                                << "\". Set to \"black\"!" << endl;
761
762                         string const arg = lcolor.getLyXName(lc) + " black";
763                         parent_.controller().setColor(lc, "black");
764                         continue;
765                 }
766
767                 // X has found the color. Now find the "appropriate" X11 name
768                 // for this color.
769
770                 // Note that X stores the RGB values in the range 0 - 65535
771                 // whilst we require them in the range 0 - 255.
772                 RGBColor col;
773                 col.r = xcol.red   / 256;
774                 col.g = xcol.green / 256;
775                 col.b = xcol.blue  / 256;
776
777                 // Create a valid X11 name of the form "#rrggbb" and change the
778                 // LColor X11name to this. Don't want to trigger a redraw,
779                 // as we're just changing the name not the RGB values.
780                 // Also reset the system_lcolor names, so that we don't output
781                 // unnecessary changes.
782                 string const hexname = X11hexname(col);
783
784                 if (lcolor.getX11Name(lc) != hexname) {
785                         lcolor.setColor(lc, hexname);
786                         system_lcolor.setColor(lc, hexname);
787                 }
788
789                 // Finally, push the color onto the database
790                 NamedColor ncol(lcolor.getGUIName(lc), col);
791                 lyxColorDB.push_back(ncol);
792         }
793
794         // Now construct the browser
795         FL_OBJECT * colbr = dialog_->browser_lyx_objs;
796         fl_freeze_form(dialog_->form);
797         fl_clear_browser(colbr);
798         for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
799              cit != xformsColorDB.end(); ++cit) {
800                 fl_addto_browser(colbr, cit->getname().c_str());
801         }
802         for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
803              cit != lyxColorDB.end(); ++cit) {
804                 fl_addto_browser(colbr, cit->getname().c_str());
805         }
806
807         // just to be safe...
808         fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
809         fl_select_browser_line(dialog_->browser_lyx_objs, 1);
810         fl_unfreeze_form(dialog_->form);
811
812         InputBrowserLyX();
813 }
814
815
816 void FormPreferences::Colors::Modify()
817 {
818         vector<NamedColor>::size_type const selLyX =
819                 fl_get_browser(dialog_->browser_lyx_objs);
820         if (selLyX < 1)
821                 return;
822
823         RGBColor col;
824         fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
825
826         // Is the choice an Xforms color...
827         if (selLyX - 1 < xformsColorDB.size()) {
828                 vector<XformsColor>::size_type const i = selLyX - 1;
829                 xformsColorDB[i].r  = col.r;
830                 xformsColorDB[i].g  = col.g;
831                 xformsColorDB[i].b  = col.b;
832         }
833         // or a LyX Logical color?
834         else {
835                 vector<NamedColor>::size_type const i = selLyX - 1 -
836                         xformsColorDB.size();
837                 lyxColorDB[i].r  = col.r;
838                 lyxColorDB[i].g  = col.g;
839                 lyxColorDB[i].b  = col.b;
840         }
841
842         fl_freeze_form(dialog_->form);
843         setEnabled(dialog_->button_modify, false);
844         fl_unfreeze_form(dialog_->form);
845 }
846
847
848 void FormPreferences::Colors::SwitchColorSpace() const
849 {
850         bool const hsv = fl_get_button(dialog_->radio_hsv);
851
852         RGBColor col;
853         fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
854
855         fl_freeze_form(dialog_->form);
856
857         if (hsv) {
858                 fl_hide_object(dialog_->slider_red);
859                 fl_hide_object(dialog_->slider_blue);
860                 fl_hide_object(dialog_->slider_green);
861                 fl_show_object(dialog_->dial_hue);
862                 fl_show_object(dialog_->slider_saturation);
863                 fl_show_object(dialog_->slider_value);
864
865                 HSVColor hsv = HSVColor(col);
866                 hsv.h = max(hsv.h, 0.0);
867
868                 fl_set_dial_value(dialog_->dial_hue, hsv.h);
869                 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
870                 fl_set_slider_value(dialog_->slider_value, hsv.v);
871
872                 col = HSVColor(hsv.h, 1.0, 1.0);
873                 col.r = max(col.r, 0);
874                 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
875                 fl_redraw_object(dialog_->dial_hue);
876
877                 // Adjust the label a bit, but not the actual values.
878                 // Means that toggling from one space to the other has no
879                 // effect on the final color.
880                 int const h = int(hsv.h);
881                 int const s = int(100 * hsv.s);
882                 int const v = int(100 * hsv.v);
883                 string const label = tostr(h) + ", " + tostr(s) +
884                         ", " + tostr(v);
885                 fl_set_object_label(dialog_->text_color_values, label.c_str());
886
887         } else {
888                 fl_show_object(dialog_->slider_red);
889                 fl_show_object(dialog_->slider_blue);
890                 fl_show_object(dialog_->slider_green);
891                 fl_hide_object(dialog_->dial_hue);
892                 fl_hide_object(dialog_->slider_saturation);
893                 fl_hide_object(dialog_->slider_value);
894
895                 fl_set_slider_value(dialog_->slider_red,   col.r);
896                 fl_set_slider_value(dialog_->slider_green, col.g);
897                 fl_set_slider_value(dialog_->slider_blue,  col.b);
898
899                 // Adjust the label a bit. Same reasoning as above.
900                 int const r = int(col.r);
901                 int const g = int(col.g);
902                 int const b = int(col.b);
903                 string const label = tostr(r) + ", " + tostr(g) +
904                         ", " + tostr(b);
905                 fl_set_object_label(dialog_->text_color_values, label.c_str());
906         }
907
908         fl_unfreeze_form(dialog_->form);
909 }
910
911 string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
912 {
913         ostringstream ostr;
914
915         ostr << '#' << std::setbase(16) << setfill('0')
916              << setw(2) << col.r
917              << setw(2) << col.g
918              << setw(2) << col.b;
919
920         return STRCONV(ostr.str());
921 }
922
923
924 FormPreferences::Converters::Converters(FormPreferences & p)
925         : parent_(p)
926 {}
927
928
929 FD_preferences_converters const * FormPreferences::Converters::dialog()
930 {
931         return dialog_.get();
932 }
933
934
935 void FormPreferences::Converters::apply() const
936 {
937         parent_.controller().setConverters(local_converters);
938 }
939
940
941 void FormPreferences::Converters::build()
942 {
943         dialog_.reset(build_preferences_converters(&parent_));
944
945         fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
946         fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
947
948         // set up the feedback mechanism
949         setPrehandler(dialog_->browser_all);
950         setPrehandler(dialog_->button_delete);
951         setPrehandler(dialog_->button_add);
952         setPrehandler(dialog_->input_converter);
953         setPrehandler(dialog_->choice_from);
954         setPrehandler(dialog_->choice_to);
955         setPrehandler(dialog_->input_flags);
956 }
957
958
959 string const
960 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
961 {
962         if (ob == dialog_->browser_all)
963                 return _("All the currently defined converters known to LyX.");
964
965         if (ob == dialog_->choice_from)
966                 return _("Convert \"from\" this format");
967
968         if (ob == dialog_->choice_to)
969                 return _("Convert \"to\" this format");
970
971         if (ob == dialog_->input_converter)
972                 return _("The conversion command. $$i is the input file name, "
973                          "$$b is the file name without its extension and $$o is "
974                          "the name of the output file. $$s can be used as path to "
975                          "LyX's own collection of conversion scripts.");
976
977         if (ob == dialog_->input_flags)
978                 return _("Extra information for the Converter class, whether and "
979                          "how to parse the result, and various other things.");
980
981         if (ob == dialog_->button_delete)
982                 return _("Remove the current converter from the list of available "
983                          "converters. Note: you must then \"Apply\" the change.");
984
985         if (ob == dialog_->button_add) {
986                 if (string(ob->label) == _("Add"))
987                         return _("Add the current converter to the list of available "
988                                  "converters. Note: you must then \"Apply\" the change.");
989                 else
990                         return _("Modify the contents of the current converter. "
991                                  "Note: you must then \"Apply\" the change.");
992         }
993
994         return string();
995 }
996
997
998 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
999 {
1000         if (ob == dialog_->browser_all)
1001                 return Browser();
1002
1003         if (ob == dialog_->choice_from
1004                    || ob == dialog_->choice_to
1005                    || ob == dialog_->input_converter
1006                    || ob == dialog_->input_flags)
1007                 return Input();
1008
1009         if (ob == dialog_->button_add)
1010                 return Add();
1011
1012         if (ob == dialog_->button_delete)
1013                 return erase();
1014
1015         return true;
1016 }
1017
1018
1019 void FormPreferences::Converters::update()
1020 {
1021         local_converters = converters;
1022         local_converters.update(local_formats);
1023         UpdateBrowser();
1024 }
1025
1026
1027 void FormPreferences::Converters::UpdateBrowser()
1028 {
1029         local_converters.sort();
1030
1031         fl_freeze_form(dialog_->form);
1032         fl_clear_browser(dialog_->browser_all);
1033         for (::Converters::const_iterator cit = local_converters.begin();
1034              cit != local_converters.end(); ++cit) {
1035                 string const name = cit->From->prettyname() + " -> "
1036                         + cit->To->prettyname();
1037                 fl_addto_browser(dialog_->browser_all, name.c_str());
1038         }
1039         Input();
1040         fl_unfreeze_form(dialog_->form);
1041 }
1042
1043
1044 bool FormPreferences::Converters::Add()
1045 {
1046         string const from = GetFrom();
1047         string const to = GetTo();
1048         string const command = fl_get_input(dialog_->input_converter);
1049         string const flags = fl_get_input(dialog_->input_flags);
1050
1051         Converter const * old = local_converters.getConverter(from, to);
1052         local_converters.add(from, to, command, flags);
1053         if (!old) {
1054                 local_converters.updateLast(local_formats);
1055                 UpdateBrowser();
1056         }
1057         setEnabled(dialog_->button_add, false);
1058
1059         return true;
1060 }
1061
1062
1063 bool FormPreferences::Converters::Browser()
1064 {
1065         int const i = fl_get_browser(dialog_->browser_all);
1066         if (i <= 0) return false;
1067
1068         fl_freeze_form(dialog_->form);
1069
1070         Converter const & c = local_converters.get(i - 1);
1071         int j = local_formats.getNumber(c.from);
1072         if (j >= 0)
1073                 fl_set_choice(dialog_->choice_from, j + 1);
1074
1075         j = local_formats.getNumber(c.to);
1076         if (j >= 0)
1077                 fl_set_choice(dialog_->choice_to, j + 1);
1078
1079         fl_set_input(dialog_->input_converter, c.command.c_str());
1080         fl_set_input(dialog_->input_flags, c.flags.c_str());
1081
1082         fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str());
1083         fl_set_button_shortcut(dialog_->button_add,
1084                                scex(_("Modify|#M")).c_str(), 1);
1085
1086         setEnabled(dialog_->button_add,    false);
1087         setEnabled(dialog_->button_delete, true);
1088
1089         fl_unfreeze_form(dialog_->form);
1090         return false;
1091 }
1092
1093
1094 bool FormPreferences::Converters::erase()
1095 {
1096         string const from = GetFrom();
1097         string const to = GetTo();
1098
1099         local_converters.erase(from, to);
1100         UpdateBrowser();
1101         return true;
1102 }
1103
1104
1105 bool FormPreferences::Converters::Input()
1106 {
1107         string const from = GetFrom();
1108         string const to = GetTo();
1109         int const sel = local_converters.getNumber(from, to);
1110
1111         fl_freeze_form(dialog_->form);
1112
1113         if (sel < 0) {
1114                 fl_set_object_label(dialog_->button_add,
1115                                     idex(_("Add|#A")).c_str());
1116                 fl_set_button_shortcut(dialog_->button_add,
1117                                        scex(_("Add|#A")).c_str(), 1);
1118
1119                 fl_deselect_browser(dialog_->browser_all);
1120                 setEnabled(dialog_->button_delete, false);
1121
1122         } else {
1123                 fl_set_object_label(dialog_->button_add,
1124                                     idex(_("Modify|#M")).c_str());
1125                 fl_set_button_shortcut(dialog_->button_add,
1126                                        scex(_("Modify|#M")).c_str(), 1);
1127
1128                 int top = max(sel-5, 0);
1129                 fl_set_browser_topline(dialog_->browser_all, top);
1130                 fl_select_browser_line(dialog_->browser_all, sel+1);
1131                 setEnabled(dialog_->button_delete, true);
1132         }
1133
1134         string const command = rtrim(fl_get_input(dialog_->input_converter));
1135         bool const enable = !(command.empty() || from == to);
1136         setEnabled(dialog_->button_add, enable);
1137
1138         fl_unfreeze_form(dialog_->form);
1139         return false;
1140 }
1141
1142
1143 string const FormPreferences::Converters::GetFrom() const
1144 {
1145         ::Formats::FormatList::size_type const i =
1146                 fl_get_choice(dialog_->choice_from);
1147
1148         if (i > 0 && i <= local_formats.size())
1149                 return local_formats.get(i - 1).name();
1150
1151         lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
1152         return "???";
1153 }
1154
1155
1156 string const FormPreferences::Converters::GetTo() const
1157 {
1158         ::Formats::FormatList::size_type const i =
1159                 fl_get_choice(dialog_->choice_to);
1160
1161         if (i > 0 && i <= local_formats.size())
1162                 return local_formats.get(i - 1).name();
1163
1164         lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
1165         return "???";
1166 }
1167
1168
1169 void FormPreferences::Converters::UpdateChoices() const
1170 {
1171         string choice;
1172         for (::Formats::const_iterator cit = local_formats.begin();
1173              cit != local_formats.end(); ++cit) {
1174                 if (!choice.empty())
1175                         choice += " | ";
1176                 else
1177                         choice += ' ';
1178                 choice += cit->prettyname();
1179         }
1180         choice += ' ';
1181
1182         fl_clear_choice(dialog_->choice_from);
1183         fl_addto_choice(dialog_->choice_from, choice.c_str());
1184
1185         fl_clear_choice(dialog_->choice_to);
1186         fl_addto_choice(dialog_->choice_to, choice.c_str());
1187 }
1188
1189
1190 FormPreferences::Formats::Formats(FormPreferences &  p)
1191         : parent_(p)
1192 {}
1193
1194
1195 FD_preferences_formats const * FormPreferences::Formats::dialog()
1196 {
1197         return dialog_.get();
1198 }
1199
1200
1201 void FormPreferences::Formats::apply() const
1202 {
1203         parent_.controller().setFormats(local_formats);
1204 }
1205
1206
1207 void FormPreferences::Formats::build()
1208 {
1209         dialog_.reset(build_preferences_formats(&parent_));
1210
1211         fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1212         fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1213         fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1214         fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1215         fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1216
1217         fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1218
1219         // set up the feedback mechanism
1220         setPrehandler(dialog_->browser_all);
1221         setPrehandler(dialog_->input_format);
1222         setPrehandler(dialog_->input_gui_name);
1223         setPrehandler(dialog_->button_delete);
1224         setPrehandler(dialog_->button_add);
1225         setPrehandler(dialog_->input_extension);
1226         setPrehandler(dialog_->input_viewer);
1227         setPrehandler(dialog_->input_shrtcut);
1228 }
1229
1230
1231 string const
1232 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1233 {
1234         if (ob == dialog_->browser_all)
1235                 return  _("All the currently defined formats known to LyX.");
1236
1237         if (ob == dialog_->input_format)
1238                 return  _("The format identifier.");
1239
1240         if (ob == dialog_->input_gui_name)
1241                 return  _("The format name as it will appear in the menus.");
1242
1243         if (ob == dialog_->input_shrtcut)
1244                 return  _("The keyboard accelerator. Use a letter in the GUI name. "
1245                           "Case sensitive.");
1246
1247         if (ob == dialog_->input_extension)
1248                 return  _("Used to recognize the file. E.g., ps, pdf, tex.");
1249
1250         if (ob == dialog_->input_viewer)
1251                 return  _("The command used to launch the viewer application.");
1252
1253         if (ob == dialog_->button_delete)
1254                 return  _("Remove the current format from the list of available "
1255                           "formats. Note: you must then \"Apply\" the change.");
1256
1257         if (ob == dialog_->button_add) {
1258                 if (string(ob->label) == _("Add"))
1259                         return  _("Add the current format to the list of available "
1260                                   "formats. Note: you must then \"Apply\" the change.");
1261                 else
1262                         return  _("Modify the contents of the current format. Note: "
1263                                   "you must then \"Apply\" the change.");
1264         }
1265
1266         return string();
1267 }
1268
1269
1270 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1271 {
1272         if (ob == dialog_->browser_all)
1273                 return Browser();
1274
1275         if (ob == dialog_->input_format
1276          || ob == dialog_->input_gui_name
1277          || ob == dialog_->input_shrtcut
1278          || ob == dialog_->input_extension
1279          || ob == dialog_->input_viewer)
1280                 return Input();
1281
1282         if (ob == dialog_->button_add)
1283                 return Add();
1284
1285         if (ob == dialog_->button_delete)
1286                 return erase();
1287
1288         return false;
1289 }
1290
1291
1292 void FormPreferences::Formats::update()
1293 {
1294         local_formats = formats;
1295         UpdateBrowser();
1296 }
1297
1298
1299 void FormPreferences::Formats::UpdateBrowser()
1300 {
1301         local_formats.sort();
1302
1303         fl_freeze_form(dialog_->form);
1304         fl_deselect_browser(dialog_->browser_all);
1305         fl_clear_browser(dialog_->browser_all);
1306         for (::Formats::const_iterator cit = local_formats.begin();
1307              cit != local_formats.end(); ++cit)
1308                 fl_addto_browser(dialog_->browser_all,
1309                                  cit->prettyname().c_str());
1310
1311         Input();
1312         fl_unfreeze_form(dialog_->form);
1313
1314         // Mustn't forget to update the Formats available to the converters_
1315         parent_.converters_.UpdateChoices();
1316         local_converters.update(local_formats);
1317 }
1318
1319
1320 bool FormPreferences::Formats::Add()
1321 {
1322         string const name = fl_get_input(dialog_->input_format);
1323         string const prettyname = fl_get_input(dialog_->input_gui_name);
1324         string const extension = fl_get_input(dialog_->input_extension);
1325         string const shortcut =  fl_get_input(dialog_->input_shrtcut);
1326         string const viewer =  fl_get_input(dialog_->input_viewer);
1327
1328         Format const * old = local_formats.getFormat(name);
1329         string const old_prettyname = old ? old->prettyname() : string();
1330         local_formats.add(name, extension, prettyname, shortcut);
1331         local_formats.setViewer(name, viewer);
1332         if (!old || prettyname != old_prettyname) {
1333                 UpdateBrowser();
1334                 if (old)
1335                         parent_.converters_.UpdateBrowser();
1336         }
1337         setEnabled(dialog_->button_add, false);
1338
1339         return true;
1340 }
1341
1342
1343 bool FormPreferences::Formats::Browser()
1344 {
1345         int const i = fl_get_browser(dialog_->browser_all);
1346         if (i <= 0)
1347                 return false;
1348
1349         fl_freeze_form(dialog_->form);
1350
1351         Format const & f = local_formats.get(i - 1);
1352
1353         fl_set_input(dialog_->input_format, f.name().c_str());
1354         fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1355         fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1356         fl_set_input(dialog_->input_extension, f.extension().c_str());
1357         fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1358
1359         fl_set_object_label(dialog_->button_add,
1360                             idex(_("Modify|#M")).c_str());
1361         fl_set_button_shortcut(dialog_->button_add,
1362                                scex(_("Modify|#M")).c_str(), 1);
1363
1364         setEnabled(dialog_->button_add,    false);
1365         setEnabled(dialog_->button_delete, true);
1366
1367         fl_unfreeze_form(dialog_->form);
1368         return false;
1369 }
1370
1371
1372 bool FormPreferences::Formats::erase()
1373 {
1374         string const name = fl_get_input(dialog_->input_format);
1375
1376         if (local_converters.formatIsUsed(name)) {
1377                 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1378                                       "Remove the converter first."));
1379                 setEnabled(dialog_->button_delete, false);
1380                 return false;
1381         }
1382
1383         local_formats.erase(name);
1384         UpdateBrowser();
1385         return true;
1386 }
1387
1388
1389 bool FormPreferences::Formats::Input()
1390 {
1391         string const name = fl_get_input(dialog_->input_format);
1392         int const sel = local_formats.getNumber(name);
1393         fl_freeze_form(dialog_->form);
1394
1395         if (sel < 0) {
1396                 fl_set_object_label(dialog_->button_add,
1397                                     idex(_("Add|#A")).c_str());
1398                 fl_set_button_shortcut(dialog_->button_add,
1399                                        scex(_("Add|#A")).c_str(), 1);
1400
1401                 fl_deselect_browser(dialog_->browser_all);
1402                 setEnabled(dialog_->button_delete, false);
1403
1404         } else {
1405                 fl_set_object_label(dialog_->button_add,
1406                                     idex(_("Modify|#M")).c_str());
1407                 fl_set_button_shortcut(dialog_->button_add,
1408                                        scex(_("Modify|#M")).c_str(), 1);
1409
1410                 int const top = max(sel-5, 0);
1411                 fl_set_browser_topline(dialog_->browser_all, top);
1412                 fl_select_browser_line(dialog_->browser_all, sel+1);
1413
1414                 setEnabled(dialog_->button_add, true);
1415                 setEnabled(dialog_->button_delete, true);
1416         }
1417
1418         string const prettyname = fl_get_input(dialog_->input_gui_name);
1419         bool const enable = !(name.empty() || prettyname.empty());
1420         setEnabled(dialog_->button_add, enable);
1421
1422         fl_unfreeze_form(dialog_->form);
1423         return false;
1424 }
1425
1426
1427 FormPreferences::InputsMisc::InputsMisc(FormPreferences &  p)
1428         : parent_(p)
1429 {}
1430
1431
1432 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1433 {
1434         return dialog_.get();
1435 }
1436
1437
1438 void FormPreferences::InputsMisc::apply(LyXRC & rc) const
1439 {
1440         rc.date_insert_format =
1441                 fl_get_input(dialog_->input_date_format);
1442 }
1443
1444
1445 void FormPreferences::InputsMisc::build()
1446 {
1447         dialog_.reset(build_preferences_inputs_misc(&parent_));
1448
1449         fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1450
1451         // set up the feedback mechanism
1452         setPrehandler(dialog_->input_date_format);
1453 }
1454
1455
1456 string const
1457 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1458 {
1459         if (ob == dialog_->input_date_format)
1460                 return LyXRC::getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1461         return string();
1462 }
1463
1464
1465 void FormPreferences::InputsMisc::update(LyXRC const & rc)
1466 {
1467         fl_set_input(dialog_->input_date_format,
1468                      rc.date_insert_format.c_str());
1469 }
1470
1471
1472 FormPreferences::Interface::Interface(FormPreferences &  p)
1473         : parent_(p)
1474 {}
1475
1476
1477 FD_preferences_interface const * FormPreferences::Interface::dialog()
1478 {
1479         return dialog_.get();
1480 }
1481
1482
1483 void FormPreferences::Interface::apply(LyXRC & rc) const
1484 {
1485         rc.popup_normal_font =
1486                 fl_get_input(dialog_->input_popup_normal_font);
1487         rc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1488         rc.popup_font_encoding =
1489                 fl_get_input(dialog_->input_popup_font_encoding);
1490         rc.bind_file = fl_get_input(dialog_->input_bind_file);
1491         rc.ui_file = fl_get_input(dialog_->input_ui_file);
1492 }
1493
1494
1495 void FormPreferences::Interface::build()
1496 {
1497         dialog_.reset(build_preferences_interface(&parent_));
1498
1499         fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1500         fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1501         fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1502         fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1503         fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1504
1505         // set up the feedback mechanism
1506         setPrehandler(dialog_->input_popup_normal_font);
1507         setPrehandler(dialog_->input_popup_bold_font);
1508         setPrehandler(dialog_->input_popup_font_encoding);
1509         setPrehandler(dialog_->input_bind_file);
1510         setPrehandler(dialog_->button_bind_file_browse);
1511         setPrehandler(dialog_->input_ui_file);
1512         setPrehandler(dialog_->button_ui_file_browse);
1513 }
1514
1515
1516 string const
1517 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1518 {
1519         if (ob == dialog_->input_popup_normal_font)
1520                 return LyXRC::getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1521         if (ob == dialog_->input_popup_bold_font)
1522                 return LyXRC::getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1523         if (ob == dialog_->input_popup_font_encoding)
1524                 return LyXRC::getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1525         if (ob == dialog_->input_bind_file)
1526                 return LyXRC::getDescription(LyXRC::RC_BINDFILE);
1527         if (ob == dialog_->input_ui_file)
1528                 return LyXRC::getDescription(LyXRC::RC_UIFILE);
1529         return string();
1530 }
1531
1532
1533 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1534 {
1535         if (ob == dialog_->button_bind_file_browse) {
1536                 string f = parent_.controller().browsebind(
1537                         fl_get_input(dialog_->input_bind_file));
1538
1539                 fl_set_input(dialog_->input_bind_file, f.c_str());
1540         } else if (ob == dialog_->button_ui_file_browse) {
1541                 string f = parent_.controller().browseUI(
1542                         fl_get_input(dialog_->input_ui_file));
1543
1544                 fl_set_input(dialog_->input_ui_file, f.c_str());
1545         }
1546
1547         return true;
1548 }
1549
1550
1551 void FormPreferences::Interface::update(LyXRC const & rc)
1552 {
1553         fl_set_input(dialog_->input_popup_normal_font,
1554                      rc.popup_normal_font.c_str());
1555         fl_set_input(dialog_->input_popup_bold_font,
1556                      rc.popup_bold_font.c_str());
1557         fl_set_input(dialog_->input_popup_font_encoding,
1558                      rc.popup_font_encoding.c_str());
1559         fl_set_input(dialog_->input_bind_file,
1560                      rc.bind_file.c_str());
1561         fl_set_input(dialog_->input_ui_file,
1562                      rc.ui_file.c_str());
1563 }
1564
1565
1566 FormPreferences::Language::Language(FormPreferences &  p)
1567         : parent_(p)
1568 {}
1569
1570
1571 FD_preferences_language const * FormPreferences::Language::dialog()
1572 {
1573         return dialog_.get();
1574 }
1575
1576
1577 void FormPreferences::Language::apply(LyXRC & rc)
1578 {
1579         int const pos = combo_default_lang->get();
1580         rc.default_language = lang_[pos-1];
1581
1582         int button = fl_get_button(dialog_->check_use_kbmap);
1583         string const name_1 = fl_get_input(dialog_->input_kbmap1);
1584         string const name_2 = fl_get_input(dialog_->input_kbmap2);
1585         if (button)
1586                 button = !(name_1.empty() && name_2.empty());
1587         rc.use_kbmap = static_cast<bool>(button);
1588
1589         if (rc.use_kbmap) {
1590                 rc.primary_kbmap = name_1;
1591                 rc.secondary_kbmap = name_2;
1592         }
1593
1594         button = fl_get_button(dialog_->check_rtl_support);
1595         rc.rtl_support = static_cast<bool>(button);
1596
1597         button = fl_get_button(dialog_->check_mark_foreign);
1598         rc.mark_foreign_language = static_cast<bool>(button);
1599
1600         button = fl_get_button(dialog_->check_auto_begin);
1601         rc.language_auto_begin = static_cast<bool>(button);
1602
1603         button = fl_get_button(dialog_->check_auto_end);
1604         rc.language_auto_end = static_cast<bool>(button);
1605
1606         button = fl_get_button(dialog_->check_use_babel);
1607         rc.language_use_babel = static_cast<bool>(button);
1608
1609         button = fl_get_button(dialog_->check_global_options);
1610         rc.language_global_options = static_cast<bool>(button);
1611
1612         rc.language_package = fl_get_input(dialog_->input_package);
1613         rc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1614         rc.language_command_end = fl_get_input(dialog_->input_command_end);
1615
1616         // Ensure that all is self-consistent.
1617         update(rc);
1618 }
1619
1620
1621 void FormPreferences::Language::build()
1622 {
1623         dialog_.reset(build_preferences_language(&parent_));
1624
1625         fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1626         fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1627         fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1628
1629         // Store the lang identifiers for later
1630         vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
1631         lang_ = getSecond(langs);
1632
1633         // The default_language is a combo-box and has to be inserted manually
1634         fl_freeze_form(dialog_->form);
1635         fl_addto_form(dialog_->form);
1636
1637         FL_OBJECT * obj = dialog_->choice_default_lang;
1638         fl_deactivate_object(dialog_->choice_default_lang);
1639         combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
1640         combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400);
1641         combo_default_lang->shortcut("#L",1);
1642         combo_default_lang->setcallback(ComboCB, &parent_);
1643
1644         vector<frnt::LanguagePair>::const_iterator lit  = langs.begin();
1645         vector<frnt::LanguagePair>::const_iterator lend = langs.end();
1646         for (; lit != lend; ++lit) {
1647                 combo_default_lang->addto(lit->first);
1648         }
1649         combo_default_lang->select(1);
1650
1651         fl_end_form();
1652         fl_unfreeze_form(dialog_->form);
1653
1654         // set up the feedback mechanism
1655         setPrehandler(dialog_->input_package);
1656         setPrehandler(dialog_->check_use_kbmap);
1657
1658         // This is safe, as nothing is done to the pointer, other than
1659         // to use its address in a block-if statement.
1660         // No it's not! Leads to crash.
1661         // setPrehandler(
1662         //              reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1663         //              C_FormPreferencesFeedbackCB);
1664
1665         setPrehandler(dialog_->input_kbmap1);
1666         setPrehandler(dialog_->input_kbmap2);
1667         setPrehandler(dialog_->check_rtl_support);
1668         setPrehandler(dialog_->check_mark_foreign);
1669         setPrehandler(dialog_->check_auto_begin);
1670         setPrehandler(dialog_->check_auto_end);
1671         setPrehandler(dialog_->check_use_babel);
1672         setPrehandler(dialog_->check_global_options);
1673         setPrehandler(dialog_->input_command_begin);
1674         setPrehandler(dialog_->input_command_end);
1675
1676         // Activate/Deactivate the input fields dependent on the state of the
1677         // buttons.
1678         input(0);
1679 }
1680
1681
1682 string const
1683 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1684 {
1685         if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
1686                 return LyXRC::getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1687         if (ob == dialog_->check_use_kbmap)
1688                 return LyXRC::getDescription(LyXRC::RC_KBMAP);
1689         if (ob == dialog_->input_kbmap1)
1690                 return LyXRC::getDescription(LyXRC::RC_KBMAP_PRIMARY);
1691         if (ob == dialog_->input_kbmap2)
1692                 return LyXRC::getDescription(LyXRC::RC_KBMAP_SECONDARY);
1693         if (ob == dialog_->check_rtl_support)
1694                 return LyXRC::getDescription(LyXRC::RC_RTL_SUPPORT);
1695         if (ob == dialog_->check_mark_foreign)
1696                 return LyXRC::getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1697         if (ob == dialog_->check_auto_begin)
1698                 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1699         if (ob == dialog_->check_auto_end)
1700                 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1701         if (ob == dialog_->check_use_babel)
1702                 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1703         if (ob == dialog_->check_global_options)
1704                 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1705         if (ob == dialog_->input_package)
1706                 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1707         if (ob == dialog_->input_command_begin)
1708                 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1709         if (ob == dialog_->input_command_end)
1710                 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1711         return string();
1712 }
1713
1714
1715 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1716 {
1717         bool activate = true;
1718
1719         // !ob if function is called from Language::build() to de/activate
1720         // objects,
1721         // otherwise the function is called by an xforms CB via input().
1722         if (!ob || ob == dialog_->check_use_kbmap) {
1723                 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1724                 setEnabled(dialog_->button_kbmap1_browse, enable);
1725                 setEnabled(dialog_->button_kbmap2_browse, enable);
1726                 setEnabled(dialog_->input_kbmap1, enable);
1727                 setEnabled(dialog_->input_kbmap2, enable);
1728         }
1729
1730         if (ob == dialog_->button_kbmap1_browse) {
1731                 string f = parent_.controller().browsekbmap(
1732                         fl_get_input(dialog_->input_kbmap1));
1733
1734                 fl_set_input(dialog_->input_kbmap1, f.c_str());
1735         } else if (ob == dialog_->button_kbmap2_browse) {
1736                 string f = parent_.controller().browsekbmap(
1737                         fl_get_input(dialog_->input_kbmap2));
1738
1739                 fl_set_input(dialog_->input_kbmap2, f.c_str());
1740         }
1741
1742         return activate;
1743 }
1744
1745
1746 void FormPreferences::Language::update(LyXRC const & rc)
1747 {
1748         fl_set_button(dialog_->check_use_kbmap,
1749                       rc.use_kbmap);
1750
1751         int const pos = int(findPos(lang_, rc.default_language));
1752         combo_default_lang->select(pos + 1);
1753
1754         if (rc.use_kbmap) {
1755                 fl_set_input(dialog_->input_kbmap1,
1756                              rc.primary_kbmap.c_str());
1757                 fl_set_input(dialog_->input_kbmap2,
1758                              rc.secondary_kbmap.c_str());
1759         } else {
1760                 fl_set_input(dialog_->input_kbmap1, "");
1761                 fl_set_input(dialog_->input_kbmap2, "");
1762         }
1763
1764         fl_set_button(dialog_->check_rtl_support, rc.rtl_support);
1765         fl_set_button(dialog_->check_mark_foreign,
1766                       rc.mark_foreign_language);
1767         fl_set_button(dialog_->check_auto_begin, rc.language_auto_begin);
1768         fl_set_button(dialog_->check_auto_end, rc.language_auto_end);
1769         fl_set_button(dialog_->check_use_babel, rc.language_use_babel);
1770         fl_set_button(dialog_->check_global_options,
1771                       rc.language_global_options);
1772
1773         fl_set_input(dialog_->input_package,
1774                      rc.language_package.c_str());
1775         fl_set_input(dialog_->input_command_begin,
1776                      rc.language_command_begin.c_str());
1777         fl_set_input(dialog_->input_command_end,
1778                      rc.language_command_end.c_str());
1779
1780         // Activate/Deactivate the input fields dependent on the state of the
1781         // buttons.
1782         input(0);
1783 }
1784
1785
1786 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1787 {
1788         FormPreferences * pre = static_cast<FormPreferences*>(v);
1789         // This is safe, as nothing is done to the pointer, other than
1790         // to use its address in a block-if statement.
1791         pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1792 }
1793
1794
1795 FormPreferences::LnFmisc::LnFmisc(FormPreferences &  p)
1796         : parent_(p)
1797 {}
1798
1799
1800 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1801 {
1802         return dialog_.get();
1803 }
1804
1805
1806 void FormPreferences::LnFmisc::apply(LyXRC & rc) const
1807 {
1808         rc.auto_region_delete =
1809                 fl_get_button(dialog_->check_auto_region_delete);
1810         rc.cursor_follows_scrollbar =
1811                 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1812         rc.dialogs_iconify_with_main =
1813                 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1814         rc.preview = fl_get_button(dialog_->check_preview_latex);
1815         rc.autosave = static_cast<unsigned int>
1816                 (fl_get_counter_value(dialog_->counter_autosave));
1817         rc.wheel_jump = static_cast<unsigned int>
1818                 (fl_get_counter_value(dialog_->counter_wm_jump));
1819
1820         // See FIXME below
1821         // grfx::DisplayType old_value = rc.display_graphics;
1822         switch (fl_get_choice(dialog_->choice_display)) {
1823                 case 4: rc.display_graphics = grfx::NoDisplay; break;
1824                 case 3: rc.display_graphics = grfx::ColorDisplay; break;
1825                 case 2: rc.display_graphics = grfx::GrayscaleDisplay; break;
1826                 case 1: rc.display_graphics = grfx::MonochromeDisplay; break;
1827                 default: rc.display_graphics = grfx::ColorDisplay; break;
1828         }
1829
1830 #ifdef WITH_WARNINGS
1831 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1832 #endif
1833 #if 0
1834         if (old_value != rc.display_graphics) {
1835                 grfx::GCache & gc = grfx::GCache::get();
1836                 gc.changeDisplay();
1837         }
1838 #endif
1839 }
1840
1841
1842 void FormPreferences::LnFmisc::build()
1843 {
1844         dialog_.reset(build_preferences_lnf_misc(&parent_));
1845
1846         fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1847         fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1848
1849         fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1850         fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1851
1852         // set up the feedback mechanism
1853         setPrehandler(dialog_->check_auto_region_delete);
1854         setPrehandler(dialog_->counter_autosave);
1855         setPrehandler(dialog_->check_cursor_follows_scrollbar);
1856         setPrehandler(dialog_->check_dialogs_iconify_with_main);
1857         setPrehandler(dialog_->check_preview_latex);
1858         setPrehandler(dialog_->counter_wm_jump);
1859
1860         fl_addto_choice(dialog_->choice_display, _("Monochrome|Grayscale|Color|Do not display"));
1861 }
1862
1863
1864 string const
1865 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1866 {
1867         if (ob == dialog_->check_auto_region_delete)
1868                 return LyXRC::getDescription(LyXRC::RC_AUTOREGIONDELETE);
1869         if (ob == dialog_->check_cursor_follows_scrollbar)
1870                 return LyXRC::getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1871         if (ob == dialog_->check_dialogs_iconify_with_main)
1872                 return LyXRC::getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1873         if (ob == dialog_->check_preview_latex)
1874                 return LyXRC::getDescription(LyXRC::RC_PREVIEW);
1875         if (ob == dialog_->counter_autosave)
1876                 return LyXRC::getDescription(LyXRC::RC_AUTOSAVE);
1877         if (ob == dialog_->counter_wm_jump)
1878                 return LyXRC::getDescription(LyXRC::RC_WHEEL_JUMP);
1879         if (ob == dialog_->choice_display)
1880                 return LyXRC::getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1881         return string();
1882 }
1883
1884
1885 void FormPreferences::LnFmisc::update(LyXRC const & rc)
1886 {
1887         fl_set_button(dialog_->check_auto_region_delete,
1888                       rc.auto_region_delete);
1889         fl_set_button(dialog_->check_cursor_follows_scrollbar,
1890                       rc.cursor_follows_scrollbar);
1891         fl_set_button(dialog_->check_dialogs_iconify_with_main,
1892                       rc.dialogs_iconify_with_main);
1893         fl_set_button(dialog_->check_preview_latex,
1894                       rc.preview);
1895         fl_set_counter_value(dialog_->counter_autosave, rc.autosave);
1896         fl_set_counter_value(dialog_->counter_wm_jump, rc.wheel_jump);
1897
1898         switch (rc.display_graphics) {
1899                 case grfx::NoDisplay:           fl_set_choice(dialog_->choice_display, 4); break;
1900                 case grfx::ColorDisplay:        fl_set_choice(dialog_->choice_display, 3); break;
1901                 case grfx::GrayscaleDisplay:    fl_set_choice(dialog_->choice_display, 2); break;
1902                 case grfx::MonochromeDisplay:   fl_set_choice(dialog_->choice_display, 1); break;
1903                 default:                        fl_set_choice(dialog_->choice_display, 3); break;
1904         }
1905 }
1906
1907
1908 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences &  p)
1909         : parent_(p)
1910 {}
1911
1912
1913 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1914 {
1915         return dialog_.get();
1916 }
1917
1918
1919 void FormPreferences::OutputsMisc::apply(LyXRC & rc) const
1920 {
1921         rc.ascii_linelen = static_cast<unsigned int>
1922                 (fl_get_counter_value(dialog_->counter_line_len));
1923         rc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1924
1925         int const choice =
1926                 fl_get_choice(dialog_->choice_default_papersize) - 1;
1927         rc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1928
1929         rc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1930         rc.chktex_command = fl_get_input(dialog_->input_checktex);
1931         rc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1932         rc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1933 }
1934
1935
1936 void FormPreferences::OutputsMisc::build()
1937 {
1938         dialog_.reset(build_preferences_outputs_misc(&parent_));
1939
1940         fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1941
1942         fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1943         fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1944         fl_set_input_return(dialog_->input_ascii_roff,   FL_RETURN_CHANGED);
1945         fl_set_input_return(dialog_->input_checktex,     FL_RETURN_CHANGED);
1946         fl_set_input_return(dialog_->input_paperoption,  FL_RETURN_CHANGED);
1947
1948         fl_addto_choice(dialog_->choice_default_papersize,
1949                         _(" default | US letter | US legal | US executive | A3 | A4 | A5 | B5 "));
1950
1951         // set up the feedback mechanism
1952         setPrehandler(dialog_->counter_line_len);
1953         setPrehandler(dialog_->input_tex_encoding);
1954         setPrehandler(dialog_->choice_default_papersize);
1955         setPrehandler(dialog_->input_ascii_roff);
1956         setPrehandler(dialog_->input_checktex);
1957         setPrehandler(dialog_->input_paperoption);
1958         setPrehandler(dialog_->check_autoreset_classopt);
1959 }
1960
1961
1962 string const
1963 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1964 {
1965         if (ob == dialog_->counter_line_len)
1966                 return LyXRC::getDescription(LyXRC::RC_ASCII_LINELEN);
1967         if (ob == dialog_->input_tex_encoding)
1968                 return LyXRC::getDescription(LyXRC::RC_FONT_ENCODING);
1969         if (ob == dialog_->input_ascii_roff)
1970                 return LyXRC::getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
1971         if (ob == dialog_->input_checktex)
1972                 return LyXRC::getDescription(LyXRC::RC_CHKTEX_COMMAND);
1973         if (ob == dialog_->choice_default_papersize)
1974                 return LyXRC::getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
1975         if (ob == dialog_->input_paperoption)
1976                 return LyXRC::getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
1977         if (ob == dialog_->check_autoreset_classopt)
1978                 return LyXRC::getDescription(LyXRC::RC_AUTORESET_OPTIONS);
1979         return string();
1980 }
1981
1982
1983 void FormPreferences::OutputsMisc::update(LyXRC const & rc)
1984 {
1985         fl_set_counter_value(dialog_->counter_line_len,
1986                              rc.ascii_linelen);
1987         fl_set_input(dialog_->input_tex_encoding,
1988                      rc.fontenc.c_str());
1989         fl_set_choice(dialog_->choice_default_papersize,
1990                       rc.default_papersize + 1);
1991         fl_set_input(dialog_->input_ascii_roff,
1992                      rc.ascii_roff_command.c_str());
1993         fl_set_input(dialog_->input_checktex,
1994                      rc.chktex_command.c_str());
1995         fl_set_input(dialog_->input_paperoption,
1996                      rc.view_dvi_paper_option.c_str());
1997         fl_set_button(dialog_->check_autoreset_classopt,
1998                       rc.auto_reset_options);
1999
2000 }
2001
2002
2003 FormPreferences::Paths::Paths(FormPreferences &  p)
2004         : parent_(p)
2005 {}
2006
2007
2008 FD_preferences_paths const * FormPreferences::Paths::dialog()
2009 {
2010         return dialog_.get();
2011 }
2012
2013
2014 void FormPreferences::Paths::apply(LyXRC & rc)
2015 {
2016         rc.document_path = fl_get_input(dialog_->input_default_path);
2017         rc.template_path = fl_get_input(dialog_->input_template_path);
2018
2019         int button = fl_get_button(dialog_->check_use_temp_dir);
2020         string str  = fl_get_input(dialog_->input_temp_dir);
2021         if (!button)
2022                 str.erase();
2023
2024         rc.use_tempdir = button;
2025         rc.tempdir_path = str;
2026
2027         button = fl_get_button(dialog_->check_last_files);
2028         str = fl_get_input(dialog_->input_lastfiles);
2029         if (!button) str.erase();
2030
2031         rc.check_lastfiles = button;
2032         rc.lastfiles = str;
2033         rc.num_lastfiles = static_cast<unsigned int>
2034                 (fl_get_counter_value(dialog_->counter_lastfiles));
2035
2036         button = fl_get_button(dialog_->check_make_backups);
2037         str = fl_get_input(dialog_->input_backup_path);
2038         if (!button)
2039                 str.erase();
2040
2041         rc.make_backup = button;
2042         rc.backupdir_path = str;
2043
2044         rc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2045
2046         // update view
2047         update(rc);
2048 }
2049
2050
2051 void FormPreferences::Paths::build()
2052 {
2053         dialog_.reset(build_preferences_paths(&parent_));
2054
2055         fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2056         fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2057         fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2058         fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2059         fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2060         fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2061         fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2062
2063         // set up the feedback mechanism
2064         setPrehandler(dialog_->input_default_path);
2065         setPrehandler(dialog_->counter_lastfiles);
2066         setPrehandler(dialog_->input_template_path);
2067         setPrehandler(dialog_->check_last_files);
2068         setPrehandler(dialog_->input_lastfiles);
2069         setPrehandler(dialog_->check_make_backups);
2070         setPrehandler(dialog_->input_backup_path);
2071         setPrehandler(dialog_->input_serverpipe);
2072         setPrehandler(dialog_->input_temp_dir);
2073         setPrehandler(dialog_->check_use_temp_dir);
2074 }
2075
2076
2077 string const
2078 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2079 {
2080         if (ob == dialog_->input_default_path)
2081                 return LyXRC::getDescription(LyXRC::RC_DOCUMENTPATH);
2082         if (ob == dialog_->input_template_path)
2083                 return LyXRC::getDescription(LyXRC::RC_TEMPLATEPATH);
2084         if (ob == dialog_->check_use_temp_dir)
2085                 return LyXRC::getDescription(LyXRC::RC_USETEMPDIR);
2086         if (ob == dialog_->input_temp_dir)
2087                 return LyXRC::getDescription(LyXRC::RC_TEMPDIRPATH);
2088         if (ob == dialog_->check_last_files)
2089                 return LyXRC::getDescription(LyXRC::RC_CHECKLASTFILES);
2090         if (ob == dialog_->input_lastfiles)
2091                 return LyXRC::getDescription(LyXRC::RC_LASTFILES);
2092         if (ob == dialog_->counter_lastfiles)
2093                 return LyXRC::getDescription(LyXRC::RC_NUMLASTFILES);
2094         if (ob == dialog_->check_make_backups)
2095                 return LyXRC::getDescription(LyXRC::RC_MAKE_BACKUP);
2096         if (ob == dialog_->input_backup_path)
2097                 return LyXRC::getDescription(LyXRC::RC_BACKUPDIR_PATH);
2098         if (ob == dialog_->input_serverpipe)
2099                 return LyXRC::getDescription(LyXRC::RC_SERVERPIPE);
2100         return string();
2101 }
2102
2103
2104 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2105 {
2106         bool activate = true;
2107
2108         // !ob if function is called from Paths::update() to de/activate
2109         // objects,
2110         // otherwise the function is called by an xforms CB via input().
2111         if (!ob || ob == dialog_->check_use_temp_dir) {
2112                 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2113                 setEnabled(dialog_->input_temp_dir, enable);
2114         }
2115
2116         if (!ob || ob == dialog_->check_last_files) {
2117                 bool const enable = fl_get_button(dialog_->check_last_files);
2118                 setEnabled(dialog_->input_lastfiles, enable);
2119         }
2120
2121         if (!ob || ob == dialog_->check_make_backups) {
2122                 bool const enable = fl_get_button(dialog_->check_make_backups);
2123                 setEnabled(dialog_->input_backup_path, enable);
2124         }
2125
2126         if (!ob || ob == dialog_->input_default_path) {
2127                 string const name = fl_get_input(dialog_->input_default_path);
2128                 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2129                         parent_.postWarning(RWInfo::ErrorMessage());
2130                         return false;
2131                 }
2132         }
2133
2134         if (!ob || ob == dialog_->input_template_path) {
2135                 string const name = fl_get_input(dialog_->input_template_path);
2136                 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2137                         parent_.postWarning(RWInfo::ErrorMessage());
2138                         return false;
2139                 }
2140         }
2141
2142         if (!ob || ob == dialog_->input_temp_dir) {
2143                 string const name = fl_get_input(dialog_->input_temp_dir);
2144                 if (fl_get_button(dialog_->check_make_backups)
2145                     && !name.empty()
2146                     && !RWInfo::WriteableDir(name)) {
2147                         parent_.postWarning(RWInfo::ErrorMessage());
2148                         return false;
2149                 }
2150         }
2151
2152         if (!ob || ob == dialog_->input_backup_path) {
2153                 string const name = fl_get_input(dialog_->input_backup_path);
2154                 if (fl_get_button(dialog_->check_make_backups)
2155                     && !name.empty()
2156                     && !RWInfo::WriteableDir(name)) {
2157                         parent_.postWarning(RWInfo::ErrorMessage());
2158                         return false;
2159                 }
2160         }
2161
2162         if (!ob || ob == dialog_->input_lastfiles) {
2163                 string const name = fl_get_input(dialog_->input_lastfiles);
2164                 if (fl_get_button(dialog_->check_last_files)
2165                     && !name.empty()
2166                     && !RWInfo::WriteableFile(name)) {
2167                         parent_.postWarning(RWInfo::ErrorMessage());
2168                         return false;
2169                 }
2170         }
2171
2172         if (!ob || ob == dialog_->input_serverpipe) {
2173                 string const name = fl_get_input(dialog_->input_serverpipe);
2174                 if (!name.empty()) {
2175                         // strip off the extension
2176                         string const str = ChangeExtension(name, "");
2177                         if (!RWInfo::WriteableFile(str + ".in")) {
2178                                 parent_.postWarning(RWInfo::ErrorMessage());
2179                                 return false;
2180                         }
2181                         if (!RWInfo::WriteableFile(str + ".out")) {
2182                                 parent_.postWarning(RWInfo::ErrorMessage());
2183                                 return false;
2184                         }
2185                 }
2186         }
2187
2188         if (ob == dialog_->button_default_path_browse) {
2189                 string f = parent_.controller().browsedir(
2190                         fl_get_input(dialog_->input_default_path), _("Default path"));
2191                 if (!f.empty())
2192                         fl_set_input(dialog_->input_default_path, f.c_str());
2193         } else if (ob == dialog_->button_template_path_browse) {
2194                 string f = parent_.controller().browsedir(
2195                         fl_get_input(dialog_->input_template_path), _("Template path"));
2196                 if (!f.empty())
2197                         fl_set_input(dialog_->input_template_path, f.c_str());
2198         } else if (ob == dialog_->button_temp_dir_browse) {
2199                 string f = parent_.controller().browsedir(
2200                         fl_get_input(dialog_->input_temp_dir), _("Temporary dir"));
2201                 if (!f.empty())
2202                         fl_set_input(dialog_->input_temp_dir, f.c_str());
2203         } else if (ob == dialog_->button_lastfiles_browse) {
2204                 string f = parent_.controller().browse(
2205                         fl_get_input(dialog_->input_lastfiles), _("Last files"));
2206                 if (!f.empty())
2207                         fl_set_input(dialog_->input_lastfiles, f.c_str());
2208         } else if (ob == dialog_->button_backup_path_browse) {
2209                 string f = parent_.controller().browsedir(
2210                         fl_get_input(dialog_->input_backup_path), _("Backup path"));
2211                 if (!f.empty())
2212                         fl_set_input(dialog_->input_backup_path, f.c_str());
2213         } else if (ob == dialog_->button_serverpipe_browse) {
2214                 string f = parent_.controller().browse(
2215                         fl_get_input(dialog_->input_serverpipe), _("LyX server pipes"));
2216                 if (!f.empty())
2217                         fl_set_input(dialog_->input_serverpipe, f.c_str());
2218         }
2219
2220         return activate;
2221 }
2222
2223
2224 void FormPreferences::Paths::update(LyXRC const & rc)
2225 {
2226         fl_set_input(dialog_->input_default_path,
2227                      rc.document_path.c_str());
2228         fl_set_input(dialog_->input_template_path,
2229                      rc.template_path.c_str());
2230
2231         string str;
2232         if (rc.make_backup)
2233                 str = rc.backupdir_path;
2234
2235         fl_set_button(dialog_->check_make_backups,
2236                       rc.make_backup);
2237         fl_set_input(dialog_->input_backup_path, str.c_str());
2238
2239         str.erase();
2240         if (rc.use_tempdir)
2241                 str = rc.tempdir_path;
2242
2243         fl_set_button(dialog_->check_use_temp_dir,
2244                       rc.use_tempdir);
2245         fl_set_input(dialog_->input_temp_dir, str.c_str());
2246
2247         str.erase();
2248         if (rc.check_lastfiles)
2249                 str = rc.lastfiles;
2250
2251         fl_set_button(dialog_->check_last_files,
2252                       rc.check_lastfiles);
2253         fl_set_input(dialog_->input_lastfiles, str.c_str());
2254         fl_set_counter_value(dialog_->counter_lastfiles,
2255                              rc.num_lastfiles);
2256
2257         fl_set_input(dialog_->input_serverpipe, rc.lyxpipes.c_str());
2258
2259         // Activate/Deactivate the input fields dependent on the state of the
2260         // buttons.
2261         input(0);
2262 }
2263
2264
2265 FormPreferences::Printer::Printer(FormPreferences &  p)
2266         : parent_(p)
2267 {}
2268
2269
2270 FD_preferences_printer const * FormPreferences::Printer::dialog()
2271 {
2272         return dialog_.get();
2273 }
2274
2275
2276 void FormPreferences::Printer::apply(LyXRC & rc) const
2277 {
2278         rc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2279         rc.print_command = fl_get_input(dialog_->input_command);
2280         rc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2281         rc.print_copies_flag = fl_get_input(dialog_->input_copies);
2282         rc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2283         rc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2284         rc.print_file_extension =
2285                 fl_get_input(dialog_->input_file_extension);
2286         rc.print_spool_command =
2287                 fl_get_input(dialog_->input_spool_command);
2288         rc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2289         rc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2290         rc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2291         rc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2292         rc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2293         rc.print_to_file = fl_get_input(dialog_->input_to_file);
2294         rc.print_extra_options =
2295                 fl_get_input(dialog_->input_extra_options);
2296         rc.print_spool_printerprefix =
2297                 fl_get_input(dialog_->input_spool_prefix);
2298         rc.print_paper_dimension_flag =
2299                 fl_get_input(dialog_->input_paper_size);
2300         rc.printer = fl_get_input(dialog_->input_name);
2301 }
2302
2303
2304 string const
2305 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2306 {
2307         if (ob == dialog_->input_command)
2308                 return LyXRC::getDescription(LyXRC::RC_PRINT_COMMAND);
2309         if (ob == dialog_->check_adapt_output)
2310                 return LyXRC::getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2311         if (ob == dialog_->input_to_printer)
2312                 return LyXRC::getDescription(LyXRC::RC_PRINTTOPRINTER);
2313         if (ob == dialog_->input_to_file)
2314                 return LyXRC::getDescription(LyXRC::RC_PRINTTOFILE);
2315         if (ob == dialog_->input_file_extension)
2316                 return LyXRC::getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2317         if (ob == dialog_->input_extra_options)
2318                 return LyXRC::getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2319         if (ob == dialog_->input_spool_command)
2320                 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2321         if (ob == dialog_->input_spool_prefix)
2322                 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2323         if (ob == dialog_->input_name)
2324                 return LyXRC::getDescription(LyXRC::RC_PRINTER);
2325         if (ob == dialog_->input_even_pages)
2326                 return LyXRC::getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2327         if (ob == dialog_->input_odd_pages)
2328                 return LyXRC::getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2329         if (ob == dialog_->input_page_range)
2330                 return LyXRC::getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2331         if (ob == dialog_->input_reverse)
2332                 return LyXRC::getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2333         if (ob == dialog_->input_landscape)
2334                 return LyXRC::getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2335         if (ob == dialog_->input_copies)
2336                 return LyXRC::getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2337         if (ob == dialog_->input_collated)
2338                 return LyXRC::getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2339         if (ob == dialog_->input_paper_type)
2340                 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERFLAG);
2341         if (ob == dialog_->input_paper_size)
2342                 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2343         return string();
2344 }
2345
2346
2347 void FormPreferences::Printer::build()
2348 {
2349         dialog_.reset(build_preferences_printer(&parent_));
2350
2351         fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2352         fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2353         fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2354         fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2355         fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2356         fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2357         fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2358         fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2359         fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2360         fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2361         fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2362         fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2363         fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2364         fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2365         fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2366         fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2367         fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2368
2369         // set up the feedback mechanism
2370         setPrehandler(dialog_->input_command);
2371         setPrehandler(dialog_->input_page_range);
2372         setPrehandler(dialog_->input_copies);
2373         setPrehandler(dialog_->input_reverse);
2374         setPrehandler(dialog_->input_to_printer);
2375         setPrehandler(dialog_->input_file_extension);
2376         setPrehandler(dialog_->input_spool_command);
2377         setPrehandler(dialog_->input_paper_type);
2378         setPrehandler(dialog_->input_even_pages);
2379         setPrehandler(dialog_->input_odd_pages);
2380         setPrehandler(dialog_->input_collated);
2381         setPrehandler(dialog_->input_landscape);
2382         setPrehandler(dialog_->input_to_file);
2383         setPrehandler(dialog_->input_extra_options);
2384         setPrehandler(dialog_->input_spool_prefix);
2385         setPrehandler(dialog_->input_paper_size);
2386         setPrehandler(dialog_->input_name);
2387         setPrehandler(dialog_->check_adapt_output);
2388 }
2389
2390
2391 void FormPreferences::Printer::update(LyXRC const & rc)
2392 {
2393         fl_set_button(dialog_->check_adapt_output,
2394                       rc.print_adapt_output);
2395         fl_set_input(dialog_->input_command,
2396                      rc.print_command.c_str());
2397         fl_set_input(dialog_->input_page_range,
2398                      rc.print_pagerange_flag.c_str());
2399         fl_set_input(dialog_->input_copies,
2400                      rc.print_copies_flag.c_str());
2401         fl_set_input(dialog_->input_reverse,
2402                      rc.print_reverse_flag.c_str());
2403         fl_set_input(dialog_->input_to_printer,
2404                      rc.print_to_printer.c_str());
2405         fl_set_input(dialog_->input_file_extension,
2406                      rc.print_file_extension.c_str());
2407         fl_set_input(dialog_->input_spool_command,
2408                      rc.print_spool_command.c_str());
2409         fl_set_input(dialog_->input_paper_type,
2410                      rc.print_paper_flag.c_str());
2411         fl_set_input(dialog_->input_even_pages,
2412                      rc.print_evenpage_flag.c_str());
2413         fl_set_input(dialog_->input_odd_pages,
2414                      rc.print_oddpage_flag.c_str());
2415         fl_set_input(dialog_->input_collated,
2416                      rc.print_collcopies_flag.c_str());
2417         fl_set_input(dialog_->input_landscape,
2418                      rc.print_landscape_flag.c_str());
2419         fl_set_input(dialog_->input_to_file,
2420                      rc.print_to_file.c_str());
2421         fl_set_input(dialog_->input_extra_options,
2422                      rc.print_extra_options.c_str());
2423         fl_set_input(dialog_->input_spool_prefix,
2424                      rc.print_spool_printerprefix.c_str());
2425         fl_set_input(dialog_->input_paper_size,
2426                      rc.print_paper_dimension_flag.c_str());
2427         fl_set_input(dialog_->input_name,
2428                      rc.printer.c_str());
2429 }
2430
2431
2432 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences &  p)
2433         : parent_(p)
2434 {}
2435
2436
2437 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2438 {
2439         return dialog_.get();
2440 }
2441
2442
2443 void FormPreferences::ScreenFonts::apply(LyXRC & rc) const
2444 {
2445         bool changed = false;
2446
2447         pair<string, string> tmp =
2448                 parseFontName(fl_get_input(dialog_->input_roman));
2449         if (rc.roman_font_name != tmp.first ||
2450             rc.roman_font_foundry != tmp.second) {
2451                 changed = true;
2452                 rc.roman_font_name = tmp.first;
2453                 rc.roman_font_foundry = tmp.second;
2454         }
2455
2456         tmp = parseFontName(fl_get_input(dialog_->input_sans));
2457         if (rc.sans_font_name != tmp.first ||
2458             rc.sans_font_foundry != tmp.second) {
2459                 changed = true;
2460                 rc.sans_font_name = tmp.first;
2461                 rc.sans_font_foundry = tmp.second;
2462         }
2463
2464         tmp = parseFontName(fl_get_input(dialog_->input_typewriter));
2465         if (rc.typewriter_font_name != tmp.first ||
2466             rc.typewriter_font_foundry != tmp.second) {
2467                 changed = true;
2468                 rc.typewriter_font_name = tmp.first;
2469                 rc.typewriter_font_foundry = tmp.second;
2470         }
2471
2472         string str = fl_get_input(dialog_->input_screen_encoding);
2473         if (rc.font_norm != str) {
2474                 changed = true;
2475                 rc.font_norm = str;
2476         }
2477
2478         bool button = fl_get_button(dialog_->check_scalable);
2479         if (rc.use_scalable_fonts != button) {
2480                 changed = true;
2481                 rc.use_scalable_fonts = button;
2482         }
2483
2484         unsigned int ivalue = static_cast<unsigned int>
2485                 (fl_get_counter_value(dialog_->counter_zoom));
2486         if (rc.zoom != ivalue) {
2487                 changed = true;
2488                 rc.zoom = ivalue;
2489         }
2490
2491         ivalue = static_cast<unsigned int>
2492                 (fl_get_counter_value(dialog_->counter_dpi));
2493         if (rc.dpi != ivalue) {
2494                 changed = true;
2495                 rc.dpi = ivalue;
2496         }
2497
2498         double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2499         if (rc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2500                 changed = true;
2501                 rc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2502         }
2503
2504         dvalue = strToDbl(fl_get_input(dialog_->input_script));
2505         if (rc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2506                 changed = true;
2507                 rc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2508         }
2509
2510         dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2511         if (rc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2512                 changed = true;
2513                 rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2514         }
2515
2516         dvalue = strToDbl(fl_get_input(dialog_->input_small));
2517         if (rc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2518                 changed = true;
2519                 rc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2520         }
2521
2522         dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2523         if (rc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2524                 changed = true;
2525                 rc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2526         }
2527
2528         dvalue = strToDbl(fl_get_input(dialog_->input_large));
2529         if (rc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2530                 changed = true;
2531                 rc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2532         }
2533
2534         dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2535         if (rc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2536                 changed = true;
2537                 rc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2538         }
2539
2540         dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2541         if (rc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2542                 changed = true;
2543                 rc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2544         }
2545
2546         dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2547         if (rc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2548                 changed = true;
2549                 rc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2550         }
2551
2552         dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2553         if (rc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2554                 changed = true;
2555                 rc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2556         }
2557
2558         if (changed) {
2559                 // Now update the buffers
2560                 // Can anything below here affect the redraw process?
2561                 parent_.controller().updateScreenFonts();
2562         }
2563 }
2564
2565
2566 void FormPreferences::ScreenFonts::build()
2567 {
2568         dialog_.reset(build_preferences_screen_fonts(&parent_));
2569
2570         fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2571         fl_set_counter_step(dialog_->counter_dpi,  1, 10);
2572
2573         fl_set_input_return(dialog_->input_roman,           FL_RETURN_CHANGED);
2574         fl_set_input_return(dialog_->input_sans,            FL_RETURN_CHANGED);
2575         fl_set_input_return(dialog_->input_typewriter,      FL_RETURN_CHANGED);
2576         fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2577         fl_set_counter_return(dialog_->counter_zoom,        FL_RETURN_CHANGED);
2578         fl_set_counter_return(dialog_->counter_dpi,         FL_RETURN_CHANGED);
2579         fl_set_input_return(dialog_->input_tiny,            FL_RETURN_CHANGED);
2580         fl_set_input_return(dialog_->input_script,          FL_RETURN_CHANGED);
2581         fl_set_input_return(dialog_->input_footnote,        FL_RETURN_CHANGED);
2582         fl_set_input_return(dialog_->input_small,           FL_RETURN_CHANGED);
2583         fl_set_input_return(dialog_->input_normal,          FL_RETURN_CHANGED);
2584         fl_set_input_return(dialog_->input_large,           FL_RETURN_CHANGED);
2585         fl_set_input_return(dialog_->input_larger,          FL_RETURN_CHANGED);
2586         fl_set_input_return(dialog_->input_largest,         FL_RETURN_CHANGED);
2587         fl_set_input_return(dialog_->input_huge,            FL_RETURN_CHANGED);
2588         fl_set_input_return(dialog_->input_huger,           FL_RETURN_CHANGED);
2589
2590         fl_set_input_filter(dialog_->input_tiny,     fl_unsigned_float_filter);
2591         fl_set_input_filter(dialog_->input_script,   fl_unsigned_float_filter);
2592         fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2593         fl_set_input_filter(dialog_->input_small,    fl_unsigned_float_filter);
2594         fl_set_input_filter(dialog_->input_normal,   fl_unsigned_float_filter);
2595         fl_set_input_filter(dialog_->input_large,    fl_unsigned_float_filter);
2596         fl_set_input_filter(dialog_->input_larger,   fl_unsigned_float_filter);
2597         fl_set_input_filter(dialog_->input_largest,  fl_unsigned_float_filter);
2598         fl_set_input_filter(dialog_->input_huge,     fl_unsigned_float_filter);
2599         fl_set_input_filter(dialog_->input_huger,    fl_unsigned_float_filter);
2600
2601         // set up the feedback mechanism
2602         setPrehandler(dialog_->input_roman);
2603         setPrehandler(dialog_->input_sans);
2604         setPrehandler(dialog_->input_typewriter);
2605         setPrehandler(dialog_->counter_zoom);
2606         setPrehandler(dialog_->counter_dpi);
2607         setPrehandler(dialog_->check_scalable);
2608         setPrehandler(dialog_->input_screen_encoding);
2609         setPrehandler(dialog_->input_tiny);
2610         setPrehandler(dialog_->input_script);
2611         setPrehandler(dialog_->input_footnote);
2612         setPrehandler(dialog_->input_small);
2613         setPrehandler(dialog_->input_large);
2614         setPrehandler(dialog_->input_larger);
2615         setPrehandler(dialog_->input_largest);
2616         setPrehandler(dialog_->input_normal);
2617         setPrehandler(dialog_->input_huge);
2618         setPrehandler(dialog_->input_huger);
2619 }
2620
2621
2622 string const
2623 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2624 {
2625         if (ob == dialog_->input_roman)
2626                 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2627         if (ob == dialog_->input_sans)
2628                 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2629         if (ob == dialog_->input_typewriter)
2630                 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2631         if (ob == dialog_->check_scalable)
2632                 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2633         if (ob == dialog_->input_screen_encoding)
2634                 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2635         if (ob == dialog_->counter_zoom)
2636                 return LyXRC::getDescription(LyXRC::RC_SCREEN_ZOOM);
2637         if (ob == dialog_->counter_dpi)
2638                 return LyXRC::getDescription(LyXRC::RC_SCREEN_DPI);
2639         if (ob == dialog_->input_tiny
2640                  || ob == dialog_->input_script
2641                  || ob == dialog_->input_footnote
2642                  || ob == dialog_->input_small
2643                  || ob == dialog_->input_large
2644                  || ob == dialog_->input_larger
2645                  || ob == dialog_->input_larger
2646                  || ob == dialog_->input_largest
2647                  || ob == dialog_->input_normal
2648                  || ob == dialog_->input_huge
2649                  || ob == dialog_->input_huger)
2650                 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2651         return string();
2652 }
2653
2654
2655 bool FormPreferences::ScreenFonts::input()
2656 {
2657         bool activate = true;
2658         string str;
2659
2660         // Make sure that all fonts all have positive entries
2661         // Also note that an empty entry is returned as 0.0 by strToDbl
2662         if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2663             || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2664             || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2665             || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2666             || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2667             || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2668             || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2669             || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2670             || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2671             || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2672                 activate = false;
2673                 str = _("Fonts must be positive!");
2674
2675         } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2676                    // Fontsizes -- tiny < script < footnote etc.
2677                    strToDbl(fl_get_input(dialog_->input_script)) ||
2678                    strToDbl(fl_get_input(dialog_->input_script)) >
2679                    strToDbl(fl_get_input(dialog_->input_footnote)) ||
2680                    strToDbl(fl_get_input(dialog_->input_footnote)) >
2681                    strToDbl(fl_get_input(dialog_->input_small)) ||
2682                    strToDbl(fl_get_input(dialog_->input_small)) >
2683                    strToDbl(fl_get_input(dialog_->input_normal)) ||
2684                    strToDbl(fl_get_input(dialog_->input_normal)) >
2685                    strToDbl(fl_get_input(dialog_->input_large)) ||
2686                    strToDbl(fl_get_input(dialog_->input_large)) >
2687                    strToDbl(fl_get_input(dialog_->input_larger)) ||
2688                    strToDbl(fl_get_input(dialog_->input_larger)) >
2689                    strToDbl(fl_get_input(dialog_->input_largest)) ||
2690                    strToDbl(fl_get_input(dialog_->input_largest)) >
2691                    strToDbl(fl_get_input(dialog_->input_huge)) ||
2692                    strToDbl(fl_get_input(dialog_->input_huge)) >
2693                    strToDbl(fl_get_input(dialog_->input_huger))) {
2694                 activate = false;
2695
2696                 str = _("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
2697         }
2698
2699         if (!activate)
2700                 parent_.postWarning(str);
2701
2702         return activate;
2703 }
2704
2705
2706 void FormPreferences::ScreenFonts::update(LyXRC const & rc)
2707 {
2708         fl_set_input(dialog_->input_roman,
2709                      makeFontName(rc.roman_font_name,
2710                                   rc.roman_font_foundry).c_str());
2711         fl_set_input(dialog_->input_sans,
2712                      makeFontName(rc.sans_font_name,
2713                                   rc.sans_font_foundry).c_str());
2714         fl_set_input(dialog_->input_typewriter,
2715                      makeFontName(rc.typewriter_font_name,
2716                                   rc.typewriter_font_foundry).c_str());
2717         fl_set_input(dialog_->input_screen_encoding,
2718                      rc.font_norm.c_str());
2719         fl_set_button(dialog_->check_scalable,
2720                       rc.use_scalable_fonts);
2721         fl_set_counter_value(dialog_->counter_zoom, rc.zoom);
2722         fl_set_counter_value(dialog_->counter_dpi,  rc.dpi);
2723         fl_set_input(dialog_->input_tiny,
2724                      tostr(rc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2725         fl_set_input(dialog_->input_script,
2726                      tostr(rc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2727         fl_set_input(dialog_->input_footnote,
2728                      tostr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2729         fl_set_input(dialog_->input_small,
2730                      tostr(rc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2731         fl_set_input(dialog_->input_normal,
2732                      tostr(rc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2733         fl_set_input(dialog_->input_large,
2734                      tostr(rc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2735         fl_set_input(dialog_->input_larger,
2736                      tostr(rc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2737         fl_set_input(dialog_->input_largest,
2738                      tostr(rc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2739         fl_set_input(dialog_->input_huge,
2740                      tostr(rc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2741         fl_set_input(dialog_->input_huger,
2742                      tostr(rc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2743 }
2744
2745
2746
2747 FormPreferences::SpellOptions::SpellOptions(FormPreferences &  p)
2748         : parent_(p)
2749 {}
2750
2751
2752 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2753 {
2754         return dialog_.get();
2755 }
2756
2757
2758 void FormPreferences::SpellOptions::apply(LyXRC & rc)
2759 {
2760         string choice = fl_get_choice_text(dialog_->choice_spell_command);
2761         choice = trim(choice);
2762
2763         rc.isp_command = choice;
2764
2765 #if 0
2766         // If spell checker == "none", all other input set to off.
2767         if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2768                 rc.isp_use_alt_lang = false;
2769                 rc.isp_alt_lang.erase();
2770
2771                 rc.isp_use_esc_chars = false;
2772                 rc.isp_esc_chars.erase();
2773
2774                 rc.isp_use_pers_dict = false;
2775                 rc.isp_pers_dict.erase();
2776
2777                 rc.isp_accept_compound = false;
2778                 rc.isp_use_input_encoding = false;
2779         } else {
2780 #else
2781                 int button = fl_get_button(dialog_->check_alt_lang);
2782                 choice = fl_get_input(dialog_->input_alt_lang);
2783                 if (button && choice.empty()) button = 0;
2784                 if (!button) choice.erase();
2785
2786                 rc.isp_use_alt_lang = static_cast<bool>(button);
2787                 rc.isp_alt_lang = choice;
2788
2789                 button = fl_get_button(dialog_->check_escape_chars);
2790                 choice = fl_get_input(dialog_->input_escape_chars);
2791                 if (button && choice.empty()) button = 0;
2792                 if (!button) choice.erase();
2793
2794                 rc.isp_use_esc_chars = static_cast<bool>(button);
2795                 rc.isp_esc_chars = choice;
2796
2797                 button = fl_get_button(dialog_->check_personal_dict);
2798                 choice = fl_get_input(dialog_->input_personal_dict);
2799                 if (button && choice.empty()) button = 0;
2800                 if (!button) choice.erase();
2801
2802                 rc.isp_use_pers_dict = static_cast<bool>(button);
2803                 rc.isp_pers_dict = choice;
2804
2805                 button = fl_get_button(dialog_->check_compound_words);
2806                 rc.isp_accept_compound = static_cast<bool>(button);
2807
2808                 button = fl_get_button(dialog_->check_input_enc);
2809                 rc.isp_use_input_encoding = static_cast<bool>(button);
2810 #endif
2811 #if 0
2812         }
2813 #endif
2814
2815         // Reset view
2816         update(rc);
2817 }
2818
2819
2820 void FormPreferences::SpellOptions::build()
2821 {
2822         dialog_.reset(build_preferences_spelloptions(&parent_));
2823
2824         fl_addto_choice(dialog_->choice_spell_command,
2825                         _(" ispell | aspell "));
2826         fl_set_input_return(dialog_->input_alt_lang,      FL_RETURN_CHANGED);
2827         fl_set_input_return(dialog_->input_escape_chars,  FL_RETURN_CHANGED);
2828         fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2829
2830         // set up the feedback mechanism
2831         setPrehandler(dialog_->choice_spell_command);
2832         setPrehandler(dialog_->check_alt_lang);
2833         setPrehandler(dialog_->input_alt_lang);
2834         setPrehandler(dialog_->check_escape_chars);
2835         setPrehandler(dialog_->input_escape_chars);
2836         setPrehandler(dialog_->check_personal_dict);
2837         setPrehandler(dialog_->input_personal_dict);
2838         setPrehandler(dialog_->button_personal_dict);
2839         setPrehandler(dialog_->check_compound_words);
2840         setPrehandler(dialog_->check_input_enc);
2841 }
2842
2843
2844 string const
2845 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2846 {
2847         if (ob == dialog_->choice_spell_command)
2848                 return LyXRC::getDescription(LyXRC::RC_SPELL_COMMAND);
2849         if (ob == dialog_->check_alt_lang)
2850                 return LyXRC::getDescription(LyXRC::RC_USE_ALT_LANG);
2851         if (ob == dialog_->input_alt_lang)
2852                 return LyXRC::getDescription(LyXRC::RC_ALT_LANG);
2853         if (ob == dialog_->check_escape_chars)
2854                 return LyXRC::getDescription(LyXRC::RC_USE_ESC_CHARS);
2855         if (ob == dialog_->input_escape_chars)
2856                 return LyXRC::getDescription(LyXRC::RC_ESC_CHARS);
2857         if (ob == dialog_->check_personal_dict)
2858                 return LyXRC::getDescription(LyXRC::RC_USE_PERS_DICT);
2859         if (ob == dialog_->input_personal_dict)
2860                 return LyXRC::getDescription(LyXRC::RC_PERS_DICT);
2861         if (ob == dialog_->check_compound_words)
2862                 return LyXRC::getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2863         if (ob == dialog_->check_input_enc)
2864                 return LyXRC::getDescription(LyXRC::RC_USE_INP_ENC);
2865         return string();
2866 }
2867
2868
2869 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2870 {
2871         // !ob if function is called from updateSpellOptions() to de/activate
2872         // objects,
2873         // otherwise the function is called by an xforms CB via input().
2874
2875 #if 0
2876         // If spell checker == "none", disable all input.
2877         if (!ob || ob == dialog_->choice_spell_command) {
2878                 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2879                         fl_deactivate_object(dialog_->check_alt_lang);
2880                         fl_deactivate_object(dialog_->input_alt_lang);
2881                         fl_deactivate_object(dialog_->check_escape_chars);
2882                         fl_deactivate_object(dialog_->input_escape_chars);
2883                         fl_deactivate_object(dialog_->check_personal_dict);
2884                         fl_deactivate_object(dialog_->input_personal_dict);
2885                         fl_deactivate_object(dialog_->check_compound_words);
2886                         fl_deactivate_object(dialog_->check_input_enc);
2887                         return true;
2888                 } else {
2889                         fl_activate_object(dialog_->check_alt_lang);
2890                         fl_activate_object(dialog_->check_escape_chars);
2891                         fl_activate_object(dialog_->check_personal_dict);
2892                         fl_activate_object(dialog_->check_compound_words);
2893                         fl_activate_object(dialog_->check_input_enc);
2894                 }
2895         }
2896 #endif
2897
2898         if (!ob || ob == dialog_->check_alt_lang) {
2899                 bool const enable = fl_get_button(dialog_->check_alt_lang);
2900                 setEnabled(dialog_->input_alt_lang, enable);
2901         }
2902
2903         if (!ob || ob == dialog_->check_escape_chars) {
2904                 bool const enable = fl_get_button(dialog_->check_escape_chars);
2905                 setEnabled(dialog_->input_escape_chars, enable);
2906         }
2907
2908         if (!ob || ob == dialog_->check_personal_dict) {
2909                 bool const enable = fl_get_button(dialog_->check_personal_dict);
2910                 setEnabled(dialog_->input_personal_dict, enable);
2911         }
2912
2913         if (ob == dialog_->button_personal_dict) {
2914                 string f = parent_.controller().browsedict(
2915                         fl_get_input(dialog_->input_personal_dict));
2916                 fl_set_input(dialog_->input_personal_dict, f.c_str());
2917         }
2918
2919         return true; // All input is valid!
2920 }
2921
2922
2923 void FormPreferences::SpellOptions::update(LyXRC const & rc)
2924 {
2925         int choice = 1;
2926 #if 0
2927         if (rc.isp_command == "none")
2928                 choice = 1;
2929         else if (rc.isp_command == "ispell")
2930                 choice = 2;
2931         else if (rc.isp_command == "aspell")
2932                 choice = 3;
2933 #else
2934         if (rc.isp_command == "ispell")
2935                 choice = 1;
2936         else if (rc.isp_command == "aspell")
2937                 choice = 2;
2938 #endif
2939         fl_set_choice(dialog_->choice_spell_command, choice);
2940
2941         string str;
2942         if (rc.isp_use_alt_lang)
2943                 str = rc.isp_alt_lang;
2944
2945         fl_set_button(dialog_->check_alt_lang,
2946                       rc.isp_use_alt_lang);
2947         fl_set_input(dialog_->input_alt_lang, str.c_str());
2948
2949         str.erase();
2950         if (rc.isp_use_esc_chars)
2951                 str = rc.isp_esc_chars;
2952
2953         fl_set_button(dialog_->check_escape_chars,
2954                       rc.isp_use_esc_chars);
2955         fl_set_input(dialog_->input_escape_chars, str.c_str());
2956
2957         str.erase();
2958         if (rc.isp_use_pers_dict)
2959                 str = rc.isp_pers_dict;
2960
2961         fl_set_button(dialog_->check_personal_dict,
2962                       rc.isp_use_pers_dict);
2963         fl_set_input(dialog_->input_personal_dict, str.c_str());
2964
2965         fl_set_button(dialog_->check_compound_words,
2966                       rc.isp_accept_compound);
2967         fl_set_button(dialog_->check_input_enc,
2968                       rc.isp_use_input_encoding);
2969
2970         // Activate/Deactivate the input fields dependent on the state of the
2971         // buttons.
2972         input(0);
2973 }