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