[ekiga/ds-gtk-application] Use the new Actor subsystem. (still incomplete).



commit 985efeffc4e4b135d85abf30be6e9502fdea3674
Author: Damien Sandras <dsandras beip be>
Date:   Sat Sep 13 16:59:28 2014 +0200

    Use the new Actor subsystem. (still incomplete).

 TODO                                               |    2 +
 lib/engine/addressbook/contact-core.cpp            |   10 +--
 lib/engine/addressbook/contact-core.h              |   15 +---
 .../components/call-history/history-contact.cpp    |   13 +++-
 .../components/call-history/history-contact.h      |    3 +
 .../components/local-roster/local-cluster.cpp      |    8 +-
 lib/engine/components/local-roster/local-cluster.h |    1 +
 lib/engine/components/opal/opal-account.cpp        |   34 ++++++---
 lib/engine/components/opal/opal-account.h          |    2 +
 lib/engine/components/opal/opal-call-manager.cpp   |   69 +++++++++++------
 lib/engine/components/opal/opal-call-manager.h     |   13 +++-
 lib/engine/engine.cpp                              |    6 --
 .../gui/gtk-frontend/call-history-view-gtk.cpp     |   81 ++++++--------------
 .../gui/gtk-frontend/call-history-view-gtk.h       |    9 +--
 lib/engine/gui/gtk-frontend/main_window.cpp        |   19 ++---
 lib/engine/gui/gtk-frontend/roster-view-gtk.cpp    |   28 ++-----
 lib/engine/protocol/call-core.cpp                  |   34 +--------
 lib/engine/protocol/call-core.h                    |    7 --
 18 files changed, 156 insertions(+), 198 deletions(-)
---
diff --git a/TODO b/TODO
index 0fb1ad0..075cf52 100644
--- a/TODO
+++ b/TODO
@@ -3,3 +3,5 @@ See our wiki: http://wiki.ekiga.org/index.php/ToDo
 - Update DOC with 4.0 screenshots
 - Make sure that automatic reREGISTER and presence reSUBSCRIBE/PUBLISH still works when a registrar is down 
then comes online.
 - Make sure refresh also works as expected.
+
+- Remove PresentityDecorator && ContactDecorator
diff --git a/lib/engine/addressbook/contact-core.cpp b/lib/engine/addressbook/contact-core.cpp
index a131191..a7563f6 100644
--- a/lib/engine/addressbook/contact-core.cpp
+++ b/lib/engine/addressbook/contact-core.cpp
@@ -65,6 +65,7 @@ Ekiga::ContactCore::populate_menu (MenuBuilder &builder)
   return populated;
 }
 
