]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GViewBase.C
some tabular fixes for the problems reported by Helge
[lyx.git] / src / frontends / gtk / GViewBase.C
1 /**
2  * \file GViewBase.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Huang Ying
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 "GViewBase.h"
22 #include "support/filetools.h"
23
24 using std::string;
25
26 namespace lyx {
27 namespace frontend {
28
29 GViewBase::GViewBase(Dialog & parent, string const & t, bool allowResize) :
30         Dialog::View(parent, t), allowResize_(allowResize)
31 {
32 }
33
34
35 GViewBase::~GViewBase()
36 {
37 }
38
39
40 void GViewBase::hide()
41 {
42         window()->hide();
43 }
44
45
46 void GViewBase::build()
47 {
48         doBuild();
49         string const iconName =
50                 support::LibFileSearch("images", "lyx", "xpm");
51         if (!iconName.empty())
52                 window()->set_icon_from_file(iconName);
53         window()->signal_delete_event().connect(
54                 sigc::mem_fun(*this, &GViewBase::onDeleteEvent));
55         window()->set_title(Glib::locale_to_utf8(getTitle()));
56 }
57
58
59 void GViewBase::show()
60 {
61         if (!window()) {
62                 build();
63         }
64         update();
65         window()->show();
66 }
67
68
69 bool GViewBase::isVisible() const
70 {
71         return window() && window()->is_visible();
72 }
73
74
75 GBC & GViewBase::bcview()
76 {
77         return static_cast<GBC &>(dialog().bc().view());
78 }
79
80
81 void GViewBase::setCancel(Gtk::Button * cancel)
82 {
83         bcview().setCancel(cancel);
84         cancel->signal_clicked().connect(
85                 sigc::mem_fun(*this, &GViewBase::onCancel));
86 }
87
88
89 void GViewBase::setApply(Gtk::Button * apply)
90 {
91         bcview().setApply(apply);
92         apply->signal_clicked().connect(
93                 sigc::mem_fun(*this, &GViewBase::onApply));
94 }
95
96
97 void GViewBase::setOK(Gtk::Button * ok)
98 {
99         bcview().setOK(ok);
100         ok->signal_clicked().connect(
101                 sigc::mem_fun(*this, &GViewBase::onOK));
102 }
103
104
105 void GViewBase::setRestore(Gtk::Button * restore)
106 {
107         bcview().setRestore(restore);
108         restore->signal_clicked().connect(
109                 sigc::mem_fun(*this, &GViewBase::onRestore));
110 }
111
112
113 void GViewBase::setTitle(std::string const & title)
114 {
115         Dialog::View::setTitle(title);
116         window()->set_title(title);
117 }
118
119
120 bool GViewBase::readOnly() const
121 {
122         return kernel().isBufferReadonly();
123 }
124
125
126 void GViewBase::onApply()
127 {
128         dialog().ApplyButton();
129 }
130
131
132 void GViewBase::onOK()
133 {
134         dialog().OKButton();
135 }
136
137
138 void GViewBase::onCancel()
139 {
140         dialog().CancelButton();
141 }
142
143
144 void GViewBase::onRestore()
145 {
146         dialog().RestoreButton();
147 }
148
149
150 bool GViewBase::onDeleteEvent(GdkEventAny *)
151 {
152         dialog().CancelButton();
153         return false;
154 }
155
156
157 GViewGladeB::GViewGladeB(Dialog & parent, string const & t, bool allowResize) :
158         GViewBase(parent, t, allowResize)
159 {
160 }
161
162
163 Gtk::Window * GViewGladeB::window()
164 {
165         Gtk::Window * win;
166         if (!xml_)
167                 return 0;
168         xml_->get_widget("dialog", win);
169         return win;
170 }
171
172
173 Gtk::Window const * GViewGladeB::window() const
174 {
175         Gtk::Window * win;
176         if (!xml_)
177                 return 0;
178         xml_->get_widget("dialog", win);
179         return win;
180 }
181
182 } // namespace frontend
183 } // namespace lyx