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