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