[ekiga] The roster view now has a method to know what is selected



commit 231ded1f66a8a954b0ef30b592188d642518b10c
Author: Julien Puydt <jpuydt gnome org>
Date:   Tue Sep 28 22:10:38 2010 +0200

    The roster view now has a method to know what is selected
    
    I added the method and documented it.
    
    And while I was at it, I documented the available signals
    in the header file too.
    
    This fixes bug #630790.

 lib/engine/gui/gtk-frontend/roster-view-gtk.cpp |   71 +++++++++++++++++++++++
 lib/engine/gui/gtk-frontend/roster-view-gtk.h   |   33 ++++++++++-
 2 files changed, 103 insertions(+), 1 deletions(-)
---
diff --git a/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp b/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp
index 4537828..6b02ee5 100644
--- a/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp
+++ b/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp
@@ -1612,3 +1612,74 @@ roster_view_gtk_new (Ekiga::PresenceCore &core)
 
   return (GtkWidget *) self;
 }
+
+void
+roster_view_gtk_get_selected (RosterViewGtk* self,
+			      Ekiga::Heap** heap,
+			      gchar** group,
+			      Ekiga::Presentity** presentity)
+{
+  g_return_if_fail (IS_ROSTER_VIEW_GTK (self)
+		    && heap != NULL
+		    && group != NULL
+		    && presentity != NULL);
+
+  GtkTreeSelection* selection = NULL;
+  GtkTreeModel* model = NULL;
+  GtkTreeIter iter;
+
+  selection = gtk_tree_view_get_selection (self->priv->tree_view);
+
+  if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
+
+    gint column_type;
+    gchar* group_ = NULL;
+    Ekiga::Heap* heap_ = NULL;
+    Ekiga::Presentity *presentity_ = NULL;
+    gtk_tree_model_get (model, &iter,
+			COLUMN_NAME, &group_,
+			COLUMN_TYPE, &column_type,
+			COLUMN_HEAP, &heap_,
+			COLUMN_PRESENTITY, &presentity_,
+			-1);
+
+    switch (column_type) {
+
+    case TYPE_PRESENTITY: {
+
+      *heap = NULL;
+      *group = NULL;
+      *presentity = presentity_;
+      break;
+    }
+    case TYPE_HEAP: {
+
+      *heap = heap_;
+      *group = NULL;
+      *presentity = NULL;
+      break;
+    }
+
+    case TYPE_GROUP: {
+
+      *heap = heap_;
+      *group = g_strdup (group_);
+      *presentity = NULL;
+      break;
+    }
+    default:
+
+      *heap = NULL;
+      *group = NULL;
+      *presentity = NULL;
+      break;
+    }
+
+    g_free (group_);
+  } else {
+
+    *heap = NULL;
+    *group = NULL;
+    *presentity = NULL;
+  }
+}
diff --git a/lib/engine/gui/gtk-frontend/roster-view-gtk.h b/lib/engine/gui/gtk-frontend/roster-view-gtk.h
index 9b63d25..416c737 100644
--- a/lib/engine/gui/gtk-frontend/roster-view-gtk.h
+++ b/lib/engine/gui/gtk-frontend/roster-view-gtk.h
@@ -45,10 +45,41 @@ typedef struct _RosterViewGtk RosterViewGtk;
 typedef struct _RosterViewGtkPrivate RosterViewGtkPrivate;
 typedef struct _RosterViewGtkClass RosterViewGtkClass;
 
-/* Public API */
+/*
+ * Public API
+ *
+ */
+
+/* Creating the widget, connected to an Ekiga::PresenceCore object */
 GtkWidget *roster_view_gtk_new (Ekiga::PresenceCore &core);
 
 
+/* Knowning what is selected in the view
+ * If it's:
+ * - a heap, you'll get it through 'heap' and the other two will be NULL ;
+ * - a group, you'll get the heap and the name through 'heap' and 'group', and 'presentity' will be NULL ;
+ *   (and you'll have to free the group name afterwards)
+ * - a presentity, you'll get it through 'presentity', and the other two will be NULL ;
+ */
+void roster_view_gtk_get_selected (RosterViewGtk* self,
+				   Ekiga::Heap** heap,
+				   gchar** group, /* you'll have to free it */
+				   Ekiga::Presentity** presentity);
+
+/* Signals emitted by that widget :
+ *
+ * - "heap-selected", comes with a pointer which is an Ekiga::Heap*
+ * (or NULL if no heap is selected anymore)
+ *
+ * - "heap-group-selected", comes with a pointer which is an Ekiga::Heap*
+ * (or NULL if no group is selected anymore)
+ * and a string which is the name of the group
+ *
+ * - "presentity-selected", comes with a pointer which is an Ekiga::Presentity*
+ * (or NULL if no presentity is selected anymore)
+ */
+
+
 /* GObject thingies */
 struct _RosterViewGtk
 {



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