[glibmm] ActionMap: Add add_action(name, slot).
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] ActionMap: Add add_action(name, slot).
- Date: Mon, 22 Jul 2013 10:29:06 +0000 (UTC)
commit adbf749ac8342832c56c149c622270e09c712d83
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Jul 22 12:22:01 2013 +0200
ActionMap: Add add_action(name, slot).
This is a convenience method similar to
g_action_map_add_action_entries() in C.
gio/src/actionmap.ccg | 8 ++++++++
gio/src/actionmap.hg | 20 +++++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/gio/src/actionmap.ccg b/gio/src/actionmap.ccg
index e80e599..9e3c562 100644
--- a/gio/src/actionmap.ccg
+++ b/gio/src/actionmap.ccg
@@ -18,8 +18,16 @@
*/
#include <giomm/action.h>
+#include <giomm/simpleaction.h>
namespace Gio
{
+Glib::RefPtr<SimpleAction> ActionMap::add_action(const Glib::ustring& name, const ActivateSlot& slot)
+{
+ Glib::RefPtr<SimpleAction> action = SimpleAction::create(name);
+ action->signal_activate().connect(slot);
+ return action;
+}
+
} // namespace Gio
diff --git a/gio/src/actionmap.hg b/gio/src/actionmap.hg
index 3a51893..05fa572 100644
--- a/gio/src/actionmap.hg
+++ b/gio/src/actionmap.hg
@@ -18,6 +18,7 @@
*/
#include <glibmm/interface.h>
+#include <giomm/simpleaction.h>
_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/interface_p.h)
@@ -54,7 +55,24 @@ public:
_WRAP_METHOD(Glib::RefPtr<Action> lookup_action(const Glib::ustring& action_name),
g_action_map_lookup_action)
_WRAP_METHOD(Glib::RefPtr<const Action> lookup_action(const Glib::ustring& action_name) const,
g_action_map_lookup_action, constversion)
- //TODO: _WRAP_METHOD(void add_action_entries(const GActionEntry* entries, int n_entries, gpointer
user_data), g_action_map_add_action_entries)
+ /** A Slot to be called when an action has been activated.
+ * See add_action().
+ *
+ * For instance,
+ * void on_slot_activated(const Glib::VariantBase& parameter);
+ */
+ typedef sigc::slot< void,const Glib::VariantBase& > ActivateSlot;
+
+ //This is our equivalent for g_action_map_add_action_entries().
+ /** A convenience method for creating a SimpleAction instance
+ * and adding it to the ActionMap.
+ *
+ * @param name The name of the Action.
+ * @param slot The callback method to be called when the action is activated.
+ * @return The Action.
+ */
+ Glib::RefPtr<SimpleAction> add_action(const Glib::ustring& name, const ActivateSlot& slot);
+ _IGNORE(g_action_map_add_action_entries)
_WRAP_METHOD(void add_action(const Glib::RefPtr<Action>& action), g_action_map_add_action)
_WRAP_METHOD(void remove_action(const Glib::ustring& action_name), g_action_map_remove_action)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]