[ekiga/ds-gtk-application] Roster: Started moving Presentities and Roster to the new Action stuff.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga/ds-gtk-application] Roster: Started moving Presentities and Roster to the new Action stuff.
- Date: Sun, 14 Sep 2014 17:13:16 +0000 (UTC)
commit aeff7f7054e1f34de30bc2f569eae3e8cea1fbc0
Author: Damien Sandras <dsandras beip be>
Date: Sun Sep 14 19:12:11 2014 +0200
Roster: Started moving Presentities and Roster to the new Action stuff.
lib/engine/components/opal/opal-presentity.cpp | 28 +++------
lib/engine/components/opal/opal-presentity.h | 6 ++-
lib/engine/gui/gtk-frontend/roster-view-gtk.cpp | 68 ++++++++++++++++++++++-
lib/engine/presence/presentity.h | 2 +
4 files changed, 81 insertions(+), 23 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-presentity.cpp b/lib/engine/components/opal/opal-presentity.cpp
index 2e61a78..6afc46e 100644
--- a/lib/engine/components/opal/opal-presentity.cpp
+++ b/lib/engine/components/opal/opal-presentity.cpp
@@ -104,6 +104,13 @@ Opal::Presentity::Presentity (boost::weak_ptr<Ekiga::PresenceCore> presence_core
node(node_),
presence("unknown")
{
+ /* Pull actions */
+ boost::shared_ptr<Ekiga::PresenceCore> pcore = presence_core.lock ();
+ if (pcore)
+ pcore->pull_actions (actions, get_name (), get_uri ());
+
+ add_action (Ekiga::ActionPtr (new Ekiga::Action ("edit", _("_Edit"), boost::bind
(&Opal::Presentity::edit_presentity, this))));
+ add_action (Ekiga::ActionPtr (new Ekiga::Action ("remove", _("_Remove"), boost::bind
(&Opal::Presentity::remove, this))));
}
@@ -229,24 +236,6 @@ Opal::Presentity::set_status (const std::string status_)
bool
Opal::Presentity::populate_menu (Ekiga::MenuBuilder &builder)
{
- bool populated = false;
- boost::shared_ptr<Ekiga::PresenceCore> pcore = presence_core.lock ();
-
- if (!pcore)
- return false;
-
- populated
- = pcore->populate_presentity_menu (PresentityPtr(this, null_deleter ()),
- get_uri (), builder);
-
- if (populated)
- builder.add_separator ();
-
- builder.add_action ("edit", _("_Edit"),
- boost::bind (&Opal::Presentity::edit_presentity, this));
- builder.add_action ("remove", _("_Remove"),
- boost::bind (&Opal::Presentity::remove, this));
-
return true;
}
@@ -254,7 +243,8 @@ Opal::Presentity::populate_menu (Ekiga::MenuBuilder &builder)
void
Opal::Presentity::edit_presentity ()
{
- boost::shared_ptr<Ekiga::FormRequestSimple> request = boost::shared_ptr<Ekiga::FormRequestSimple> (new
Ekiga::FormRequestSimple (boost::bind (&Opal::Presentity::edit_presentity_form_submitted, this, _1, _2)));
+ boost::shared_ptr<Ekiga::FormRequestSimple> request =
+ boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind
(&Opal::Presentity::edit_presentity_form_submitted, this, _1, _2)));
std::string name = get_name ();
std::string uri = get_uri ();
diff --git a/lib/engine/components/opal/opal-presentity.h b/lib/engine/components/opal/opal-presentity.h
index 91a23c9..ded3b04 100644
--- a/lib/engine/components/opal/opal-presentity.h
+++ b/lib/engine/components/opal/opal-presentity.h
@@ -42,9 +42,12 @@
#include <boost/smart_ptr.hpp>
#include "form.h"
+
#include "presence-core.h"
+
#include "presentity.h"
+
namespace Opal
{
class Cluster;
@@ -54,7 +57,8 @@ namespace Opal
* probably be abstracted, should the need arise!
*/
- class Presentity: public Ekiga::Presentity
+ class Presentity:
+ public Ekiga::Presentity
{
public:
diff --git a/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp b/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp
index bd67f4e..433339e 100644
--- a/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp
+++ b/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp
@@ -48,6 +48,7 @@
#include "menu-builder-gtk.h"
#include "form-dialog-gtk.h"
#include "scoped-connections.h"
+#include "gactor-menu.h"
/*
* The Roster
@@ -61,7 +62,8 @@ struct _RosterViewGtkPrivate
GSList *folded_groups;
gboolean show_offline_contacts;
- //Ekiga::ActorMenuPtr menu;
+ Ekiga::Presentity *selected_presentity;
+ Ekiga::GActorMenuPtr presentity_menu;
};
typedef struct _StatusIconInfo {
@@ -660,12 +662,65 @@ show_offline_contacts_changed_cb (GSettings *settings,
static void
-on_selection_changed (G_GNUC_UNUSED GtkTreeSelection* selection,
+on_selection_changed (GtkTreeSelection* selection,
gpointer data)
{
RosterViewGtk* self = NULL;
+ GtkTreeModel *model = NULL;
+ GtkTreeIter iter;
+
+ gint column_type;
+ Ekiga::Heap *heap = NULL;
+ Ekiga::Presentity *presentity = NULL;
+ Ekiga::MenuBuilder builder;
+
+ gchar *name = NULL;
+ gchar *group_name = NULL;
self = ROSTER_VIEW_GTK (data);
+ model = gtk_tree_view_get_model (self->priv->tree_view);
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
+
+ gtk_tree_model_get (model, &iter,
+ COLUMN_NAME, &name,
+ COLUMN_GROUP_NAME, &group_name,
+ COLUMN_TYPE, &column_type,
+ COLUMN_HEAP, &heap,
+ COLUMN_PRESENTITY, &presentity,
+ -1);
+
+ switch (column_type) {
+
+ case TYPE_HEAP:
+
+ break;
+ case TYPE_GROUP:
+
+ break;
+ case TYPE_PRESENTITY:
+
+ /* Reset old data. This also ensures GIO actions are
+ * properly removed before adding new ones.
+ */
+ self->priv->presentity_menu.reset ();
+ self->priv->selected_presentity = NULL;
+
+ if (presentity != NULL) {
+ self->priv->selected_presentity = presentity;
+ self->priv->presentity_menu = Ekiga::GActorMenuPtr (new Ekiga::GActorMenu
(*self->priv->selected_presentity));
+ }
+
+ presentity->populate_menu (builder);
+ break;
+ default:
+
+ g_assert_not_reached ();
+ break; // shouldn't happen
+ }
+ g_free (group_name);
+ g_free (name);
+ }
g_signal_emit (self, signals[SELECTION_CHANGED_SIGNAL], 0);
}
@@ -680,6 +735,7 @@ on_view_event_after (GtkWidget *tree_view,
GtkTreePath *path = NULL;
GtkTreeIter iter;
+
// take into account only clicks and Enter keys
if (event->type != GDK_BUTTON_PRESS && event->type != GDK_2BUTTON_PRESS && event->type != GDK_KEY_PRESS)
return FALSE;
@@ -735,7 +791,10 @@ on_view_event_after (GtkWidget *tree_view,
case TYPE_PRESENTITY:
if (event->type == GDK_BUTTON_PRESS && event->button == 3)
- on_clicked_show_presentity_menu (heap, presentity, event);
+ gtk_menu_popup (GTK_MENU (self->priv->presentity_menu->get_menu ()),
+ NULL, NULL, NULL, NULL, event->button, event->time);
+ //on_clicked_show_presentity_menu (heap, presentity, event);
+
if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_KEY_PRESS)
on_clicked_trigger_presentity (presentity);
break;
@@ -745,6 +804,7 @@ on_view_event_after (GtkWidget *tree_view,
break; // shouldn't happen
}
g_free (name);
+ g_free (group_name);
}
gtk_tree_path_free (path);
@@ -1406,6 +1466,8 @@ roster_view_gtk_init (RosterViewGtk* self)
self->priv = new RosterViewGtkPrivate;
+ self->priv->selected_presentity = NULL;
+
self->priv->settings = new Ekiga::Settings (CONTACTS_SCHEMA);
self->priv->folded_groups = self->priv->settings->get_slist ("roster-folded-groups");
self->priv->show_offline_contacts = self->priv->settings->get_bool ("show-offline-contacts");
diff --git a/lib/engine/presence/presentity.h b/lib/engine/presence/presentity.h
index 42dda66..5f0442b 100644
--- a/lib/engine/presence/presentity.h
+++ b/lib/engine/presence/presentity.h
@@ -40,6 +40,7 @@
#include <string>
#include "live-object.h"
+#include "actor.h"
namespace Ekiga
{
@@ -52,6 +53,7 @@ namespace Ekiga
/** A presentity is a piece of presence information for a single URI.
*/
class Presentity:
+ public Actor,
public virtual LiveObject
{
public:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]