~ubuntu-branches/ubuntu/vivid/ardour/vivid-proposed

« back to all changes in this revision

Viewing changes to libs/gtkmm2/gtk/gtkmm/menu_elems.cc

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler, Jaromír Mikeš, Felipe Sateler
  • Date: 2014-05-22 14:39:25 UTC
  • mfrom: (29 sid)
  • mto: This revision was merged to the branch mainline in revision 30.
  • Revision ID: package-import@ubuntu.com-20140522143925-vwqfo9287pmkrroe
Tags: 1:2.8.16+git20131003-3
* Team upload

[ Jaromír Mikeš ]
* Add -dbg package

[ Felipe Sateler ]
* Upload to experimental

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- c++ -*-
 
2
/* $Id$ */
 
3
 
 
4
/* 
 
5
 *
 
6
 * Copyright 1998-2002 The gtkmm Development Team
 
7
 *
 
8
 * This library is free software; you can redistribute it and/or
 
9
 * modify it under the terms of the GNU Library General Public
 
10
 * License as published by the Free Software Foundation; either
 
11
 * version 2 of the License, or (at your option) any later version.
 
12
 *
 
13
 * This library is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 * Library General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU Library General Public
 
19
 * License along with this library; if not, write to the Free
 
20
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
21
 */
 
22
 
 
23
#include <gtk/gtkimagemenuitem.h>
 
24
 
 
25
#include <gtkmm/menu_elems.h>
 
26
#include <gtkmm/label.h>
 
27
 
 
28
#ifndef GLIBMM_WIN32
 
29
#include <strings.h>
 
30
#endif // GLIBMM_WIN32
 
31
 
 
32
namespace Gtk
 
