[ekiga/ds-gtk-application] ContactAction: Improved code readability thanks to typedef's.



commit b3b2512ccfef7774389e5d5e2537a90cb5892b6b
Author: Damien Sandras <dsandras beip be>
Date:   Sun Apr 6 17:28:23 2014 +0200

    ContactAction: Improved code readability thanks to typedef's.

 lib/engine/action/actor.h                          |    2 ++
 lib/engine/action/data-action.h                    |    9 +++++----
 lib/engine/action/data-actor.h                     |    4 ++++
 lib/engine/addressbook/contact-core.h              |    4 +++-
 lib/engine/gui/gtk-core/actor-menu.h               |    7 +++++--
 .../gui/gtk-frontend/call-history-view-gtk.cpp     |    6 +++---
 lib/engine/gui/gtk-frontend/main_window.cpp        |    4 ++--
 7 files changed, 24 insertions(+), 12 deletions(-)
---
diff --git a/lib/engine/action/actor.h b/lib/engine/action/actor.h
index ada1cb8..7d96444 100644
--- a/lib/engine/action/actor.h
+++ b/lib/engine/action/actor.h
@@ -102,6 +102,8 @@ namespace Ekiga {
     std::list<std::string> action_names;
   };
 
+  typedef boost::shared_ptr< Actor > ActorPtr;
+
   /**
    * @}
    */
