[ekiga] Cleaned up the roster view and call history view widgets' code



commit 1d1b4a67167f6e21fb68cbe086203820b5589da5
Author: Snark <jpuydt gnome org>
Date:   Tue Oct 12 22:58:03 2010 +0200

    Cleaned up the roster view and call history view widgets' code
    
    I removed the old selection api -- and fixed a few typos along the way.
    
    This is the final fix for bug #631735.

 .../gui/gtk-frontend/call-history-view-gtk.cpp     |   33 +----
 .../gui/gtk-frontend/call-history-view-gtk.h       |   16 +--
 lib/engine/gui/gtk-frontend/roster-view-gtk.cpp    |  183 +-------------------
 lib/engine/gui/gtk-frontend/roster-view-gtk.h      |   29 ---
 4 files changed, 8 insertions(+), 253 deletions(-)
---
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 02a114c..8a04ad0 100644
--- a/lib/engine/gui/gtk-frontend/call-history-view-gtk.cpp
+++ b/lib/engine/gui/gtk-frontend/call-history-view-gtk.cpp
@@ -70,7 +70,6 @@ enum {
 
 /* and this is the list of signals supported */
 enum {
-  CONTACT_SELECTED_SIGNAL,
   SELECTION_CHANGED_SIGNAL,
   LAST_SIGNAL
 };
@@ -205,25 +204,13 @@ on_clicked (GtkWidget *tree,
 }
 
 static void
-on_selection_changed (GtkTreeSelection* selection,
+on_selection_changed (G_GNUC_UNUSED GtkTreeSelection* selection,
 		      gpointer data)
 {
   CallHistoryViewGtk* self = NULL;
-  GtkTreeModel* model = NULL;
-  GtkTreeIter iter;
 
   self = CALL_HISTORY_VIEW_GTK (data);
 
-  if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
-
-    History::Contact* contact = NULL;
-    gtk_tree_model_get (model, &iter,
-			COLUMN_CONTACT, &contact,
-			-1);
-    g_signal_emit (self, signals[CONTACT_SELECTED_SIGNAL], 0, contact);
-  } else
-    g_signal_emit (self, signals[CONTACT_SELECTED_SIGNAL], 0, NULL);
-
   g_signal_emit (self, signals[SELECTION_CHANGED_SIGNAL], 0);
 }
 
@@ -284,7 +271,6 @@ static void
 call_history_view_gtk_class_init (gpointer g_class,
 				  gpointer /*class_data*/)
 {
-  CallHistoryViewGtkClass* call_history_view_gtk_class = NULL;
   GObjectClass* gobject_class = NULL;
 
   parent_class = (GObjectClass*) g_type_class_peek_parent (g_class);
@@ -293,29 +279,14 @@ call_history_view_gtk_class_init (gpointer g_class,
   gobject_class->dispose = call_history_view_gtk_dispose;
   gobject_class->finalize = call_history_view_gtk_finalize;
 
-  signals[CONTACT_SELECTED_SIGNAL] =
-    g_signal_new ("contact-selected",
-		  G_OBJECT_CLASS_TYPE (gobject_class),
-		  G_SIGNAL_RUN_LAST,
-		  G_STRUCT_OFFSET (CallHistoryViewGtkClass, contact_selected),
-		  NULL, NULL,
-		  g_cclosure_marshal_VOID__POINTER,
-		  G_TYPE_NONE, 1,
-		  G_TYPE_POINTER);
-
   signals[SELECTION_CHANGED_SIGNAL] =
     g_signal_new ("selection-changed",
 		  G_OBJECT_CLASS_TYPE (gobject_class),
 		  G_SIGNAL_RUN_LAST,
-		  G_STRUCT_OFFSET (CallHistoryViewGtkClass, contact_selected),
+		  G_STRUCT_OFFSET (CallHistoryViewGtkClass, selection_changed),
 		  NULL, NULL,
 		  g_cclosure_marshal_VOID__VOID,
 		  G_TYPE_NONE, 0);
-
-  /* FIXME: is it useful? */
-  call_history_view_gtk_class = (CallHistoryViewGtkClass*)g_class;
-  call_history_view_gtk_class->contact_selected = NULL;
-  call_history_view_gtk_class->selection_changed = NULL;
 }
 
 GType
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 33f1a90..b34d552 100644
--- a/lib/engine/gui/gtk-frontend/call-history-view-gtk.h
+++ b/lib/engine/gui/gtk-frontend/call-history-view-gtk.h
@@ -52,23 +52,17 @@ 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);
 
-/* Knowing what is selected in the view */
-void call_history_view_gtk_get_selected (CallHistoryViewGtk* self,
-					 History::Contact** contact);
-
 
 /* 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);
 
-/* This widget emits two signals :
- * "contact-selected", comes with a pointer which is a History::Contact*
- * (or NULL if no contact is selected anymore)
+/* The signals emitted by this widget:
  *
- * "selection-changed", comes with nothing -- it just says that either something
- * else has been selected, or what was selected changed (which can't happen for
- * call history items!)
+ * - "selection-changed", comes with nothing -- it just says that either
+ * something else has been selected, or what was selected changed (which can't
+ * happen for call history items!)
  */
 
 /* GObject thingies */
@@ -83,8 +77,6 @@ struct _CallHistoryViewGtkClass
 {
   GtkScrolledWindowClass parent;
 
-  void (*contact_selected) (CallHistoryViewGtk* self,
-			    gpointer contact);
   void (*selection_changed) (CallHistoryViewGtk* self);
 };
 
diff --git a/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp b/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp
index 65c5a41..20b31a2 100644
--- a/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp
+++ b/lib/engine/gui/gtk-frontend/roster-view-gtk.cpp
@@ -77,9 +77,6 @@ enum {
 };
 
 enum {
-  PRESENTITY_SELECTED_SIGNAL,
-  HEAP_SELECTED_SIGNAL,
-  HEAP_GROUP_SELECTED_SIGNAL,
   SELECTION_CHANGED_SIGNAL,
   LAST_SIGNAL
 };
@@ -126,12 +123,6 @@ enum {
  * Helpers
  */
 
-/* DESCRIPTION: Remove a child from a GtkContainer
- *
- */
-static void remove_child (GtkWidget* child,
-			  GtkWidget* container);
-
 /* DESCRIPTION : Set of functions called when the user clicks in a view
  * BEHAVIOUR   : Folds/unfolds, shows a menu or triggers default action
  */
@@ -450,13 +441,6 @@ static void roster_view_gtk_update_groups (RosterViewGtk *view,
 /* Implementation of the helpers */
 
 static void
-remove_child (GtkWidget* child,
-	      GtkWidget* container)
-{
-  gtk_container_remove (GTK_CONTAINER (container), child);
-}
-
-static void
 on_clicked_show_heap_menu (Ekiga::Heap* heap,
 			   GdkEventButton* event)
 {
@@ -641,66 +625,13 @@ show_offline_contacts_changed_nt (G_GNUC_UNUSED gpointer id,
 
 
 static void
-on_selection_changed (GtkTreeSelection* selection,
+on_selection_changed (G_GNUC_UNUSED GtkTreeSelection* selection,
 		      gpointer data)
 {
   RosterViewGtk* self = NULL;
-  GtkTreeModel* model = NULL;
-  GtkTreeIter iter;
 
   self = ROSTER_VIEW_GTK (data);
 
-  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);
-    gtk_container_foreach (GTK_CONTAINER (self->priv->toolbar),
-			   (GtkCallback)remove_child, self->priv->toolbar);
-
-    switch (column_type) {
-
-    case TYPE_PRESENTITY: {
-
-      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[PRESENTITY_SELECTED_SIGNAL], 0, presentity);
-      break;
-    }
-    case TYPE_HEAP: {
-
-      g_signal_emit (self, signals[PRESENTITY_SELECTED_SIGNAL], 0, NULL);
-      g_signal_emit (self, signals[HEAP_GROUP_SELECTED_SIGNAL], 0, NULL, NULL);
-      g_signal_emit (self, signals[HEAP_SELECTED_SIGNAL], 0, heap);
-      break;
-    }
-
-    case TYPE_GROUP: {
-
-      g_signal_emit (self, signals[PRESENTITY_SELECTED_SIGNAL], 0, NULL);
-      g_signal_emit (self, signals[HEAP_SELECTED_SIGNAL], 0, NULL);
-      g_signal_emit (self, signals[HEAP_GROUP_SELECTED_SIGNAL], 0, heap, name);
-      break;
-    }
-    default:
-      break;
-    }
-
-    g_free (name);
-  } else {
-
-    g_signal_emit (self, signals[PRESENTITY_SELECTED_SIGNAL], 0, NULL);
-    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);
 }
 
@@ -1406,7 +1337,6 @@ static void
 roster_view_gtk_class_init (gpointer g_class,
 			    gpointer /*class_data*/)
 {
-  RosterViewGtkClass* roster_view_gtk_class = NULL;
   GObjectClass *gobject_class = NULL;
 
   parent_class = (GObjectClass *) g_type_class_peek_parent (g_class);
@@ -1415,52 +1345,14 @@ roster_view_gtk_class_init (gpointer g_class,
   gobject_class->dispose = roster_view_gtk_dispose;
   gobject_class->finalize = roster_view_gtk_finalize;
 
-  signals[PRESENTITY_SELECTED_SIGNAL] =
-    g_signal_new ("presentity-selected",
-		  G_OBJECT_CLASS_TYPE (gobject_class),
-		  G_SIGNAL_RUN_LAST,
-		  G_STRUCT_OFFSET (RosterViewGtkClass, presentity_selected),
-		  NULL, NULL,
-		  g_cclosure_marshal_VOID__POINTER,
-		  G_TYPE_NONE, 1,
-		  G_TYPE_POINTER);
-
-  signals[HEAP_SELECTED_SIGNAL] =
-    g_signal_new ("heap-selected",
-		  G_OBJECT_CLASS_TYPE (gobject_class),
-		  G_SIGNAL_RUN_LAST,
-		  G_STRUCT_OFFSET (RosterViewGtkClass, heap_selected),
-		  NULL, NULL,
-		  g_cclosure_marshal_VOID__POINTER,
-		  G_TYPE_NONE, 1,
-		  G_TYPE_POINTER);
-
-  signals[HEAP_GROUP_SELECTED_SIGNAL] =
-    g_signal_new ("heap-group-selected",
-		  G_OBJECT_CLASS_TYPE (gobject_class),
-		  G_SIGNAL_RUN_LAST,
-		  G_STRUCT_OFFSET (RosterViewGtkClass, heap_group_selected),
-		  NULL, NULL,
-		  gm_marshal_VOID__POINTER_STRING,
-		  G_TYPE_NONE, 2,
-		  G_TYPE_POINTER,
-		  G_TYPE_STRING);
-
   signals[SELECTION_CHANGED_SIGNAL] =
     g_signal_new ("selection-changed",
 		  G_OBJECT_CLASS_TYPE (gobject_class),
 		  G_SIGNAL_RUN_LAST,
-		  G_STRUCT_OFFSET (RosterViewGtkClass, heap_group_selected),
+		  G_STRUCT_OFFSET (RosterViewGtkClass, selection_changed),
 		  NULL, NULL,
 		  g_cclosure_marshal_VOID__VOID,
 		  G_TYPE_NONE, 0);
-
-  /* FIXME: is it useful? */
-  roster_view_gtk_class = (RosterViewGtkClass*)g_class;
-  roster_view_gtk_class->presentity_selected = NULL;
-  roster_view_gtk_class->heap_selected = NULL;
-  roster_view_gtk_class->heap_group_selected = NULL;
-  roster_view_gtk_class->selection_changed = NULL;
 }
 
 
@@ -1661,77 +1553,6 @@ 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;
-  }
-}
-
 bool
 roster_view_gtk_populate_menu_for_selected (RosterViewGtk* self,
 					    Ekiga::MenuBuilder& builder)
diff --git a/lib/engine/gui/gtk-frontend/roster-view-gtk.h b/lib/engine/gui/gtk-frontend/roster-view-gtk.h
index fbeba43..346d314 100644
--- a/lib/engine/gui/gtk-frontend/roster-view-gtk.h
+++ b/lib/engine/gui/gtk-frontend/roster-view-gtk.h
@@ -54,18 +54,6 @@ typedef struct _RosterViewGtkClass RosterViewGtkClass;
 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);
-
 /* This method populates the given builder with the actions possible on the
  * selected item, whatever that is (heap, group, presentity)
  */
@@ -74,16 +62,6 @@ bool roster_view_gtk_populate_menu_for_selected (RosterViewGtk* self,
 
 /* 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)
- *
  * - "selection-changed", comes with nothing, and notifies whether either the
  * selection changed, or the selected object changed.
  */
@@ -101,13 +79,6 @@ struct _RosterViewGtkClass
 {
   GtkFrameClass parent;
 
-  void (*presentity_selected) (RosterViewGtk* self,
-			       gpointer presentity);
-  void (*heap_selected) (RosterViewGtk* self,
-			 gpointer heap);
-  void (*heap_group_selected) (RosterViewGtk* self,
-			       gpointer heap,
-			       const gchar* group_name);
   void (*selection_changed) (RosterViewGtk* self);
 };
 



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