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