]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormTexinfo.C
This file is part of LyX, the document processor.
[lyx.git] / src / frontends / xforms / FormTexinfo.C
1 /**
2  * \file FormTexinfo.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Herbert Voss
7  *
8  * Full author contact details are available in file CREDITS
9  * \date 2001-10-01
10  */
11
12 #include <config.h>
13 #include <fstream>
14
15 #ifdef __GNUG__
16 #pragma implementation
17 #endif
18
19 #include "xformsBC.h"
20 #include "FormTexinfo.h"
21 #include "forms/form_texinfo.h"
22 #include "Tooltips.h"
23 #include "gettext.h"
24 #include "debug.h"
25 #include "xforms_helpers.h"
26 #include "support/LAssert.h"
27 #include FORMS_H_LOCATION
28
29
30 typedef FormCB<ControlTexinfo, FormDB<FD_texinfo> > base_class;
31 FormTexinfo::FormTexinfo()
32         : base_class(_("LaTeX Information")),
33           activeStyle(ControlTexinfo::cls)
34 {}
35
36
37 void FormTexinfo::build() {
38         dialog_.reset(build_texinfo(this));
39         // courier medium
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);
44
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);
48
49         str = _("Shows the contents of the marked file. Only possible in full path mode.");
50         tooltips().init(dialog_->button_view, str);
51
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);
54
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);
57
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);
60
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);
63
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);
66 }
67
68
69 ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long) {
70
71         if (ob == dialog_->radio_cls) {
72                 updateStyles(ControlTexinfo::cls);
73
74         } else if (ob == dialog_->radio_sty) {
75                 updateStyles(ControlTexinfo::sty);
76
77         } else if (ob == dialog_->radio_bst) {
78                 updateStyles(ControlTexinfo::bst);
79
80         } else if (ob == dialog_->button_rescan) {
81                 // build new *Files.lst
82                 controller().rescanStyles();
83                 updateStyles(activeStyle);
84
85         } else if (ob == dialog_->check_fullpath) {
86                 setEnabled(dialog_->button_view,
87                            fl_get_button(dialog_->check_fullpath));
88                 updateStyles(activeStyle);
89
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();
96
97         } else if (ob == dialog_->button_view) {
98                 unsigned int selection = fl_get_browser(dialog_->browser);
99                 // a valid entry?
100                 if (selection > 0) {
101                         controller().viewFile(
102                                 fl_get_browser_line(dialog_->browser,
103                                                     selection));
104                 }
105         }
106
107         return ButtonPolicy::SMI_VALID;
108 }
109
110 void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
111 {
112         fl_clear_browser(dialog_->browser);
113
114         bool const withFullPath = fl_get_button(dialog_->check_fullpath);
115
116         string const str =
117                 controller().getContents(whichStyle, withFullPath);
118         fl_add_browser_line(dialog_->browser, str.c_str());
119
120         activeStyle = whichStyle;
121 }