3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS
16 #pragma implementation
20 #include "FormTexinfo.h"
21 #include "forms/form_texinfo.h"
25 #include "xforms_helpers.h"
26 #include "support/LAssert.h"
27 #include FORMS_H_LOCATION
30 typedef FormCB<ControlTexinfo, FormDB<FD_texinfo> > base_class;
31 FormTexinfo::FormTexinfo()
32 : base_class(_("LaTeX Information")),
33 activeStyle(ControlTexinfo::cls)
37 void FormTexinfo::build() {
38 dialog_.reset(build_texinfo(this));
40 fl_set_browser_fontstyle(dialog_->browser,FL_FIXED_STYLE);
41 // with Path is default
42 fl_set_button(dialog_->check_fullpath, 1);
43 updateStyles(ControlTexinfo::cls);
45 // set up the tooltips
46 string str = _("Runs the script \"TexFiles.sh\" to build new file lists.");
47 tooltips().init(dialog_->button_rescan, str);
49 str = _("Shows the contents of the marked file. Only possible in full path mode.");
50 tooltips().init(dialog_->button_view, str);
52 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.");
53 tooltips().init(dialog_->button_texhash, str);
55 str = _("View full path or only file name. Full path is needed to view the contents of a file.");
56 tooltips().init(dialog_->check_fullpath, str);
58 str = _("Shows the installed LaTeX Document classes. Remember, that these classes are only available in LyX if a corresponding LyX layout file exists!");
59 tooltips().init(dialog_->radio_cls, str);
61 str = _("Shows the installed LaTeX style files, which are available in LyX by default, like \"babel\" or through \\usepackage{<the stylefile>} in LaTeX preamble.");
62 tooltips().init(dialog_->radio_sty, str);
64 str = _("Shows the installed style files for BibTeX. They can be loaded through insert->Lists&Toc->BibTeX Reference->Style.");
65 tooltips().init(dialog_->radio_bst, str);
69 ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long) {
71 if (ob == dialog_->radio_cls) {
72 updateStyles(ControlTexinfo::cls);
74 } else if (ob == dialog_->radio_sty) {
75 updateStyles(ControlTexinfo::sty);
77 } else if (ob == dialog_->radio_bst) {
78 updateStyles(ControlTexinfo::bst);
80 } else if (ob == dialog_->button_rescan) {
81 // build new *Files.lst
82 controller().rescanStyles();
83 updateStyles(activeStyle);
85 } else if (ob == dialog_->check_fullpath) {
86 setEnabled(dialog_->button_view,
87 fl_get_button(dialog_->check_fullpath));
88 updateStyles(activeStyle);
90 } else if (ob == dialog_->button_texhash) {
91 // makes only sense if the rights are set well for
92 // users (/var/lib/texmf/ls-R)
93 controller().runTexhash();
94 // update files in fact of texhash
95 controller().rescanStyles();
97 } else if (ob == dialog_->button_view) {
98 unsigned int selection = fl_get_browser(dialog_->browser);
101 controller().viewFile(
102 fl_get_browser_line(dialog_->browser,
107 return ButtonPolicy::SMI_VALID;
110 void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
112 fl_clear_browser(dialog_->browser);
114 bool const withFullPath = fl_get_button(dialog_->check_fullpath);
117 controller().getContents(whichStyle, withFullPath);
118 fl_add_browser_line(dialog_->browser, str.c_str());
120 activeStyle = whichStyle;