[ekiga/ds-gtk-application] Action: Added the possibility to create a disabled action + cleanup.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga/ds-gtk-application] Action: Added the possibility to create a disabled action + cleanup.
- Date: Tue, 16 Sep 2014 19:22:01 +0000 (UTC)
commit 7a83359435c8efbf3d037443bac94795206295ff
Author: Damien Sandras <dsandras seconix com>
Date: Tue Sep 16 20:47:57 2014 +0200
Action: Added the possibility to create a disabled action + cleanup.
lib/engine/action/action.cpp | 22 ++++------------------
lib/engine/action/action.h | 19 ++++++-------------
2 files changed, 10 insertions(+), 31 deletions(-)
---
diff --git a/lib/engine/action/action.cpp b/lib/engine/action/action.cpp
index e7808c5..9c44127 100644
--- a/lib/engine/action/action.cpp
+++ b/lib/engine/action/action.cpp
@@ -41,25 +41,10 @@ using namespace Ekiga;
Action::Action (const std::string & _name,
- const std::string & _description)
-{
- name = _name;
- description = _description;
- action_enabled = true;
-
- conns.add (activated.connect (boost::bind (&Action::on_activated, this)));
-}
-
-
-Action::Action (const std::string & _name,
const std::string & _description,
- boost::function0<void> _callback)
+ boost::function0<void> _callback,
+ bool _enabled) : name (_name), description (_description), callback (_callback),
action_enabled (_enabled)
{
- name = _name;
- description = _description;
- callback = _callback;
- action_enabled = true;
-
conns.add (activated.connect (boost::bind (&Action::on_activated, this)));
}
@@ -117,5 +102,6 @@ Action::is_enabled () const
void
Action::on_activated ()
{
- callback ();
+ if (!callback.empty ())
+ callback ();
}
diff --git a/lib/engine/action/action.h b/lib/engine/action/action.h
index 833639e..05c26ea 100644
--- a/lib/engine/action/action.h
+++ b/lib/engine/action/action.h
@@ -89,25 +89,18 @@ namespace Ekiga {
public:
- /** Create an Action given a name and a description.
- * @param the Action name (please read 'CONVENTION').
- * @param the Action description. Can be used as description in menus
- * implementing Actions.
- */
- Action (const std::string & _name,
- const std::string & _description);
-
-
/** Create an Action given a name, a description and a callback.
* @param the Action name (please read 'CONVENTION').
* @param the Action description. Can be used as description in menus
* implementing Actions.
- * @param the callback to executed when the Action is activated by
- * the user (from a menu or from the code itself).
+ * @param the callback to execute when the Action is activated by
+ * the user (from a menu or from the code itself), if any.
+ * @param true if the Action is enabled, false otherwise.
*/
Action (const std::string & _name,
const std::string & _description,
- boost::function0<void> _callback);
+ boost::function0<void> _callback = NULL,
+ bool enabled = true);
/** Destructor.
*
@@ -159,8 +152,8 @@ namespace Ekiga {
std::string name;
std::string description;
- bool action_enabled;
boost::function0<void> callback;
+ bool action_enabled;
/** Those signals are emitted when the Action is enabled/disabled.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]