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