]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GViewBase.C
Display accelerator (binding) labels in menus.
[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         update();
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::mem_fun(*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::mem_fun(*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::mem_fun(*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::mem_fun(*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