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 "forms/form_texinfo.h"
23 #include "xforms_helpers.h"
24 #include "support/LAssert.h"
25 #include FORMS_H_LOCATION
28 typedef FormCB<ControlTexinfo, FormDB<FD_texinfo> > base_class;
29 FormTexinfo::FormTexinfo(ControlTexinfo & c)
30 : base_class(c, _("LaTeX Information")),
31 activeStyle(ControlTexinfo::cls)
35 void FormTexinfo::build() {
36 dialog_.reset(build_texinfo(this));
38 fl_set_browser_fontstyle(dialog_->browser,FL_FIXED_STYLE);
39 // with Path is default
40 fl_set_button(dialog_->check_fullpath, 1);
41 updateStyles(ControlTexinfo::cls);
43 // set up the tooltips
44 string str = _("Runs the script \"TexFiles.sh\" to build new file lists.");
45 tooltips().init(dialog_->button_rescan, str);
47 str = _("Shows the contents of the marked file. Only possible in full path mode.");
48 tooltips().init(dialog_->button_view, str);
50 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.");
51 tooltips().init(dialog_->button_texhash, str);
53 str = _("View full path or only file name. Full path is needed to view the contents of a file.");
54 tooltips().init(dialog_->check_fullpath, str);
56 str = _("Shows the installed LaTeX Document classes. Remember, that these classes are only available in LyX if a corresponding LyX layout file exists!");
57 tooltips().init(dialog_->radio_cls, str);
59 str = _("Shows the installed LaTeX style files, which are available in LyX by default, like \"babel\" or through \\usepackage{<the stylefile>} in LaTeX preamble.");
60 tooltips().init(dialog_->radio_sty, str);
62 str = _("Shows the installed style files for BibTeX. They can be loaded through insert->Lists&Toc->BibTeX Reference->Style.");
63 tooltips().init(dialog_->radio_bst, str);
67 ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long) {
69 if (ob == dialog_->radio_cls) {
70 updateStyles(ControlTexinfo::cls);
72 } else if (ob == dialog_->radio_sty) {
73 updateStyles(ControlTexinfo::sty);
75 } else if (ob == dialog_->radio_bst) {
76 updateStyles(ControlTexinfo::bst);
78 } else if (ob == dialog_->button_rescan) {
79 // build new *Files.lst
80 controller().rescanStyles();
81 updateStyles(activeStyle);
83 } else if (ob == dialog_->check_fullpath) {
84 setEnabled(dialog_->button_view,
85 fl_get_button(dialog_->check_fullpath));
86 updateStyles(activeStyle);
88 } else if (ob == dialog_->button_texhash) {
89 // makes only sense if the rights are set well for
90 // users (/var/lib/texmf/ls-R)
91 controller().runTexhash();
92 // update files in fact of texhash
93 controller().rescanStyles();
95 } else if (ob == dialog_->button_view) {
96 unsigned int selection = fl_get_browser(dialog_->browser);
99 controller().viewFile(
100 fl_get_browser_line(dialog_->browser,
105 return ButtonPolicy::SMI_VALID;
108 void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
110 fl_clear_browser(dialog_->browser);
112 bool const withFullPath = fl_get_button(dialog_->check_fullpath);
115 controller().getContents(whichStyle, withFullPath);
116 fl_add_browser_line(dialog_->browser, str.c_str());
118 activeStyle = whichStyle;