]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GShowFile.C
enable Font cache only for MacOSX and inline width() for other platform.
[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 <config.h>
12
13 // Too hard to make concept checks work with this file
14 #ifdef _GLIBCXX_CONCEPT_CHECKS
15 #undef _GLIBCXX_CONCEPT_CHECKS
16 #endif
17 #ifdef _GLIBCPP_CONCEPT_CHECKS
18 #undef _GLIBCPP_CONCEPT_CHECKS
19 #endif
20
21 #include "GShowFile.h"
22 #include "ControlShowFile.h"
23
24 #include "ghelpers.h"
25
26 using std::string;
27
28 namespace lyx {
29 namespace frontend {
30
31 GShowFile::GShowFile(Dialog & parent)
32         : GViewCB<ControlShowFile, GViewGladeB>(parent, lyx::to_utf8(_("Show File")), false)
33 {}
34
35
36 void GShowFile::doBuild()
37 {
38         string const gladeName = findGladeFile("showfile");
39         xml_ = Gnome::Glade::Xml::create(gladeName);
40
41         Gtk::Button * closebutton;
42         xml_->get_widget("Close", closebutton);
43         setCancel(closebutton);
44
45         Gtk::TextView * contentview;
46         xml_->get_widget("ContentView", contentview);
47         contentbuffer_ = contentview->get_buffer();
48 }
49
50
51 void GShowFile::update()
52 {
53         string const title = controller().getFileName();
54
55         if (!title.empty())
56                 setTitle(title);
57
58         string const contents = controller().getFileContents();
59
60         if (!contents.empty())
61                 contentbuffer_->set_text(contents);
62         else
63                 contentbuffer_->set_text(lyx::to_utf8(_("Error reading file!")));
64 }
65
66 } // namespace frontend
67 } // namespace lyx