+
 void
 Ekiga::ContactCore::add_source (SourcePtr source)
 {
@@ -99,7 +100,6 @@ Ekiga::ContactCore::add_contact_decorator (boost::shared_ptr<ContactDecorator> d
   contact_decorators.push_back (decorator);
 }
 
-
 bool
 Ekiga::ContactCore::populate_contact_menu (ContactPtr _contact,
                                           const std::string _uri,
@@ -117,11 +117,3 @@ Ekiga::ContactCore::populate_contact_menu (ContactPtr _contact,
 
   return populated;
 }
-
-
-void
-Ekiga::ContactCore::register_actions ()
-{
-  // We have nothing to do. Other Core's will add their own contact actions
-  // to us.
-}
diff --git a/lib/engine/addressbook/contact-core.h b/lib/engine/addressbook/contact-core.h
index acc3d91..6ca3dd0 100644
--- a/lib/engine/addressbook/contact-core.h
+++ b/lib/engine/addressbook/contact-core.h
@@ -37,9 +37,9 @@
 #define __CONTACT_CORE_H__
 
 #include "services.h"
-#include "data-actor.h"
 #include "source.h"
 #include "scoped-connections.h"
+#include "action-provider.h"
 
 /* declaration of a few helper classes */
 namespace Ekiga
@@ -50,13 +50,6 @@ namespace Ekiga
  * @{
  */
 
-  /* 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
   {
   public:
@@ -69,6 +62,7 @@ namespace Ekiga
                                MenuBuilder& /*builder*/) = 0;
   };
 
+
   /** Core object for address book support.
    *
    * Notice that you give sources to this object as references, so they won't
@@ -76,7 +70,7 @@ namespace Ekiga
    */
   class ContactCore:
     public virtual LiveObject,
-    public ContactActor,
+    public URIActionProviderStore,
     public Service
   {
   public:
@@ -102,6 +96,7 @@ namespace Ekiga
     const std::string get_description () const
     { return "\tContact managing object"; }
 
+
     /*** LiveObject implementation ***/
     bool populate_menu (MenuBuilder& builder);
 
@@ -178,8 +173,6 @@ namespace Ekiga
 
   private:
 
-    void register_actions ();
-
     std::list<boost::shared_ptr<ContactDecorator> > contact_decorators;
 
     /*** Misc stuff ***/
diff --git a/lib/engine/components/call-history/history-contact.cpp 
b/lib/engine/components/call-history/history-contact.cpp
index a9d2cf8..0e76b2a 100644
--- a/lib/engine/components/call-history/history-contact.cpp
+++ b/lib/engine/components/call-history/history-contact.cpp
@@ -38,6 +38,8 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 
+#include "call-core.h"
+
 #include "robust-xml.h"
 
 /* at one point we will return a smart pointer on this... and if we don't use
@@ -104,6 +106,11 @@ History::Contact::Contact (boost::shared_ptr<Ekiga::ContactCore> _contact_core,
       }
     }
   }
+
+  /* Pull actions */
+  boost::shared_ptr<Ekiga::ContactCore> ccore = contact_core.lock ();
+  if (ccore)
+    ccore->pull_actions (actions, name, uri);
 }
 
 
@@ -139,6 +146,11 @@ History::Contact::Contact (boost::shared_ptr<Ekiga::ContactCore> _contact_core,
   tmp = g_strdup_printf ("%d", m_type);
   xmlSetProp (node, BAD_CAST "type", BAD_CAST tmp);
   g_free (tmp);
+
+  /* Pull actions */
+  boost::shared_ptr<Ekiga::ContactCore> ccore = contact_core.lock ();
+  if (ccore)
+    ccore->pull_actions (actions, name, uri);
 }
 
 History::Contact::~Contact ()
@@ -183,7 +195,6 @@ History::Contact::get_groups () const
 bool
 History::Contact::populate_menu (Ekiga::MenuBuilder &builder)
 {
-  
   boost::shared_ptr<Ekiga::ContactCore> ccore = contact_core.lock ();
   if (ccore)
     return ccore->populate_contact_menu (ContactPtr (this, null_deleter ()),
diff --git a/lib/engine/components/call-history/history-contact.h 
b/lib/engine/components/call-history/history-contact.h
index db8cec3..b395d37 100644
--- a/lib/engine/components/call-history/history-contact.h
+++ b/lib/engine/components/call-history/history-contact.h
@@ -41,6 +41,7 @@
 #include <boost/smart_ptr.hpp>
 
 #include "services.h"
+#include "actor.h"
 #include "contact-core.h"
 
 namespace History
@@ -61,6 +62,7 @@ namespace History
 
   class Contact:
     public Ekiga::Contact,
+    public Ekiga::Actor,
     public boost::signals2::trackable
   {
   public:
@@ -89,6 +91,7 @@ namespace History
 
     bool populate_menu (Ekiga::MenuBuilder &builder);
 
+
     /*** more specific api ***/
 
     xmlNodePtr get_node ();
diff --git a/lib/engine/components/local-roster/local-cluster.cpp 
b/lib/engine/components/local-roster/local-cluster.cpp
index 61e6a17..cf97f50 100644
--- a/lib/engine/components/local-roster/local-cluster.cpp
+++ b/lib/engine/components/local-roster/local-cluster.cpp
@@ -92,6 +92,7 @@ void Local::Cluster::on_status_received (std::string uri,
 
 void Local::Cluster::register_actions (boost::shared_ptr<Ekiga::ContactCore> contact_core)
 {
+  /*
   Ekiga::ContactAction::TesterList testers;
   testers.push_back (boost::bind (&Local::Cluster::is_supported_uri, this, _2));
   testers.push_back (boost::bind (&Local::Heap::has_no_presentity_with_uri, heap, _2));
@@ -99,11 +100,12 @@ void Local::Cluster::register_actions (boost::shared_ptr<Ekiga::ContactCore> con
                                                          boost::bind (static_cast<void 
(Local::Heap::*)(const Ekiga::ContactPtr&, const std::string&)>(&Local::Heap::new_presentity), heap, _1, _2),
                                                          testers));
   contact_core->add_action (add);
+  */
 }
 
 void Local::Cluster::register_actions ()
 {
-  /* Add Actor actions */
-  add_action (Ekiga::ActionPtr (new Ekiga::Action ("local-cluster-new", _("New Contact"),
-                                                   boost::bind (static_cast<void (Local::Heap::*)(const 
std::string&, const std::string&)>(&Local::Heap::new_presentity), heap, "", ""))));
+//  /* Add Actor actions */
+  //add_action (Ekiga::ActionPtr (new Ekiga::Action ("local-cluster-new", _("New Contact"),
+    //                                               boost::bind (static_cast<void (Local::Heap::*)(const 
std::string&, const std::string&)>(&Local::Heap::new_presentity), heap, "", ""))));
 }
