1 /* $Id: actiongroup.hg,v 1.17 2006/04/12 11:11:25 murrayc Exp $ */
3 /* Copyright (C) 2003 The gtkmm Development Team
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <gtkmm/widget.h>
21 #include <gtkmm/action.h>
22 #include <gtkmm/accelkey.h>
25 _PINCLUDE(glibmm/private/object_p.h)
31 class ActionGroup : public Glib::Object
33 _CLASS_GOBJECT(ActionGroup, GtkActionGroup, GTK_ACTION_GROUP, Glib::Object, GObject)
36 _WRAP_CTOR(ActionGroup(const Glib::ustring& name = Glib::ustring()), gtk_action_group_new)
39 _WRAP_CREATE(const Glib::ustring& name = Glib::ustring())
41 _WRAP_METHOD(Glib::ustring get_name() const, gtk_action_group_get_name)
43 _WRAP_METHOD(bool get_sensitive() const, gtk_action_group_get_sensitive)
44 _WRAP_METHOD(void set_sensitive(bool sensitive = true), gtk_action_group_set_sensitive)
45 _WRAP_METHOD(bool get_visible() const, gtk_action_group_get_visible)
46 _WRAP_METHOD(void set_visible(bool visible = true), gtk_action_group_set_visible)
48 _WRAP_METHOD(Glib::RefPtr<Action> get_action(const Glib::ustring& action_name), gtk_action_group_get_action, refreturn)
49 _WRAP_METHOD(Glib::RefPtr<const Action> get_action(const Glib::ustring& action_name) const, gtk_action_group_get_action, refreturn, constversion)
51 _WRAP_METHOD(Glib::ListHandle< Glib::RefPtr<Action> > get_actions(), gtk_action_group_list_actions)
52 _WRAP_METHOD(Glib::ListHandle< Glib::RefPtr<const Action> > get_actions() const, gtk_action_group_list_actions)
54 void add(const Glib::RefPtr<Action>& action);
55 _IGNORE(gtk_action_group_add_action)
56 //We want it to always try to use the stock accelerator,
57 //so we use gtk_action_group_add_action_with_accel(), instead of gtk_action_group_add_action(),
58 //passing null for the accelerator.
60 void add(const Glib::RefPtr<Action>& action, const AccelKey& accel_key);
61 _IGNORE(gtk_action_group_add_action_with_accel)
62 //We need to duplicate the gtk_action_group_add_action_with_accel() implementation, because we want to
63 //use AccelKey, not just the accelerator string format that is _one_ of the ways to create an AccelKey.
65 //TODO: Could this whole class have an STL-style interface?
66 void add(const Glib::RefPtr<Action>& action, const Action::SlotActivate& slot);
67 void add(const Glib::RefPtr<Action>& action, const AccelKey& accel_key, const Action::SlotActivate& slot);
68 _WRAP_METHOD(void remove(const Glib::RefPtr<Action>& action), gtk_action_group_remove_action)
70 //TODO: We probably need to use this in our add_actions() implementation:
71 _WRAP_METHOD(Glib::ustring translate_string(const Glib::ustring& str) const, gtk_action_group_translate_string)
74 //These are just C convenience methods:
75 _IGNORE(gtk_action_group_add_actions, gtk_action_group_add_toggle_actions, gtk_action_group_add_radio_actions,
76 gtk_action_group_add_actions_full, gtk_action_group_add_toggle_actions_full,
77 gtk_action_group_add_radio_actions_full)
78 //These are also just C convenience methods that are useless unless you are using the other convenience methods:
79 _IGNORE(gtk_action_group_set_translate_func, gtk_action_group_set_translation_domain)
81 /** The connect_proxy signal is emitted after connecting a proxy to
82 * an action in the group. Note that the proxy may have been connected
83 * to a different action before.
85 * This is intended for simple customizations for which a custom action
86 * class would be too clumsy, e.g. showing tooltips for menuitems in the
89 * UIManager proxies the signal and provides global notification
90 * just before any action is connected to a proxy, which is probably more
93 * @param action the action
94 * @param proxy the proxy
96 _WRAP_SIGNAL(void connect_proxy(const Glib::RefPtr<Action>& action, Widget* proxy), "connect_proxy", no_default_handler)
98 /** The disconnect_proxy signal is emitted after disconnecting a proxy
99 * from an action in the group.
101 * UIManager proxies the signal and provides global notification
102 * just before any action is connected to a proxy, which is probably more
105 * @param action the action
106 * @param proxy the proxy
108 _WRAP_SIGNAL(void disconnect_proxy(const Glib::RefPtr<Action>& action, Widget* proxy), "disconnect_proxy", no_default_handler)
110 /** The pre_activate signal is emitted just before the @action in the
111 * action_group is activated
113 * This is intended for UIManager to proxy the signal and provide global
114 * notification just before any action is activated.
118 _WRAP_SIGNAL(void pre_activate(const Glib::RefPtr<Action>& action), "pre_activate", no_default_handler)
120 /** The post_activate signal is emitted just after the @action in the
121 * @action_group is activated
123 * This is intended for UIManager to proxy the signal and provide global
124 * notification just after any action is activated.
126 * @param action the action
128 _WRAP_SIGNAL(void post_activate(const Glib::RefPtr<Action>& action), "post_activate", no_default_handler)