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