diff --git a/lib/engine/action/data-action.h b/lib/engine/action/data-action.h
index d29a8c1..e0ff5a1 100644
--- a/lib/engine/action/data-action.h
+++ b/lib/engine/action/data-action.h
@@ -46,7 +46,6 @@
 namespace Ekiga {
 
 
-
   /**
    * @defgroup contacts Address Book
    * @{
@@ -56,8 +55,10 @@ namespace Ekiga {
    * the data it should act on.
    *
    * The main difference between an Action and a DataAction is the fact
-   * that a DataAction is executed for a given (Data, string) tuple
-   * iff the (Data, s) tuple is valid for the given action.
+   * that a DataAction is executed for a given (DataPtr, string) tuple
+   * iff the (DataPtr, s) tuple is valid for the given action.
+   *
+   * Usually, DataPtr will be a boost::shared_ptr< Data >.
    */
   template < class T >
   class DataAction : public Action
@@ -103,7 +104,7 @@ namespace Ekiga {
                 const TesterList & _testers);
 
 
-    /** Set the (Data, string) tuple on which the DataAction should be run.
+    /** Set the (DataPtr, string) tuple on which the DataAction should be run.
      * They must stay valid until the DataAction is activated.
      * The Action is enabled/disabled following the parameters validity.
      * @param the contact part of the tuple.
diff --git a/lib/engine/action/data-actor.h b/lib/engine/action/data-actor.h
index be37a76..e3fe350 100644
--- a/lib/engine/action/data-actor.h
+++ b/lib/engine/action/data-actor.h
@@ -50,6 +50,10 @@ namespace Ekiga {
    * @{
    */
 
+  /**
+   * Forward declaration of the DataActorMenu class.
+   */
+  template < class T > class DataActorMenu;
 
   /* An actor is an object able to execute Actions.
    *
diff --git a/lib/engine/addressbook/contact-core.h b/lib/engine/addressbook/contact-core.h
index ddd8e6a..acc3d91 100644
--- a/lib/engine/addressbook/contact-core.h
+++ b/lib/engine/addressbook/contact-core.h
@@ -50,10 +50,12 @@ namespace Ekiga
  * @{
  */
 
-  /* DataActor stuff */
+  /* Action stuff */
   typedef DataActor< ContactPtr > ContactActor;
   typedef DataAction< ContactPtr > ContactAction;
+  typedef DataActorMenu< ContactPtr > ContactActorMenu;
   typedef boost::shared_ptr< ContactAction > ContactActionPtr;
+  typedef boost::shared_ptr< ContactActorMenu > ContactActorMenuPtr;
 
   class ContactDecorator
   {
diff --git a/lib/engine/gui/gtk-core/actor-menu.h b/lib/engine/gui/gtk-core/actor-menu.h
index 84ad237..13b3cc4 100644
--- a/lib/engine/gui/gtk-core/actor-menu.h
+++ b/lib/engine/gui/gtk-core/actor-menu.h
@@ -117,11 +117,13 @@ namespace Ekiga {
   template < class T >
   class DataActorMenu : public ActorMenu
   {
+    typedef boost::shared_ptr< DataActor< T > > DataActorPtr;
+
   public:
 
     DataActorMenu (DataActor< T > & _obj) : ActorMenu (_obj) {};
 
-    /** Set the (data, string) tuple usable by the DataActorMenu.
+    /** Set the (DataPtr, string) tuple usable by the DataActorMenu.
      *  Available actions will depend on the data being set.
      * @param the Data part of the tuple.
      * @param the s part of the tuple.
@@ -129,11 +131,12 @@ namespace Ekiga {
     void set_data (T _t = T (),
                    const std::string & _s = "")
     {
-      boost::shared_ptr< DataActor< T > > a = boost::dynamic_pointer_cast< DataActor< T > > 
(boost::shared_ptr< Actor > (&obj, null_deleter2 ()));
+      DataActorPtr a = boost::dynamic_pointer_cast< DataActor< T > > (ActorPtr (&obj, null_deleter2 ()));
       if (a) a->set_data (_t, _s);
       sync_gio_actions ();
     };
   };
+
   typedef boost::shared_ptr<ActorMenu> ActorMenuPtr;
 }
 #endif
diff --git a/lib/engine/gui/gtk-frontend/call-history-view-gtk.cpp 
b/lib/engine/gui/gtk-frontend/call-history-view-gtk.cpp
index 3fb17f4..664f86f 100644
--- a/lib/engine/gui/gtk-frontend/call-history-view-gtk.cpp
+++ b/lib/engine/gui/gtk-frontend/call-history-view-gtk.cpp
@@ -61,8 +61,8 @@ struct _CallHistoryViewGtkPrivate
   {}
 
   boost::shared_ptr<History::Book> book;
-  boost::shared_ptr<Ekiga::ActorMenu> menu;
-  boost::shared_ptr<Ekiga::DataActorMenu < Ekiga::ContactPtr > > contact_menu;
+  Ekiga::ActorMenuPtr menu;
+  Ekiga::ContactActorMenuPtr contact_menu;
   GtkListStore* store;
   GtkTreeView* tree;
   boost::signals2::scoped_connection connection;
@@ -364,7 +364,7 @@ call_history_view_gtk_new (boost::shared_ptr<History::Book> book,
   /* register book actions */
   self->priv->menu = Ekiga::ActorMenuPtr (new Ekiga::ActorMenu (*book));
   self->priv->contact_menu =
-    boost::shared_ptr< Ekiga::DataActorMenu < Ekiga::ContactPtr> > (new Ekiga::DataActorMenu< 
Ekiga::ContactPtr > (*ccore));
+    Ekiga::ContactActorMenuPtr (new Ekiga::ContactActorMenu (*ccore));
 
   return GTK_WIDGET (self);
 }
diff --git a/lib/engine/gui/gtk-frontend/main_window.cpp b/lib/engine/gui/gtk-frontend/main_window.cpp
index 09e11e3..4114238 100644
--- a/lib/engine/gui/gtk-frontend/main_window.cpp
+++ b/lib/engine/gui/gtk-frontend/main_window.cpp
@@ -156,7 +156,7 @@ struct _EkigaMainWindowPrivate
   Ekiga::scoped_connections connections;
 
   /* Menu */
-  boost::shared_ptr<Ekiga::DataActorMenu < Ekiga::ContactPtr > > contact_menu;
+  Ekiga::ContactActorMenuPtr contact_menu;
 
   /* GSettings */
   boost::shared_ptr<Ekiga::Settings> user_interface_settings;
@@ -1245,7 +1245,7 @@ gm_main_window_new (GmApplication *app)
     = core->get<History::Source> ("call-history-store");
 
   mw->priv->contact_menu =
-    boost::shared_ptr< Ekiga::DataActorMenu < Ekiga::ContactPtr> > (new Ekiga::DataActorMenu< 
Ekiga::ContactPtr > (*mw->priv->contact_core));
+    Ekiga::ContactActorMenuPtr (new Ekiga::ContactActorMenu (*mw->priv->contact_core));
 
   ekiga_main_window_connect_engine_signals (mw);
 


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