]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/GLog.C
Martin's changes to the Note inset.
[lyx.git] / src / frontends / gnome / GLog.C
1 /**
2  * \file GLog.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Michael Koziarski
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11
12 #include <config.h>
13 #include <fstream>
14
15 #include "gnomeBC.h"
16 #include "GLog.h"
17
18 #include <gtkmm/button.h>
19 #include <gtkmm/textview.h>
20 #include <gtkmm/dialog.h>
21
22 GLog::GLog()
23         : GnomeCB<ControlLog>("GLog")
24 {}
25
26
27 GLog::~GLog()
28 {}
29
30
31 void GLog::build()
32 {
33         // Connect the buttons.
34         close_btn()->signal_clicked().connect(SigC::slot(*this, &GLog::CancelClicked));
35         refresh_btn()->signal_clicked().connect(SigC::slot(*this, &GLog::update));
36
37         // Manage the buttons state
38         bc().setCancel(close_btn());
39         bc().refresh();
40 }
41
42 void GLog::apply()
43 {}
44
45
46 void GLog::update()
47 {
48         using namespace std;
49         pair<Buffer::LogType, string> const logfile = controller().logfile();
50
51         if (logfile.first == Buffer::buildlog)
52                 dialog()->set_title(_("Build log"));
53         else
54                 dialog()->set_title(_("LaTeX log"));
55
56         log_text()->get_buffer()->set_text("");
57
58         ifstream ifstr(logfile.second.c_str());
59         if (!ifstr) {
60                 if (logfile.first == Buffer::buildlog)
61                         log_text()->get_buffer()->set_text(_("No build log file found."));
62                 else
63                         log_text()->get_buffer()->set_text(_("No LaTeX log file found."));
64                 return;
65         }
66
67         string text;
68         string line;
69
70         while (getline(ifstr, line))
71                 text += line + "\n";
72
73         log_text()->get_buffer()->set_text(text);
74 }
75
76
77 Gtk::Button * GLog::refresh_btn() const
78 {
79         return getWidget<Gtk::Button>("r_refresh_btn");
80 }
81 Gtk::Button * GLog::close_btn() const
82 {
83         return getWidget<Gtk::Button>("r_close_btn");
84 }
85 Gtk::TextView * GLog::log_text() const
86 {
87         return getWidget<Gtk::TextView>("r_log_text");
88 }