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