Upgraded gtkmm to gtkmm-2.10.7.
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / actiongroup.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3
4 #include <gtkmm/actiongroup.h>
5 #include <gtkmm/private/actiongroup_p.h>
6
7 // -*- c++ -*-
8 /* $Id$ */
9
10 /* Copyright 2003 The gtkmm Development Team
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Library General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Library General Public License for more details.
21  *
22  * You should have received a copy of the GNU Library General Public
23  * License along with this library; if not, write to the Free
24  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25  */
26
27 #include <gtk/gtkactiongroup.h>
28 #include <gtkmm/accelmap.h>
29
30
31 namespace Gtk
32 {
33
34 void ActionGroup::add(const Glib::RefPtr<Action>& action)
35 {
36   gtk_action_group_add_action_with_accel(gobj(), Glib::unwrap(action),
37     0 /* accelerator=0 means use the stock accelerator if this is a stock item */ );
38 }
39
40 void ActionGroup::add(const Glib::RefPtr<Action>& action, const AccelKey& accel_key)
41 {
42   // We need to half-duplicate the gtk_action_group_add_action_with_accel() implementation, because we want to
43   // use AccelKey, not just the accelerator string format that is _one_ of the ways to create an AccelKey. murrayc.
44
45   //The AccelKey might have been constructed from key+mod or from an accelerator string,
46   //but it the end that just produces a key+mod.
47   guint key = accel_key.get_key();
48   Gdk::ModifierType mod = accel_key.get_mod();
49   if(key)
50   {
51     // The AccelKey constructor can take an accel path, so I suppose we should not ignore it,
52     // but I can't imagine how it would be useful with the UIManager. murrayc.
53     Glib::ustring accel_path = accel_key.get_path();
54     if(accel_path.empty())
55     {
56       //Copied from the gtk_action_group_add_action_with_accel() implementation:
57       
58       gchar* action_name = 0;
59       g_object_get(G_OBJECT(action->gobj()), "name", &action_name, NULL); /* Using 0 instead of NULL gives a warning about a missing sentinel. Possibly it must be (void*)0. */
60       if(action_name)
61       { 
62         accel_path =  "<Actions>/" + get_name() + "/" + action_name;
63         g_free(action_name);
64       }
65     }
66
67     AccelMap::add_entry(accel_path, key, mod);
68
69     action->set_accel_path(accel_path);
70   }
71
72   gtk_action_group_add_action(gobj(), action->gobj());
73 }
74
75   
76 void ActionGroup::add(const Glib::RefPtr<Action>& action, const Action::SlotActivate& slot)
77 {
78   //This is meant to be similar to the gtk_action_group_add_actions() convenience method that is used from C.
79   //This also does the work of gtk_action_group_add_toggle_actions() and gtk_action_group_add_radio_actions_full(),
80   //because the extra stuff there is already done when the Action (or a derived type, such as ToggleAction) is create()ed.
81   
82   action->signal_activate().connect(slot);
83   
84   //We probably don't need to use translate_string(), because the label and tooltip will be regular translated strings in our C++ application code.
85   //But C needs it because gtk_action_group_add_actions() takes a static array of GtkActionEntrys  whose fields 
86   //can not be translated with gettext macros.
87   //But we should soon know if menus and toolbars are not translated in non-english locales. murrayc.
88   
89   add(action);
90 }
91
92 void ActionGroup::add(const Glib::RefPtr<Action>& action, const AccelKey& accel_key, const Action::SlotActivate& slot)
93 {
94   //This is meant to be similar to the gtk_action_group_add_actions() convenience method that is used from C.
95   //This also does the work of gtk_action_group_add_toggle_actions() and gtk_action_group_add_radio_actions_full(),
96   //because the extra stuff there is already done when the Action (or a derived type, such as ToggleAction) is create()ed.
97
98   action->signal_activate().connect(slot);
99   add(action, accel_key);
100
101   /*
102   //Create the accel path (a kind of unique key):
103   Glib::ustring accel_path = "<Actions>/" + get_name() + "/" + action->get_name();
104
105   //Register the accel path:
106   Gtk::AccelMap::add_entry(accel_path, accel_key.get_key(), accel_key.get_mod());
107
108   //USe the accel path:
109   action->set_accel_path(accel_path);
110   */
111 }  
112
113
114 } // namespace Gtk
115
116
117 namespace
118 {
119
120
121 static void ActionGroup_signal_connect_proxy_callback(GtkActionGroup* self, GtkAction* p0,GtkWidget* p1,void* data)
122 {
123   using namespace Gtk;
124   typedef sigc::slot< void,const Glib::RefPtr<Action>&,Widget* > SlotType;
125
126   // Do not try to call a signal on a disassociated wrapper.
127   if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
128   {
129     #ifdef GLIBMM_EXCEPTIONS_ENABLED
130     try
131     {
132     #endif //GLIBMM_EXCEPTIONS_ENABLED
133       if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
134         (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true)
135 , Glib::wrap(p1)
136 );
137     #ifdef GLIBMM_EXCEPTIONS_ENABLED
138     }
139     catch(...)
140     {
141       Glib::exception_handlers_invoke();
142     }
143     #endif //GLIBMM_EXCEPTIONS_ENABLED
144   }
145 }
146
147 static const Glib::SignalProxyInfo ActionGroup_signal_connect_proxy_info =
148 {
149   "connect_proxy",
150   (GCallback) &ActionGroup_signal_connect_proxy_callback,
151   (GCallback) &ActionGroup_signal_connect_proxy_callback
152 };
153
154
155 static void ActionGroup_signal_disconnect_proxy_callback(GtkActionGroup* self, GtkAction* p0,GtkWidget* p1,void* data)
156 {
157   using namespace Gtk;
158   typedef sigc::slot< void,const Glib::RefPtr<Action>&,Widget* > SlotType;
159
160   // Do not try to call a signal on a disassociated wrapper.
161   if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
162   {
163     #ifdef GLIBMM_EXCEPTIONS_ENABLED
164     try
165     {
166     #endif //GLIBMM_EXCEPTIONS_ENABLED
167       if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
168         (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true)
169 , Glib::wrap(p1)
170 );
171     #ifdef GLIBMM_EXCEPTIONS_ENABLED
172     }
173     catch(...)
174     {
175       Glib::exception_handlers_invoke();
176     }
177     #endif //GLIBMM_EXCEPTIONS_ENABLED
178   }
179 }
180
181 static const Glib::SignalProxyInfo ActionGroup_signal_disconnect_proxy_info =
182 {
183   "disconnect_proxy",
184   (GCallback) &ActionGroup_signal_disconnect_proxy_callback,
185   (GCallback) &ActionGroup_signal_disconnect_proxy_callback
186 };
187
188
189 static void ActionGroup_signal_pre_activate_callback(GtkActionGroup* self, GtkAction* p0,void* data)
190 {
191   using namespace Gtk;
192   typedef sigc::slot< void,const Glib::RefPtr<Action>& > SlotType;
193
194   // Do not try to call a signal on a disassociated wrapper.
195   if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
196   {
197     #ifdef GLIBMM_EXCEPTIONS_ENABLED
198     try
199     {
200     #endif //GLIBMM_EXCEPTIONS_ENABLED
201       if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
202         (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true)
203 );
204     #ifdef GLIBMM_EXCEPTIONS_ENABLED
205     }
206     catch(...)
207     {
208       Glib::exception_handlers_invoke();
209     }
210     #endif //GLIBMM_EXCEPTIONS_ENABLED
211   }
212 }
213
214 static const Glib::SignalProxyInfo ActionGroup_signal_pre_activate_info =
215 {
216   "pre_activate",
217   (GCallback) &ActionGroup_signal_pre_activate_callback,
218   (GCallback) &ActionGroup_signal_pre_activate_callback
219 };
220
221
222 static void ActionGroup_signal_post_activate_callback(GtkActionGroup* self, GtkAction* p0,void* data)
223 {
224   using namespace Gtk;
225   typedef sigc::slot< void,const Glib::RefPtr<Action>& > SlotType;
226
227   // Do not try to call a signal on a disassociated wrapper.
228   if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
229   {
230     #ifdef GLIBMM_EXCEPTIONS_ENABLED
231     try
232     {
233     #endif //GLIBMM_EXCEPTIONS_ENABLED
234       if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
235         (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true)
236 );
237     #ifdef GLIBMM_EXCEPTIONS_ENABLED
238     }
239     catch(...)
240     {
241       Glib::exception_handlers_invoke();
242     }
243     #endif //GLIBMM_EXCEPTIONS_ENABLED
244   }
245 }
246
247 static const Glib::SignalProxyInfo ActionGroup_signal_post_activate_info =
248 {
249   "post_activate",
250   (GCallback) &ActionGroup_signal_post_activate_callback,
251   (GCallback) &ActionGroup_signal_post_activate_callback
252 };
253
254
255 } // anonymous namespace
256
257
258 namespace Glib
259 {
260
261 Glib::RefPtr<Gtk::ActionGroup> wrap(GtkActionGroup* object, bool take_copy)
262 {
263   return Glib::RefPtr<Gtk::ActionGroup>( dynamic_cast<Gtk::ActionGroup*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
264   //We use dynamic_cast<> in case of multiple inheritance.
265 }
266
267 } /* namespace Glib */
268
269
270 namespace Gtk
271 {
272
273
274 /* The *_Class implementation: */
275
276 const Glib::Class& ActionGroup_Class::init()
277 {
278   if(!gtype_) // create the GType if necessary
279   {
280     // Glib::Class has to know the class init function to clone custom types.
281     class_init_func_ = &ActionGroup_Class::class_init_function;
282
283     // This is actually just optimized away, apparently with no harm.
284     // Make sure that the parent type has been created.
285     //CppClassParent::CppObjectType::get_type();
286
287     // Create the wrapper type, with the same class/instance size as the base type.
288     register_derived_type(gtk_action_group_get_type());
289
290     // Add derived versions of interfaces, if the C type implements any interfaces:
291   }
292
293   return *this;
294 }
295
296 void ActionGroup_Class::class_init_function(void* g_class, void* class_data)
297 {
298   BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
299   CppClassParent::class_init_function(klass, class_data);
300
301 #ifdef GLIBMM_VFUNCS_ENABLED
302 #endif //GLIBMM_VFUNCS_ENABLED
303
304 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
305 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
306 }
307
308 #ifdef GLIBMM_VFUNCS_ENABLED
309 #endif //GLIBMM_VFUNCS_ENABLED
310
311 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
312 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
313
314
315 Glib::ObjectBase* ActionGroup_Class::wrap_new(GObject* object)
316 {
317   return new ActionGroup((GtkActionGroup*)object);
318 }
319
320
321 /* The implementation: */
322
323 GtkActionGroup* ActionGroup::gobj_copy()
324 {
325   reference();
326   return gobj();
327 }
328
329 ActionGroup::ActionGroup(const Glib::ConstructParams& construct_params)
330 :
331   Glib::Object(construct_params)
332 {}
333
334 ActionGroup::ActionGroup(GtkActionGroup* castitem)
335 :
336   Glib::Object((GObject*)(castitem))
337 {}
338
339 ActionGroup::~ActionGroup()
340 {}
341
342
343 ActionGroup::CppClassType ActionGroup::actiongroup_class_; // initialize static member
344
345 GType ActionGroup::get_type()
346 {
347   return actiongroup_class_.init().get_type();
348 }
349
350 GType ActionGroup::get_base_type()
351 {
352   return gtk_action_group_get_type();
353 }
354
355
356 ActionGroup::ActionGroup(const Glib::ustring& name)
357 :
358   Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
359   Glib::Object(Glib::ConstructParams(actiongroup_class_.init(), "name", name.c_str(), (char*) 0))
360 {
361   }
362
363 Glib::RefPtr<ActionGroup> ActionGroup::create(const Glib::ustring& name)
364 {
365   return Glib::RefPtr<ActionGroup>( new ActionGroup(name) );
366 }
367 Glib::ustring ActionGroup::get_name() const
368 {
369   return Glib::convert_const_gchar_ptr_to_ustring(gtk_action_group_get_name(const_cast<GtkActionGroup*>(gobj())));
370 }
371
372 bool ActionGroup::get_sensitive() const
373 {
374   return gtk_action_group_get_sensitive(const_cast<GtkActionGroup*>(gobj()));
375 }
376
377 void ActionGroup::set_sensitive(bool sensitive)
378 {
379 gtk_action_group_set_sensitive(gobj(), static_cast<int>(sensitive)); 
380 }
381
382 bool ActionGroup::get_visible() const
383 {
384   return gtk_action_group_get_visible(const_cast<GtkActionGroup*>(gobj()));
385 }
386
387 void ActionGroup::set_visible(bool visible)
388 {
389 gtk_action_group_set_visible(gobj(), static_cast<int>(visible)); 
390 }
391
392 Glib::RefPtr<Action> ActionGroup::get_action(const Glib::ustring& action_name)
393 {
394
395   Glib::RefPtr<Action> retvalue = Glib::wrap(gtk_action_group_get_action(gobj(), action_name.c_str()));
396   if(retvalue)
397     retvalue->reference(); //The function does not do a ref for us.
398   return retvalue;
399
400 }
401
402 Glib::RefPtr<const Action> ActionGroup::get_action(const Glib::ustring& action_name) const
403 {
404   return const_cast<ActionGroup*>(this)->get_action(action_name);
405 }
406
407 Glib::ListHandle< Glib::RefPtr<Action> > ActionGroup::get_actions()
408 {
409   return Glib::ListHandle< Glib::RefPtr<Action> >(gtk_action_group_list_actions(gobj()), Glib::OWNERSHIP_SHALLOW);
410 }
411
412 Glib::ListHandle< Glib::RefPtr<const Action> > ActionGroup::get_actions() const
413 {
414   return Glib::ListHandle< Glib::RefPtr<const Action> >(gtk_action_group_list_actions(const_cast<GtkActionGroup*>(gobj())), Glib::OWNERSHIP_SHALLOW);
415 }
416
417 void ActionGroup::remove(const Glib::RefPtr<Action>& action)
418 {
419 gtk_action_group_remove_action(gobj(), Glib::unwrap(action)); 
420 }
421
422 Glib::ustring ActionGroup::translate_string(const Glib::ustring& str) const
423 {
424   return Glib::convert_const_gchar_ptr_to_ustring(gtk_action_group_translate_string(const_cast<GtkActionGroup*>(gobj()), str.c_str()));
425 }
426
427
428 Glib::SignalProxy2< void,const Glib::RefPtr<Action>&,Widget* > ActionGroup::signal_connect_proxy()
429 {
430   return Glib::SignalProxy2< void,const Glib::RefPtr<Action>&,Widget* >(this, &ActionGroup_signal_connect_proxy_info);
431 }
432
433
434 Glib::SignalProxy2< void,const Glib::RefPtr<Action>&,Widget* > ActionGroup::signal_disconnect_proxy()
435 {
436   return Glib::SignalProxy2< void,const Glib::RefPtr<Action>&,Widget* >(this, &ActionGroup_signal_disconnect_proxy_info);
437 }
438
439
440 Glib::SignalProxy1< void,const Glib::RefPtr<Action>& > ActionGroup::signal_pre_activate()
441 {
442   return Glib::SignalProxy1< void,const Glib::RefPtr<Action>& >(this, &ActionGroup_signal_pre_activate_info);
443 }
444
445
446 Glib::SignalProxy1< void,const Glib::RefPtr<Action>& > ActionGroup::signal_post_activate()
447 {
448   return Glib::SignalProxy1< void,const Glib::RefPtr<Action>& >(this, &ActionGroup_signal_post_activate_info);
449 }
450
451
452 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
453 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
454
455 #ifdef GLIBMM_VFUNCS_ENABLED
456 #endif //GLIBMM_VFUNCS_ENABLED
457
458
459 } // namespace Gtk
460
461