33
{
 
34
 
 
35
namespace Menu_Helpers
 
36
{
 
37
 
 
38
Element::Element()
 
39
{
 
40
}
 
41
 
 
42
Element::Element(MenuItem& child)
 
43
{
 
44
  //TODO: Can't we avoid using RefPtr<> with a widget. It's not what it's meant for, and apparently it doesn't work well. murrayc.
 
45
  child_ = Glib::RefPtr<MenuItem>(&child);
 
46
  child_->reference(); //It's normally used with a create(), which starts with a refcount of 1.
 
47
}
 
48
 
 
49
Element::~Element()
 
50
{}
 
51
 
 
52
void Element::set_child(MenuItem* pChild)
 
53
{
 
54
  child_ = Glib::RefPtr<MenuItem>(pChild);
 
55
  child_->reference(); //TODO. We used to use the old RefPtr::operator=(), and this is what it did.
 
56
}
 
57
 
 
58
void Element::set_accel_key(const AccelKey& accel_key)
 
59
{
 
60
  if(child_)
 
61
    child_->set_accel_key(accel_key);
 
62
}
 
63
 
 
64
const Glib::RefPtr<MenuItem>& Element::get_child() const
 
65
{
 
66
  return child_;
 
67
}
 
68
 
 
69
MenuElem::MenuElem(MenuItem& child)
 
70
: Element(child)
 
71
{}
 
72
 
 
73
MenuElem::MenuElem(const Glib::ustring& label, 
 
74
                   const CallSlot& slot)
 
75
{
 
76
  set_child( manage(new MenuItem(label, true)) );
 
77
  if(slot)
 
78
    child_->signal_activate().connect(slot);
 
79
  child_->show();
 
80
}
 
81
 
 
82
MenuElem::MenuElem(const Glib::ustring& label,
 
83
                   const AccelKey& accel_key,
 
84
                   const CallSlot& slot)
 
85
{
 
86
  set_child( manage(new MenuItem(label, true)) );
 
87
  if(slot)
 
88
    child_->signal_activate().connect(slot);
 
89
  set_accel_key(accel_key);
 
90
  child_->show();
 
91
}
 
92
 
 
93
MenuElem::MenuElem(const Glib::ustring& label, Menu& submenu)
 
94
{
 
95
  set_child( manage(new MenuItem(label, true)) );
 
96
  child_->set_submenu(submenu);
 
97
  child_->show();
 
98
}
 
99
 
 
100
MenuElem::MenuElem(const Glib::ustring& label, 
 
101
                   const AccelKey& accel_key,
 
102
                   Gtk::Menu& submenu)
 
103
{
 
104
  set_child( manage(new MenuItem(label, true)) );
 
105
  child_->set_submenu(submenu);
 
106
  set_accel_key(accel_key);
 
107
  child_->show();
 
108
}
 
109
 
 
110
SeparatorElem::SeparatorElem()
 
111
{
 
112
  set_child( manage(new SeparatorMenuItem()) );
 
113
  child_->show();
 
114
}
 
115
 
 
116
ImageMenuElem::ImageMenuElem(ImageMenuItem& child)
 
117
: Element(child)
 
118
{}
 
119
 
 
120
ImageMenuElem::ImageMenuElem(const Glib::ustring& label,
 
121
                             Gtk::Widget& image_widget,
 
122
                             const CallSlot& slot)
 
123
{
 
124
  image_widget.show(); //We assume that the coder wants to actually show the widget.
 
125
  set_child( manage(new ImageMenuItem(image_widget, label, true)) );
 
126
  if(slot)
 
127
    child_->signal_activate().connect(slot);
 
128
  child_->show();
 
129
}
 
130
 
 
131
ImageMenuElem::ImageMenuElem(const Glib::ustring& label,
 
132
                             const AccelKey& accel_key,
 
133
                             Gtk::Widget& image_widget,
 
134
                             const CallSlot& slot)
 
135
{
 
136
  image_widget.show(); //We assume that the coder wants to actually show the widget.
 
137
  set_child( manage(new ImageMenuItem(image_widget, label, true)) );
 
138
  if(slot)
 
139
    child_->signal_activate().connect(slot);
 
140
  set_accel_key(accel_key);
 
141
  child_->show();
 
142
}
 
143
 
 
144
ImageMenuElem::ImageMenuElem(const Glib::ustring& label,
 
145
                             Gtk::Widget& image_widget,
 
146
                             Gtk::Menu& submenu)
 
147
{
 
148
  image_widget.show(); //We assume that the coder wants to actually show the widget.
 
149
  set_child( manage(new ImageMenuItem(image_widget, label, true)) );
 
150
  child_->set_submenu(submenu);
 
151
  child_->show();
 
152
}
 
153
 
 
154
ImageMenuElem::ImageMenuElem(const Glib::ustring& label,
 
155
                             const AccelKey& accel_key,
 
156
                             Gtk::Widget& image_widget,
 
157
                             Gtk::Menu& submenu)
 
158
{
 
159
  image_widget.show(); //We assume that the coder wants to actually show the widget.
 
160
  set_child( manage(new ImageMenuItem(image_widget, label, true)) );
 
161
  set_accel_key(accel_key);
 
162
  child_->set_submenu(submenu);
 
163
  child_->show();
 
164
}
 
165
 
 
166
StockMenuElem::StockMenuElem(const Gtk::StockID& stock_id,
 
167
                             const CallSlot& slot)
 
168
{
 
169
  set_child( manage(new ImageMenuItem(stock_id)) );
 
170
  if(slot)
 
171
    child_->signal_activate().connect(slot);
 
172
  child_->show();
 
173
}
 
174
 
 
175
StockMenuElem::StockMenuElem(const Gtk::StockID& stock_id,
 
176
                             const AccelKey& accel_key,
 
177
                             const CallSlot& slot)
 
178
{
 
179
  set_child( manage(new ImageMenuItem(stock_id)) );
 
180
  if(slot)
 
181
    child_->signal_activate().connect(slot);
 
182
  set_accel_key(accel_key);
 
183
  child_->show();
 
184
}
 
185
 
 
186
StockMenuElem::StockMenuElem(const Gtk::StockID& stock_id,
 
187
                             Gtk::Menu& submenu)
 
188
{
 
189
  set_child( manage(new ImageMenuItem(stock_id)) );
 
190
  child_->set_submenu(submenu);
 
191
  child_->show();
 
192
}
 
193
 
 
194
StockMenuElem::StockMenuElem(const Gtk::StockID& stock_id,
 
195
                             const AccelKey& accel_key,
 
196
                             Gtk::Menu& submenu)
 
197
{
 
198
  set_child( manage(new ImageMenuItem(stock_id)) );
 
199
  set_accel_key(accel_key);
 
200
  child_->set_submenu(submenu);
 
201
  child_->show();
 
202
}
 
203
 
 
204
CheckMenuElem::CheckMenuElem(CheckMenuItem& child)
 
205
: Element(child)
 
206
{}
 
207
 
 
208
CheckMenuElem::CheckMenuElem(const Glib::ustring& label,
 
209
                             const CallSlot& slot)
 
210
{
 
211
  CheckMenuItem* item = manage(new CheckMenuItem(label, true));
 
212
  set_child( item );
 
213
  if(slot)
 
214
    item->signal_toggled().connect(slot);
 
215
  child_->show();
 
216
}
 
217
 
 
218
CheckMenuElem::CheckMenuElem(const Glib::ustring& label,
 
219
                             const AccelKey& accel_key,
 
220
                             const CallSlot& slot)
 
221
{
 
222
  CheckMenuItem* item = manage(new CheckMenuItem(label, true));
 
223
  set_child( item );
 
224
  set_accel_key(accel_key);
 
225
  if(slot)
 
226
    item->signal_toggled().connect(slot);
 
227
  child_->show();
 
228
}
 
229
 
 
230
 
 
231
RadioMenuElem::RadioMenuElem(RadioMenuItem& child)
 
232
: Element(child), gr_(0)
 
233
{}
 
234
 
 
235
RadioMenuElem::RadioMenuElem(RadioMenuItem::Group& group,
 
236
                             const Glib::ustring& label,
 
237
                             const CallSlot& slot)
 
238
  : gr_(&group)
 
239
{
 
240
  CheckMenuItem* item = manage(new RadioMenuItem(*gr_, label, true));
 
241
  set_child( item );
 
242
  if(slot)
 
243
    item->signal_toggled().connect(slot);
 
244
  child_->show();
 
245
}
 
246
 
 
247
RadioMenuElem::RadioMenuElem(RadioMenuItem::Group& gr,
 
248
                             const Glib::ustring& label,
 
249
                             const AccelKey& accel_key,
 
250
                             const CallSlot& slot)
 
251
  : gr_(&gr)
 
252
{
 
253
  CheckMenuItem* item = manage(new RadioMenuItem(*gr_, label, true));
 
254
  set_child( item );
 
255
  set_accel_key(accel_key);
 
256
  if(slot)
 
257
    item->signal_toggled().connect(slot);
 
258
  child_->show();
 
259
}
 
260
 
 
261
TearoffMenuElem::TearoffMenuElem(TearoffMenuItem& child)
 
262
: Element(child)
 
263
{}
 
264
 
 
265
TearoffMenuElem::TearoffMenuElem(const CallSlot& slot)
 
266
{
 
267
  set_child( manage(new TearoffMenuItem()) );
 
268
  if(slot)
 
269
    child_->signal_activate().connect(slot);
 
270
  child_->show();
 
271
}
 
272
 
 
273
TearoffMenuElem::TearoffMenuElem(const AccelKey& accel_key,
 
274
                                 const CallSlot& slot)
 
275
{
 
276
  set_child( manage(new TearoffMenuItem()) );
 
277
  set_accel_key(accel_key);
 
278
  if(slot)
 
279
    child_->signal_activate().connect(slot);
 
280
  child_->show();
 
281
}
 
282
 
 
283
} /* namespace Menu_Helpers */
 
284
 
 
285
} /* namespace Gtk */
 
286