diff --git a/lib/engine/components/local-roster/local-cluster.h 
b/lib/engine/components/local-roster/local-cluster.h
index 67beb8c..af3696f 100644
--- a/lib/engine/components/local-roster/local-cluster.h
+++ b/lib/engine/components/local-roster/local-cluster.h
@@ -39,6 +39,7 @@
 #include "cluster-impl.h"
 #include "local-heap.h"
 #include "contact-core.h"
+#include "actor.h"
 
 namespace Local
 {
diff --git a/lib/engine/components/opal/opal-account.cpp b/lib/engine/components/opal/opal-account.cpp
index a419cb7..da587fa 100644
--- a/lib/engine/components/opal/opal-account.cpp
+++ b/lib/engine/components/opal/opal-account.cpp
@@ -191,7 +191,11 @@ Opal::Account::Account (boost::shared_ptr<Opal::Sip::EndPoint> _sip_endpoint,
       }
     }
   }
+
   setup_presentity ();
+
+  /* Actor stuff */
+  register_actions ();
 }
 
 
@@ -200,7 +204,7 @@ Opal::Account::get_groups () const
 {
   std::set<std::string> result;
 
-  for (const_iterator iter = begin (); iter != end (); ++iter) {
+  for (Ekiga::RefLister< Presentity >::const_iterator iter = Ekiga::RefLister< Presentity >::begin (); iter 
!= Ekiga::RefLister< Presentity >::end (); ++iter) {
 
     std::set<std::string> groups = (*iter)->get_groups ();
     result.insert (groups.begin (), groups.end ());
@@ -443,8 +447,8 @@ Opal::Account::disable ()
 
   if (presentity) {
 
-    for (iterator iter = begin ();
-        iter != end ();
+    for (Ekiga::RefLister< Presentity >::iterator iter = Ekiga::RefLister< Presentity >::begin ();
+        iter != Ekiga::RefLister< Presentity >::end ();
         ++iter) {
 
       (*iter)->set_presence ("unknown");
@@ -813,9 +817,9 @@ Opal::Account::publish (const Ekiga::PersonalDetails& details)
   else if (presence == "busy")
     personal_state = OpalPresenceInfo::Busy;
   else {  // ekiga knows only these three presence types
-    std::string s = "Warning: Unknown presence type ";
-    s.append (presence);
-    g_warning ("%s",s.data());
+    std::string str = "Warning: Unknown presence type ";
+    str.append (presence);
+    g_warning ("%s",str.data());
   }
 
   presence_status = details.get_status ();
@@ -828,6 +832,16 @@ Opal::Account::publish (const Ekiga::PersonalDetails& details)
 
 
 void
+Opal::Account::register_actions ()
+{
+  /* Add Actor actions */
+//  add_action (Ekiga::ActionPtr (new Ekiga::Action (id + "-new-contact", _("New Contact"),
+  //                                                 boost::bind (&Opal::Account::add_contact, this)));
+  std::cout << "FIXME" << std::endl << std::flush;
+}
+
+
+void
 Opal::Account::fetch (const std::string uri) const
 {
   // Check if this is a presentity we watch
@@ -873,8 +887,8 @@ Opal::Account::handle_registration_event (RegistrationState state_,
       failed_registration_already_notified = false;
       if (presentity) {
 
-       for (const_iterator iter = begin ();
-            iter != end ();
+       for (Ekiga::RefLister< Presentity >::const_iterator iter = Ekiga::RefLister< Presentity >::begin ();
+            iter != Ekiga::RefLister< Presentity >::end ();
             ++iter)
          fetch ((*iter)->get_uri());
 
@@ -1194,8 +1208,8 @@ Opal::Account::presence_status_in_main (std::string uri,
                                        std::string uri_presence,
                                        std::string uri_status) const
 {
-  for (const_iterator iter = begin ();
-       iter != end ();
+  for (Ekiga::RefLister< Presentity >::const_iterator iter = Ekiga::RefLister< Presentity >::begin ();
+       iter != Ekiga::RefLister< Presentity >::end ();
        ++iter) {
 
     if ((*iter)->has_uri (uri)) {
diff --git a/lib/engine/components/opal/opal-account.h b/lib/engine/components/opal/opal-account.h
index b4c325a..583d800 100644
--- a/lib/engine/components/opal/opal-account.h
+++ b/lib/engine/components/opal/opal-account.h
@@ -193,6 +193,8 @@ public:
     boost::signals2::signal<void(std::string, std::string)> status_received;
 
 private:
+    void register_actions ();
+
     void fetch (const std::string uri) const;
     void unfetch (const std::string uri) const;
 
diff --git a/lib/engine/components/opal/opal-call-manager.cpp 
b/lib/engine/components/opal/opal-call-manager.cpp
index a7eaf51..b8a25aa 100644
--- a/lib/engine/components/opal/opal-call-manager.cpp
+++ b/lib/engine/components/opal/opal-call-manager.cpp
@@ -58,7 +58,7 @@
 // opal manages its endpoints itself, so we must be wary
 struct null_deleter
 {
-    void operator()(void const *) const
+  void operator()(void const *) const
     { }
 };
 
@@ -75,12 +75,12 @@ class StunDetector : public PThread
 public:
 
   StunDetector (const std::string & _server,
-               Opal::CallManager& _manager,
+                Opal::CallManager& _manager,
                 GAsyncQueue* _queue)
     : PThread (1000, AutoDeleteThread),
-      server (_server),
-      manager (_manager),
-      queue (_queue)
+    server (_server),
+    manager (_manager),
+    queue (_queue)
   {
     PTRACE (3, "Ekiga\tStarted STUN detector");
     g_async_queue_ref (queue);
@@ -88,17 +88,17 @@ public:
   };
 
   ~StunDetector ()
-  {
-    g_async_queue_unref (queue);
-    PTRACE (3, "Ekiga\tStopped STUN detector");
-  }
+    {
+      g_async_queue_unref (queue);
+      PTRACE (3, "Ekiga\tStopped STUN detector");
+    }
 
   void Main ()
-  {
-    PSTUNClient::NatTypes result = manager.SetSTUNServer (server);
+    {
+      PSTUNClient::NatTypes result = manager.SetSTUNServer (server);
 
-    g_async_queue_push (queue, GUINT_TO_POINTER ((guint)result + 1));
-  };
+      g_async_queue_push (queue, GUINT_TO_POINTER ((guint)result + 1));
+    };
 
 private:
   const std::string server;
@@ -210,6 +210,10 @@ CallManager::CallManager (Ekiga::ServiceCore& core)
   personal_data_settings =
     boost::shared_ptr<Ekiga::Settings> (new Ekiga::Settings (PERSONAL_DATA_SCHEMA));
   personal_data_settings->changed.connect (boost::bind (&CallManager::setup, this, _1));
+
+  /* ContactActor registration */
+  boost::shared_ptr<Ekiga::ContactCore> contact_core = core.get< Ekiga::ContactCore > ("contact-core");
+  contact_core->push_back (Ekiga::URIActionProviderPtr (this));
 }
 
 
@@ -224,6 +228,25 @@ CallManager::~CallManager ()
 }
 
 
+void CallManager::pull_actions (Ekiga::ActionStore & store,
+                                const std::string & name,
+                                const std::string & uri)
+{
+  if (is_supported_uri (uri)) {
+
+    Ekiga::ActionPtr c (new Ekiga::Action ("call", _("Call"), boost::bind (&CallManager::dial, this, uri)));
+    Ekiga::ActionPtr t (new Ekiga::Action ("transfer", _("Transfer"), boost::bind (&CallManager::transfer, 
this, uri, false)));
+    t->disable ();
+
+    store.push_back (c);
+    store.push_back (t);
+
+//    store.push_back (Ekiga::ActionPtr (new Ekiga::Action ("message", _("Message"),
+  //                                                        boost::bind (&CallManager::message, this, name, 
uri))));
+  }
+}
+
+
 void CallManager::set_display_name (const std::string & name)
 {
   display_name = name;
@@ -613,8 +636,8 @@ void CallManager::set_stun_enabled (bool enabled)
 
 bool CallManager::dial (const std::string & uri)
 {
-  for (CallManager::iterator iter = begin ();
-       iter != end ();
+  for (Ekiga::CallManager::iterator iter = Ekiga::CallManager::begin ();
+       iter != Ekiga::CallManager::end ();
        iter++)
     if ((*iter)->dial (uri))
       return true;
@@ -632,8 +655,8 @@ void CallManager::hang_up ()
 bool CallManager::transfer (const std::string & uri,
                             bool attended)
 {
-  for (CallManager::iterator iter = begin ();
-       iter != end ();
+  for (Ekiga::CallManager::iterator iter = Ekiga::CallManager::begin ();
+       iter != Ekiga::CallManager::end ();
        iter++)
     if ((*iter)->transfer (uri, attended))
       return true;
@@ -645,8 +668,8 @@ bool CallManager::transfer (const std::string & uri,
 bool CallManager::message (const Ekiga::ContactPtr & contact,
                            const std::string & uri)
 {
-  for (CallManager::iterator iter = begin ();
-       iter != end ();
+  for (Ekiga::CallManager::iterator iter = Ekiga::CallManager::begin ();
+       iter != Ekiga::CallManager::end ();
        iter++)
     if ((*iter)->message (contact, uri))
       return true;
@@ -657,8 +680,8 @@ bool CallManager::message (const Ekiga::ContactPtr & contact,
 
 bool CallManager::is_supported_uri (const std::string & uri)
 {
-  for (CallManager::iterator iter = begin ();
-       iter != end ();
+  for (Ekiga::CallManager::iterator iter = Ekiga::CallManager::begin ();
+       iter != Ekiga::CallManager::end ();
        iter++)
     if ((*iter)->is_supported_uri (uri))
       return true;
@@ -938,8 +961,8 @@ CallManager::HandleSTUNResult ()
       error = true;
     } else {
 
-      for (Ekiga::CallManager::iterator iter = begin ();
-          iter != end ();
+      for (Ekiga::CallManager::iterator iter = Ekiga::CallManager::begin ();
+          iter != Ekiga::CallManager::end ();
           ++iter)
        (*iter)->set_listen_port ((*iter)->get_listen_interface ().port);
       ready ();
diff --git a/lib/engine/components/opal/opal-call-manager.h b/lib/engine/components/opal/opal-call-manager.h
index 67e2509..9ea5412 100644
--- a/lib/engine/components/opal/opal-call-manager.h
+++ b/lib/engine/components/opal/opal-call-manager.h
@@ -49,11 +49,15 @@
 
 #include "menu-builder.h"
 
-#include "call-manager.h"
 #include "opal-call.h"
 
+#include "call-manager.h"
+#include "contact-core.h"
+
 #include "ekiga-settings.h"
 
+#include "actor.h"
+
 #include <boost/enable_shared_from_this.hpp>
 
 
@@ -70,6 +74,7 @@ namespace Opal {
     public boost::enable_shared_from_this<CallManager>,
     public Ekiga::Service,
     public Ekiga::CallManager,
+    public Ekiga::URIActionProvider,
     public OpalManager
   {
     PCLASSINFO(CallManager, OpalManager);
@@ -80,6 +85,12 @@ public:
 
     ~CallManager ();
 
+    /* URIActionProvider stuff */
+    void pull_actions (Ekiga::ActionStore & store,
+                       const std::string & name,
+                       const std::string & uri);
+
+
     /* Ekiga::Service implementation */
     const std::string get_name () const
       { return "opal-component"; }
diff --git a/lib/engine/engine.cpp b/lib/engine/engine.cpp
index 3340cf4..d912f62 100644
--- a/lib/engine/engine.cpp
+++ b/lib/engine/engine.cpp
@@ -122,12 +122,6 @@ engine_init (Ekiga::ServiceCorePtr service_core,
   service_core->add (details);
   service_core->add (presence_core);
 
-  // Register actions
-  // FIXME: Perhaps this should be automated
-  // but I did not want to pass the contactcore as
-  // argument of the callcore...
-  call_core->register_actions (contact_core);
-
   if (!videoinput_mlogo_init (*service_core, &argc, &argv)) {
     return;
   }
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 664f86f..0ef58a4 100644
--- a/lib/engine/gui/gtk-frontend/call-history-view-gtk.cpp
+++ b/lib/engine/gui/gtk-frontend/call-history-view-gtk.cpp
@@ -37,13 +37,14 @@
 
 #include <sstream>
 #include <glib/gi18n.h>
+#include <boost/assign/ptr_list_of.hpp>
 
 #include "call-history-view-gtk.h"
 
 #include "menu-builder-tools.h"
 #include "menu-builder-gtk.h"
 #include "gm-cell-renderer-bitext.h"
-#include "actor-menu.h"
+#include "gactor-menu.h"
 
 
 struct null_deleter
@@ -61,8 +62,11 @@ struct _CallHistoryViewGtkPrivate
   {}
 
   boost::shared_ptr<History::Book> book;
-  Ekiga::ActorMenuPtr menu;
-  Ekiga::ContactActorMenuPtr contact_menu;
+  History::Contact *active_contact;
+
+  Ekiga::GActorMenuPtr menu;
+  Ekiga::GActorMenuPtr contact_menu;
+
   GtkListStore* store;
   GtkTreeView* tree;
   boost::signals2::scoped_connection connection;
@@ -167,10 +171,6 @@ on_clicked (G_GNUC_UNUSED GtkWidget *tree,
            GdkEventButton *event,
            gpointer data)
 {
-  GMenuModel *full_menu = NULL;
-  GMenuModel *contact_menu = NULL;
-  GMenuModel *history_menu = NULL;
-
   GtkWidget *menu = NULL;
 
   CallHistoryViewGtk *self = CALL_HISTORY_VIEW_GTK (data);
@@ -179,24 +179,12 @@ on_clicked (G_GNUC_UNUSED GtkWidget *tree,
   if (event->type != GDK_BUTTON_PRESS && event->type != GDK_2BUTTON_PRESS)
     return TRUE;
 
-  if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
+  if (event->type == GDK_BUTTON_PRESS && event->button == 3 && self->priv->active_contact) {
 
-    contact_menu = self->priv->contact_menu->get (); // Sometimes empty
-    history_menu = self->priv->menu->get (); // Never empty
-    if (contact_menu)
-      g_menu_append_section (G_MENU (contact_menu), NULL, history_menu);
-    full_menu = contact_menu ? contact_menu : history_menu;
-
-    menu = gtk_menu_new_from_model (full_menu);
-    gtk_widget_insert_action_group (menu, "win", G_ACTION_GROUP (g_application_get_default ()));
-    gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
-                    NULL, NULL, event->button, event->time);
-    g_object_ref (menu);
+    gtk_menu_popup (GTK_MENU (self->priv->contact_menu->get_menu (boost::assign::list_of 
(self->priv->menu))),
+                    NULL, NULL, NULL, NULL, event->button, event->time);
   }
 
-  if (event->type == GDK_2BUTTON_PRESS)
-    self->priv->contact_menu->activate ();
-
   return TRUE;
 }
 
@@ -209,14 +197,19 @@ on_selection_changed (G_GNUC_UNUSED GtkTreeSelection* selection,
 
   self = CALL_HISTORY_VIEW_GTK (data);
 
+  /* Reset old data. This also ensures GIO actions are
+   * properly removed before adding new ones.
+   */
+  self->priv->contact_menu.reset ();
+  self->priv->active_contact = NULL;
+
   /* Set or reset ContactActor data */
   call_history_view_gtk_get_selected (self, &contact);
 
-  if (contact == NULL)
-    self->priv->contact_menu->set_data (Ekiga::ContactPtr (), "");
-  else
-    self->priv->contact_menu->set_data (Ekiga::ContactPtr (contact, null_deleter ()),
-                                        contact->get_uri ());
+  if (contact != NULL) {
+    self->priv->active_contact = contact;
+    self->priv->contact_menu = Ekiga::GActorMenuPtr (new Ekiga::GActorMenu (*self->priv->active_contact));
+  }
 
   g_signal_emit (self, signals[SELECTION_CHANGED_SIGNAL], 0);
 }
@@ -301,7 +294,8 @@ call_history_view_gtk_class_init (CallHistoryViewGtkClass* klass)
 
 GtkWidget *
 call_history_view_gtk_new (boost::shared_ptr<History::Book> book,
-                           boost::shared_ptr<Ekiga::ContactCore> ccore)
+                           boost::shared_ptr<Ekiga::CallCore> call_core,
+                           boost::shared_ptr<Ekiga::ContactCore> contact_core)
 {
   CallHistoryViewGtk* self = NULL;
 
@@ -314,6 +308,7 @@ call_history_view_gtk_new (boost::shared_ptr<History::Book> book,
   self = (CallHistoryViewGtk*)g_object_new (CALL_HISTORY_VIEW_GTK_TYPE, NULL);
 
   self->priv = new _CallHistoryViewGtkPrivate (book);
+  self->priv->active_contact = NULL;
 
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (self),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@@ -362,9 +357,7 @@ call_history_view_gtk_new (boost::shared_ptr<History::Book> book,
   on_book_updated(self);
 
   /* register book actions */
-  self->priv->menu = Ekiga::ActorMenuPtr (new Ekiga::ActorMenu (*book));
-  self->priv->contact_menu =
-    Ekiga::ContactActorMenuPtr (new Ekiga::ContactActorMenu (*ccore));
+  self->priv->menu = Ekiga::GActorMenuPtr (new Ekiga::GActorMenu (*book));
 
   return GTK_WIDGET (self);
 }
@@ -389,29 +382,3 @@ call_history_view_gtk_get_selected (CallHistoryViewGtk* self,
   } else
     *contact = NULL;
 }
-
-bool
-call_history_view_gtk_populate_menu_for_selected (CallHistoryViewGtk* self,
-                                                 Ekiga::MenuBuilder &builder)
-{
-  g_return_val_if_fail (IS_CALL_HISTORY_VIEW_GTK (self), false);
-
-  bool result = false;
-  GtkTreeSelection* selection = NULL;
-  GtkTreeModel* model = NULL;
-  GtkTreeIter iter;
-
-  selection = gtk_tree_view_get_selection (self->priv->tree);
-
-  if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
-
-    Ekiga::Contact *contact = NULL;
-    gtk_tree_model_get (model, &iter,
-                       COLUMN_CONTACT, &contact,
-                       -1);
-    if (contact)
-      result = contact->populate_menu (builder);
-  }
-
-  return result;
-}
diff --git a/lib/engine/gui/gtk-frontend/call-history-view-gtk.h 
b/lib/engine/gui/gtk-frontend/call-history-view-gtk.h
index 1f74734..1c1e36b 100644
--- a/lib/engine/gui/gtk-frontend/call-history-view-gtk.h
+++ b/lib/engine/gui/gtk-frontend/call-history-view-gtk.h
@@ -51,13 +51,8 @@ typedef struct _CallHistoryViewGtkClass CallHistoryViewGtkClass;
 
 /* creating the widget, connected to an History::Book object */
 GtkWidget *call_history_view_gtk_new (boost::shared_ptr<History::Book> book,
-                                      boost::shared_ptr<Ekiga::ContactCore> ccore);
-
-
-/* Whatever is selected, we want the view to populate the given menu builder
- * for us with the possible actions */
-bool call_history_view_gtk_populate_menu_for_selected (CallHistoryViewGtk* self,
-                                                      Ekiga::MenuBuilder &builder);
+                                      boost::shared_ptr<Ekiga::CallCore> call_core,
+                                      boost::shared_ptr<Ekiga::ContactCore> contact_core);
 
 void call_history_view_gtk_get_selected (CallHistoryViewGtk* self,
                                          History::Contact** contact);
diff --git a/lib/engine/gui/gtk-frontend/main_window.cpp b/lib/engine/gui/gtk-frontend/main_window.cpp
index 0f84972..c25f16a 100644
--- a/lib/engine/gui/gtk-frontend/main_window.cpp
+++ b/lib/engine/gui/gtk-frontend/main_window.cpp
@@ -51,7 +51,6 @@
 #include "menu-builder-tools.h"
 #include "menu-builder-gtk.h"
 #include "scoped-connections.h"
-#include "actor-menu.h"
 
 #include <glib/gi18n.h>
 #include <gdk/gdkkeysyms.h>
@@ -154,9 +153,6 @@ struct _EkigaMainWindowPrivate
 
   Ekiga::scoped_connections connections;
 
-  /* Menu */
-  Ekiga::ContactActorMenuPtr contact_menu;
-
   /* GSettings */
   boost::shared_ptr<Ekiga::Settings> user_interface_settings;
   boost::shared_ptr<Ekiga::Settings> sound_events_settings;
@@ -178,6 +174,12 @@ static const char* win_menu =
   "  <menu id='menubar'>"
   "    <section>"
   "      <item>"
+  "        <attribute name='label' translatable='yes'>_Call</attribute>"
+  "        <attribute name='action'>win.call</attribute>"
+  "      </item>"
+  "    </section>"
+  "    <section>"
+  "      <item>"
   "        <attribute name='label' translatable='yes'>_Add Contact</attribute>"
   "        <attribute name='action'>win.local-cluster-new</attribute>"
   "      </item>"
@@ -661,7 +663,6 @@ menu_button_toggled_cb (GtkToggleButton *togglebutton,
                         gpointer data)
 {
   GMenu *menu = NULL;
-  GMenuModel *contact_menu = NULL;
 
   g_return_if_fail (EKIGA_IS_MAIN_WINDOW (data));
   EkigaMainWindow *mw = EKIGA_MAIN_WINDOW (data);
@@ -670,12 +671,12 @@ menu_button_toggled_cb (GtkToggleButton *togglebutton,
     return;
 
   menu = G_MENU (gtk_builder_get_object (mw->priv->builder, "menubar"));
-  if (mw->priv->contact_menu->size () > 0)
+ /* if (mw->priv->contact_menu->size () > 0)
     g_menu_remove (menu, 0);
 
   contact_menu = mw->priv->contact_menu->get ();
   if (contact_menu)
-    g_menu_insert_section (menu, 0, NULL, contact_menu);
+    g_menu_insert_section (menu, 0, NULL, contact_menu);*/
 }
 
 
@@ -972,6 +973,7 @@ ekiga_main_window_init_history (EkigaMainWindow *mw)
     = mw->priv->history_source->get_book ();
 
   mw->priv->call_history_view = call_history_view_gtk_new (history_book,
+                                                           mw->priv->call_core,
                                                            mw->priv->contact_core);
 
   label = gtk_label_new (_("Call history"));
@@ -1202,9 +1204,6 @@ gm_main_window_new (GmApplication *app)
   mw->priv->history_source
     = core->get<History::Source> ("call-history-store");
 
-  mw->priv->contact_menu =
-    Ekiga::ContactActorMenuPtr (new Ekiga::ContactActorMenu (*mw->priv->contact_core));
-
   ekiga_main_window_connect_engine_signals (mw);
 
   ekiga_main_window_init_gui (mw);
diff --git a/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp b/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp
index 23965f2..bd67f4e 100644
--- a/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp
+++ b/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp
@@ -60,6 +60,8 @@ struct _RosterViewGtkPrivate
   GtkTreeView *tree_view;
   GSList *folded_groups;
   gboolean show_offline_contacts;
+
+  //Ekiga::ActorMenuPtr menu;
 };
 
 typedef struct _StatusIconInfo {
@@ -531,27 +533,7 @@ on_clicked_show_presentity_menu (Ekiga::Heap* heap,
                                 Ekiga::Presentity* presentity,
                                 GdkEventButton* event)
 {
-  Ekiga::TemporaryMenuBuilder temp;
-  MenuBuilderGtk builder;
-
-  heap->populate_menu (temp);
-  presentity->populate_menu (builder);
-
-  if (!temp.empty ()) {
 
-    builder.add_separator ();
-    temp.populate_menu (builder);
-  }
-
-  if (!builder.empty ()) {
-    gtk_widget_show_all (builder.menu);
-    gtk_menu_popup (GTK_MENU (builder.menu), NULL, NULL,
-                    NULL, NULL, event->button, event->time);
-    g_signal_connect (builder.menu, "hide",
-                      G_CALLBACK (g_object_unref),
-                      (gpointer) builder.menu);
-  }
-  g_object_ref_sink (G_OBJECT (builder.menu));
 }
 
 static void
@@ -924,6 +906,12 @@ on_heap_added (RosterViewGtk* self,
               Ekiga::ClusterPtr cluster,
               Ekiga::HeapPtr heap)
 {
+  /* register heap actions */
+  std::cout << "FIXME" << std::endl << std::flush;
+
+  //self->priv->menu = Ekiga::ActorMenuPtr (new Ekiga::ActorMenu (*heap));
+  // SUCKS
+
   on_heap_updated (self, cluster, heap);
   heap->visit_presentities (boost::bind (&visit_presentities, self, cluster, heap, _1));
 }
diff --git a/lib/engine/protocol/call-core.cpp b/lib/engine/protocol/call-core.cpp
index 0abcdcb..b69afcb 100644
--- a/lib/engine/protocol/call-core.cpp
+++ b/lib/engine/protocol/call-core.cpp
@@ -27,7 +27,7 @@
 /*
  *                         call-core.cpp  -  description
  *                         ------------------------------------------
- *   begin                : written in 2007 by Damien Sandras 
+ *   begin                : written in 2007 by Damien Sandras
  *   copyright            : (c) 2007 by Damien Sandras
  *   description          : declaration of the interface of a call core.
  *                          A call core manages CallManagers.
@@ -40,9 +40,7 @@
 
 #include "call-core.h"
 
-
 #include "call-manager.h"
-#include "data-action.h"
 
 
 using namespace Ekiga;
@@ -149,24 +147,6 @@ bool CallCore::is_supported_uri (const std::string & uri)
 }
 
 
-void CallCore::register_actions (boost::shared_ptr<ContactCore> _contact_core)
-{
-  contact_core = _contact_core;
-  ContactActionPtr call (new ContactAction ("call", _("Call"),
-                                            boost::bind (&CallCore::dial, this, _2),
-                                            boost::bind (&CallCore::can_call, this, _2)));
-  ContactActionPtr xfer (new ContactAction ("transfer", _("Transfer"),
-                                            boost::bind (&CallCore::transfer, this, _2, false),
-                                            boost::bind (&CallCore::can_transfer, this, _2)));
-  ContactActionPtr msg (new ContactAction ("message", _("Message"),
-                                           boost::bind (&CallCore::message, this, _1, _2),
-                                           boost::bind (&CallCore::is_supported_uri, this, _2)));
-  contact_core->add_action (call);
-  contact_core->add_action (xfer);
-  contact_core->add_action (msg);
-}
-
-
 void CallCore::add_call (boost::shared_ptr<Call> call, boost::shared_ptr<CallManager> manager)
 {
   boost::shared_ptr<Ekiga::scoped_connections> conns(new Ekiga::scoped_connections);
@@ -285,15 +265,3 @@ void CallCore::on_call_removed (boost::shared_ptr<Call> call)
 {
   remove_call (call);
 }
-
-
-bool CallCore::can_call (const std::string & uri)
-{
-  return (is_supported_uri (uri) && call_connections.size () == 0);
-}
-
-
-bool CallCore::can_transfer (const std::string & uri)
-{
-  return (is_supported_uri (uri) && call_connections.size () > 0);
-}
diff --git a/lib/engine/protocol/call-core.h b/lib/engine/protocol/call-core.h
index 6acc19e..e6f3dc1 100644
--- a/lib/engine/protocol/call-core.h
+++ b/lib/engine/protocol/call-core.h
@@ -168,10 +168,6 @@ namespace Ekiga
       bool is_supported_uri (const std::string & uri);
 
 
-      /*** Actor stuff ***/
-      void register_actions (boost::shared_ptr<ContactCore> contact_core);
-
-
       /*** Call Related Signals ***/
 
       /** See call.h for the API
@@ -218,13 +214,10 @@ namespace Ekiga
       void on_manager_ready (boost::shared_ptr<CallManager> manager);
 
       void on_call_removed (boost::shared_ptr<Call> call);
-      bool can_call (const std::string & uri);
-      bool can_transfer (const std::string & uri);
 
       std::set<boost::shared_ptr<CallManager> > managers;
       std::map<std::string, boost::shared_ptr<Ekiga::scoped_connections> > call_connections;
       unsigned nr_ready;
-      boost::shared_ptr<ContactCore> contact_core;
     };
 
 /**


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