From c977e894c549b8bb146e23dd5ce88509a30c96cd Mon Sep 17 00:00:00 2001
From: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Date: Mon, 18 Jun 2012 13:15:17 +0200
Subject: roster-view: use a signal instead of a cb to handle individual
 tooltips

https://bugzilla.gnome.org/show_bug.cgi?id=678294
---
 libempathy-gtk/empathy-roster-view.c | 29 ++++++++++-------------------
 libempathy-gtk/empathy-roster-view.h | 11 -----------
 2 files changed, 10 insertions(+), 30 deletions(-)

(limited to 'libempathy-gtk')

diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c
index 7ae805239..a2033f216 100644
--- a/libempathy-gtk/empathy-roster-view.c
+++ b/libempathy-gtk/empathy-roster-view.c
@@ -27,6 +27,7 @@ enum
   SIG_INDIVIDUAL_ACTIVATED,
   SIG_POPUP_INDIVIDUAL_MENU,
   SIG_EVENT_ACTIVATED,
+  SIG_INDIVIDUAL_TOOLTIP,
   LAST_SIGNAL
 };
 
@@ -65,9 +66,6 @@ struct _EmpathyRosterViewPriv
   gboolean empty;
 
   EmpathyLiveSearch *search;
-
-  EmpathyRosterViewIndividualTooltipCb individual_tooltip_cb;
-  gpointer individual_tooltip_data;
 };
 
 typedef struct
@@ -1232,9 +1230,6 @@ empathy_roster_view_query_tooltip (GtkWidget *widget,
   FolksIndividual *individual;
   gboolean result;
 
-  if (self->priv->individual_tooltip_cb == NULL)
-    return FALSE;
-
   child = egg_list_box_get_child_at_y (EGG_LIST_BOX (self), y);
   if (!EMPATHY_IS_ROSTER_CONTACT (child))
     return FALSE;
@@ -1242,8 +1237,8 @@ empathy_roster_view_query_tooltip (GtkWidget *widget,
   contact = EMPATHY_ROSTER_CONTACT (child);
   individual = empathy_roster_contact_get_individual (contact);
 
-  result = self->priv->individual_tooltip_cb (self, individual, keyboard_mode,
-      tooltip, self->priv->individual_tooltip_data);
+  g_signal_emit (self, signals[SIG_INDIVIDUAL_TOOLTIP], 0,
+      individual, keyboard_mode, tooltip, &result);
 
   if (result)
     {
@@ -1256,17 +1251,6 @@ empathy_roster_view_query_tooltip (GtkWidget *widget,
   return result;
 }
 
-void
-empathy_roster_view_set_individual_tooltip_cb (EmpathyRosterView *self,
-    EmpathyRosterViewIndividualTooltipCb callback,
-    gpointer user_data)
-{
-  self->priv->individual_tooltip_cb = callback;
-  self->priv->individual_tooltip_data = user_data;
-
-  gtk_widget_set_has_tooltip (GTK_WIDGET (self), callback != NULL);
-}
-
 static void
 empathy_roster_view_remove (GtkContainer *container,
     GtkWidget *widget)
@@ -1350,6 +1334,13 @@ empathy_roster_view_class_init (
       G_TYPE_NONE,
       2, FOLKS_TYPE_INDIVIDUAL, G_TYPE_POINTER);
 
+  signals[SIG_INDIVIDUAL_TOOLTIP] = g_signal_new ("individual-tooltip",
+      G_OBJECT_CLASS_TYPE (klass),
+      G_SIGNAL_RUN_LAST,
+      0, g_signal_accumulator_true_handled, NULL, NULL,
+      G_TYPE_BOOLEAN,
+      3, FOLKS_TYPE_INDIVIDUAL, G_TYPE_BOOLEAN, GTK_TYPE_TOOLTIP);
+
   g_type_class_add_private (klass, sizeof (EmpathyRosterViewPriv));
 }
 
diff --git a/libempathy-gtk/empathy-roster-view.h b/libempathy-gtk/empathy-roster-view.h
index c3d475b0b..a0ed77515 100644
--- a/libempathy-gtk/empathy-roster-view.h
+++ b/libempathy-gtk/empathy-roster-view.h
@@ -64,17 +64,6 @@ void empathy_roster_view_show_groups (EmpathyRosterView *self,
 void empathy_roster_view_set_live_search (EmpathyRosterView *self,
     EmpathyLiveSearch *search);
 
-typedef gboolean (* EmpathyRosterViewIndividualTooltipCb) (
-    EmpathyRosterView *self,
-    FolksIndividual *individual,
-    gboolean keyboard_mode,
-    GtkTooltip *tooltip,
-    gpointer user_data);
-
-void empathy_roster_view_set_individual_tooltip_cb (EmpathyRosterView *self,
-    EmpathyRosterViewIndividualTooltipCb callback,
-    gpointer user_data);
-
 gboolean empathy_roster_view_is_empty (EmpathyRosterView *self);
 
 gboolean empathy_roster_view_is_searching (EmpathyRosterView *self);
-- 
cgit v1.2.3