]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/GLog.C
doxygen fixes.
[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 #ifdef __GNUG__
12 #pragma implementation
13 #endif
14
15 #include <config.h>
16 #include <fstream>
17
18 #include "gnomeBC.h"
19 #include "GLog.h"
20
21 #include <gtkmm/button.h>
22 #include <gtkmm/textview.h>
23 #include <gtkmm/dialog.h>
24
25 GLog::GLog(ControlLog & c)
26         : GnomeCB<ControlLog>(c, "GLog")
27 {}
28
29
30 GLog::~GLog()
31 {}
32
33
34 void GLog::build()
35 {
36         // Connect the buttons.
37         close_btn()->signal_clicked().connect(SigC::slot(*this, &GLog::CancelClicked));
38         refresh_btn()->signal_clicked().connect(SigC::slot(*this, &GLog::update));
39
40         // Manage the buttons state
41         bc().setCancel(close_btn());
42         bc().refresh();
43 }
44
45 void GLog::apply()
46 {}
47
48
49 void GLog::update()
50 {
51         using namespace std;
52         pair<Buffer::LogType, string> const logfile = controller().logfile();
53
54         if (logfile.first == Buffer::buildlog)
55                 dialog()->set_title(_("Build log"));
56         else
57                 dialog()->set_title(_("LaTeX log"));
58
59         log_text()->get_buffer()->set_text("");
60
61         ifstream ifstr(logfile.second.c_str());
62         if (!ifstr) {
63                 if (logfile.first == Buffer::buildlog)
64                         log_text()->get_buffer()->set_text(_("No build log file found"));
65                 else
66                         log_text()->get_buffer()->set_text(_("No LaTeX log file found"));
67                 return;
68         }
69
70         string text;
71         string line;
72
73         while (getline(ifstr, line))
74                 text += line + "\n";
75
76         log_text()->get_buffer()->set_text(text);
77 }
78
79
80 Gtk::Button * GLog::refresh_btn() const 
81 {
82         return getWidget<Gtk::Button>("r_refresh_btn");
83 }
84 Gtk::Button * GLog::close_btn() const 
85 {
86         return getWidget<Gtk::Button>("r_close_btn");
87 }
88 Gtk::TextView * GLog::log_text() const 
89 {
90         return getWidget<Gtk::TextView>("r_log_text");
91 }