]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlCredits.C
Reorganised, cleaned-up and improved documentation of controllers.
[lyx.git] / src / frontends / controllers / ControlCredits.C
1 /**
2  * \file ControlCredits.C
3  * Copyright 2001 The LyX Team.
4  * See the file COPYING.
5  *
6  * \author Edwin Leuven, leuven@fee.uva.nl
7  * \author Angus Leeming, a.leeming@.ac.uk
8  */
9
10 #include <fstream>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include <config.h>
17
18 #include "ControlCredits.h"
19 #include "Dialogs.h"
20 #include "LyXView.h"
21 #include "BufferView.h"
22 #include "gettext.h"
23 #include "support/filetools.h" // FileSearch
24
25 using SigC::slot;
26 using std::getline;
27 using std::ifstream;
28 using std::ios_base;
29 using std::vector;
30
31 ControlCredits::ControlCredits(LyXView & lv, Dialogs & d)
32         : ControlDialog<ControlConnectBI>(lv, d)
33 {
34         d_.showCredits.connect(slot(this, &ControlCredits::show));
35 }
36
37
38 // needed for the browser
39 extern string system_lyxdir;
40
41 vector<string> const ControlCredits::getCredits() const
42 {
43         vector<string> data;
44
45         string const name = FileSearch(system_lyxdir, "CREDITS");
46
47         bool found = (!name.empty());
48
49         if (found) {
50                 ifstream in(name.c_str());
51                 found = (in.get());
52
53                 if (found) {
54                         in.seekg(0, ios_base::beg); // rewind to the beginning
55
56                         for(;;) {
57                                 string line;
58                                 getline(in, line);
59                                 if (!in.good()) break;
60                                 data.push_back(line);
61                         }
62                 }
63         }
64
65         if (!found) {
66                 data.push_back(_("ERROR: LyX wasn't able to read CREDITS file"));
67                 data.push_back(_("Please install correctly to estimate the great"));
68                 data.push_back(_("amount of work other people have done for the LyX project."));
69         }
70
71         return data;
72 }