Install ardour as a binary, a script and a set of shared
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / accelgroup.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3 #include <gtkmm/accelgroup.h>
4 #include <gtkmm/private/accelgroup_p.h>
5
6 // -*- c++ -*-
7 /* $Id$ */
8
9 /* Copyright 1998-2002 The gtkmm Development Team
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Library General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Library General Public License for more details.
20  *
21  * You should have received a copy of the GNU Library General Public
22  * License along with this library; if not, write to the Free
23  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25
26 #include <gtk/gtkaccelgroup.h>
27
28
29 namespace Gtk
30 {
31
32 bool AccelGroup::valid(guint keyval, Gdk::ModifierType modifiers) 
33 {
34   return gtk_accelerator_valid(keyval, (GdkModifierType) modifiers);
35 }
36
37 void AccelGroup::parse(const Glib::ustring& accelerator,
38                        guint&               accelerator_key,
39                        Gdk::ModifierType&   accelerator_mods)
40 {
41   GdkModifierType mods = GdkModifierType(0);
42   gtk_accelerator_parse(accelerator.c_str(), &accelerator_key, &mods);
43
44   accelerator_mods = (Gdk::ModifierType) mods;
45 }
46
47 Glib::ustring AccelGroup::name(guint accelerator_key, Gdk::ModifierType accelerator_mods) 
48 {
49   return gtk_accelerator_name(accelerator_key, (GdkModifierType) accelerator_mods);
50 }
51
52 void AccelGroup::set_default_mod_mask(Gdk::ModifierType default_mod_mask) 
53 {
54   gtk_accelerator_set_default_mod_mask((GdkModifierType) default_mod_mask);
55 }
56
57 Gdk::ModifierType AccelGroup::get_default_mod_mask() 
58 {
59   return (Gdk::ModifierType) gtk_accelerator_get_default_mod_mask();
60 }
61
62 } // namespace Gtk
63
64
65 namespace
66 {
67
68 gboolean AccelGroup_signal_accel_activate_callback(GtkAccelGroup* self, GObject* p0,guint p1,GdkModifierType p2,void* data)
69 {
70   using namespace Gtk;
71   typedef sigc::slot< bool,const Glib::RefPtr<Glib::Object>&,guint,Gdk::ModifierType > SlotType;
72
73   // Do not try to call a signal on a disassociated wrapper.
74   if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
75   {
76     try
77     {
78       if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
79         return static_cast<int>((*static_cast<SlotType*>(slot))(Glib::wrap(p0, true)
80 , p1, ((Gdk::ModifierType)(p2))
81 ));
82     }
83     catch(...)
84     {
85       Glib::exception_handlers_invoke();
86     }
87   }
88
89   typedef gboolean RType;
90   return RType();
91 }
92
93 gboolean AccelGroup_signal_accel_activate_notify_callback(GtkAccelGroup* self, GObject* p0,guint p1,GdkModifierType p2, void* data)
94 {
95   using namespace Gtk;
96   typedef sigc::slot< void,const Glib::RefPtr<Glib::Object>&,guint,Gdk::ModifierType > SlotType;
97
98   // Do not try to call a signal on a disassociated wrapper.
99   if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
100   {
101     try
102     {
103       if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
104         (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true)
105 , p1, ((Gdk::ModifierType)(p2))
106 );
107     }
108     catch(...)
109     {
110       Glib::exception_handlers_invoke();
111     }
112   }
113
114   typedef gboolean RType;
115   return RType();
116 }
117
118 const Glib::SignalProxyInfo AccelGroup_signal_accel_activate_info =
119 {
120   "accel_activate",
121   (GCallback) &AccelGroup_signal_accel_activate_callback,
122   (GCallback) &AccelGroup_signal_accel_activate_notify_callback
123 };
124
125
126 void AccelGroup_signal_accel_changed_callback(GtkAccelGroup* self, guint p0,GdkModifierType p1,GClosure* p2,void* data)
127 {
128   using namespace Gtk;
129   typedef sigc::slot< void,guint,Gdk::ModifierType,GClosure* > SlotType;
130
131   // Do not try to call a signal on a disassociated wrapper.
132   if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
133   {
134     try
135     {
136       if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
137         (*static_cast<SlotType*>(slot))(p0, ((Gdk::ModifierType)(p1))
138 , p2);
139     }
140     catch(...)
141     {
142       Glib::exception_handlers_invoke();
143     }
144   }
145 }
146
147 const Glib::SignalProxyInfo AccelGroup_signal_accel_changed_info =
148 {
149   "accel_changed",
150   (GCallback) &AccelGroup_signal_accel_changed_callback,
151   (GCallback) &AccelGroup_signal_accel_changed_callback
152 };
153
154 } // anonymous namespace
155
156
157 namespace Glib
158 {
159
160 Glib::RefPtr<Gtk::AccelGroup> wrap(GtkAccelGroup* object, bool take_copy)
161 {
162   return Glib::RefPtr<Gtk::AccelGroup>( dynamic_cast<Gtk::AccelGroup*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
163   //We use dynamic_cast<> in case of multiple inheritance.
164 }
165
166 } /* namespace Glib */
167
168
169 namespace Gtk
170 {
171
172
173 /* The *_Class implementation: */
174
175 const Glib::Class& AccelGroup_Class::init()
176 {
177   if(!gtype_) // create the GType if necessary
178   {
179     // Glib::Class has to know the class init function to clone custom types.
180     class_init_func_ = &AccelGroup_Class::class_init_function;
181
182     // This is actually just optimized away, apparently with no harm.
183     // Make sure that the parent type has been created.
184     //CppClassParent::CppObjectType::get_type();
185
186     // Create the wrapper type, with the same class/instance size as the base type.
187     register_derived_type(gtk_accel_group_get_type());
188
189     // Add derived versions of interfaces, if the C type implements any interfaces:
190   }
191
192   return *this;
193 }
194
195 void AccelGroup_Class::class_init_function(void* g_class, void* class_data)
196 {
197   BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
198   CppClassParent::class_init_function(klass, class_data);
199
200   klass->accel_changed = &accel_changed_callback;
201 }
202
203
204 void AccelGroup_Class::accel_changed_callback(GtkAccelGroup* self, guint p0, GdkModifierType p1, GClosure* p2)
205 {
206   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
207       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
208
209   // Non-gtkmmproc-generated custom classes implicitly call the default
210   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
211   // generated classes can use this optimisation, which avoids the unnecessary
212   // parameter conversions if there is no possibility of the virtual function
213   // being overridden:
214   if(obj && obj->is_derived_())
215   {
216     try // Trap C++ exceptions which would normally be lost because this is a C callback.
217     {
218       // Call the virtual member method, which derived classes might override.
219       obj->on_accel_changed(p0, ((Gdk::ModifierType)(p1))
220 , p2);
221     }
222     catch(...)
223     {
224       Glib::exception_handlers_invoke();
225     }
226   }
227   else
228   {
229     BaseClassType *const base = static_cast<BaseClassType*>(
230         g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
231     );
232
233     // Call the original underlying C function:
234     if(base && base->accel_changed)
235       (*base->accel_changed)(self, p0, p1, p2);
236   }
237 }
238
239
240 Glib::ObjectBase* AccelGroup_Class::wrap_new(GObject* object)
241 {
242   return new AccelGroup((GtkAccelGroup*)object);
243 }
244
245
246 /* The implementation: */
247
248 GtkAccelGroup* AccelGroup::gobj_copy()
249 {
250   reference();
251   return gobj();
252 }
253
254 AccelGroup::AccelGroup(const Glib::ConstructParams& construct_params)
255 :
256   Glib::Object(construct_params)
257 {}
258
259 AccelGroup::AccelGroup(GtkAccelGroup* castitem)
260 :
261   Glib::Object((GObject*)(castitem))
262 {}
263
264 AccelGroup::~AccelGroup()
265 {}
266
267
268 AccelGroup::CppClassType AccelGroup::accelgroup_class_; // initialize static member
269
270 GType AccelGroup::get_type()
271 {
272   return accelgroup_class_.init().get_type();
273 }
274
275 GType AccelGroup::get_base_type()
276 {
277   return gtk_accel_group_get_type();
278 }
279
280
281 AccelGroup::AccelGroup()
282 :
283   Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
284   Glib::Object(Glib::ConstructParams(accelgroup_class_.init()))
285 {
286   }
287
288 Glib::RefPtr<AccelGroup> AccelGroup::create()
289 {
290   return Glib::RefPtr<AccelGroup>( new AccelGroup() );
291 }
292 void AccelGroup::lock()
293 {
294   gtk_accel_group_lock(gobj());
295 }
296
297 void AccelGroup::unlock()
298 {
299   gtk_accel_group_unlock(gobj());
300 }
301
302 bool AccelGroup::disconnect_key(guint accel_key, Gdk::ModifierType accel_mods)
303 {
304   return gtk_accel_group_disconnect_key(gobj(), accel_key, ((GdkModifierType)(accel_mods)));
305 }
306
307 Glib::ustring AccelGroup::get_label(guint accelerator_key, Gdk::ModifierType accelerator_mods)
308 {
309   return Glib::convert_return_gchar_ptr_to_ustring(gtk_accelerator_get_label(accelerator_key, ((GdkModifierType)(accelerator_mods))));
310 }
311
312 bool AccelGroup::activate(GQuark accel_quark, const Glib::RefPtr<Glib::Object>& acceleratable, guint accel_key, Gdk::ModifierType accel_mods)
313 {
314   return gtk_accel_group_activate(gobj(), accel_quark, Glib::unwrap(acceleratable), accel_key, ((GdkModifierType)(accel_mods)));
315 }
316
317 bool AccelGroup::activate(Gtk::Object& object, guint accel_key, Gdk::ModifierType accel_mods)
318 {
319   return gtk_accel_groups_activate((object).Glib::Object::gobj(), accel_key, ((GdkModifierType)(accel_mods)));
320 }
321
322
323 Glib::SignalProxy3< bool,const Glib::RefPtr<Glib::Object>&,guint,Gdk::ModifierType > AccelGroup::signal_accel_activate()
324 {
325   return Glib::SignalProxy3< bool,const Glib::RefPtr<Glib::Object>&,guint,Gdk::ModifierType >(this, &AccelGroup_signal_accel_activate_info);
326 }
327
328 Glib::SignalProxy3< void,guint,Gdk::ModifierType,GClosure* > AccelGroup::signal_accel_changed()
329 {
330   return Glib::SignalProxy3< void,guint,Gdk::ModifierType,GClosure* >(this, &AccelGroup_signal_accel_changed_info);
331 }
332
333
334 void Gtk::AccelGroup::on_accel_changed(guint keyval, Gdk::ModifierType modifier, GClosure* accel_closure)
335 {
336   BaseClassType *const base = static_cast<BaseClassType*>(
337       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
338   );
339
340   if(base && base->accel_changed)
341     (*base->accel_changed)(gobj(),keyval,((GdkModifierType)(modifier)),accel_closure);
342 }
343
344
345 } // namespace Gtk
346
347