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