]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlVCLog.C
Once again the user can use the Font button on the toolbar to get the current
[lyx.git] / src / frontends / controllers / ControlVCLog.C
1 /* This file is part of
2  * ======================================================
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 2001 The LyX Team.
7  *
8  * ======================================================
9  *
10  * \file ControlVCLog.C
11  * \author John Levon, moz@compsoc.man.ac.uk
12  * \author Angus Leeming <a.leeming@ic.ac.uk>
13  */
14
15 #include <config.h>
16 #include <fstream>
17 #include "Lsstream.h"
18
19 #ifdef __GNUG__
20 #pragma implementation
21 #endif
22
23 #include "ViewBase.h"
24 #include "ButtonControllerBase.h"
25 #include "ControlVCLog.h"
26 #include "buffer.h"
27 #include "LyXView.h"
28 #include "Dialogs.h"
29 #include "lyxrc.h"
30
31 using SigC::slot;
32 using std::endl;
33
34 ControlVCLog::ControlVCLog(LyXView & lv, Dialogs & d)
35         : ControlDialog<ControlConnectBD>(lv, d)
36 {
37         d_.showVCLogFile.connect(slot(this, &ControlVCLog::show));
38 }
39
40 string const ControlVCLog::getBufferFileName() const
41 {
42         return lv_.view()->buffer()->fileName();
43 }
44
45
46 std::stringstream & ControlVCLog::getVCLogFile(std::stringstream & ss) const
47 {
48         string const name = lv_.view()->buffer()->lyxvc.getLogFile();
49
50         std::ifstream in(name.c_str());
51
52         bool found = (in.get());
53
54         if (found) {
55                 in.seekg(0, std::ios::beg); // rewind to the beginning
56
57                 ss << in.rdbuf();
58                 found = ss.good();
59         }
60         
61         if (!found)
62                 ss << "No version control log file found." << endl;
63
64         lyx::unlink(name);
65
66         return ss;
67 }