]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormTexinfo.C
Yet more dialog tweaking from Rob.
[lyx.git] / src / frontends / xforms / FormTexinfo.C
1 /**
2  * \file FormTexinfo.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Herbert Voss
7  *
8  * Full author contact details are available in file CREDITS
9  * \date 2001-10-01
10  */
11
12 #include <config.h>
13 #include <fstream>
14
15 #ifdef __GNUG__
16 #pragma implementation
17 #endif
18
19 #include "xformsBC.h"
20 #include "FormTexinfo.h"
21 #include "forms/form_texinfo.h"
22 #include "Tooltips.h"
23 #include "gettext.h"
24 #include "debug.h"
25 #include "xforms_helpers.h"
26 #include "support/LAssert.h"
27 #include FORMS_H_LOCATION
28
29
30 typedef FormCB<ControlTexinfo, FormDB<FD_texinfo> > base_class;
31 FormTexinfo::FormTexinfo()
32         : base_class(_("LaTeX Information")),
33           activeStyle(ControlTexinfo::cls)
34 {}
35
36
37 void FormTexinfo::build() {
38         dialog_.reset(build_texinfo(this));
39
40         updateStyles(ControlTexinfo::cls);
41
42         string const classes_List = _("LaTeX classes|LaTeX styles|BibTeX styles");
43         fl_addto_choice(dialog_->choice_classes, classes_List.c_str());
44
45         // set up the tooltips
46         string str = _("Shows the installed classses and styles for LaTeX/BibTeX. These classes are only available in LyX if a corresponding LyX layout file exists.");
47         tooltips().init(dialog_->choice_classes, str);
48
49         str = _("View full path or only file name.");
50         tooltips().init(dialog_->check_fullpath, str);
51
52         str = _("Runs the script \"TexFiles.sh\" to build new file lists.");
53         tooltips().init(dialog_->button_rescan, str);
54
55         str = _("Shows the contents of the marked file. Only possible in full path mode.");
56         tooltips().init(dialog_->button_view, str);
57
58         str = _("Runs the script \"texhash\" which builds a new LaTeX tree. Needed if you install a new TeX class or style. You need write permissions for the TeX-dirs, often /var/lib/texmf and others.");
59         tooltips().init(dialog_->button_texhash, str);
60 }
61
62
63 ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long) {
64
65         if (ob == dialog_->choice_classes) {
66                 switch (fl_get_choice(dialog_->choice_classes)) {
67                 case 1:
68                         updateStyles(ControlTexinfo::cls);
69                         break;
70                 case 2:
71                         updateStyles(ControlTexinfo::sty);
72                         break;
73                 case 3:
74                 default:
75                         updateStyles(ControlTexinfo::bst);
76                 }
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 }