]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormTexinfo.C
80f586b04c112ecfcdf334afecda13628fa1570e
[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         setPrehandler(dialog_->button_rescan);
42         setPrehandler(dialog_->button_view);
43         setPrehandler(dialog_->button_texhash);
44         setPrehandler(dialog_->button_fullPath);
45         setPrehandler(dialog_->browser);
46         setPrehandler(dialog_->radio_cls);
47         setPrehandler(dialog_->radio_sty);
48         setPrehandler(dialog_->radio_bst);
49         setPrehandler(dialog_->message);
50
51         setTooltipHandler(dialog_->button_rescan);
52         setTooltipHandler(dialog_->button_view);
53         setTooltipHandler(dialog_->button_texhash);
54         setTooltipHandler(dialog_->button_fullPath);
55         setTooltipHandler(dialog_->browser);
56         setTooltipHandler(dialog_->radio_cls);
57         setTooltipHandler(dialog_->radio_sty);
58         setTooltipHandler(dialog_->radio_bst);
59         setTooltipHandler(dialog_->message);
60 }
61
62
63 ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long) {
64
65         if (ob == dialog_->radio_cls) {
66                 updateStyles(ControlTexinfo::cls); 
67
68         } else if (ob == dialog_->radio_sty) {
69                 updateStyles(ControlTexinfo::sty); 
70
71         } else if (ob == dialog_->radio_bst) {
72                 updateStyles(ControlTexinfo::bst); 
73
74         } else if (ob == dialog_->button_rescan) {
75                 // build new *Files.lst
76                 controller().rescanStyles();
77                 updateStyles(activeStyle);
78
79         } else if (ob == dialog_->button_fullPath) {
80                 setEnabled(dialog_->button_view,
81                            fl_get_button(dialog_->button_fullPath));
82                 updateStyles(activeStyle);
83
84         } else if (ob == dialog_->button_texhash) {
85                 // makes only sense if the rights are set well for
86                 // users (/var/lib/texmf/ls-R)
87                 controller().runTexhash();
88                 // update files in fact of texhash
89                 controller().rescanStyles();
90
91         } else if (ob == dialog_->button_view) {
92                 unsigned int selection = fl_get_browser(dialog_->browser);
93                 // a valid entry?
94                 if (selection > 0) {
95                         controller().viewFile( 
96                                 fl_get_browser_line(dialog_->browser,
97                                                     selection));
98                 }
99         }
100
101         return ButtonPolicy::SMI_VALID;
102 }
103
104 void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
105 {
106         fl_clear_browser(dialog_->browser); 
107
108         bool const withFullPath = fl_get_button(dialog_->button_fullPath);
109
110         string const str = 
111                 controller().getContents(whichStyle, withFullPath);
112         fl_add_browser_line(dialog_->browser, str.c_str());
113
114         activeStyle = whichStyle;
115 }
116
117
118 void FormTexinfo::clear_feedback()
119 {
120         fl_set_object_label(dialog_->message, "");
121         fl_redraw_object(dialog_->message);
122 }
123
124
125 string const FormTexinfo::getTooltip(FL_OBJECT * ob)
126 {
127         string str;
128
129         if (ob == dialog_->radio_cls) {
130                 str = N_("");
131
132         } else if (ob == dialog_->radio_sty) {
133                 str = _("");
134
135         } else if (ob == dialog_->radio_bst) {
136                 str = _("");
137
138         } else if (ob == dialog_->button_rescan) {
139                 str = _("Rescan File List");
140
141         } else if (ob == dialog_->button_fullPath) {
142                 str = _("Show Full Path or not");
143
144         } else if (ob == dialog_->button_texhash) {
145                 str = _("");
146
147         } else if (ob == dialog_->button_view) {
148                 str = N_("View Content of the File");
149
150         }
151
152         return str;
153 }
154
155 void FormTexinfo::feedback(FL_OBJECT * ob)
156 {
157         lyx::Assert(ob);
158
159         string str;
160
161         if (ob == dialog_->radio_cls) {
162                 str = N_("Shows the installed LaTeX Document classes. Remember, that these classes are only available in LyX if a corresponding LyX layout file exists!");
163
164         } else if (ob == dialog_->radio_sty) {
165                 str = _("Shows the installed LaTeX style files, which are available in LyX by default, like \"babel\" or through \\usepackage{<the stylefile>} in LaTeX preamble.");
166
167         } else if (ob == dialog_->radio_bst) {
168                 str = _("Shows the installed style files for BibTeX. They can be loaded through insert->Lists&Toc->BibTeX Reference->Style.");
169
170         } else if (ob == dialog_->button_rescan) {
171                 str = _("Runs the script \"TexFiles.sh\" to build new file lists.");
172
173         } else if (ob == dialog_->button_fullPath) {
174                 str = _("View full path or only file name. Full path is needed to view the contents of a file.");
175
176         } else if (ob == dialog_->button_texhash) {
177                 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.");
178
179         } else if (ob == dialog_->button_view) {
180                 str = N_("Shows the contents of the marked file. Only possible in full path mode.");
181
182         }
183
184         str = formatted(_(str), dialog_->message->w-10, FL_SMALL_SIZE);
185
186         fl_set_object_label(dialog_->message, str.c_str());
187         fl_set_object_lsize(dialog_->message, FL_SMALL_SIZE);
188         fl_redraw_object(dialog_->message);
189 }