3 * Copyright 2001 the LyX Team
4 * Read the file COPYING
6 * \author Herbert Voss, voss@lyx.org
14 #pragma implementation
18 #include "FormTexinfo.h"
19 #include "form_texinfo.h"
23 #include "xforms_helpers.h"
24 #include "support/LAssert.h"
27 typedef FormCB<ControlTexinfo, FormDB<FD_form_texinfo> > base_class;
28 FormTexinfo::FormTexinfo(ControlTexinfo & c)
29 : base_class(c, _("LaTeX Information")),
30 activeStyle(ControlTexinfo::cls)
34 void FormTexinfo::build() {
35 dialog_.reset(build_texinfo());
37 fl_set_browser_fontstyle(dialog_->browser,FL_FIXED_STYLE);
38 // with Path is default
39 fl_set_button(dialog_->check_fullpath, 1);
40 updateStyles(ControlTexinfo::cls);
42 // set up the tooltips
43 string str = _("Runs the script \"TexFiles.sh\" to build new file lists.");
44 tooltips().init(dialog_->button_rescan, str);
46 str = _("Shows the contents of the marked file. Only possible in full path mode.");
47 tooltips().init(dialog_->button_view, str);
49 str = _("Runs the script \"texhash\" which builds the a new LaTeX tree. Needed if you install a new TeX class or style. To execute it, you need the write permissions for the tex-dirs, often /var/lib/texmf and other.");
50 tooltips().init(dialog_->button_texhash, str);
52 str = _("View full path or only file name. Full path is needed to view the contents of a file.");
53 tooltips().init(dialog_->check_fullpath, str);
55 str = _("Shows the installed LaTeX Document classes. Remember, that these classes are only available in LyX if a corresponding LyX layout file exists!");
56 tooltips().init(dialog_->radio_cls, str);
58 str = _("Shows the installed LaTeX style files, which are available in LyX by default, like \"babel\" or through \\usepackage{<the stylefile>} in LaTeX preamble.");
59 tooltips().init(dialog_->radio_sty, str);
61 str = _("Shows the installed style files for BibTeX. They can be loaded through insert->Lists&Toc->BibTeX Reference->Style.");
62 tooltips().init(dialog_->radio_bst, str);
66 ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long) {
68 if (ob == dialog_->radio_cls) {
69 updateStyles(ControlTexinfo::cls);
71 } else if (ob == dialog_->radio_sty) {
72 updateStyles(ControlTexinfo::sty);
74 } else if (ob == dialog_->radio_bst) {
75 updateStyles(ControlTexinfo::bst);
77 } else if (ob == dialog_->button_rescan) {
78 // build new *Files.lst
79 controller().rescanStyles();
80 updateStyles(activeStyle);
82 } else if (ob == dialog_->check_fullpath) {
83 setEnabled(dialog_->button_view,
84 fl_get_button(dialog_->check_fullpath));
85 updateStyles(activeStyle);
87 } else if (ob == dialog_->button_texhash) {
88 // makes only sense if the rights are set well for
89 // users (/var/lib/texmf/ls-R)
90 controller().runTexhash();
91 // update files in fact of texhash
92 controller().rescanStyles();
94 } else if (ob == dialog_->button_view) {
95 unsigned int selection = fl_get_browser(dialog_->browser);
98 controller().viewFile(
99 fl_get_browser_line(dialog_->browser,
104 return ButtonPolicy::SMI_VALID;
107 void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
109 fl_clear_browser(dialog_->browser);
111 bool const withFullPath = fl_get_button(dialog_->check_fullpath);
114 controller().getContents(whichStyle, withFullPath);
115 fl_add_browser_line(dialog_->browser, str.c_str());
117 activeStyle = whichStyle;