[ekiga/ds-gtk-application] Actor: Added method to disable/enable action by name.



commit 5b571f89e025e915fd0ae2238020006ebdf3a6ec
Author: Damien Sandras <dsandras seconix com>
Date:   Tue Sep 16 20:47:12 2014 +0200

    Actor: Added method to disable/enable action by name.

 lib/engine/action/actor.cpp |   28 +++++++++++++++++++++++++++-
 lib/engine/action/actor.h   |   16 ++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletions(-)
---
diff --git a/lib/engine/action/actor.cpp b/lib/engine/action/actor.cpp
index 75dd0a6..42d1184 100644
--- a/lib/engine/action/actor.cpp
+++ b/lib/engine/action/actor.cpp
@@ -48,7 +48,7 @@ Actor::add_action (ActionPtr action)
   actions.push_back (action);
 
   conns.add (action->enabled.connect (boost::bind (boost::ref (action_enabled), action->get_name ())));
-  conns.add (action->disabled.connect (boost::bind (boost::ref (action_enabled), action->get_name ())));
+  conns.add (action->disabled.connect (boost::bind (boost::ref (action_disabled), action->get_name ())));
 
   action_added (action->get_name ());
 }
@@ -76,6 +76,32 @@ Actor::remove_action (const std::string & name)
 }
 
 
+bool
+Actor::enable_action (const std::string & name)
+{
+  for (ActionStore::iterator it = actions.begin (); it != actions.end () ; ++it) {
+    if ((*it)->get_name () == name) {
+      (*it)->enable ();
+      return true;
+    }
+  }
+  return false;
+}
+
+
+bool
+Actor::disable_action (const std::string & name)
+{
+  for (ActionStore::iterator it = actions.begin (); it != actions.end () ; ++it) {
+    if ((*it)->get_name () == name) {
+      (*it)->disable ();
+      return true;
+    }
+  }
+  return false;
+}
+
+
 void
 Actor::remove_actions ()
 {
diff --git a/lib/engine/action/actor.h b/lib/engine/action/actor.h
index 63c64fd..1db2c12 100644
--- a/lib/engine/action/actor.h
+++ b/lib/engine/action/actor.h
@@ -94,6 +94,22 @@ namespace Ekiga {
     virtual bool remove_action (const std::string & name);
 
 
+    /** Enable an action from the given Actor.
+     *
+     * @param An Action name.
+     * @return true if the Action was successfully enabled, false otherwise.
+     */
+    virtual bool enable_action (const std::string & name);
+
+
+    /** Disable an action from the given Actor.
+     *
+     * @param An Action name.
+     * @return true if the Action was successfully disabled, false otherwise.
+     */
+    virtual bool disable_action (const std::string & name);
+
+
     /** Remove all actions from the given Actor.
      *
      */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]