]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GShowFile.C
Add ShowFile dialog
[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 #include "GShowFile.h"
12 #include "ControlShowFile.h"
13
14 #include "ghelpers.h"
15
16 using std::string;
17
18 namespace lyx {
19 namespace frontend {
20
21 GShowFile::GShowFile(Dialog & parent)
22         : GViewCB<ControlShowFile, GViewGladeB>(parent, _("Show File"), false)
23 {}
24
25
26 void GShowFile::doBuild()
27 {
28         string const gladeName = findGladeFile("showfile");
29         xml_ = Gnome::Glade::Xml::create(gladeName);
30
31         Gtk::Button * closebutton;
32         xml_->get_widget("Close", closebutton);
33         setCancel(closebutton);
34
35         Gtk::TextView * contentview;
36         xml_->get_widget("ContentView", contentview);
37         contentbuffer_ = contentview->get_buffer();
38 }
39
40
41 void GShowFile::update()
42 {
43         string const title = controller().getFileName();
44
45         if (!title.empty())
46                 setTitle(title);
47
48         string const contents = controller().getFileContents();
49
50         if (!contents.empty())
51                 contentbuffer_->set_text(contents);
52         else
53                 contentbuffer_->set_text(_("Error reading file!"));
54 }
55
56 } // namespace frontend
57 } // namespace lyx