[ekiga] Added the roster_view_gtk_populate_menu_for_selected method to the roster view widget
- From: Julien Puydt <jpuydt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Added the roster_view_gtk_populate_menu_for_selected method to the roster view widget
- Date: Tue, 12 Oct 2010 20:44:51 +0000 (UTC)
commit 1d66b6025844e9e14e763616c1a65f6ae11eb363
Author: Snark <jpuydt gnome org>
Date: Tue Oct 12 21:45:51 2010 +0200
Added the roster_view_gtk_populate_menu_for_selected method to the roster view widget
lib/engine/gui/gtk-frontend/roster-view-gtk.cpp | 62 +++++++++++++++++++++++
lib/engine/gui/gtk-frontend/roster-view-gtk.h | 6 ++
2 files changed, 68 insertions(+), 0 deletions(-)
---
diff --git a/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp b/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp
index 93dbbc8..573b117 100644
--- a/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp
+++ b/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp
@@ -700,6 +700,8 @@ on_selection_changed (GtkTreeSelection* selection,
g_signal_emit (self, signals[HEAP_SELECTED_SIGNAL], 0, NULL);
g_signal_emit (self, signals[HEAP_GROUP_SELECTED_SIGNAL], 0, NULL, NULL);
}
+
+ g_signal_emit (self, signals[SELECTION_CHANGED_SIGNAL], 0);
}
static gint
@@ -964,6 +966,7 @@ on_heap_updated (Ekiga::ClusterPtr /*cluster*/,
{
RosterViewGtk *self = ROSTER_VIEW_GTK (data);
GtkTreeIter iter;
+ GtkTreeSelection* selection = NULL;
roster_view_gtk_find_iter_for_heap (self, heap, &iter);
@@ -973,6 +976,10 @@ on_heap_updated (Ekiga::ClusterPtr /*cluster*/,
COLUMN_NAME, heap->get_name ().c_str (),
-1);
gtk_tree_view_expand_all (self->priv->tree_view);
+
+ selection = gtk_tree_view_get_selection (self->priv->tree_view);
+ if (gtk_tree_selection_iter_is_selected (selection, &iter))
+ g_signal_emit (self, signals[SELECTION_CHANGED_SIGNAL], 0);
}
@@ -1077,6 +1084,7 @@ on_presentity_updated (Ekiga::ClusterPtr cluster,
GtkTreeIter iter;
gchar *group_name = NULL;
std::set<std::string> groups = presentity->get_groups ();
+ GtkTreeSelection* selection = NULL;
model = GTK_TREE_MODEL (self->priv->store);
@@ -1112,6 +1120,11 @@ on_presentity_updated (Ekiga::ClusterPtr cluster,
model = gtk_tree_view_get_model (self->priv->tree_view);
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (model));
+
+ selection = gtk_tree_view_get_selection (self->priv->tree_view);
+ if (gtk_tree_selection_iter_is_selected (selection, &iter))
+ g_signal_emit (self, signals[SELECTION_CHANGED_SIGNAL], 0);
+
}
@@ -1704,3 +1717,52 @@ roster_view_gtk_get_selected (RosterViewGtk* self,
*presentity = NULL;
}
}
+
+bool
+roster_view_gtk_populate_menu_for_selected (RosterViewGtk* self,
+ Ekiga::MenuBuilder& builder)
+{
+ bool result = false;
+ GtkTreeSelection* selection = NULL;
+ GtkTreeModel* model = NULL;
+ GtkTreeIter iter;
+
+ g_return_val_if_fail (IS_ROSTER_VIEW_GTK (self), false);
+
+ selection = gtk_tree_view_get_selection (self->priv->tree_view);
+ if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
+
+ gint column_type;
+ gchar* name = NULL;
+ Ekiga::Heap* heap = NULL;
+ Ekiga::Presentity *presentity = NULL;
+ gtk_tree_model_get (model, &iter,
+ COLUMN_NAME, &name,
+ COLUMN_TYPE, &column_type,
+ COLUMN_HEAP, &heap,
+ COLUMN_PRESENTITY, &presentity,
+ -1);
+ switch (column_type) {
+
+ case TYPE_PRESENTITY:
+
+ result = presentity->populate_menu (builder);
+ break;
+ case TYPE_HEAP:
+
+ result = heap->populate_menu (builder);
+ break;
+
+ case TYPE_GROUP:
+
+ result = heap->populate_menu_for_group (name, builder);
+ break;
+
+ default:
+ break;
+ }
+
+ g_free (name);
+ }
+ return result;
+}
diff --git a/lib/engine/gui/gtk-frontend/roster-view-gtk.h b/lib/engine/gui/gtk-frontend/roster-view-gtk.h
index e284595..fbeba43 100644
--- a/lib/engine/gui/gtk-frontend/roster-view-gtk.h
+++ b/lib/engine/gui/gtk-frontend/roster-view-gtk.h
@@ -66,6 +66,12 @@ void roster_view_gtk_get_selected (RosterViewGtk* self,
gchar** group, /* you'll have to free it */
Ekiga::Presentity** presentity);
+/* This method populates the given builder with the actions possible on the
+ * selected item, whatever that is (heap, group, presentity)
+ */
+bool roster_view_gtk_populate_menu_for_selected (RosterViewGtk* self,
+ Ekiga::MenuBuilder& builder);
+
/* Signals emitted by that widget :
*
* - "heap-selected", comes with a pointer which is an Ekiga::Heap*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]