]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormTexinfo.C
Really dull and boring header shit
[lyx.git] / src / frontends / xforms / FormTexinfo.C
1 /**
2  * \file FormTexinfo.C
3  * Read the file COPYING
4  *
5  * \author Herbert Voss
6  *
7  * Full author contact details are available in file CREDITS
8  * \date 2001-10-01
9  */
10
11 #include <config.h>
12 #include <fstream>
13
14 #ifdef __GNUG__
15 #pragma implementation
16 #endif
17
18 #include "xformsBC.h"
19 #include "FormTexinfo.h"
20 #include "forms/form_texinfo.h"
21 #include "Tooltips.h"
22 #include "gettext.h"
23 #include "debug.h"
24 #include "xforms_helpers.h"
25 #include "support/LAssert.h"
26 #include FORMS_H_LOCATION
27
28
29 typedef FormCB<ControlTexinfo, FormDB<FD_texinfo> > base_class;
30 FormTexinfo::FormTexinfo()
31         : base_class(_("LaTeX Information")),
32           activeStyle(ControlTexinfo::cls)
33 {}
34
35
36 void FormTexinfo::build() {
37         dialog_.reset(build_texinfo(this));
38         // courier medium
39         fl_set_browser_fontstyle(dialog_->browser,FL_FIXED_STYLE);
40         // with Path is default
41         fl_set_button(dialog_->check_fullpath, 1);
42         updateStyles(ControlTexinfo::cls);
43
44         // set up the tooltips
45         string str = _("Runs the script \"TexFiles.sh\" to build new file lists.");
46         tooltips().init(dialog_->button_rescan, str);
47
48         str = _("Shows the contents of the marked file. Only possible in full path mode.");
49         tooltips().init(dialog_->button_view, str);
50
51         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.");
52         tooltips().init(dialog_->button_texhash, str);
53
54         str = _("View full path or only file name. Full path is needed to view the contents of a file.");
55         tooltips().init(dialog_->check_fullpath, str);
56
57         str = _("Shows the installed LaTeX Document classes. Remember, that these classes are only available in LyX if a corresponding LyX layout file exists!");
58         tooltips().init(dialog_->radio_cls, str);
59
60         str = _("Shows the installed LaTeX style files, which are available in LyX by default, like \"babel\" or through \\usepackage{<the stylefile>} in LaTeX preamble.");
61         tooltips().init(dialog_->radio_sty, str);
62
63         str = _("Shows the installed style files for BibTeX. They can be loaded through insert->Lists&Toc->BibTeX Reference->Style.");
64         tooltips().init(dialog_->radio_bst, str);
65 }
66
67
68 ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long) {
69
70         if (ob == dialog_->radio_cls) {
71                 updateStyles(ControlTexinfo::cls);
72
73         } else if (ob == dialog_->radio_sty) {
74                 updateStyles(ControlTexinfo::sty);
75
76         } else if (ob == dialog_->radio_bst) {
77                 updateStyles(ControlTexinfo::bst);
78
79         } else if (ob == dialog_->button_rescan) {
80                 // build new *Files.lst
81                 controller().rescanStyles();
82                 updateStyles(activeStyle);
83
84         } else if (ob == dialog_->check_fullpath) {
85                 setEnabled(dialog_->button_view,
86                            fl_get_button(dialog_->check_fullpath));
87                 updateStyles(activeStyle);
88
89         } else if (ob == dialog_->button_texhash) {
90                 // makes only sense if the rights are set well for
91                 // users (/var/lib/texmf/ls-R)
92                 controller().runTexhash();
93                 // update files in fact of texhash
94                 controller().rescanStyles();
95
96         } else if (ob == dialog_->button_view) {
97                 unsigned int selection = fl_get_browser(dialog_->browser);
98                 // a valid entry?
99                 if (selection > 0) {
100                         controller().viewFile(
101                                 fl_get_browser_line(dialog_->browser,
102                                                     selection));
103                 }
104         }
105
106         return ButtonPolicy::SMI_VALID;
107 }
108
109 void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
110 {
111         fl_clear_browser(dialog_->browser);
112
113         bool const withFullPath = fl_get_button(dialog_->check_fullpath);
114
115         string const str =
116                 controller().getContents(whichStyle, withFullPath);
117         fl_add_browser_line(dialog_->browser, str.c_str());
118
119         activeStyle = whichStyle;
120 }