]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormPreferences.C
Added lyx-func tabular-feature for menu structure.
[lyx.git] / src / frontends / xforms / FormPreferences.C
1 /* FormPreferences.C
2  * FormPreferences Interface Class Implementation
3  */
4
5 #include <config.h>
6
7 #include FORMS_H_LOCATION
8
9 #ifdef __GNUG_
10 #pragma implementation
11 #endif
12
13 #include "FormPreferences.h"
14 #include "form_preferences.h"
15 #include "xform_macros.h"
16 #include "input_validators.h"
17 #include "LyXView.h"
18 #include "lyxfunc.h"
19 #include "Dialogs.h"
20 #include "lyxrc.h"
21 #include "debug.h"
22 #include "support/FileInfo.h"
23 #include "support/filetools.h"
24 #include "lyx_gui_misc.h"
25 #include "gettext.h"
26
27 #ifdef SIGC_CXX_NAMESPACES
28 using SigC::slot;
29 #endif
30
31 C_RETURNCB(FormPreferences,  WMHideCB)
32 C_GENERICCB(FormPreferences, OKCB)
33 C_GENERICCB(FormPreferences, ApplyCB)
34 C_GENERICCB(FormPreferences, CancelCB)
35 C_GENERICCB(FormPreferences, InputCB)
36
37
38 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
39         : dialog_(0), bind_(0), misc_(0), screen_fonts_(0),
40           interface_fonts_(0), printer_(0), paths_(0),
41           lv_(lv), d_(d), u_(0), h_(0), status(DIALOG_UNMODIFIED)
42 {
43         // let the dialog be shown
44         // This is a permanent connection so we won't bother
45         // storing a copy because we won't be disconnecting.
46         d->showPreferences.connect(slot(this,&FormPreferences::show));
47 }
48
49
50 FormPreferences::~FormPreferences()
51 {
52         free();
53 }
54
55
56 void FormPreferences::build()
57 {
58         dialog_ = build_preferences();
59         bind_ = build_bind();
60         screen_fonts_ = build_screen_fonts();
61         interface_fonts_ = build_interface_fonts();
62         misc_ = build_misc();
63         printer_ = build_printer();
64         paths_ = build_paths();
65
66         // setup the input returns
67         // Bind tab
68         fl_set_input_return(bind_->input_bind, FL_RETURN_CHANGED);
69         // Misc tab
70         fl_set_counter_return(misc_->counter_autosave, FL_RETURN_CHANGED);
71         fl_set_counter_return(misc_->counter_line_len, FL_RETURN_CHANGED);
72         // Screen fonts
73         fl_set_input_return(screen_fonts_->input_roman, FL_RETURN_CHANGED);
74         fl_set_input_return(screen_fonts_->input_sans, FL_RETURN_CHANGED);
75         fl_set_input_return(screen_fonts_->input_typewriter,
76                             FL_RETURN_CHANGED);
77         fl_set_input_return(screen_fonts_->input_encoding, FL_RETURN_CHANGED);
78         fl_set_counter_return(screen_fonts_->counter_zoom, FL_RETURN_CHANGED);
79         fl_set_input_return(screen_fonts_->input_tiny, FL_RETURN_CHANGED);
80         fl_set_input_return(screen_fonts_->input_script, FL_RETURN_CHANGED);
81         fl_set_input_return(screen_fonts_->input_footnote, FL_RETURN_CHANGED);
82         fl_set_input_return(screen_fonts_->input_small, FL_RETURN_CHANGED);
83         fl_set_input_return(screen_fonts_->input_normal, FL_RETURN_CHANGED);
84         fl_set_input_return(screen_fonts_->input_large, FL_RETURN_CHANGED);
85         fl_set_input_return(screen_fonts_->input_larger, FL_RETURN_CHANGED);
86         fl_set_input_return(screen_fonts_->input_largest, FL_RETURN_CHANGED);
87         fl_set_input_return(screen_fonts_->input_huge, FL_RETURN_CHANGED);
88         fl_set_input_return(screen_fonts_->input_huger, FL_RETURN_CHANGED);
89         // interface fonts
90         fl_set_input_return(interface_fonts_->input_popup_font,
91                             FL_RETURN_CHANGED);
92         fl_set_input_return(interface_fonts_->input_menu_font,
93                             FL_RETURN_CHANGED);
94         fl_set_input_return(interface_fonts_->input_encoding,
95                             FL_RETURN_CHANGED);
96         // printer
97         fl_set_input_return(printer_->input_command, FL_RETURN_CHANGED);
98         fl_set_input_return(printer_->input_page_range, FL_RETURN_CHANGED);
99         fl_set_input_return(printer_->input_copies, FL_RETURN_CHANGED);
100         fl_set_input_return(printer_->input_reverse, FL_RETURN_CHANGED);
101         fl_set_input_return(printer_->input_to_printer, FL_RETURN_CHANGED);
102         fl_set_input_return(printer_->input_file_extension, FL_RETURN_CHANGED);
103         fl_set_input_return(printer_->input_spool_command, FL_RETURN_CHANGED);
104         fl_set_input_return(printer_->input_paper_type, FL_RETURN_CHANGED);
105         fl_set_input_return(printer_->input_even_pages, FL_RETURN_CHANGED);
106         fl_set_input_return(printer_->input_odd_pages, FL_RETURN_CHANGED);
107         fl_set_input_return(printer_->input_collated, FL_RETURN_CHANGED);
108         fl_set_input_return(printer_->input_landscape, FL_RETURN_CHANGED);
109         fl_set_input_return(printer_->input_to_file, FL_RETURN_CHANGED);
110         fl_set_input_return(printer_->input_extra_options, FL_RETURN_CHANGED);
111         fl_set_input_return(printer_->input_spool_prefix, FL_RETURN_CHANGED);
112         fl_set_input_return(printer_->input_paper_size, FL_RETURN_CHANGED);
113         fl_set_input_return(printer_->input_name, FL_RETURN_CHANGED);
114         // paths
115         fl_set_input_return(paths_->input_default_path, FL_RETURN_CHANGED);
116         fl_set_input_return(paths_->input_template_path, FL_RETURN_CHANGED);
117         fl_set_input_return(paths_->input_temp_dir, FL_RETURN_CHANGED);
118         fl_set_input_return(paths_->input_lastfiles, FL_RETURN_CHANGED);
119         fl_set_input_return(paths_->input_backup_path, FL_RETURN_CHANGED);
120         fl_set_counter_return(paths_->counter_lastfiles, FL_RETURN_CHANGED);
121
122         // Now add them to the tabfolder
123         fl_addto_tabfolder(dialog_->tabfolder_prefs,
124                            _("Bindings"),
125                            bind_->form_bind);
126         fl_addto_tabfolder(dialog_->tabfolder_prefs,
127                            _("Screen Fonts"),
128                            screen_fonts_->form_screen_fonts);
129         fl_addto_tabfolder(dialog_->tabfolder_prefs,
130                            _("Interface Fonts"),
131                            interface_fonts_->form_interface_fonts);
132         fl_addto_tabfolder(dialog_->tabfolder_prefs,
133                            _("Miscellaneous"),
134                            misc_->form_misc);
135         fl_addto_tabfolder(dialog_->tabfolder_prefs,
136                            _("Printer"),
137                            printer_->form_printer);
138         fl_addto_tabfolder(dialog_->tabfolder_prefs,
139                            _("Paths"),
140                            paths_->form_paths);
141
142         fl_set_form_atclose(dialog_->form_preferences,
143                             C_FormPreferencesWMHideCB, 0);
144
145         // deactivate the various browse buttons because they
146         // currently aren't implemented
147         fl_deactivate_object(bind_->button_bind_file_browse);
148         fl_deactivate_object(paths_->button_document_browse);
149         fl_deactivate_object(paths_->button_template_browse);
150         fl_deactivate_object(paths_->button_temp_dir_browse);
151         fl_deactivate_object(paths_->button_lastfiles_browse);
152         fl_deactivate_object(paths_->button_backup_path_browse);
153         fl_set_object_lcol(bind_->button_bind_file_browse, FL_INACTIVE);
154         fl_set_object_lcol(paths_->button_document_browse, FL_INACTIVE);
155         fl_set_object_lcol(paths_->button_template_browse, FL_INACTIVE);
156         fl_set_object_lcol(paths_->button_temp_dir_browse, FL_INACTIVE);
157         fl_set_object_lcol(paths_->button_lastfiles_browse, FL_INACTIVE);
158         fl_set_object_lcol(paths_->button_backup_path_browse, FL_INACTIVE);
159 }
160
161
162 void FormPreferences::show()
163 {
164         if (!dialog_) {
165                 build();
166         }
167         update();  // make sure its up-to-date
168
169         if (dialog_->form_preferences->visible) {
170                 fl_raise_form(dialog_->form_preferences);
171         } else {
172                 status = DIALOG_UNMODIFIED;
173                 fl_deactivate_object(dialog_->button_ok);
174                 fl_deactivate_object(dialog_->button_apply);
175                 fl_set_object_lcol(dialog_->button_ok, FL_INACTIVE);
176                 fl_set_object_lcol(dialog_->button_apply, FL_INACTIVE);
177
178                 fl_show_form(dialog_->form_preferences,
179                              FL_PLACE_MOUSE | FL_FREE_SIZE,
180                              FL_FULLBORDER,
181                              _("Preferences"));
182         }
183 }
184
185
186 void FormPreferences::hide()
187 {
188         if (dialog_
189             && dialog_->form_preferences
190             && dialog_->form_preferences->visible) {
191                 fl_hide_form(dialog_->form_preferences);
192         }
193 }
194
195
196 void FormPreferences::apply()
197 {
198         // set the new lyxrc entries
199         // many of these need to trigger other functions when the assignment
200         // is made.  For example, screen zoom and font types.  These could be
201         // handled either by signals/slots in lyxrc or just directly call the
202         // associated functions here.
203
204         // Bind tab
205         lyxrc.bind_file = fl_get_input(bind_->input_bind);
206         // Misc tab
207         lyxrc.show_banner = fl_get_button(misc_->check_banner);
208         lyxrc.auto_region_delete = fl_get_button(misc_->
209                                                  check_auto_region_delete);
210         lyxrc.exit_confirmation = fl_get_button(misc_->check_exit_confirm);
211         lyxrc.display_shortcuts =
212                 fl_get_button(misc_->check_display_shortcuts);
213         lyxrc.autosave = static_cast<unsigned int>
214                 (fl_get_counter_value(misc_->counter_autosave));
215         lyxrc.ascii_linelen = static_cast<unsigned int>
216                 (fl_get_counter_value(misc_->counter_line_len));
217         // Screen fonts
218         lyxrc.roman_font_name = fl_get_input(screen_fonts_->input_roman);
219         lyxrc.sans_font_name = fl_get_input(screen_fonts_->input_sans);
220         lyxrc.typewriter_font_name = fl_get_input(screen_fonts_->
221                                                   input_typewriter);
222         lyxrc.font_norm = fl_get_input(screen_fonts_->input_encoding);
223         lyxrc.use_scalable_fonts =
224                 fl_get_button(screen_fonts_->check_scalable);
225         lyxrc.zoom = static_cast<unsigned int>
226                 (fl_get_counter_value(screen_fonts_->counter_zoom));
227         lyxrc.font_sizes[LyXFont::SIZE_TINY] = 
228                 strToDbl(fl_get_input(screen_fonts_->input_tiny));
229         lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] =
230                 strToDbl(fl_get_input(screen_fonts_->input_script));
231         lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] =
232                 strToDbl(fl_get_input(screen_fonts_->input_footnote));
233         lyxrc.font_sizes[LyXFont::SIZE_SMALL] =
234                 strToDbl(fl_get_input(screen_fonts_->input_small));
235         lyxrc.font_sizes[LyXFont::SIZE_NORMAL] =
236                 strToDbl(fl_get_input(screen_fonts_->input_normal));
237         lyxrc.font_sizes[LyXFont::SIZE_LARGE] =
238                 strToDbl(fl_get_input(screen_fonts_->input_large));
239         lyxrc.font_sizes[LyXFont::SIZE_LARGER] =
240                 strToDbl(fl_get_input(screen_fonts_->input_larger));
241         lyxrc.font_sizes[LyXFont::SIZE_LARGEST] =
242                 strToDbl(fl_get_input(screen_fonts_->input_largest));
243         lyxrc.font_sizes[LyXFont::SIZE_HUGE] =
244                 strToDbl(fl_get_input(screen_fonts_->input_huge));
245         lyxrc.font_sizes[LyXFont::SIZE_HUGER] =
246                 strToDbl(fl_get_input(screen_fonts_->input_huger));
247         // interface fonts
248         lyxrc.popup_font_name =
249                 fl_get_input(interface_fonts_->input_popup_font);
250         lyxrc.menu_font_name = fl_get_input(interface_fonts_->input_menu_font);
251         lyxrc.font_norm_menu = fl_get_input(interface_fonts_->input_encoding);
252         // printer
253         lyxrc.print_adapt_output = fl_get_button(printer_->check_adapt_output);
254         lyxrc.print_command = fl_get_input(printer_->input_command);
255         lyxrc.print_pagerange_flag = fl_get_input(printer_->input_page_range);
256         lyxrc.print_copies_flag = fl_get_input(printer_->input_copies);
257         lyxrc.print_reverse_flag = fl_get_input(printer_->input_reverse);
258         lyxrc.print_to_printer = fl_get_input(printer_->input_to_printer);
259         lyxrc.print_file_extension =
260                 fl_get_input(printer_->input_file_extension);
261         lyxrc.print_spool_command =
262                 fl_get_input(printer_->input_spool_command);
263         lyxrc.print_paper_flag = fl_get_input(printer_->input_paper_type);
264         lyxrc.print_evenpage_flag = fl_get_input(printer_->input_even_pages);
265         lyxrc.print_oddpage_flag = fl_get_input(printer_->input_odd_pages);
266         lyxrc.print_collcopies_flag = fl_get_input(printer_->input_collated);
267         lyxrc.print_landscape_flag = fl_get_input(printer_->input_landscape);
268         lyxrc.print_to_file = fl_get_input(printer_->input_to_file);
269         lyxrc.print_extra_options =
270                 fl_get_input(printer_->input_extra_options);
271         lyxrc.print_spool_printerprefix =
272                 fl_get_input(printer_->input_spool_prefix);
273         lyxrc.print_paper_dimension_flag =
274                 fl_get_input(printer_->input_paper_size);
275         lyxrc.printer = fl_get_input(printer_->input_name);
276         // paths
277         lyxrc.document_path = fl_get_input(paths_->input_default_path);
278         lyxrc.template_path = fl_get_input(paths_->input_template_path);
279         lyxrc.tempdir_path = fl_get_input(paths_->input_temp_dir);
280         lyxrc.lastfiles = fl_get_input(paths_->input_lastfiles);
281         lyxrc.backupdir_path = fl_get_input(paths_->input_backup_path);
282         lyxrc.use_tempdir = fl_get_button(paths_->check_use_temp_dir);
283         lyxrc.check_lastfiles = fl_get_button(paths_->check_last_files);
284         lyxrc.make_backup = fl_get_button(paths_->check_make_backups);
285         lyxrc.num_lastfiles = static_cast<unsigned int>
286                 (fl_get_counter_value(paths_->counter_lastfiles));
287 }
288
289
290 void FormPreferences::update()
291 {
292         if (dialog_) {
293                 // read lyxrc entries
294                 // Bind tab
295                 fl_set_input(bind_->input_bind, lyxrc.bind_file.c_str());
296                 // Misc tab
297                 fl_set_button(misc_->check_banner,
298                               lyxrc.show_banner);
299                 fl_set_button(misc_->check_auto_region_delete,
300                               lyxrc.auto_region_delete);
301                 fl_set_button(misc_->check_exit_confirm,
302                               lyxrc.exit_confirmation);
303                 fl_set_button(misc_->check_display_shortcuts,
304                               lyxrc.display_shortcuts);
305                 fl_set_counter_value(misc_->counter_autosave,
306                                      lyxrc.autosave);
307                 fl_set_counter_value(misc_->counter_line_len,
308                                      lyxrc.ascii_linelen);
309                 // Screen fonts
310                 fl_set_input(screen_fonts_->input_roman,
311                              lyxrc.roman_font_name.c_str());
312                 fl_set_input(screen_fonts_->input_sans,
313                              lyxrc.sans_font_name.c_str());
314                 fl_set_input(screen_fonts_->input_typewriter,
315                              lyxrc.typewriter_font_name.c_str());
316                 fl_set_input(screen_fonts_->input_encoding,
317                              lyxrc.font_norm.c_str());
318                 fl_set_button(screen_fonts_->check_scalable,
319                              lyxrc.use_scalable_fonts);
320                 fl_set_counter_value(screen_fonts_->counter_zoom,
321                              lyxrc.zoom);
322                 fl_set_input(screen_fonts_->input_tiny,
323                              tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
324                 fl_set_input(screen_fonts_->input_script,
325                              tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
326                 fl_set_input(screen_fonts_->input_footnote,
327                              tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
328                 fl_set_input(screen_fonts_->input_small,
329                              tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
330                 fl_set_input(screen_fonts_->input_normal,
331                              tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
332                 fl_set_input(screen_fonts_->input_large,
333                              tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
334                 fl_set_input(screen_fonts_->input_larger,
335                              tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
336                 fl_set_input(screen_fonts_->input_largest,
337                              tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
338                 fl_set_input(screen_fonts_->input_huge,
339                              tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
340                 fl_set_input(screen_fonts_->input_huger,
341                              tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
342                 // interface fonts
343                 fl_set_input(interface_fonts_->input_popup_font,
344                              lyxrc.popup_font_name.c_str());
345                 fl_set_input(interface_fonts_->input_menu_font,
346                              lyxrc.menu_font_name.c_str());
347                 fl_set_input(interface_fonts_->input_encoding,
348                              lyxrc.font_norm_menu.c_str());
349                 // printer
350                 fl_set_button(printer_->check_adapt_output,
351                               lyxrc.print_adapt_output);
352                 fl_set_input(printer_->input_command,
353                              lyxrc.print_command.c_str());
354                 fl_set_input(printer_->input_page_range,
355                              lyxrc.print_pagerange_flag.c_str());
356                 fl_set_input(printer_->input_copies,
357                              lyxrc.print_copies_flag.c_str());
358                 fl_set_input(printer_->input_reverse,
359                               lyxrc.print_reverse_flag.c_str());
360                 fl_set_input(printer_->input_to_printer,
361                              lyxrc.print_to_printer.c_str());
362                 fl_set_input(printer_->input_file_extension,
363                              lyxrc.print_file_extension.c_str());
364                 fl_set_input(printer_->input_spool_command,
365                              lyxrc.print_spool_command.c_str());
366                 fl_set_input(printer_->input_paper_type,
367                              lyxrc.print_paper_flag.c_str());
368                 fl_set_input(printer_->input_even_pages,
369                              lyxrc.print_evenpage_flag.c_str());
370                 fl_set_input(printer_->input_odd_pages,
371                              lyxrc.print_oddpage_flag.c_str());
372                 fl_set_input(printer_->input_collated,
373                              lyxrc.print_collcopies_flag.c_str());
374                 fl_set_input(printer_->input_landscape,
375                              lyxrc.print_landscape_flag.c_str());
376                 fl_set_input(printer_->input_to_file,
377                              lyxrc.print_to_file.c_str());
378                 fl_set_input(printer_->input_extra_options,
379                              lyxrc.print_extra_options.c_str());
380                 fl_set_input(printer_->input_spool_prefix,
381                              lyxrc.print_spool_printerprefix.c_str());
382                 fl_set_input(printer_->input_paper_size,
383                              lyxrc.print_paper_dimension_flag.c_str());
384                 fl_set_input(printer_->input_name,
385                              lyxrc.printer.c_str());
386                 // paths
387                 fl_set_input(paths_->input_default_path,
388                              lyxrc.document_path.c_str());
389                 fl_set_input(paths_->input_template_path,
390                              lyxrc.template_path.c_str());
391                 fl_set_input(paths_->input_temp_dir,
392                              lyxrc.tempdir_path.c_str());
393                 fl_set_input(paths_->input_lastfiles,
394                              lyxrc.lastfiles.c_str());
395                 fl_set_input(paths_->input_backup_path,
396                              lyxrc.backupdir_path.c_str());
397                 fl_set_button(paths_->check_use_temp_dir,
398                               lyxrc.use_tempdir);
399                 fl_set_button(paths_->check_last_files,
400                               lyxrc.check_lastfiles);           
401                 fl_set_button(paths_->check_make_backups,
402                               lyxrc.make_backup);
403                 fl_set_counter_value(paths_->counter_lastfiles,
404                                      lyxrc.num_lastfiles);
405         }
406 }
407
408
409 void FormPreferences::input()
410 {
411         bool activate = true;
412         //
413         // whatever checks you need to ensure the user hasn't entered
414         // some totally ridiculous value somewhere.  Change activate to suit.
415         //
416         // Examples:
417         //  paths -- all dirs in the path should exist, be writable & absolute
418         if (!AbsolutePath(fl_get_input(paths_->input_default_path))
419             || 1 != IsDirWriteable(fl_get_input(paths_->input_default_path))
420             || !AbsolutePath(fl_get_input(paths_->input_template_path))
421             || 1 != IsDirWriteable(fl_get_input(paths_->input_template_path))
422             // lastfiles: exists && writeable || non-existent && isn't a dir
423             // NOTE: assumes IsFileWriteable == -1 means non-existent hence
424             //       the extra check to see if its a directory
425             || !AbsolutePath(fl_get_input(paths_->input_lastfiles))
426             || 1 != IsDirWriteable(OnlyPath(fl_get_input(paths_->
427                                                          input_lastfiles)))
428             || 0 == IsFileWriteable(OnlyPath(fl_get_input(paths_->
429                                                           input_lastfiles)))
430             || FileInfo(fl_get_input(paths_->input_lastfiles)).isDir()
431             // tmpdir: only check if we are using it
432             || (fl_get_button(paths_->check_use_temp_dir)
433                 && (1 != IsDirWriteable(fl_get_input(paths_->input_temp_dir))
434                     || !AbsolutePath(fl_get_input(paths_->input_temp_dir))))
435             // backupdir: can safely be left empty
436             || (fl_get_button(paths_->check_make_backups)
437                 && (!string(fl_get_input(paths_->input_backup_path)).empty()
438                     && (1 != IsDirWriteable(fl_get_input(paths_->
439                                                         input_backup_path))
440                         || !AbsolutePath(fl_get_input(paths_->
441                                                       input_backup_path)))))) {
442                 activate = false;
443         }
444
445         //  fontsizes -- tiny < script < footnote etc.
446         if (0.0 >= strToDbl(fl_get_input(screen_fonts_->input_tiny))
447             || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_script))
448             || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_footnote))
449             || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_small))
450             || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_normal))
451             || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_large))
452             || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_larger))
453             || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_largest))
454             || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_huge))
455             || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_huger))) {
456                 // make sure they all have positive entries
457                 // Also note that an empty entry is returned as 0.0 by strToDbl
458                 activate = false;
459         } else if (strToDbl(fl_get_input(screen_fonts_->input_tiny)) >
460                    strToDbl(fl_get_input(screen_fonts_->input_script)) ||
461                    strToDbl(fl_get_input(screen_fonts_->input_script)) >
462                    strToDbl(fl_get_input(screen_fonts_->input_footnote)) ||
463                    strToDbl(fl_get_input(screen_fonts_->input_footnote)) >
464                    strToDbl(fl_get_input(screen_fonts_->input_small)) ||
465                    strToDbl(fl_get_input(screen_fonts_->input_small)) >
466                    strToDbl(fl_get_input(screen_fonts_->input_normal)) ||
467                    strToDbl(fl_get_input(screen_fonts_->input_normal)) >
468                    strToDbl(fl_get_input(screen_fonts_->input_large)) ||
469                    strToDbl(fl_get_input(screen_fonts_->input_large)) >
470                    strToDbl(fl_get_input(screen_fonts_->input_larger)) ||
471                    strToDbl(fl_get_input(screen_fonts_->input_larger)) >
472                    strToDbl(fl_get_input(screen_fonts_->input_largest)) ||
473                    strToDbl(fl_get_input(screen_fonts_->input_largest)) >
474                    strToDbl(fl_get_input(screen_fonts_->input_huge)) ||
475                    strToDbl(fl_get_input(screen_fonts_->input_huge)) >
476                    strToDbl(fl_get_input(screen_fonts_->input_huger))) {
477                 activate = false;
478         }
479
480         //
481         // You can modify the dialog and still have the buttons disabled
482         status = DIALOG_MODIFIED;
483
484         if (status == DIALOG_MODIFIED
485             && activate) {
486                 fl_activate_object(dialog_->button_ok);
487                 fl_activate_object(dialog_->button_apply);
488                 fl_set_object_lcol(dialog_->button_ok, FL_BLACK);
489                 fl_set_object_lcol(dialog_->button_apply, FL_BLACK);
490         } else {
491                 fl_deactivate_object(dialog_->button_ok);
492                 fl_deactivate_object(dialog_->button_apply);
493                 fl_set_object_lcol(dialog_->button_ok, FL_INACTIVE);
494                 fl_set_object_lcol(dialog_->button_apply, FL_INACTIVE);
495         }
496 }
497
498
499 void FormPreferences::free()
500 {
501         // we don't need to delete u and h here because
502         // hide() does that after disconnecting.
503         if (dialog_) {
504                 if (dialog_->form_preferences
505                     && dialog_->form_preferences->visible) {
506                         hide();
507                 }
508                 fl_free_form(dialog_->form_preferences);
509                 delete dialog_;
510                 dialog_ = 0;
511         }
512 }
513
514
515 int FormPreferences::WMHideCB(FL_FORM * form, void *)
516 {
517         // Ensure that the signals (u and h) are disconnected even if the
518         // window manager is used to close the dialog.
519         FormPreferences * pre = static_cast<FormPreferences*>(form->u_vdata);
520         pre->hide();
521         return FL_CANCEL;
522 }
523
524
525 void FormPreferences::OKCB(FL_OBJECT * ob, long)
526 {
527         FormPreferences * pre = static_cast<FormPreferences*>(ob->form->u_vdata);
528         pre->apply();
529         pre->hide();
530
531         pre->lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES);
532 }
533
534
535 void FormPreferences::ApplyCB(FL_OBJECT * ob, long)
536 {
537         FormPreferences * pre = static_cast<FormPreferences*>(ob->form->u_vdata);
538         pre->apply();
539 }
540
541
542 void FormPreferences::CancelCB(FL_OBJECT * ob, long)
543 {
544         FormPreferences * pre = static_cast<FormPreferences*>(ob->form->u_vdata);
545         pre->hide();
546 }
547
548
549 void FormPreferences::InputCB(FL_OBJECT * ob, long)
550 {
551         FormPreferences * pre = static_cast<FormPreferences*>(ob->form->u_vdata);
552         pre->input();
553 }