1 // Generated by gtkmmproc -- DO NOT MODIFY!
4 #include <gtkmm/actiongroup.h>
5 #include <gtkmm/private/actiongroup_p.h>
10 /* Copyright 2003 The gtkmm Development Team
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.
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.
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.
27 #include <gtk/gtkactiongroup.h>
28 #include <gtkmm/accelmap.h>
34 void ActionGroup::add(const Glib::RefPtr<Action>& action)
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 */ );
40 void ActionGroup::add(const Glib::RefPtr<Action>& action, const AccelKey& accel_key)
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.
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();
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())
56 //Copied from the gtk_action_group_add_action_with_accel() implementation:
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. */
62 accel_path = "<Actions>/" + get_name() + "/" + action_name;
67 AccelMap::add_entry(accel_path, key, mod);
69 action->set_accel_path(accel_path);
72 gtk_action_group_add_action(gobj(), action->gobj());
76 void ActionGroup::add(const Glib::RefPtr<Action>& action, const Action::SlotActivate& slot)
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.
82 action->signal_activate().connect(slot);
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.
92 void ActionGroup::add(const Glib::RefPtr<Action>& action, const AccelKey& accel_key, const Action::SlotActivate& slot)
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.
98 action->signal_activate().connect(slot);
99 add(action, accel_key);
102 //Create the accel path (a kind of unique key):
103 Glib::ustring accel_path = "<Actions>/" + get_name() + "/" + action->get_name();
105 //Register the accel path:
106 Gtk::AccelMap::add_entry(accel_path, accel_key.get_key(), accel_key.get_mod());
108 //USe the accel path:
109 action->set_accel_path(accel_path);
121 static void ActionGroup_signal_connect_proxy_callback(GtkActionGroup* self, GtkAction* p0,GtkWidget* p1,void* data)
124 typedef sigc::slot< void,const Glib::RefPtr<Action>&,Widget* > SlotType;
126 // Do not try to call a signal on a disassociated wrapper.
127 if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
129 #ifdef GLIBMM_EXCEPTIONS_ENABLED
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)
137 #ifdef GLIBMM_EXCEPTIONS_ENABLED
141 Glib::exception_handlers_invoke();
143 #endif //GLIBMM_EXCEPTIONS_ENABLED
147 static const Glib::SignalProxyInfo ActionGroup_signal_connect_proxy_info =
150 (GCallback) &ActionGroup_signal_connect_proxy_callback,
151 (GCallback) &ActionGroup_signal_connect_proxy_callback
155 static void ActionGroup_signal_disconnect_proxy_callback(GtkActionGroup* self, GtkAction* p0,GtkWidget* p1,void* data)
158 typedef sigc::slot< void,const Glib::RefPtr<Action>&,Widget* > SlotType;
160 // Do not try to call a signal on a disassociated wrapper.
161 if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
163 #ifdef GLIBMM_EXCEPTIONS_ENABLED
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)
171 #ifdef GLIBMM_EXCEPTIONS_ENABLED
175 Glib::exception_handlers_invoke();
177 #endif //GLIBMM_EXCEPTIONS_ENABLED
181 static const Glib::SignalProxyInfo ActionGroup_signal_disconnect_proxy_info =
184 (GCallback) &ActionGroup_signal_disconnect_proxy_callback,
185 (GCallback) &ActionGroup_signal_disconnect_proxy_callback
189 static void ActionGroup_signal_pre_activate_callback(GtkActionGroup* self, GtkAction* p0,void* data)
192 typedef sigc::slot< void,const Glib::RefPtr<Action>& > SlotType;
194 // Do not try to call a signal on a disassociated wrapper.
195 if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
197 #ifdef GLIBMM_EXCEPTIONS_ENABLED
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)
204 #ifdef GLIBMM_EXCEPTIONS_ENABLED
208 Glib::exception_handlers_invoke();
210 #endif //GLIBMM_EXCEPTIONS_ENABLED
214 static const Glib::SignalProxyInfo ActionGroup_signal_pre_activate_info =
217 (GCallback) &ActionGroup_signal_pre_activate_callback,
218 (GCallback) &ActionGroup_signal_pre_activate_callback
222 static void ActionGroup_signal_post_activate_callback(GtkActionGroup* self, GtkAction* p0,void* data)
225 typedef sigc::slot< void,const Glib::RefPtr<Action>& > SlotType;
227 // Do not try to call a signal on a disassociated wrapper.
228 if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
230 #ifdef GLIBMM_EXCEPTIONS_ENABLED
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)
237 #ifdef GLIBMM_EXCEPTIONS_ENABLED
241 Glib::exception_handlers_invoke();
243 #endif //GLIBMM_EXCEPTIONS_ENABLED
247 static const Glib::SignalProxyInfo ActionGroup_signal_post_activate_info =
250 (GCallback) &ActionGroup_signal_post_activate_callback,
251 (GCallback) &ActionGroup_signal_post_activate_callback
255 } // anonymous namespace
261 Glib::RefPtr<Gtk::ActionGroup> wrap(GtkActionGroup* object, bool take_copy)
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.
267 } /* namespace Glib */
274 /* The *_Class implementation: */
276 const Glib::Class& ActionGroup_Class::init()
278 if(!gtype_) // create the GType if necessary
280 // Glib::Class has to know the class init function to clone custom types.
281 class_init_func_ = &ActionGroup_Class::class_init_function;
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();
287 // Create the wrapper type, with the same class/instance size as the base type.
288 register_derived_type(gtk_action_group_get_type());
290 // Add derived versions of interfaces, if the C type implements any interfaces:
296 void ActionGroup_Class::class_init_function(void* g_class, void* class_data)
298 BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
299 CppClassParent::class_init_function(klass, class_data);
301 #ifdef GLIBMM_VFUNCS_ENABLED
302 #endif //GLIBMM_VFUNCS_ENABLED
304 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
305 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
308 #ifdef GLIBMM_VFUNCS_ENABLED
309 #endif //GLIBMM_VFUNCS_ENABLED
311 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
312 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
315 Glib::ObjectBase* ActionGroup_Class::wrap_new(GObject* object)
317 return new ActionGroup((GtkActionGroup*)object);
321 /* The implementation: */
323 GtkActionGroup* ActionGroup::gobj_copy()
329 ActionGroup::ActionGroup(const Glib::ConstructParams& construct_params)
331 Glib::Object(construct_params)
334 ActionGroup::ActionGroup(GtkActionGroup* castitem)
336 Glib::Object((GObject*)(castitem))
339 ActionGroup::~ActionGroup()
343 ActionGroup::CppClassType ActionGroup::actiongroup_class_; // initialize static member
345 GType ActionGroup::get_type()
347 return actiongroup_class_.init().get_type();
350 GType ActionGroup::get_base_type()
352 return gtk_action_group_get_type();
356 ActionGroup::ActionGroup(const Glib::ustring& name)
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))
363 Glib::RefPtr<ActionGroup> ActionGroup::create(const Glib::ustring& name)
365 return Glib::RefPtr<ActionGroup>( new ActionGroup(name) );
367 Glib::ustring ActionGroup::get_name() const
369 return Glib::convert_const_gchar_ptr_to_ustring(gtk_action_group_get_name(const_cast<GtkActionGroup*>(gobj())));
372 bool ActionGroup::get_sensitive() const
374 return gtk_action_group_get_sensitive(const_cast<GtkActionGroup*>(gobj()));
377 void ActionGroup::set_sensitive(bool sensitive)
379 gtk_action_group_set_sensitive(gobj(), static_cast<int>(sensitive));
382 bool ActionGroup::get_visible() const
384 return gtk_action_group_get_visible(const_cast<GtkActionGroup*>(gobj()));
387 void ActionGroup::set_visible(bool visible)
389 gtk_action_group_set_visible(gobj(), static_cast<int>(visible));
392 Glib::RefPtr<Action> ActionGroup::get_action(const Glib::ustring& action_name)
395 Glib::RefPtr<Action> retvalue = Glib::wrap(gtk_action_group_get_action(gobj(), action_name.c_str()));
397 retvalue->reference(); //The function does not do a ref for us.
402 Glib::RefPtr<const Action> ActionGroup::get_action(const Glib::ustring& action_name) const
404 return const_cast<ActionGroup*>(this)->get_action(action_name);
407 Glib::ListHandle< Glib::RefPtr<Action> > ActionGroup::get_actions()
409 return Glib::ListHandle< Glib::RefPtr<Action> >(gtk_action_group_list_actions(gobj()), Glib::OWNERSHIP_SHALLOW);
412 Glib::ListHandle< Glib::RefPtr<const Action> > ActionGroup::get_actions() const
414 return Glib::ListHandle< Glib::RefPtr<const Action> >(gtk_action_group_list_actions(const_cast<GtkActionGroup*>(gobj())), Glib::OWNERSHIP_SHALLOW);
417 void ActionGroup::remove(const Glib::RefPtr<Action>& action)
419 gtk_action_group_remove_action(gobj(), Glib::unwrap(action));
422 Glib::ustring ActionGroup::translate_string(const Glib::ustring& str) const
424 return Glib::convert_const_gchar_ptr_to_ustring(gtk_action_group_translate_string(const_cast<GtkActionGroup*>(gobj()), str.c_str()));
428 Glib::SignalProxy2< void,const Glib::RefPtr<Action>&,Widget* > ActionGroup::signal_connect_proxy()
430 return Glib::SignalProxy2< void,const Glib::RefPtr<Action>&,Widget* >(this, &ActionGroup_signal_connect_proxy_info);
434 Glib::SignalProxy2< void,const Glib::RefPtr<Action>&,Widget* > ActionGroup::signal_disconnect_proxy()
436 return Glib::SignalProxy2< void,const Glib::RefPtr<Action>&,Widget* >(this, &ActionGroup_signal_disconnect_proxy_info);
440 Glib::SignalProxy1< void,const Glib::RefPtr<Action>& > ActionGroup::signal_pre_activate()
442 return Glib::SignalProxy1< void,const Glib::RefPtr<Action>& >(this, &ActionGroup_signal_pre_activate_info);
446 Glib::SignalProxy1< void,const Glib::RefPtr<Action>& > ActionGroup::signal_post_activate()
448 return Glib::SignalProxy1< void,const Glib::RefPtr<Action>& >(this, &ActionGroup_signal_post_activate_info);
452 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
453 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
455 #ifdef GLIBMM_VFUNCS_ENABLED
456 #endif //GLIBMM_VFUNCS_ENABLED