[ekiga/ds-gtk-application] Actor: Added removed/added signals + method to remove an action.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga/ds-gtk-application] Actor: Added removed/added signals + method to remove an action.
- Date: Sun, 16 Mar 2014 16:52:54 +0000 (UTC)
commit bb9e539edec3404fcb6b0d4e7239b0b033f83eac
Author: Damien Sandras <dsandras beip be>
Date: Sun Mar 16 17:47:37 2014 +0100
Actor: Added removed/added signals + method to remove an action.
This allows actions to be dynamically added and removed.
lib/engine/framework/actor.cpp | 12 ++++++++++++
lib/engine/framework/actor.h | 16 +++++++++++++++-
2 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/lib/engine/framework/actor.cpp b/lib/engine/framework/actor.cpp
index 4b1af8e..6e8d9fd 100644
--- a/lib/engine/framework/actor.cpp
+++ b/lib/engine/framework/actor.cpp
@@ -44,4 +44,16 @@ void
Actor::add_action (ActionPtr action)
{
actions.insert (std::make_pair (action->get_name (), action));
+ action_added (action->get_name ());
+}
+
+
+bool
+Actor::remove_action (const std::string & name)
+{
+ bool success = (actions.erase (name) > 0);
+ if (success)
+ action_removed (name);
+
+ return success;
}
diff --git a/lib/engine/framework/actor.h b/lib/engine/framework/actor.h
index 3a21d3b..8009710 100644
--- a/lib/engine/framework/actor.h
+++ b/lib/engine/framework/actor.h
@@ -38,6 +38,8 @@
#ifndef __ACTOR_H__
#define __ACTOR_H__
+#include <string>
+
#include "action.h"
namespace Ekiga {
@@ -60,7 +62,6 @@ namespace Ekiga {
public:
-
/** Register an action on the given Actor.
*
* Actions that are not "added" using this method will not be usable
@@ -71,12 +72,25 @@ namespace Ekiga {
void add_action (ActionPtr action);
+ /** Remove an action on the given Actor.
+ *
+ * @param An Action name.
+ * @return True if the action has been removed, false otherwise.
+ */
+ bool remove_action (const std::string & name);
+
+
protected:
/** This method must be called by each Actor to register Actions.
*/
virtual void register_actions () = 0;
+ /** Those signals are emitted when the ActionMap is updated.
+ */
+ boost::signals2::signal<void(const std::string &)> action_added;
+ boost::signals2::signal<void(const std::string &)> action_removed;
+
ActionMap actions;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]