]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GShowFile.C
some tabular fixes for the problems reported by Helge
[lyx.git] / src / frontends / gtk / GShowFile.C
1 /**
2  * \file GShowFile.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Spray
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 // Too hard to make concept checks work with this file
12 #ifdef _GLIBCXX_CONCEPT_CHECKS
13 #undef _GLIBCXX_CONCEPT_CHECKS
14 #endif
15
16 #include "GShowFile.h"
17 #include "ControlShowFile.h"
18
19 #include "ghelpers.h"
20
21 using std::string;
22
23 namespace lyx {
24 namespace frontend {
25
26 GShowFile::GShowFile(Dialog & parent)
27         : GViewCB<ControlShowFile, GViewGladeB>(parent, _("Show File"), false)
28 {}
29
30
31 void GShowFile::doBuild()
32 {
33         string const gladeName = findGladeFile("showfile");
34         xml_ = Gnome::Glade::Xml::create(gladeName);
35
36         Gtk::Button * closebutton;
37         xml_->get_widget("Close", closebutton);
38         setCancel(closebutton);
39
40         Gtk::TextView * contentview;
41         xml_->get_widget("ContentView", contentview);
42         contentbuffer_ = contentview->get_buffer();
43 }
44
45
46 void GShowFile::update()
47 {
48         string const title = controller().getFileName();
49
50         if (!title.empty())
51                 setTitle(title);
52
53         string const contents = controller().getFileContents();
54
55         if (!contents.empty())
56                 contentbuffer_->set_text(contents);
57         else
58                 contentbuffer_->set_text(_("Error reading file!"));
59 }
60
61 } // namespace frontend
62 } // namespace lyx