2 * FormPreferences Interface Class Implementation
7 #include FORMS_H_LOCATION
10 #pragma implementation
13 #include "FormPreferences.h"
14 #include "form_preferences.h"
15 #include "input_validators.h"
21 #include "support/FileInfo.h"
22 #include "support/filetools.h"
23 #include "lyx_gui_misc.h"
25 #ifdef SIGC_CXX_NAMESPACES
30 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
31 : FormBaseBI(lv, d, _("Preferences"), new PreferencesPolicy),
32 dialog_(0), outputs_tab_(0), look_n_feel_tab_(0), inputs_tab_(0),
33 lnf_general_(0), screen_fonts_(0), interface_(0),
34 printer_(0), paths_(0), outputs_general_(0)
36 // let the dialog be shown
37 // This is a permanent connection so we won't bother
38 // storing a copy because we won't be disconnecting.
39 d->showPreferences.connect(slot(this, &FormPreferences::show));
43 FormPreferences::~FormPreferences()
46 delete look_n_feel_tab_;
54 delete outputs_general_;
58 void FormPreferences::hide()
60 // We need to hide the active tabfolder otherwise we get a
61 // BadDrawable error from X windows and LyX crashes without saving.
62 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder_prefs);
64 && outer_form->visible) {
65 fl_hide_form(outer_form);
71 void FormPreferences::build()
73 dialog_ = build_preferences();
75 // manage the restore, save, apply and cancel/close buttons
76 bc_.setOK(dialog_->button_ok);
77 bc_.setApply(dialog_->button_apply);
78 bc_.setCancel(dialog_->button_cancel);
79 bc_.setUndoAll(dialog_->button_restore);
82 // Workaround dumb xforms sizing bug
86 // build the tab folders
87 outputs_tab_ = build_outer_tab();
88 look_n_feel_tab_ = build_outer_tab();
89 inputs_tab_ = build_outer_tab();
91 // build actual tabfolder contents
92 // these will become nested tabfolders
93 screen_fonts_ = build_screen_fonts();
94 interface_ = build_interface();
95 lnf_general_ = build_lnf_general();
96 printer_ = build_printer();
97 paths_ = build_paths();
98 outputs_general_ = build_outputs_general();
100 // setup the input returns
102 fl_set_counter_return(lnf_general_->counter_autosave, FL_RETURN_CHANGED);
103 fl_set_counter_return(lnf_general_->counter_wm_jump, FL_RETURN_CHANGED);
105 fl_set_input_return(screen_fonts_->input_roman, FL_RETURN_CHANGED);
106 fl_set_input_return(screen_fonts_->input_sans, FL_RETURN_CHANGED);
107 fl_set_input_return(screen_fonts_->input_typewriter,
109 fl_set_input_return(screen_fonts_->input_screen_encoding,
111 fl_set_counter_return(screen_fonts_->counter_zoom, FL_RETURN_CHANGED);
112 fl_set_input_return(screen_fonts_->input_tiny, FL_RETURN_CHANGED);
113 fl_set_input_return(screen_fonts_->input_script, FL_RETURN_CHANGED);
114 fl_set_input_return(screen_fonts_->input_footnote, FL_RETURN_CHANGED);
115 fl_set_input_return(screen_fonts_->input_small, FL_RETURN_CHANGED);
116 fl_set_input_return(screen_fonts_->input_normal, FL_RETURN_CHANGED);
117 fl_set_input_return(screen_fonts_->input_large, FL_RETURN_CHANGED);
118 fl_set_input_return(screen_fonts_->input_larger, FL_RETURN_CHANGED);
119 fl_set_input_return(screen_fonts_->input_largest, FL_RETURN_CHANGED);
120 fl_set_input_return(screen_fonts_->input_huge, FL_RETURN_CHANGED);
121 fl_set_input_return(screen_fonts_->input_huger, FL_RETURN_CHANGED);
123 fl_set_input_return(interface_->input_popup_font,
125 fl_set_input_return(interface_->input_menu_font,
127 fl_set_input_return(interface_->input_popup_encoding,
129 fl_set_input_return(interface_->input_bind_file,
131 fl_set_input_return(interface_->input_ui_file,
134 fl_set_input_return(printer_->input_command, FL_RETURN_CHANGED);
135 fl_set_input_return(printer_->input_page_range, FL_RETURN_CHANGED);
136 fl_set_input_return(printer_->input_copies, FL_RETURN_CHANGED);
137 fl_set_input_return(printer_->input_reverse, FL_RETURN_CHANGED);
138 fl_set_input_return(printer_->input_to_printer, FL_RETURN_CHANGED);
139 fl_set_input_return(printer_->input_file_extension, FL_RETURN_CHANGED);
140 fl_set_input_return(printer_->input_spool_command, FL_RETURN_CHANGED);
141 fl_set_input_return(printer_->input_paper_type, FL_RETURN_CHANGED);
142 fl_set_input_return(printer_->input_even_pages, FL_RETURN_CHANGED);
143 fl_set_input_return(printer_->input_odd_pages, FL_RETURN_CHANGED);
144 fl_set_input_return(printer_->input_collated, FL_RETURN_CHANGED);
145 fl_set_input_return(printer_->input_landscape, FL_RETURN_CHANGED);
146 fl_set_input_return(printer_->input_to_file, FL_RETURN_CHANGED);
147 fl_set_input_return(printer_->input_extra_options, FL_RETURN_CHANGED);
148 fl_set_input_return(printer_->input_spool_prefix, FL_RETURN_CHANGED);
149 fl_set_input_return(printer_->input_paper_size, FL_RETURN_CHANGED);
150 fl_set_input_return(printer_->input_name, FL_RETURN_CHANGED);
152 fl_set_input_return(paths_->input_default_path, FL_RETURN_CHANGED);
153 fl_set_input_return(paths_->input_template_path, FL_RETURN_CHANGED);
154 fl_set_input_return(paths_->input_temp_dir, FL_RETURN_CHANGED);
155 fl_set_input_return(paths_->input_lastfiles, FL_RETURN_CHANGED);
156 fl_set_input_return(paths_->input_backup_path, FL_RETURN_CHANGED);
157 fl_set_counter_return(paths_->counter_lastfiles, FL_RETURN_CHANGED);
158 fl_set_input_return(paths_->input_serverpipe, FL_RETURN_CHANGED);
160 fl_set_counter_return(outputs_general_->counter_line_len,
163 // Now add them to the tabfolder
164 fl_addto_tabfolder(dialog_->tabfolder_prefs,
166 look_n_feel_tab_->form);
167 fl_addto_tabfolder(dialog_->tabfolder_prefs,
170 fl_addto_tabfolder(dialog_->tabfolder_prefs,
174 // now build the nested tabfolders
175 // Starting with look and feel
176 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
178 screen_fonts_->form);
179 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
182 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
187 // Paths should probably go in a few outer_tab called Files
188 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
192 // then building outputs
193 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
196 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
198 outputs_general_->form);
200 // deactivate the various browse buttons because they
201 // currently aren't implemented
202 fl_deactivate_object(interface_->button_bind_file_browse);
203 fl_deactivate_object(interface_->button_ui_file_browse);
204 fl_deactivate_object(paths_->button_document_browse);
205 fl_deactivate_object(paths_->button_template_browse);
206 fl_deactivate_object(paths_->button_temp_dir_browse);
207 fl_deactivate_object(paths_->button_lastfiles_browse);
208 fl_deactivate_object(paths_->button_backup_path_browse);
209 fl_deactivate_object(paths_->button_serverpipe_browse);
210 fl_set_object_lcol(interface_->button_bind_file_browse, FL_INACTIVE);
211 fl_set_object_lcol(interface_->button_ui_file_browse, FL_INACTIVE);
212 fl_set_object_lcol(paths_->button_document_browse, FL_INACTIVE);
213 fl_set_object_lcol(paths_->button_template_browse, FL_INACTIVE);
214 fl_set_object_lcol(paths_->button_temp_dir_browse, FL_INACTIVE);
215 fl_set_object_lcol(paths_->button_lastfiles_browse, FL_INACTIVE);
216 fl_set_object_lcol(paths_->button_backup_path_browse, FL_INACTIVE);
217 fl_set_object_lcol(paths_->button_serverpipe_browse, FL_INACTIVE);
221 FL_FORM * FormPreferences::form() const
223 if (dialog_) return dialog_->form;
228 void FormPreferences::apply()
230 // set the new lyxrc entries
231 // many of these need to trigger other functions when the assignment
232 // is made. For example, screen zoom and font types. These could be
233 // handled either by signals/slots in lyxrc or just directly call the
234 // associated functions here.
235 // There are other problems with this scheme. We really should check
236 // what we copy to make sure that it really is necessary to do things
237 // like update the screen fonts because that flushes the textcache
238 // and other stuff which may cost us a lot on slower/high-load machines.
240 // Look 'n Feel General tab
241 lyxrc.show_banner = fl_get_button(lnf_general_->check_banner);
242 lyxrc.auto_region_delete = fl_get_button(lnf_general_->
243 check_auto_region_delete);
244 lyxrc.exit_confirmation = fl_get_button(lnf_general_->check_exit_confirm);
245 lyxrc.display_shortcuts =
246 fl_get_button(lnf_general_->check_display_shortcuts);
247 lyxrc.new_ask_filename = fl_get_button(lnf_general_->check_ask_new_file);
248 lyxrc.cursor_follows_scrollbar =
249 fl_get_button(lnf_general_->check_cursor_follows_scrollbar);
250 lyxrc.autosave = static_cast<unsigned int>
251 (fl_get_counter_value(lnf_general_->counter_autosave));
252 lyxrc.wheel_jump = static_cast<unsigned int>
253 (fl_get_counter_value(lnf_general_->counter_wm_jump));
255 lyxrc.popup_font_name =
256 fl_get_input(interface_->input_popup_font);
257 lyxrc.menu_font_name = fl_get_input(interface_->input_menu_font);
258 lyxrc.font_norm_menu =
259 fl_get_input(interface_->input_popup_encoding);
260 lyxrc.bind_file = fl_get_input(interface_->input_bind_file);
261 lyxrc.ui_file = fl_get_input(interface_->input_ui_file);
262 lyxrc.override_x_deadkeys =
263 fl_get_button(interface_->check_override_x_dead_keys);
265 if (lyxrc.roman_font_name !=
266 fl_get_input(screen_fonts_->input_roman) ||
267 lyxrc.sans_font_name !=
268 fl_get_input(screen_fonts_->input_sans) ||
269 lyxrc.typewriter_font_name !=
270 fl_get_input(screen_fonts_->input_typewriter) ||
272 fl_get_input(screen_fonts_->input_screen_encoding) ||
273 lyxrc.use_scalable_fonts !=
274 fl_get_button(screen_fonts_->check_scalable) ||
275 lyxrc.zoom != static_cast<unsigned int>
276 (fl_get_counter_value(screen_fonts_->counter_zoom)) ||
277 lyxrc.font_sizes[LyXFont::SIZE_TINY] !=
278 strToDbl(fl_get_input(screen_fonts_->input_tiny)) ||
279 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] !=
280 strToDbl(fl_get_input(screen_fonts_->input_script)) ||
281 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] !=
282 strToDbl(fl_get_input(screen_fonts_->input_footnote)) ||
283 lyxrc.font_sizes[LyXFont::SIZE_SMALL] !=
284 strToDbl(fl_get_input(screen_fonts_->input_small)) ||
285 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] !=
286 strToDbl(fl_get_input(screen_fonts_->input_normal)) ||
287 lyxrc.font_sizes[LyXFont::SIZE_LARGE] !=
288 strToDbl(fl_get_input(screen_fonts_->input_large)) ||
289 lyxrc.font_sizes[LyXFont::SIZE_LARGER] !=
290 strToDbl(fl_get_input(screen_fonts_->input_larger)) ||
291 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] !=
292 strToDbl(fl_get_input(screen_fonts_->input_largest)) ||
293 lyxrc.font_sizes[LyXFont::SIZE_HUGE] !=
294 strToDbl(fl_get_input(screen_fonts_->input_huge)) ||
295 lyxrc.font_sizes[LyXFont::SIZE_HUGER] !=
296 strToDbl(fl_get_input(screen_fonts_->input_huger))) {
297 // Something has changed so copy all of them and then force
298 // an update of the screen fonts (ie. redraw every buffer)
299 lyxrc.roman_font_name = fl_get_input(screen_fonts_->input_roman);
300 lyxrc.sans_font_name = fl_get_input(screen_fonts_->input_sans);
301 lyxrc.typewriter_font_name = fl_get_input(screen_fonts_->
303 lyxrc.font_norm = fl_get_input(screen_fonts_->
304 input_screen_encoding);
305 lyxrc.use_scalable_fonts =
306 fl_get_button(screen_fonts_->check_scalable);
307 lyxrc.zoom = static_cast<unsigned int>
308 (fl_get_counter_value(screen_fonts_->counter_zoom));
309 lyxrc.font_sizes[LyXFont::SIZE_TINY] =
310 strToDbl(fl_get_input(screen_fonts_->input_tiny));
311 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] =
312 strToDbl(fl_get_input(screen_fonts_->input_script));
313 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] =
314 strToDbl(fl_get_input(screen_fonts_->input_footnote));
315 lyxrc.font_sizes[LyXFont::SIZE_SMALL] =
316 strToDbl(fl_get_input(screen_fonts_->input_small));
317 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] =
318 strToDbl(fl_get_input(screen_fonts_->input_normal));
319 lyxrc.font_sizes[LyXFont::SIZE_LARGE] =
320 strToDbl(fl_get_input(screen_fonts_->input_large));
321 lyxrc.font_sizes[LyXFont::SIZE_LARGER] =
322 strToDbl(fl_get_input(screen_fonts_->input_larger));
323 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] =
324 strToDbl(fl_get_input(screen_fonts_->input_largest));
325 lyxrc.font_sizes[LyXFont::SIZE_HUGE] =
326 strToDbl(fl_get_input(screen_fonts_->input_huge));
327 lyxrc.font_sizes[LyXFont::SIZE_HUGER] =
328 strToDbl(fl_get_input(screen_fonts_->input_huger));
329 // Now update the buffers
330 // Can anything below here affect the redraw process?
331 lv_->getLyXFunc()->Dispatch(LFUN_SCREEN_FONT_UPDATE);
334 lyxrc.print_adapt_output = fl_get_button(printer_->check_adapt_output);
335 lyxrc.print_command = fl_get_input(printer_->input_command);
336 lyxrc.print_pagerange_flag = fl_get_input(printer_->input_page_range);
337 lyxrc.print_copies_flag = fl_get_input(printer_->input_copies);
338 lyxrc.print_reverse_flag = fl_get_input(printer_->input_reverse);
339 lyxrc.print_to_printer = fl_get_input(printer_->input_to_printer);
340 lyxrc.print_file_extension =
341 fl_get_input(printer_->input_file_extension);
342 lyxrc.print_spool_command =
343 fl_get_input(printer_->input_spool_command);
344 lyxrc.print_paper_flag = fl_get_input(printer_->input_paper_type);
345 lyxrc.print_evenpage_flag = fl_get_input(printer_->input_even_pages);
346 lyxrc.print_oddpage_flag = fl_get_input(printer_->input_odd_pages);
347 lyxrc.print_collcopies_flag = fl_get_input(printer_->input_collated);
348 lyxrc.print_landscape_flag = fl_get_input(printer_->input_landscape);
349 lyxrc.print_to_file = fl_get_input(printer_->input_to_file);
350 lyxrc.print_extra_options =
351 fl_get_input(printer_->input_extra_options);
352 lyxrc.print_spool_printerprefix =
353 fl_get_input(printer_->input_spool_prefix);
354 lyxrc.print_paper_dimension_flag =
355 fl_get_input(printer_->input_paper_size);
356 lyxrc.printer = fl_get_input(printer_->input_name);
358 lyxrc.document_path = fl_get_input(paths_->input_default_path);
359 lyxrc.template_path = fl_get_input(paths_->input_template_path);
360 lyxrc.tempdir_path = fl_get_input(paths_->input_temp_dir);
361 lyxrc.lastfiles = fl_get_input(paths_->input_lastfiles);
362 lyxrc.backupdir_path = fl_get_input(paths_->input_backup_path);
363 lyxrc.use_tempdir = fl_get_button(paths_->check_use_temp_dir);
364 lyxrc.check_lastfiles = fl_get_button(paths_->check_last_files);
365 lyxrc.make_backup = fl_get_button(paths_->check_make_backups);
366 lyxrc.num_lastfiles = static_cast<unsigned int>
367 (fl_get_counter_value(paths_->counter_lastfiles));
368 lyxrc.lyxpipes = fl_get_input(paths_->input_serverpipe);
370 lyxrc.ascii_linelen = static_cast<unsigned int>
371 (fl_get_counter_value(outputs_general_->counter_line_len));
375 void FormPreferences::update()
378 // read lyxrc entries
380 fl_set_button(lnf_general_->check_banner,
382 fl_set_button(lnf_general_->check_auto_region_delete,
383 lyxrc.auto_region_delete);
384 fl_set_button(lnf_general_->check_exit_confirm,
385 lyxrc.exit_confirmation);
386 fl_set_button(lnf_general_->check_display_shortcuts,
387 lyxrc.display_shortcuts);
388 fl_set_button(lnf_general_->check_ask_new_file,
389 lyxrc.new_ask_filename);
390 fl_set_button(lnf_general_->check_cursor_follows_scrollbar,
391 lyxrc.cursor_follows_scrollbar);
392 fl_set_counter_value(lnf_general_->counter_autosave,
394 fl_set_counter_value(lnf_general_->counter_wm_jump,
397 fl_set_input(screen_fonts_->input_roman,
398 lyxrc.roman_font_name.c_str());
399 fl_set_input(screen_fonts_->input_sans,
400 lyxrc.sans_font_name.c_str());
401 fl_set_input(screen_fonts_->input_typewriter,
402 lyxrc.typewriter_font_name.c_str());
403 fl_set_input(screen_fonts_->input_screen_encoding,
404 lyxrc.font_norm.c_str());
405 fl_set_button(screen_fonts_->check_scalable,
406 lyxrc.use_scalable_fonts);
407 fl_set_counter_value(screen_fonts_->counter_zoom,
409 fl_set_input(screen_fonts_->input_tiny,
410 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
411 fl_set_input(screen_fonts_->input_script,
412 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
413 fl_set_input(screen_fonts_->input_footnote,
414 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
415 fl_set_input(screen_fonts_->input_small,
416 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
417 fl_set_input(screen_fonts_->input_normal,
418 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
419 fl_set_input(screen_fonts_->input_large,
420 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
421 fl_set_input(screen_fonts_->input_larger,
422 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
423 fl_set_input(screen_fonts_->input_largest,
424 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
425 fl_set_input(screen_fonts_->input_huge,
426 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
427 fl_set_input(screen_fonts_->input_huger,
428 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
430 fl_set_input(interface_->input_popup_font,
431 lyxrc.popup_font_name.c_str());
432 fl_set_input(interface_->input_menu_font,
433 lyxrc.menu_font_name.c_str());
434 fl_set_input(interface_->input_popup_encoding,
435 lyxrc.font_norm_menu.c_str());
436 fl_set_input(interface_->input_bind_file,
437 lyxrc.bind_file.c_str());
438 fl_set_input(interface_->input_ui_file,
439 lyxrc.ui_file.c_str());
440 fl_set_button(interface_->check_override_x_dead_keys,
441 lyxrc.override_x_deadkeys);
443 fl_set_button(printer_->check_adapt_output,
444 lyxrc.print_adapt_output);
445 fl_set_input(printer_->input_command,
446 lyxrc.print_command.c_str());
447 fl_set_input(printer_->input_page_range,
448 lyxrc.print_pagerange_flag.c_str());
449 fl_set_input(printer_->input_copies,
450 lyxrc.print_copies_flag.c_str());
451 fl_set_input(printer_->input_reverse,
452 lyxrc.print_reverse_flag.c_str());
453 fl_set_input(printer_->input_to_printer,
454 lyxrc.print_to_printer.c_str());
455 fl_set_input(printer_->input_file_extension,
456 lyxrc.print_file_extension.c_str());
457 fl_set_input(printer_->input_spool_command,
458 lyxrc.print_spool_command.c_str());
459 fl_set_input(printer_->input_paper_type,
460 lyxrc.print_paper_flag.c_str());
461 fl_set_input(printer_->input_even_pages,
462 lyxrc.print_evenpage_flag.c_str());
463 fl_set_input(printer_->input_odd_pages,
464 lyxrc.print_oddpage_flag.c_str());
465 fl_set_input(printer_->input_collated,
466 lyxrc.print_collcopies_flag.c_str());
467 fl_set_input(printer_->input_landscape,
468 lyxrc.print_landscape_flag.c_str());
469 fl_set_input(printer_->input_to_file,
470 lyxrc.print_to_file.c_str());
471 fl_set_input(printer_->input_extra_options,
472 lyxrc.print_extra_options.c_str());
473 fl_set_input(printer_->input_spool_prefix,
474 lyxrc.print_spool_printerprefix.c_str());
475 fl_set_input(printer_->input_paper_size,
476 lyxrc.print_paper_dimension_flag.c_str());
477 fl_set_input(printer_->input_name,
478 lyxrc.printer.c_str());
480 fl_set_input(paths_->input_default_path,
481 lyxrc.document_path.c_str());
482 fl_set_input(paths_->input_template_path,
483 lyxrc.template_path.c_str());
484 fl_set_input(paths_->input_temp_dir,
485 lyxrc.tempdir_path.c_str());
486 fl_set_input(paths_->input_lastfiles,
487 lyxrc.lastfiles.c_str());
488 fl_set_input(paths_->input_backup_path,
489 lyxrc.backupdir_path.c_str());
490 fl_set_button(paths_->check_use_temp_dir,
492 fl_set_button(paths_->check_last_files,
493 lyxrc.check_lastfiles);
494 fl_set_button(paths_->check_make_backups,
496 fl_set_counter_value(paths_->counter_lastfiles,
497 lyxrc.num_lastfiles);
498 fl_set_input(paths_->input_serverpipe, lyxrc.lyxpipes.c_str());
500 fl_set_counter_value(outputs_general_->counter_line_len,
501 lyxrc.ascii_linelen);
507 bool FormPreferences::input(FL_OBJECT *, long)
509 bool activate = true;
511 // whatever checks you need to ensure the user hasn't entered
512 // some totally ridiculous value somewhere. Change activate to suit.
513 // comments before each test describe what is _valid_
515 // input path -- dir should exist, be writable & absolute
516 if (!AbsolutePath(fl_get_input(paths_->input_default_path))
517 || 1 != IsDirWriteable(fl_get_input(paths_->input_default_path))) {
519 lyxerr[Debug::GUI] << "Preferences: input path is wrong\n";
523 // template_path should be a readable directory
524 string temp(fl_get_input(paths_->input_template_path));
526 if (!AbsolutePath(temp)
530 lyxerr[Debug::GUI] << "Preferences: template path is wrong\n";
535 // || writable directory
536 if (fl_get_button(paths_->check_use_temp_dir)
537 && (1 != IsDirWriteable(fl_get_input(paths_->input_temp_dir))
538 || !AbsolutePath(fl_get_input(paths_->input_temp_dir)))) {
540 lyxerr[Debug::GUI] << "Preferences: tmpdir is wrong\n";
543 // backupdir: not used
546 if (fl_get_button(paths_->check_make_backups)
547 && (!string(fl_get_input(paths_->input_backup_path)).empty()
548 && (1 != IsDirWriteable(fl_get_input(paths_->
550 || !AbsolutePath(fl_get_input(paths_->
551 input_backup_path))))) {
553 lyxerr[Debug::GUI] << "Preferences: backupdir is wrong\n";
556 // lastfiles: exists && writeable
557 // || non-existent && isn't a dir
559 #warning incorrectly allows files in /, other tests might also do this
562 string lastfiles(fl_get_input(paths_->input_lastfiles));
563 FileInfo lf(lastfiles);
564 if (!AbsolutePath(lastfiles)
565 || 1 != IsDirWriteable(OnlyPath(lastfiles))
568 || !lf.writable()))) {
570 lyxerr[Debug::GUI] << "Preferences: lastfiles is wrong\n";
575 // || non-existent && isn't a dir
576 // || exists && writeable
577 // remember we append .in and .out later
578 if (!string(fl_get_input(paths_->input_serverpipe)).empty()) {
579 string pipe(fl_get_input(paths_->input_serverpipe));
580 FileInfo sp_in(pipe + ".in");
581 FileInfo sp_out(pipe + ".out");
582 if (!AbsolutePath(pipe)
583 || 1 != IsDirWriteable(OnlyPath(pipe))
585 && (!sp_in.writable()
588 && (!sp_out.writable()
589 || sp_out.isDir()))) {
591 lyxerr[Debug::GUI] << "Preferences: Serverpipe is wrong\n";
595 // fontsizes -- tiny < script < footnote etc.
596 if (0.0 >= strToDbl(fl_get_input(screen_fonts_->input_tiny))
597 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_script))
598 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_footnote))
599 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_small))
600 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_normal))
601 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_large))
602 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_larger))
603 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_largest))
604 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_huge))
605 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_huger))) {
606 // make sure they all have positive entries
607 // Also note that an empty entry is returned as 0.0 by strToDbl
609 lyxerr[Debug::GUI] << "Preferences: Sizes are wrong\n";
610 } else if (strToDbl(fl_get_input(screen_fonts_->input_tiny)) >
611 strToDbl(fl_get_input(screen_fonts_->input_script)) ||
612 strToDbl(fl_get_input(screen_fonts_->input_script)) >
613 strToDbl(fl_get_input(screen_fonts_->input_footnote)) ||
614 strToDbl(fl_get_input(screen_fonts_->input_footnote)) >
615 strToDbl(fl_get_input(screen_fonts_->input_small)) ||
616 strToDbl(fl_get_input(screen_fonts_->input_small)) >
617 strToDbl(fl_get_input(screen_fonts_->input_normal)) ||
618 strToDbl(fl_get_input(screen_fonts_->input_normal)) >
619 strToDbl(fl_get_input(screen_fonts_->input_large)) ||
620 strToDbl(fl_get_input(screen_fonts_->input_large)) >
621 strToDbl(fl_get_input(screen_fonts_->input_larger)) ||
622 strToDbl(fl_get_input(screen_fonts_->input_larger)) >
623 strToDbl(fl_get_input(screen_fonts_->input_largest)) ||
624 strToDbl(fl_get_input(screen_fonts_->input_largest)) >
625 strToDbl(fl_get_input(screen_fonts_->input_huge)) ||
626 strToDbl(fl_get_input(screen_fonts_->input_huge)) >
627 strToDbl(fl_get_input(screen_fonts_->input_huger))) {
629 lyxerr[Debug::GUI] << "Preferences: Sizes are wrong\n";
636 void FormPreferences::ok()
639 lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES);
643 void FormPreferences::restore()
646 // if I add an error message line to the dialog it'll have to be controlled
647 // within input(). I don't need it yet so I'll leave it commented out.
648 // bc_.valid(input(0));