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"
22 #include "xforms_helpers.h"
23 #include "support/LAssert.h"
26 typedef FormCB<ControlTexinfo, FormDB<FD_form_texinfo> > base_class;
27 FormTexinfo::FormTexinfo(ControlTexinfo & c)
28 : base_class(c, _("LaTeX Information")),
29 activeStyle(ControlTexinfo::cls)
33 void FormTexinfo::build() {
34 dialog_.reset(build_texinfo());
36 fl_set_browser_fontstyle(dialog_->browser,FL_FIXED_STYLE);
37 // with Path is default
38 fl_set_button(dialog_->button_fullPath, 1);
39 updateStyles(ControlTexinfo::cls);
42 fillTooltipChoice(dialog_->choice_help);
44 // setting up the help mechanism
45 setTooltipHandler(dialog_->button_rescan);
46 setTooltipHandler(dialog_->button_view);
47 setTooltipHandler(dialog_->button_texhash);
48 setTooltipHandler(dialog_->button_fullPath);
49 setTooltipHandler(dialog_->browser);
50 setTooltipHandler(dialog_->radio_cls);
51 setTooltipHandler(dialog_->radio_sty);
52 setTooltipHandler(dialog_->radio_bst);
56 ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long) {
58 if (ob == dialog_->radio_cls) {
59 updateStyles(ControlTexinfo::cls);
61 } else if (ob == dialog_->radio_sty) {
62 updateStyles(ControlTexinfo::sty);
64 } else if (ob == dialog_->radio_bst) {
65 updateStyles(ControlTexinfo::bst);
67 } else if (ob == dialog_->button_rescan) {
68 // build new *Files.lst
69 controller().rescanStyles();
70 updateStyles(activeStyle);
72 } else if (ob == dialog_->button_fullPath) {
73 setEnabled(dialog_->button_view,
74 fl_get_button(dialog_->button_fullPath));
75 updateStyles(activeStyle);
77 } else if (ob == dialog_->button_texhash) {
78 // makes only sense if the rights are set well for
79 // users (/var/lib/texmf/ls-R)
80 controller().runTexhash();
81 // update files in fact of texhash
82 controller().rescanStyles();
84 } else if (ob == dialog_->button_view) {
85 unsigned int selection = fl_get_browser(dialog_->browser);
88 controller().viewFile(
89 fl_get_browser_line(dialog_->browser,
94 if (ob == dialog_->choice_help) {
95 setTooltipLevel(dialog_->choice_help);
96 return ButtonPolicy::SMI_NOOP;
99 return ButtonPolicy::SMI_VALID;
102 void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
104 fl_clear_browser(dialog_->browser);
106 bool const withFullPath = fl_get_button(dialog_->button_fullPath);
109 controller().getContents(whichStyle, withFullPath);
110 fl_add_browser_line(dialog_->browser, str.c_str());
112 activeStyle = whichStyle;
116 string const FormTexinfo::getMinimalTooltip(FL_OBJECT const * ob) const
120 if (ob == dialog_->radio_cls) {
121 str = N_("Available LaTeX Classes");
123 } else if (ob == dialog_->radio_sty) {
124 str = _("Available LaTeX Styles");
126 } else if (ob == dialog_->radio_bst) {
127 str = _("Available BibTeX Styles");
129 } else if (ob == dialog_->button_rescan) {
130 str = _("Rescan File List");
132 } else if (ob == dialog_->button_fullPath) {
133 str = _("Show Full Path or not");
135 } else if (ob == dialog_->button_texhash) {
136 str = _("Execute Script \"Texhash\"");
138 } else if (ob == dialog_->button_view) {
139 str = N_("View Content of the File");
147 string const FormTexinfo::getVerboseTooltip(FL_OBJECT const * ob) const
151 if (ob == dialog_->radio_cls) {
152 str = N_("Shows the installed LaTeX Document classes. Remember, that these classes are only available in LyX if a corresponding LyX layout file exists!");
154 } else if (ob == dialog_->radio_sty) {
155 str = _("Shows the installed LaTeX style files, which are available in LyX by default, like \"babel\" or through \\usepackage{<the stylefile>} in LaTeX preamble.");
157 } else if (ob == dialog_->radio_bst) {
158 str = _("Shows the installed style files for BibTeX. They can be loaded through insert->Lists&Toc->BibTeX Reference->Style.");
160 } else if (ob == dialog_->button_rescan) {
161 str = _("Runs the script \"TexFiles.sh\" to build new file lists.");
163 } else if (ob == dialog_->button_fullPath) {
164 str = _("View full path or only file name. Full path is needed to view the contents of a file.");
166 } else if (ob == dialog_->button_texhash) {
167 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.");
169 } else if (ob == dialog_->button_view) {
170 str = N_("Shows the contents of the marked file. Only possible in full path mode.");