2 * FormPreferences Interface Class Implementation
7 #include FORMS_H_LOCATION
10 #pragma implementation
15 #include "FormPreferences.h"
16 #include "form_preferences.h"
17 #include "input_validators.h"
24 #include "support/FileInfo.h"
25 #include "support/filetools.h"
26 #include "lyx_gui_misc.h"
28 #ifdef SIGC_CXX_NAMESPACES
35 extern Languages languages;
36 static vector<string> languageNames;
38 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
39 : FormBaseBI(lv, d, _("Preferences"), new PreferencesPolicy),
40 dialog_(0), outputs_tab_(0), look_n_feel_tab_(0), inputs_tab_(0),
41 usage_tab_(0), colours_(0), inputs_misc_(0), interface_(0),
42 language_(0), lnf_misc_(0), outputs_misc_(0), paths_(0), printer_(0),
43 screen_fonts_(0), spellchecker_(0)
45 // let the dialog be shown
46 // This is a permanent connection so we won't bother
47 // storing a copy because we won't be disconnecting.
48 d->showPreferences.connect(slot(this, &FormPreferences::show));
52 FormPreferences::~FormPreferences()
55 delete look_n_feel_tab_;
72 FL_FORM * FormPreferences::form() const
74 if (dialog_) return dialog_->form;
79 void FormPreferences::ok()
82 lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES);
86 void FormPreferences::restore()
89 // if I add an error message line to the dialog it'll have to be controlled
90 // within input(). I don't need it yet so I'll leave it commented out.
91 // bc_.valid(input(0));
95 void FormPreferences::hide()
97 // We need to hide the active tabfolder otherwise we get a
98 // BadDrawable error from X windows and LyX crashes without saving.
99 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder_prefs);
101 && outer_form->visible) {
102 fl_hide_form(outer_form);
108 void FormPreferences::build()
110 dialog_ = build_preferences();
112 // manage the restore, save, apply and cancel/close buttons
113 bc_.setOK(dialog_->button_ok);
114 bc_.setApply(dialog_->button_apply);
115 bc_.setCancel(dialog_->button_cancel);
116 bc_.setUndoAll(dialog_->button_restore);
119 // Workaround dumb xforms sizing bug
123 // build the tab folders
124 outputs_tab_ = build_outer_tab();
125 look_n_feel_tab_ = build_outer_tab();
126 inputs_tab_ = build_outer_tab();
127 usage_tab_ = build_outer_tab();
129 // build actual tabfolder contents
130 // these will become nested tabfolders
142 // Now add them to the tabfolder
143 fl_addto_tabfolder(dialog_->tabfolder_prefs,
145 look_n_feel_tab_->form);
146 fl_addto_tabfolder(dialog_->tabfolder_prefs,
149 fl_addto_tabfolder(dialog_->tabfolder_prefs,
152 fl_addto_tabfolder(dialog_->tabfolder_prefs,
156 // now build the nested tabfolders
157 // Starting with look and feel
158 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
160 screen_fonts_->form);
161 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
164 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
167 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
172 // Paths should probably go in a few outer_tab called Files
173 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
176 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
180 // then building outputs
181 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
184 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
186 outputs_misc_->form);
188 // then building usage
189 fl_addto_tabfolder(usage_tab_->tabfolder_outer,
191 spellchecker_->form);
192 fl_addto_tabfolder(usage_tab_->tabfolder_outer,
198 void FormPreferences::apply()
200 // set the new lyxrc entries
201 // many of these need to trigger other functions when the assignment
202 // is made. For example, screen zoom and font types. These could be
203 // handled either by signals/slots in lyxrc or just directly call the
204 // associated functions here.
205 // There are other problems with this scheme. We really should check
206 // what we copy to make sure that it really is necessary to do things
207 // like update the screen fonts because that flushes the textcache
208 // and other stuff which may cost us a lot on slower/high-load machines.
223 void FormPreferences::update()
225 if (!dialog_) return;
227 // read lyxrc entries
237 updateSpellChecker();
241 bool FormPreferences::input(FL_OBJECT * ob, long data)
243 bool activate = true;
245 // Remove any existing messages
246 fl_set_object_label(dialog_->text_warning, " ");
248 // whatever checks you need to ensure the user hasn't entered
249 // some totally ridiculous value somewhere. Change activate to suit.
250 // comments before each test describe what is _valid_
252 State cb = static_cast<State>( data );
255 feedbackColours( ob );
259 feedbackInputsMisc( ob );
263 feedbackInterface( ob );
267 feedbackLanguage( ob );
268 if( ! inputLanguage( ob ) )
273 feedbackLnFmisc( ob );
277 feedbackOutputsMisc( ob );
282 if( ! inputPaths( ob ) )
287 feedbackPrinter( ob );
291 feedbackScreenFonts( ob );
292 if( ! inputScreenFonts() )
297 feedbackSpellChecker( ob );
298 if( ! inputSpellChecker( ob ) )
310 void FormPreferences::applyColours()
315 void FormPreferences::buildColours()
317 colours_ = build_colours();
321 void FormPreferences::feedbackColours( FL_OBJECT const * const )
326 void FormPreferences::updateColours()
331 void FormPreferences::applyInputsMisc()
333 lyxrc.date_insert_format = fl_get_input(inputs_misc_->input_date_format);
337 void FormPreferences::buildInputsMisc()
339 inputs_misc_ = build_inputs_misc();
341 fl_set_input_return(inputs_misc_->input_date_format,
346 void FormPreferences::feedbackInputsMisc( FL_OBJECT const * const ob )
350 if( ob == inputs_misc_->input_date_format ) {
351 str = N_("This accepts the normal strftime formats; see man strftime for full details.\nE.g.\"%A, %e. %B %Y\".");
354 fl_set_object_label(dialog_->text_warning, str.c_str());
355 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
359 void FormPreferences::updateInputsMisc()
361 fl_set_input(inputs_misc_->input_date_format,
362 lyxrc.date_insert_format.c_str());
366 void FormPreferences::applyInterface()
368 lyxrc.popup_font_name =
369 fl_get_input(interface_->input_popup_font);
370 lyxrc.menu_font_name = fl_get_input(interface_->input_menu_font);
371 lyxrc.font_norm_menu =
372 fl_get_input(interface_->input_popup_encoding);
373 lyxrc.bind_file = fl_get_input(interface_->input_bind_file);
374 lyxrc.ui_file = fl_get_input(interface_->input_ui_file);
375 lyxrc.override_x_deadkeys =
376 fl_get_button(interface_->check_override_x_dead_keys);
380 void FormPreferences::buildInterface()
382 interface_ = build_interface();
384 fl_set_input_return(interface_->input_popup_font, FL_RETURN_CHANGED);
385 fl_set_input_return(interface_->input_menu_font, FL_RETURN_CHANGED);
386 fl_set_input_return(interface_->input_popup_encoding,
388 fl_set_input_return(interface_->input_bind_file, FL_RETURN_CHANGED);
389 fl_set_input_return(interface_->input_ui_file, FL_RETURN_CHANGED);
391 // deactivate the browse buttons because they aren't implemented
392 fl_deactivate_object(interface_->button_bind_file_browse);
393 fl_deactivate_object(interface_->button_ui_file_browse);
394 fl_set_object_lcol(interface_->button_bind_file_browse, FL_INACTIVE);
395 fl_set_object_lcol(interface_->button_ui_file_browse, FL_INACTIVE);
399 void FormPreferences::feedbackInterface( FL_OBJECT const * const ob )
403 if( ob == interface_->input_popup_font ) {
404 str = N_("The font for popups.");
405 } else if ( ob == interface_->input_menu_font ) {
406 str = N_("The font for menus (and groups titles in popups).");
407 } else if ( ob == interface_->input_popup_encoding ) {
408 str = N_("The norm for the menu/popups fonts.");
409 } else if ( ob == interface_->input_bind_file ) {
410 str = N_("Keybindings file. Can either specify an absolute path,\nor LyX will look in its global and local bind/ directories.");
411 } else if ( ob == interface_->input_ui_file ) {
412 str = N_("The UI (user interface) file. Can either specify an absolute path,\nor LyX will look in its global and local ui/ directories.");
413 } else if ( ob == interface_->check_override_x_dead_keys ) {
414 str = N_("Set to true for LyX to take over the handling of the dead keys\n(a.k.a accent keys) that may be defined for your keyboard.");
417 fl_set_object_label(dialog_->text_warning, str.c_str());
418 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
422 void FormPreferences::updateInterface()
424 fl_set_input(interface_->input_popup_font,
425 lyxrc.popup_font_name.c_str());
426 fl_set_input(interface_->input_menu_font,
427 lyxrc.menu_font_name.c_str());
428 fl_set_input(interface_->input_popup_encoding,
429 lyxrc.font_norm_menu.c_str());
430 fl_set_input(interface_->input_bind_file,
431 lyxrc.bind_file.c_str());
432 fl_set_input(interface_->input_ui_file,
433 lyxrc.ui_file.c_str());
434 fl_set_button(interface_->check_override_x_dead_keys,
435 lyxrc.override_x_deadkeys);
439 void FormPreferences::applyLanguage()
441 vector<string>::size_type choice =
442 fl_get_choice(language_->choice_default_lang) - 1;
443 lyxrc.default_language = languageNames[choice];
445 int button = fl_get_button(language_->check_use_kbmap);
446 lyxrc.use_kbmap = static_cast<bool>(button);
449 choice = fl_get_choice(language_->choice_kbmap_1) - 1;
450 lyxrc.primary_kbmap = languageNames[choice];
452 choice = fl_get_choice(language_->choice_kbmap_2) - 1;
453 lyxrc.secondary_kbmap = languageNames[choice];
456 button = fl_get_button(language_->check_rtl_support);
457 lyxrc.rtl_support = static_cast<bool>(button);
459 button = fl_get_button(language_->check_auto_begin);
460 lyxrc.language_auto_begin = static_cast<bool>(button);
462 button = fl_get_button(language_->check_auto_end);
463 lyxrc.language_auto_end = static_cast<bool>(button);
465 button = fl_get_button(language_->check_mark_foreign);
466 lyxrc.mark_foreign_language = static_cast<bool>(button);
468 lyxrc.language_package = fl_get_input(language_->input_package);
469 lyxrc.language_command_begin = fl_get_input(language_->input_command_begin);
470 lyxrc.language_command_end = fl_get_input(language_->input_command_end);
474 void FormPreferences::buildLanguage()
476 language_ = build_language();
478 fl_set_input_return(language_->input_package, FL_RETURN_CHANGED);
479 fl_set_input_return(language_->input_command_begin, FL_RETURN_CHANGED);
480 fl_set_input_return(language_->input_command_end, FL_RETURN_CHANGED);
482 // Only do this the first time buildLanguage() is called.
483 if( languageNames.empty() ) {
484 for( Languages::const_iterator lang = languages.begin();
485 lang != languages.end(); lang++ ) {
486 languageNames.push_back( (*lang).second.lang() );
490 string names = " " + languageNames.front();
491 for( vector<string>::const_iterator lang = languageNames.begin();
492 lang != languageNames.end(); ++lang ) {
493 names += " | " + (*lang);
497 fl_addto_choice(language_->choice_default_lang, names.c_str());
498 fl_addto_choice(language_->choice_kbmap_1, names.c_str());
499 fl_addto_choice(language_->choice_kbmap_2, names.c_str());
503 void FormPreferences::feedbackLanguage( FL_OBJECT const * const ob )
507 if( ob == language_->choice_default_lang ) {
508 str = N_("New documents will be assigned this language.");
509 } else if( ob == language_->check_use_kbmap
510 || ob == language_->choice_kbmap_1
511 || ob == language_->choice_kbmap_2 ) {
512 str = N_("Use this to set the correct mapping file for your keyboard.\nYou'll need this if you for instance want to type German documents\non an American keyboard.");
513 } else if( ob == language_->check_rtl_support ) {
514 str = N_("Use to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
515 } else if( ob == language_->check_auto_begin ) {
516 str = N_("Use if a language switching command is needed at the beginning\nof the document.");
517 } else if( ob == language_->check_auto_end ) {
518 str = N_("Use if a language switching command is needed at the end\nof the document.");
519 } else if( ob == language_->check_mark_foreign ) {
520 str = N_("Use to control the highlighting of words with a language foreign to\nthat of the document.");
521 } else if( ob == language_->input_package ) {
522 str = N_("The latex command for loading the language package.\nE.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
523 } else if( ob == language_->input_command_begin ) {
524 str = N_("The latex command for changing from the language of the document\nto another language.\nE.g. \\selectlanguage{$$lang} where $$lang is substituted by the name\nof the second language.");
525 } else if( ob == language_->input_command_end ) {
526 str = N_("The latex command for changing back to the language of the document.");
529 fl_set_object_label(dialog_->text_warning, str.c_str());
530 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
534 bool FormPreferences::inputLanguage( FL_OBJECT const * const ob )
536 bool activate = true;
538 if( !ob || ob == language_->check_use_kbmap ) {
539 if( fl_get_button(language_->check_use_kbmap) ) {
540 fl_activate_object(language_->choice_kbmap_1);
541 fl_activate_object(language_->choice_kbmap_2);
542 fl_set_object_lcol(language_->choice_kbmap_1,
544 fl_set_object_lcol(language_->choice_kbmap_2,
547 fl_deactivate_object(language_->choice_kbmap_1);
548 fl_deactivate_object(language_->choice_kbmap_2);
549 fl_set_object_lcol(language_->choice_kbmap_1,
551 fl_set_object_lcol(language_->choice_kbmap_2,
560 void FormPreferences::updateLanguage()
562 fl_set_button(language_->check_use_kbmap,
565 vector<string>::iterator it =
566 find( languageNames.begin(), languageNames.end(),
567 lyxrc.default_language );
569 if( it != languageNames.end() )
570 choice = static_cast<int>( it - languageNames.begin() );
572 fl_set_choice(language_->choice_default_lang, choice+1);
574 it = find( languageNames.begin(), languageNames.end(),
575 lyxrc.primary_kbmap );
577 if( it != languageNames.end() )
578 choice = static_cast<int>( it - languageNames.begin() );
580 fl_set_choice(language_->choice_kbmap_1, choice+1);
582 it = find( languageNames.begin(), languageNames.end(),
583 lyxrc.secondary_kbmap );
585 if( it != languageNames.end() )
586 choice = static_cast<int>( it - languageNames.begin() );
588 fl_set_choice(language_->choice_kbmap_2, choice+1);
590 fl_set_button(language_->check_rtl_support, lyxrc.rtl_support);
591 fl_set_button(language_->check_auto_begin, lyxrc.language_auto_begin);
592 fl_set_button(language_->check_auto_end, lyxrc.language_auto_end);
593 fl_set_button(language_->check_mark_foreign,
594 lyxrc.mark_foreign_language);
596 fl_set_input(language_->input_package,
597 lyxrc.language_package.c_str());
598 fl_set_input(language_->input_command_begin,
599 lyxrc.language_command_begin.c_str());
600 fl_set_input(language_->input_command_end,
601 lyxrc.language_command_end.c_str());
603 // Activate/Deactivate the input fields dependent on the state of the
609 void FormPreferences::applyLnFmisc()
611 lyxrc.show_banner = fl_get_button(lnf_misc_->check_banner);
612 lyxrc.auto_region_delete = fl_get_button(lnf_misc_->
613 check_auto_region_delete);
614 lyxrc.exit_confirmation = fl_get_button(lnf_misc_->check_exit_confirm);
615 lyxrc.display_shortcuts =
616 fl_get_button(lnf_misc_->check_display_shortcuts);
617 lyxrc.new_ask_filename = fl_get_button(lnf_misc_->check_ask_new_file);
618 lyxrc.cursor_follows_scrollbar =
619 fl_get_button(lnf_misc_->check_cursor_follows_scrollbar);
620 lyxrc.autosave = static_cast<unsigned int>
621 (fl_get_counter_value(lnf_misc_->counter_autosave));
622 lyxrc.wheel_jump = static_cast<unsigned int>
623 (fl_get_counter_value(lnf_misc_->counter_wm_jump));
627 void FormPreferences::buildLnFmisc()
629 lnf_misc_ = build_lnf_misc();
631 fl_set_counter_return(lnf_misc_->counter_autosave,
633 fl_set_counter_return(lnf_misc_->counter_wm_jump,
638 void FormPreferences::feedbackLnFmisc( FL_OBJECT const * const ob )
642 if( ob == lnf_misc_->check_banner ) {
643 str = N_("Set to false if you don't want the startup banner.");
644 } else if( ob == lnf_misc_->check_auto_region_delete ) {
645 str = N_("Set to false if you don't want the current selection to be replaced\nautomatically by what you type.");
646 } else if( ob == lnf_misc_->check_exit_confirm ) {
647 str = N_("Sets whether LyX asks for a second confirmation to exit when you have\nchanged documents.\n(LyX will still ask to save changed documents.)");
648 } else if( ob == lnf_misc_->check_display_shortcuts ) {
649 str = N_("LyX continously displays names of last command executed,\nalong with a list of defined short-cuts for it in the minibuffer.\nSet to false if LyX seems slow.");
650 } else if( ob == lnf_misc_->check_ask_new_file ) {
651 str = N_("This sets the behaviour if you want to be asked for a filename when\ncreating a new document or wait until you save it and be asked then.");
652 } else if( ob == lnf_misc_->check_cursor_follows_scrollbar ) {
653 str = N_("LyX normally doesn't update the cursor position if you move the scrollbar.\nSet to true if you'd prefer to always have the cursor on screen.");
654 } else if( ob == lnf_misc_->counter_autosave ) {
655 str = N_("The time interval between auto-saves (in seconds).\n0 means no auto-save");
656 } else if( ob == lnf_misc_->counter_wm_jump ) {
657 str = N_("The wheel movement factor (for mice with wheels or five button mice)");
660 fl_set_object_label(dialog_->text_warning, str.c_str());
661 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
664 void FormPreferences::updateLnFmisc()
666 fl_set_button(lnf_misc_->check_banner,
668 fl_set_button(lnf_misc_->check_auto_region_delete,
669 lyxrc.auto_region_delete);
670 fl_set_button(lnf_misc_->check_exit_confirm,
671 lyxrc.exit_confirmation);
672 fl_set_button(lnf_misc_->check_display_shortcuts,
673 lyxrc.display_shortcuts);
674 fl_set_button(lnf_misc_->check_ask_new_file,
675 lyxrc.new_ask_filename);
676 fl_set_button(lnf_misc_->check_cursor_follows_scrollbar,
677 lyxrc.cursor_follows_scrollbar);
678 fl_set_counter_value(lnf_misc_->counter_autosave,
680 fl_set_counter_value(lnf_misc_->counter_wm_jump,
685 void FormPreferences::applyOutputsMisc()
687 lyxrc.ascii_linelen = static_cast<unsigned int>
688 (fl_get_counter_value(outputs_misc_->counter_line_len));
689 lyxrc.fontenc = fl_get_input(outputs_misc_->input_tex_encoding);
692 fl_get_choice(outputs_misc_->choice_default_papersize) - 1;
693 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
695 lyxrc.ascii_roff_command = fl_get_input(outputs_misc_->input_ascii_roff);
696 lyxrc.chktex_command = fl_get_input(outputs_misc_->input_checktex);
700 void FormPreferences::buildOutputsMisc()
702 outputs_misc_ = build_outputs_misc();
704 fl_set_counter_return(outputs_misc_->counter_line_len,
706 fl_set_input_return(outputs_misc_->input_tex_encoding,
708 fl_set_input_return(outputs_misc_->input_ascii_roff,
710 fl_set_input_return(outputs_misc_->input_checktex,
712 fl_addto_choice(outputs_misc_->choice_default_papersize,
713 _(" default | US letter | legal | executive | A3 | A4 | A5 | B5 "));
717 void FormPreferences::feedbackOutputsMisc(FL_OBJECT const * const ob )
721 if( ob == outputs_misc_->counter_line_len ) {
722 str = N_("This is the maximum line length of an exported ASCII file\n(LaTeX, SGML or plain text).");
723 } else if( ob == outputs_misc_->input_tex_encoding ) {
724 str = N_("The font encoding used for the LaTeX2e fontenc package.\nT1 is highly recommended for non-English languages.");
725 } else if( ob == outputs_misc_->input_ascii_roff ) {
726 str = N_("Use to define an external program to render tables in the ASCII output.\nE.g. \"groff -t -Tlatin1 $$FName\" where $$FName is the input file.\nIf \"none\" is specified, an internal routine is used.");
727 } else if( ob == outputs_misc_->input_checktex ) {
728 str = N_("Define how to run chktex.\nE.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\"\nRefer to the ChkTeX documentation.");
729 } else if( ob == outputs_misc_->choice_default_papersize ) {
730 str = N_("Specify the default paper size.");
733 fl_set_object_label(dialog_->text_warning, str.c_str());
734 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
738 void FormPreferences::updateOutputsMisc()
740 fl_set_counter_value(outputs_misc_->counter_line_len,
741 lyxrc.ascii_linelen);
742 fl_set_input(outputs_misc_->input_tex_encoding,
743 lyxrc.fontenc.c_str());
744 fl_set_choice(outputs_misc_->choice_default_papersize,
745 lyxrc.default_papersize+1);
746 fl_set_input(outputs_misc_->input_ascii_roff,
747 lyxrc.ascii_roff_command.c_str());
748 fl_set_input(outputs_misc_->input_checktex,
749 lyxrc.chktex_command.c_str());
753 void FormPreferences::applyPaths()
755 lyxrc.document_path = fl_get_input(paths_->input_default_path);
756 lyxrc.template_path = fl_get_input(paths_->input_template_path);
758 int button = fl_get_button(paths_->check_use_temp_dir);
759 string str = fl_get_input(paths_->input_temp_dir);
760 if( !button ) str.erase();
762 lyxrc.use_tempdir = button;
763 lyxrc.tempdir_path = str;
765 button = fl_get_button(paths_->check_last_files);
766 str = fl_get_input(paths_->input_lastfiles);
767 if( !button ) str.erase();
769 lyxrc.check_lastfiles = button;
770 lyxrc.lastfiles = str;
771 lyxrc.num_lastfiles = static_cast<unsigned int>
772 (fl_get_counter_value(paths_->counter_lastfiles));
774 button = fl_get_button(paths_->check_make_backups);
775 str = fl_get_input(paths_->input_backup_path);
776 if( !button ) str.erase();
778 lyxrc.make_backup = button;
779 lyxrc.backupdir_path = str;
781 lyxrc.lyxpipes = fl_get_input(paths_->input_serverpipe);
788 void FormPreferences::buildPaths()
790 paths_ = build_paths();
792 fl_set_input_return(paths_->input_default_path, FL_RETURN_CHANGED);
793 fl_set_input_return(paths_->input_template_path, FL_RETURN_CHANGED);
794 fl_set_input_return(paths_->input_temp_dir, FL_RETURN_CHANGED);
795 fl_set_input_return(paths_->input_lastfiles, FL_RETURN_CHANGED);
796 fl_set_input_return(paths_->input_backup_path, FL_RETURN_CHANGED);
797 fl_set_counter_return(paths_->counter_lastfiles, FL_RETURN_CHANGED);
798 fl_set_input_return(paths_->input_serverpipe, FL_RETURN_CHANGED);
800 // deactivate the browse buttons because they aren't implemented
801 fl_deactivate_object(paths_->button_document_browse);
802 fl_deactivate_object(paths_->button_template_browse);
803 fl_deactivate_object(paths_->button_temp_dir_browse);
804 fl_deactivate_object(paths_->button_lastfiles_browse);
805 fl_deactivate_object(paths_->button_backup_path_browse);
806 fl_deactivate_object(paths_->button_serverpipe_browse);
807 fl_set_object_lcol(paths_->button_document_browse, FL_INACTIVE);
808 fl_set_object_lcol(paths_->button_template_browse, FL_INACTIVE);
809 fl_set_object_lcol(paths_->button_temp_dir_browse, FL_INACTIVE);
810 fl_set_object_lcol(paths_->button_lastfiles_browse, FL_INACTIVE);
811 fl_set_object_lcol(paths_->button_backup_path_browse, FL_INACTIVE);
812 fl_set_object_lcol(paths_->button_serverpipe_browse, FL_INACTIVE);
816 void FormPreferences::feedbackPaths( FL_OBJECT const * const ob )
819 if( ob == paths_->input_default_path ) {
820 str = N_("The default path for your documents.");
821 } else if ( ob == paths_->input_template_path ) {
822 str = N_("The path that LyX will set when offering to choose a template.");
823 } else if ( ob == paths_->check_use_temp_dir ) {
824 str = N_("Specify to use a temporary directory to store temporary TeX output.\nThis directory is deleted when you quit LyX.");
825 } else if ( ob == paths_->input_temp_dir ) {
826 str = N_("The path that LyX will use to store temporary TeX output.");
827 } else if ( ob == paths_->check_last_files ) {
828 str = N_("Specify to check whether the lastfiles still exist.");
829 } else if ( ob == paths_->input_lastfiles ) {
830 str = N_("The file where the last-files information should be stored.");
831 } else if ( ob == paths_->counter_lastfiles ) {
832 str = N_("Maximal number of lastfiles. Up to 9 can appear in the file menu.");
833 } else if ( ob == paths_->check_make_backups ) {
834 str = N_("Set to false if you don't want LyX to create backup files.");
835 } else if ( ob == paths_->input_backup_path ) {
836 str = N_("The path for storing backup files. If it is an empty string,\nLyX will store the backup file in the same directory as the original file.");
837 } else if ( ob == paths_->input_serverpipe ) {
838 str = N_("This starts the lyxserver. The pipes get an additional extension\n\".in\" and \".out\". Only for advanced users.");
841 fl_set_object_label(dialog_->text_warning, str.c_str());
842 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
846 bool FormPreferences::inputPaths( FL_OBJECT const * const ob )
848 bool activate = true;
850 if( !ob || ob == paths_->check_use_temp_dir ) {
851 if( fl_get_button(paths_->check_use_temp_dir) ) {
852 fl_activate_object(paths_->input_temp_dir);
853 fl_set_object_lcol(paths_->input_temp_dir,
856 fl_deactivate_object(paths_->input_temp_dir);
857 fl_set_object_lcol(paths_->input_temp_dir,
862 if( !ob || ob == paths_->check_last_files ) {
863 if( fl_get_button(paths_->check_last_files) ) {
864 fl_activate_object(paths_->input_lastfiles);
865 fl_set_object_lcol(paths_->input_lastfiles,
868 fl_deactivate_object(paths_->input_lastfiles);
869 fl_set_object_lcol(paths_->input_lastfiles,
874 if( !ob || ob == paths_->check_make_backups ) {
875 if( fl_get_button(paths_->check_make_backups) ) {
876 fl_activate_object(paths_->input_backup_path);
877 fl_set_object_lcol(paths_->input_backup_path,
880 fl_deactivate_object(paths_->input_backup_path);
881 fl_set_object_lcol(paths_->input_backup_path,
886 if( !ob || ob == paths_->input_default_path ) {
887 string name = fl_get_input(paths_->input_default_path);
888 if( !WriteableDir(name) )
892 if( !ob || ob == paths_->input_template_path ) {
893 string name = fl_get_input(paths_->input_template_path);
894 if( !ReadableDir(name) )
898 if( !ob || ob == paths_->input_temp_dir ) {
899 string name = fl_get_input(paths_->input_temp_dir);
900 if( fl_get_button(paths_->check_make_backups)
902 && !WriteableDir(name) )
906 if( !ob || ob == paths_->input_backup_path ) {
907 string name = fl_get_input(paths_->input_backup_path);
908 if( fl_get_button(paths_->check_make_backups)
910 && !WriteableDir(name) )
914 if( !ob || ob == paths_->input_lastfiles ) {
915 string name = fl_get_input(paths_->input_lastfiles);
916 if( fl_get_button(paths_->check_last_files)
918 && !WriteableFile(name) )
922 if( !ob || ob == paths_->input_serverpipe ) {
923 string name = fl_get_input(paths_->input_serverpipe);
924 if( !name.empty() ) {
925 if( !WriteableFile(name, ".in") )
927 if( !WriteableFile(name, ".out") )
936 void FormPreferences::updatePaths()
938 fl_set_input(paths_->input_default_path,
939 lyxrc.document_path.c_str());
940 fl_set_input(paths_->input_template_path,
941 lyxrc.template_path.c_str());
943 string str = string();
944 if( lyxrc.make_backup ) str = lyxrc.backupdir_path;
946 fl_set_button(paths_->check_make_backups,
948 fl_set_input(paths_->input_backup_path, str.c_str());
951 if( lyxrc.use_tempdir ) str = lyxrc.tempdir_path;
953 fl_set_button(paths_->check_use_temp_dir,
955 fl_set_input(paths_->input_temp_dir, str.c_str());
958 if( lyxrc.check_lastfiles ) str = lyxrc.lastfiles;
960 fl_set_button(paths_->check_last_files,
961 lyxrc.check_lastfiles);
962 fl_set_input(paths_->input_lastfiles, str.c_str());
963 fl_set_counter_value(paths_->counter_lastfiles,
964 lyxrc.num_lastfiles);
966 fl_set_input(paths_->input_serverpipe, lyxrc.lyxpipes.c_str());
968 // Activate/Deactivate the input fields dependent on the state of the
974 void FormPreferences::applyPrinter()
976 lyxrc.print_adapt_output = fl_get_button(printer_->check_adapt_output);
977 lyxrc.print_command = fl_get_input(printer_->input_command);
978 lyxrc.print_pagerange_flag = fl_get_input(printer_->input_page_range);
979 lyxrc.print_copies_flag = fl_get_input(printer_->input_copies);
980 lyxrc.print_reverse_flag = fl_get_input(printer_->input_reverse);
981 lyxrc.print_to_printer = fl_get_input(printer_->input_to_printer);
982 lyxrc.print_file_extension =
983 fl_get_input(printer_->input_file_extension);
984 lyxrc.print_spool_command =
985 fl_get_input(printer_->input_spool_command);
986 lyxrc.print_paper_flag = fl_get_input(printer_->input_paper_type);
987 lyxrc.print_evenpage_flag = fl_get_input(printer_->input_even_pages);
988 lyxrc.print_oddpage_flag = fl_get_input(printer_->input_odd_pages);
989 lyxrc.print_collcopies_flag = fl_get_input(printer_->input_collated);
990 lyxrc.print_landscape_flag = fl_get_input(printer_->input_landscape);
991 lyxrc.print_to_file = fl_get_input(printer_->input_to_file);
992 lyxrc.print_extra_options =
993 fl_get_input(printer_->input_extra_options);
994 lyxrc.print_spool_printerprefix =
995 fl_get_input(printer_->input_spool_prefix);
996 lyxrc.print_paper_dimension_flag =
997 fl_get_input(printer_->input_paper_size);
998 lyxrc.printer = fl_get_input(printer_->input_name);
1002 void FormPreferences::feedbackPrinter( FL_OBJECT const * const ob )
1006 if( ob == printer_->input_command ) {
1007 str = N_("Your favorite print program, eg \"dvips\", \"dvilj4\"");
1008 } else if( ob == printer_->check_adapt_output ) {
1009 str = N_("Set to true for LyX to pass the name of the destination printer to your\nprint command.");
1010 } else if( ob == printer_->input_to_printer ) {
1011 str = N_("Option to pass to the print program to print on a specific printer.");
1012 } else if( ob == printer_->input_to_file ) {
1013 str = N_("Option to pass to the print program to print to a file.");
1014 } else if( ob == printer_->input_file_extension ) {
1015 str = N_("Extension of printer program output file. Usually .ps");
1016 } else if( ob == printer_->input_extra_options ) {
1017 str = N_("Extra options to pass to printing program after everything else,\nbut before the filename of the DVI file to be printed.");
1018 } else if( ob == printer_->input_spool_command ) {
1019 str = N_("When set, this printer option automatically prints to a file and then calls\na separate print spooling program on that file with the given name\nand arguments.");
1020 } else if( ob == printer_->input_spool_prefix ) {
1021 str = N_("If you specify a printer name in the print dialog, the following argument\nis prepended along with the printer name after the spool command.");
1022 } else if( ob == printer_->input_name ) {
1023 str = N_("The default printer to print on. If none is specified, LyX will\nuse the environment variable PRINTER.");
1024 } else if( ob == printer_->input_even_pages
1025 || ob == printer_->input_odd_pages
1026 || ob == printer_->input_page_range
1027 || ob == printer_->input_reverse
1028 || ob == printer_->input_landscape
1029 || ob == printer_->input_copies
1030 || ob == printer_->input_collated
1031 || ob == printer_->input_paper_type
1032 || ob == printer_->input_paper_size ) {
1033 str = N_("Look at the man page for your favorite print program to learn\nwhich options to use.");
1037 fl_set_object_label(dialog_->text_warning, str.c_str());
1038 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
1042 void FormPreferences::buildPrinter()
1044 printer_ = build_printer();
1046 fl_set_input_return(printer_->input_command, FL_RETURN_CHANGED);
1047 fl_set_input_return(printer_->input_page_range, FL_RETURN_CHANGED);
1048 fl_set_input_return(printer_->input_copies, FL_RETURN_CHANGED);
1049 fl_set_input_return(printer_->input_reverse, FL_RETURN_CHANGED);
1050 fl_set_input_return(printer_->input_to_printer, FL_RETURN_CHANGED);
1051 fl_set_input_return(printer_->input_file_extension, FL_RETURN_CHANGED);
1052 fl_set_input_return(printer_->input_spool_command, FL_RETURN_CHANGED);
1053 fl_set_input_return(printer_->input_paper_type, FL_RETURN_CHANGED);
1054 fl_set_input_return(printer_->input_even_pages, FL_RETURN_CHANGED);
1055 fl_set_input_return(printer_->input_odd_pages, FL_RETURN_CHANGED);
1056 fl_set_input_return(printer_->input_collated, FL_RETURN_CHANGED);
1057 fl_set_input_return(printer_->input_landscape, FL_RETURN_CHANGED);
1058 fl_set_input_return(printer_->input_to_file, FL_RETURN_CHANGED);
1059 fl_set_input_return(printer_->input_extra_options, FL_RETURN_CHANGED);
1060 fl_set_input_return(printer_->input_spool_prefix, FL_RETURN_CHANGED);
1061 fl_set_input_return(printer_->input_paper_size, FL_RETURN_CHANGED);
1062 fl_set_input_return(printer_->input_name, FL_RETURN_CHANGED);
1066 void FormPreferences::updatePrinter()
1068 fl_set_button(printer_->check_adapt_output,
1069 lyxrc.print_adapt_output);
1070 fl_set_input(printer_->input_command,
1071 lyxrc.print_command.c_str());
1072 fl_set_input(printer_->input_page_range,
1073 lyxrc.print_pagerange_flag.c_str());
1074 fl_set_input(printer_->input_copies,
1075 lyxrc.print_copies_flag.c_str());
1076 fl_set_input(printer_->input_reverse,
1077 lyxrc.print_reverse_flag.c_str());
1078 fl_set_input(printer_->input_to_printer,
1079 lyxrc.print_to_printer.c_str());
1080 fl_set_input(printer_->input_file_extension,
1081 lyxrc.print_file_extension.c_str());
1082 fl_set_input(printer_->input_spool_command,
1083 lyxrc.print_spool_command.c_str());
1084 fl_set_input(printer_->input_paper_type,
1085 lyxrc.print_paper_flag.c_str());
1086 fl_set_input(printer_->input_even_pages,
1087 lyxrc.print_evenpage_flag.c_str());
1088 fl_set_input(printer_->input_odd_pages,
1089 lyxrc.print_oddpage_flag.c_str());
1090 fl_set_input(printer_->input_collated,
1091 lyxrc.print_collcopies_flag.c_str());
1092 fl_set_input(printer_->input_landscape,
1093 lyxrc.print_landscape_flag.c_str());
1094 fl_set_input(printer_->input_to_file,
1095 lyxrc.print_to_file.c_str());
1096 fl_set_input(printer_->input_extra_options,
1097 lyxrc.print_extra_options.c_str());
1098 fl_set_input(printer_->input_spool_prefix,
1099 lyxrc.print_spool_printerprefix.c_str());
1100 fl_set_input(printer_->input_paper_size,
1101 lyxrc.print_paper_dimension_flag.c_str());
1102 fl_set_input(printer_->input_name,
1103 lyxrc.printer.c_str());
1107 void FormPreferences::applyScreenFonts()
1109 bool changed = false;
1111 string str = fl_get_input(screen_fonts_->input_roman);
1112 if( lyxrc.roman_font_name != str ) {
1114 lyxrc.roman_font_name = str;
1117 str = fl_get_input(screen_fonts_->input_sans);
1118 if( lyxrc.sans_font_name != str ) {
1120 lyxrc.sans_font_name = str;
1123 str = fl_get_input(screen_fonts_->input_typewriter);
1124 if( lyxrc.typewriter_font_name != str ) {
1126 lyxrc.typewriter_font_name = str;
1129 str = fl_get_input(screen_fonts_->input_screen_encoding);
1130 if( lyxrc.font_norm != str ) {
1132 lyxrc.font_norm = str;
1135 bool button = fl_get_button(screen_fonts_->check_scalable);
1136 if( lyxrc.use_scalable_fonts != button ) {
1138 lyxrc.use_scalable_fonts = button;
1141 int ivalue = fl_get_counter_value(screen_fonts_->counter_zoom);
1142 if( lyxrc.zoom != static_cast<unsigned int>( ivalue ) ) {
1144 lyxrc.zoom = static_cast<unsigned int>( ivalue );
1147 double dvalue = strToDbl(fl_get_input(screen_fonts_->input_tiny));
1148 if( lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue ) {
1150 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
1153 dvalue = strToDbl(fl_get_input(screen_fonts_->input_script));
1154 if( lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue ) {
1156 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
1159 dvalue = strToDbl(fl_get_input(screen_fonts_->input_footnote));
1160 if( lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue ) {
1162 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
1165 dvalue = strToDbl(fl_get_input(screen_fonts_->input_small));
1166 if( lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue ) {
1168 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
1171 dvalue = strToDbl(fl_get_input(screen_fonts_->input_normal));
1172 if( lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue ) {
1174 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
1177 dvalue = strToDbl(fl_get_input(screen_fonts_->input_large));
1178 if( lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue ) {
1180 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
1183 dvalue = strToDbl(fl_get_input(screen_fonts_->input_larger));
1184 if( lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue ) {
1186 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
1189 dvalue = strToDbl(fl_get_input(screen_fonts_->input_largest));
1190 if( lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue ) {
1192 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
1195 dvalue = strToDbl(fl_get_input(screen_fonts_->input_huge));
1196 if( lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue ) {
1198 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
1201 dvalue = strToDbl(fl_get_input(screen_fonts_->input_huger));
1202 if( lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue ) {
1204 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
1208 // Now update the buffers
1209 // Can anything below here affect the redraw process?
1210 lv_->getLyXFunc()->Dispatch(LFUN_SCREEN_FONT_UPDATE);
1215 void FormPreferences::buildScreenFonts()
1217 screen_fonts_ = build_screen_fonts();
1219 fl_set_input_return(screen_fonts_->input_roman, FL_RETURN_CHANGED);
1220 fl_set_input_return(screen_fonts_->input_sans, FL_RETURN_CHANGED);
1221 fl_set_input_return(screen_fonts_->input_typewriter,
1223 fl_set_input_return(screen_fonts_->input_screen_encoding,
1225 fl_set_counter_return(screen_fonts_->counter_zoom, FL_RETURN_CHANGED);
1226 fl_set_input_return(screen_fonts_->input_tiny, FL_RETURN_CHANGED);
1227 fl_set_input_return(screen_fonts_->input_script, FL_RETURN_CHANGED);
1228 fl_set_input_return(screen_fonts_->input_footnote, FL_RETURN_CHANGED);
1229 fl_set_input_return(screen_fonts_->input_small, FL_RETURN_CHANGED);
1230 fl_set_input_return(screen_fonts_->input_normal, FL_RETURN_CHANGED);
1231 fl_set_input_return(screen_fonts_->input_large, FL_RETURN_CHANGED);
1232 fl_set_input_return(screen_fonts_->input_larger, FL_RETURN_CHANGED);
1233 fl_set_input_return(screen_fonts_->input_largest, FL_RETURN_CHANGED);
1234 fl_set_input_return(screen_fonts_->input_huge, FL_RETURN_CHANGED);
1235 fl_set_input_return(screen_fonts_->input_huger, FL_RETURN_CHANGED);
1239 void FormPreferences::feedbackScreenFonts(FL_OBJECT const * const ob )
1243 if( ob == screen_fonts_->input_roman
1244 || ob == screen_fonts_->input_sans
1245 || ob == screen_fonts_->input_typewriter ) {
1246 str = N_("The screen fonts used to display the text while editing.");
1247 } else if( ob == screen_fonts_->check_scalable ) {
1248 str = N_("Allow the use of scalable screen fonts? If false, LyX will use the\nclosest existing size for a match. Use this if the scalable fonts\nlook bad and you have many fixed size fonts.");
1249 } else if( ob == screen_fonts_->input_screen_encoding ) {
1250 str = N_("The norm for the screen fonts.");
1251 } else if( ob == screen_fonts_->counter_zoom ) {
1252 str = N_("The zoom percentage for screen fonts.\nA setting of 100% will make the fonts roughly the same size as on paper.");
1253 } else if( ob == screen_fonts_->input_tiny
1254 || ob == screen_fonts_->input_script
1255 || ob == screen_fonts_->input_footnote
1256 || ob == screen_fonts_->input_small
1257 || ob == screen_fonts_->input_large
1258 || ob == screen_fonts_->input_larger
1259 || ob == screen_fonts_->input_larger
1260 || ob == screen_fonts_->input_largest
1261 || ob == screen_fonts_->input_normal
1262 || ob == screen_fonts_->input_huge
1263 || ob == screen_fonts_->input_huger ) {
1264 str = N_("The font sizes used for calculating the scaling of the screen fonts.");
1267 fl_set_object_label(dialog_->text_warning, str.c_str());
1268 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
1272 bool FormPreferences::inputScreenFonts()
1274 bool activate = true;
1277 // Make sure that all fonts all have positive entries
1278 // Also note that an empty entry is returned as 0.0 by strToDbl
1279 if (0.0 >= strToDbl(fl_get_input(screen_fonts_->input_tiny))
1280 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_script))
1281 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_footnote))
1282 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_small))
1283 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_normal))
1284 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_large))
1285 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_larger))
1286 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_largest))
1287 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_huge))
1288 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_huger))) {
1290 str = N_("WARNING! Fonts must be positive!");
1292 // Fontsizes -- tiny < script < footnote etc.
1293 } else if (strToDbl(fl_get_input(screen_fonts_->input_tiny)) >
1294 strToDbl(fl_get_input(screen_fonts_->input_script)) ||
1295 strToDbl(fl_get_input(screen_fonts_->input_script)) >
1296 strToDbl(fl_get_input(screen_fonts_->input_footnote)) ||
1297 strToDbl(fl_get_input(screen_fonts_->input_footnote)) >
1298 strToDbl(fl_get_input(screen_fonts_->input_small)) ||
1299 strToDbl(fl_get_input(screen_fonts_->input_small)) >
1300 strToDbl(fl_get_input(screen_fonts_->input_normal)) ||
1301 strToDbl(fl_get_input(screen_fonts_->input_normal)) >
1302 strToDbl(fl_get_input(screen_fonts_->input_large)) ||
1303 strToDbl(fl_get_input(screen_fonts_->input_large)) >
1304 strToDbl(fl_get_input(screen_fonts_->input_larger)) ||
1305 strToDbl(fl_get_input(screen_fonts_->input_larger)) >
1306 strToDbl(fl_get_input(screen_fonts_->input_largest)) ||
1307 strToDbl(fl_get_input(screen_fonts_->input_largest)) >
1308 strToDbl(fl_get_input(screen_fonts_->input_huge)) ||
1309 strToDbl(fl_get_input(screen_fonts_->input_huge)) >
1310 strToDbl(fl_get_input(screen_fonts_->input_huger))) {
1313 str = N_("WARNING! Fonts must be input in the order tiny > script>\nfootnote > small > normal > large > larger > largest > huge > huger.");
1317 fl_set_object_label(dialog_->text_warning, str.c_str());
1318 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
1325 void FormPreferences::updateScreenFonts()
1327 fl_set_input(screen_fonts_->input_roman,
1328 lyxrc.roman_font_name.c_str());
1329 fl_set_input(screen_fonts_->input_sans,
1330 lyxrc.sans_font_name.c_str());
1331 fl_set_input(screen_fonts_->input_typewriter,
1332 lyxrc.typewriter_font_name.c_str());
1333 fl_set_input(screen_fonts_->input_screen_encoding,
1334 lyxrc.font_norm.c_str());
1335 fl_set_button(screen_fonts_->check_scalable,
1336 lyxrc.use_scalable_fonts);
1337 fl_set_counter_value(screen_fonts_->counter_zoom,
1339 fl_set_input(screen_fonts_->input_tiny,
1340 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
1341 fl_set_input(screen_fonts_->input_script,
1342 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
1343 fl_set_input(screen_fonts_->input_footnote,
1344 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
1345 fl_set_input(screen_fonts_->input_small,
1346 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
1347 fl_set_input(screen_fonts_->input_normal,
1348 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
1349 fl_set_input(screen_fonts_->input_large,
1350 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
1351 fl_set_input(screen_fonts_->input_larger,
1352 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
1353 fl_set_input(screen_fonts_->input_largest,
1354 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
1355 fl_set_input(screen_fonts_->input_huge,
1356 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
1357 fl_set_input(screen_fonts_->input_huger,
1358 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
1362 void FormPreferences::applySpellChecker()
1365 string choice = "none";
1366 switch(fl_get_choice(spellchecker_->choice_spell_command)) {
1379 lyxrc.isp_command = choice;
1381 // If spell checker == "none", all other input set to off.
1382 if( fl_get_choice(spellchecker_->choice_spell_command) == 1 ) {
1383 lyxrc.isp_use_alt_lang = false;
1384 lyxrc.isp_alt_lang.erase();
1386 lyxrc.isp_use_esc_chars = false;
1387 lyxrc.isp_esc_chars.erase();
1389 lyxrc.isp_use_pers_dict = false;
1390 lyxrc.isp_pers_dict.erase();
1392 lyxrc.isp_accept_compound = false;
1393 lyxrc.isp_use_input_encoding = false;
1395 int button = fl_get_button(spellchecker_->check_alt_lang);
1396 choice = fl_get_input(spellchecker_->input_alt_lang);
1397 if( button && choice.empty() ) button = 0;
1398 if( !button ) choice.erase();
1400 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
1401 lyxrc.isp_alt_lang = choice;
1403 button = fl_get_button(spellchecker_->check_escape_chars);
1404 choice = fl_get_input(spellchecker_->input_escape_chars);
1405 if( button && choice.empty() ) button = 0;
1406 if( !button ) choice.erase();
1408 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
1409 lyxrc.isp_esc_chars = choice;
1411 button = fl_get_button(spellchecker_->check_personal_dict);
1412 choice = fl_get_input(spellchecker_->input_personal_dict);
1413 if( button && choice.empty() ) button = 0;
1414 if( !button ) choice.erase();
1416 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
1417 lyxrc.isp_pers_dict = choice;
1419 button = fl_get_button(spellchecker_->check_compound_words);
1420 lyxrc.isp_accept_compound = static_cast<bool>(button);
1422 button = fl_get_button(spellchecker_->check_input_enc);
1423 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
1427 updateSpellChecker();
1431 void FormPreferences::buildSpellchecker()
1433 spellchecker_ = build_spellchecker();
1435 fl_addto_choice(spellchecker_->choice_spell_command,
1436 _(" none | ispell | aspell "));
1437 fl_set_input_return(spellchecker_->input_alt_lang,
1439 fl_set_input_return(spellchecker_->input_escape_chars,
1441 fl_set_input_return(spellchecker_->input_personal_dict,
1444 // deactivate the browse button because it isn't implemented
1445 fl_deactivate_object(spellchecker_->button_personal_dict);
1446 fl_set_object_lcol(spellchecker_->button_personal_dict,
1451 void FormPreferences::feedbackSpellChecker( FL_OBJECT const * const ob )
1454 if( ob == spellchecker_->choice_spell_command ) {
1455 str = N_("What command runs the spell checker?");
1456 } else if( ob == spellchecker_->check_alt_lang ) {
1457 str = N_("Specify an alternate language.\nThe default is to use the language of the document.");
1458 } else if( ob == spellchecker_->check_escape_chars ) {
1459 str = N_("Specify additional chars that can be part of a word.");
1460 } else if( ob == spellchecker_->check_personal_dict ) {
1461 str = N_("Specify an alternate personal dictionary file.\nE.g. \".ispell_english\".");
1462 } else if( ob == spellchecker_->check_compound_words ) {
1463 str = N_("Consider run-together words, such as \"notthe\" for \"not the\",\nas legal words?");
1464 } else if( ob == spellchecker_->check_input_enc ) {
1465 str = N_("Specify whether to pass the -T input encoding option to ispell.\nEnable this if you can't spellcheck words with international letters\nin them.\nThis may not work with all dictionaries.");
1468 fl_set_object_label(dialog_->text_warning, str.c_str());
1469 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
1473 bool FormPreferences::inputSpellChecker( FL_OBJECT const * const ob )
1475 // Allow/dissallow input
1477 // If spell checker == "none", disable all input.
1478 if( !ob || ob == spellchecker_->choice_spell_command ) {
1479 if( fl_get_choice(spellchecker_->choice_spell_command) == 1 ) {
1480 fl_deactivate_object( spellchecker_->check_alt_lang );
1481 fl_deactivate_object( spellchecker_->input_alt_lang );
1482 fl_deactivate_object( spellchecker_->check_escape_chars );
1483 fl_deactivate_object( spellchecker_->input_escape_chars );
1484 fl_deactivate_object( spellchecker_->check_personal_dict );
1485 fl_deactivate_object( spellchecker_->input_personal_dict );
1486 fl_deactivate_object( spellchecker_->check_compound_words );
1487 fl_deactivate_object( spellchecker_->check_input_enc );
1490 fl_activate_object( spellchecker_->check_alt_lang );
1491 fl_activate_object( spellchecker_->check_escape_chars );
1492 fl_activate_object( spellchecker_->check_personal_dict );
1493 fl_activate_object( spellchecker_->check_compound_words );
1494 fl_activate_object( spellchecker_->check_input_enc );
1498 if( !ob || ob == spellchecker_->check_alt_lang ) {
1499 if( fl_get_button(spellchecker_->check_alt_lang) ) {
1500 fl_activate_object(spellchecker_->input_alt_lang);
1501 fl_set_object_lcol(spellchecker_->input_alt_lang,
1504 fl_deactivate_object(spellchecker_->input_alt_lang);
1505 fl_set_object_lcol(spellchecker_->input_alt_lang,
1510 if( !ob || ob == spellchecker_->check_escape_chars ) {
1511 if( fl_get_button(spellchecker_->check_escape_chars) ) {
1512 fl_activate_object(spellchecker_->input_escape_chars);
1513 fl_set_object_lcol(spellchecker_->input_escape_chars,
1516 fl_deactivate_object(spellchecker_->input_escape_chars);
1517 fl_set_object_lcol(spellchecker_->input_escape_chars,
1522 if( !ob || ob == spellchecker_->check_personal_dict ) {
1523 if( fl_get_button(spellchecker_->check_personal_dict) ) {
1524 fl_activate_object(spellchecker_->input_personal_dict);
1525 fl_set_object_lcol(spellchecker_->input_personal_dict,
1528 fl_deactivate_object(spellchecker_->input_personal_dict);
1529 fl_set_object_lcol(spellchecker_->input_personal_dict,
1534 return true; // all input is valid!
1538 void FormPreferences::updateSpellChecker()
1541 if( lyxrc.isp_command == "none" )
1543 else if( lyxrc.isp_command == "ispell" )
1545 else if( lyxrc.isp_command == "aspell" )
1547 fl_set_choice(spellchecker_->choice_spell_command, choice);
1549 string str = string();
1550 if( lyxrc.isp_use_alt_lang ) str = lyxrc.isp_alt_lang;
1552 fl_set_button(spellchecker_->check_alt_lang,
1553 lyxrc.isp_use_alt_lang);
1554 fl_set_input(spellchecker_->input_alt_lang, str.c_str());
1557 if( lyxrc.isp_use_esc_chars ) str = lyxrc.isp_esc_chars;
1559 fl_set_button(spellchecker_->check_escape_chars,
1560 lyxrc.isp_use_esc_chars);
1561 fl_set_input(spellchecker_->input_escape_chars, str.c_str());
1564 if( lyxrc.isp_use_pers_dict ) str = lyxrc.isp_pers_dict;
1566 fl_set_button(spellchecker_->check_personal_dict,
1567 lyxrc.isp_use_pers_dict);
1568 fl_set_input(spellchecker_->input_personal_dict, str.c_str());
1570 fl_set_button(spellchecker_->check_compound_words,
1571 lyxrc.isp_accept_compound);
1572 fl_set_button(spellchecker_->check_input_enc,
1573 lyxrc.isp_use_input_encoding);
1575 // Activate/Deactivate the input fields dependent on the state of the
1577 inputSpellChecker( 0 );
1581 bool FormPreferences::WriteableDir( string const & name ) const
1583 bool success = true;
1586 if( !AbsolutePath(name) ) {
1588 str = N_("WARNING! The absolute path is required.");
1592 if( success && !tp.isDir() ) {
1594 str = N_("WARNING! Directory does not exist.");
1597 if( success && !tp.writable() ) {
1599 str = N_("WARNING! Cannot write to this directory.");
1603 fl_set_object_label(dialog_->text_warning, str.c_str());
1604 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
1611 bool FormPreferences::ReadableDir( string const & name ) const
1613 bool success = true;
1616 if( !AbsolutePath(name) ) {
1618 str = N_("WARNING! The absolute path is required.");
1622 if( success && !tp.isDir() ) {
1624 str = N_("WARNING! Directory does not exist.");
1627 if( success && !tp.readable() ) {
1629 str = N_("WARNING! Cannot read this directory.");
1633 fl_set_object_label(dialog_->text_warning, str.c_str());
1634 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
1641 bool FormPreferences::WriteableFile( string const & name, string const & suffix ) const
1643 // A writeable file is either:
1644 // * An existing file to which we have write access, or
1645 // * A file that doesn't yet exist but that would exist in a writeable
1648 bool success = true;
1651 if( name.empty() ) {
1653 str = N_("WARNING! No file input.");
1656 string dir = OnlyPath(name);
1657 if( success && !AbsolutePath(dir) ) {
1659 str = N_("WARNING! The absolute path is required.");
1672 if( success && !d.isDir()) {
1674 str = N_("WARNING! Directory does not exist.");
1677 if( success && !d.writable() ) {
1679 str = N_("WARNING! Cannot write to this directory.");
1682 FileInfo f(name+suffix);
1683 if( success && (dir == name || f.isDir()) ) {
1685 str = N_("WARNING! A file is required, not a directory.");
1688 if( success && (f.exist() && !f.writable()) ) {
1690 str = N_("WARNING! Cannot write to this file.");
1694 fl_set_object_label(dialog_->text_warning, str.c_str());
1695 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);