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 updateStyles(ControlTexinfo::cls);
42 string const classes_List = _("LaTeX classes|LaTeX styles|BibTeX styles");
43 fl_addto_choice(dialog_->choice_classes, classes_List.c_str());
45 // set up the tooltips
46 string str = _("Shows the installed classses and styles for LaTeX/BibTeX. These classes are only available in LyX if a corresponding LyX layout file exists.");
47 tooltips().init(dialog_->choice_classes, str);
49 str = _("View full path or only file name.");
50 tooltips().init(dialog_->check_fullpath, str);
52 str = _("Runs the script \"TexFiles.sh\" to build new file lists.");
53 tooltips().init(dialog_->button_rescan, str);
55 str = _("Shows the contents of the marked file. Only possible in full path mode.");
56 tooltips().init(dialog_->button_view, str);
58 str = _("Runs the script \"texhash\" which builds a new LaTeX tree. Needed if you install a new TeX class or style. You need write permissions for the TeX-dirs, often /var/lib/texmf and others.");
59 tooltips().init(dialog_->button_texhash, str);
63 ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long) {
65 if (ob == dialog_->choice_classes) {
66 switch (fl_get_choice(dialog_->choice_classes)) {
68 updateStyles(ControlTexinfo::cls);
71 updateStyles(ControlTexinfo::sty);
75 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;