]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormTexinfo.C
Stabilise the tooltips interface and use it successfully in the Bibtex,
[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 "gettext.h"
21 #include "debug.h"
22 #include "xforms_helpers.h"
23 #include "support/LAssert.h"
24     
25
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)
30 {}
31
32
33 void FormTexinfo::build() {
34         dialog_.reset(build_texinfo());
35         // courier medium
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);
40
41         // the help choice
42         fillTooltipChoice(dialog_->choice_help);
43
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);
53 }
54
55
56 ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long) {
57
58         if (ob == dialog_->radio_cls) {
59                 updateStyles(ControlTexinfo::cls);
60
61         } else if (ob == dialog_->radio_sty) {
62                 updateStyles(ControlTexinfo::sty); 
63
64         } else if (ob == dialog_->radio_bst) {
65                 updateStyles(ControlTexinfo::bst); 
66
67         } else if (ob == dialog_->button_rescan) {
68                 // build new *Files.lst
69                 controller().rescanStyles();
70                 updateStyles(activeStyle);
71
72         } else if (ob == dialog_->button_fullPath) {
73                 setEnabled(dialog_->button_view,
74                            fl_get_button(dialog_->button_fullPath));
75                 updateStyles(activeStyle);
76
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();
83
84         } else if (ob == dialog_->button_view) {
85                 unsigned int selection = fl_get_browser(dialog_->browser);
86                 // a valid entry?
87                 if (selection > 0) {
88                         controller().viewFile( 
89                                 fl_get_browser_line(dialog_->browser,
90                                                     selection));
91                 }
92         }
93
94         if (ob == dialog_->choice_help) {
95                 setTooltipLevel(dialog_->choice_help);
96                 return ButtonPolicy::SMI_NOOP;
97         }
98
99         return ButtonPolicy::SMI_VALID;
100 }
101
102 void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
103 {
104         fl_clear_browser(dialog_->browser); 
105
106         bool const withFullPath = fl_get_button(dialog_->button_fullPath);
107
108         string const str = 
109                 controller().getContents(whichStyle, withFullPath);
110         fl_add_browser_line(dialog_->browser, str.c_str());
111
112         activeStyle = whichStyle;
113 }
114
115
116 string const FormTexinfo::getMinimalTooltip(FL_OBJECT const * ob) const
117 {
118         string str;
119
120         if (ob == dialog_->radio_cls) {
121                 str = N_("Available LaTeX Classes");
122
123         } else if (ob == dialog_->radio_sty) {
124                 str = _("Available LaTeX Styles");
125
126         } else if (ob == dialog_->radio_bst) {
127                 str = _("Available BibTeX Styles");
128
129         } else if (ob == dialog_->button_rescan) {
130                 str = _("Rescan File List");
131
132         } else if (ob == dialog_->button_fullPath) {
133                 str = _("Show Full Path or not");
134
135         } else if (ob == dialog_->button_texhash) {
136                 str = _("Execute Script \"Texhash\"");
137
138         } else if (ob == dialog_->button_view) {
139                 str = N_("View Content of the File");
140
141         }
142
143         return str;
144 }
145
146
147 string const FormTexinfo::getVerboseTooltip(FL_OBJECT const * ob) const
148 {
149         string str;
150
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!");
153
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.");
156
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.");
159
160         } else if (ob == dialog_->button_rescan) {
161                 str = _("Runs the script \"TexFiles.sh\" to build new file lists.");
162
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.");
165
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.");
168
169         } else if (ob == dialog_->button_view) {
170                 str = N_("Shows the contents of the marked file. Only possible in full path mode.");
171
172         }
173
174         return str;
175 }