static gboolean
contact_list_view_query_tooltip_cb (EmpathyContactListView *view,
				    gint                    x,
				    gint                    y,
				    gboolean                keyboard_mode,
				    GtkTooltip             *tooltip,
				    gpointer                user_data)
{
	EmpathyContactListViewPriv *priv = GET_PRIV (view);
	EmpathyContact             *contact;
	GtkTreeModel               *model;
	GtkTreeIter                 iter;
	GtkTreePath                *path;

	/* FIXME: We need GTK version >= 2.12.10. See GNOME bug #504087 */
	if (gtk_check_version (2, 12, 10)) {
		return FALSE;
	}

	if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (view), &x, &y,
						keyboard_mode,
						&model, &path, &iter)) {
		return FALSE;
	}

	gtk_tree_view_set_tooltip_row (GTK_TREE_VIEW (view), tooltip, path);
	gtk_tree_path_free (path);

	gtk_tree_model_get (model, &iter,
			    EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact,
			    -1);
	if (!contact) {
		return FALSE;
	}

	if (!priv->tooltip_widget) {
		priv->tooltip_widget = empathy_contact_widget_new (contact,
			EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP);
		g_object_ref (priv->tooltip_widget);
		g_signal_connect (priv->tooltip_widget, "destroy",
				  G_CALLBACK (contact_list_view_tooltip_destroy_cb),
				  view);
	} else {
		empathy_contact_widget_set_contact (priv->tooltip_widget,
						    contact);
	}

	gtk_tooltip_set_custom (tooltip, priv->tooltip_widget);

	g_object_unref (contact);

	return TRUE;
}
static gboolean
contact_list_view_query_tooltip_cb (EmpathyContactListView *view,
				    gint                    x,
				    gint                    y,
				    gboolean                keyboard_mode,
				    GtkTooltip             *tooltip,
				    gpointer                user_data)
{
	EmpathyContactListViewPriv *priv = GET_PRIV (view);
	EmpathyContact             *contact;
	GtkTreeModel               *model;
	GtkTreeIter                 iter;
	GtkTreePath                *path;

	/* FIXME: We need GTK version >= 2.12.10. See GNOME bug #504087 */
	if (100 * gtk_minor_version + gtk_micro_version < 1210) {
		return FALSE;
	}

	if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (view), &x, &y,
						keyboard_mode,
						&model, &path, &iter)) {
		return FALSE;
	}

	gtk_tree_view_set_tooltip_row (GTK_TREE_VIEW (view), tooltip, path);
	gtk_tree_path_free (path);

	gtk_tree_model_get (model, &iter,
			    EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact,
			    -1);
	if (!contact) {
		return FALSE;
	}

	if (!priv->tooltip_widget) {
		priv->tooltip_widget = empathy_contact_widget_new (contact,
			EMPATHY_CONTACT_WIDGET_EDIT_NONE);
		g_object_add_weak_pointer (G_OBJECT (priv->tooltip_widget),
					   (gpointer) &priv->tooltip_widget);
	} else {
		empathy_contact_widget_set_contact (priv->tooltip_widget,
						    contact);
	}

	gtk_tooltip_set_custom (tooltip, priv->tooltip_widget);

	g_object_unref (contact);

	return TRUE;
}
static gboolean
contact_list_view_query_tooltip_cb (EmpathyContactListView *view,
				    gint                    x,
				    gint                    y,
				    gboolean                keyboard_mode,
				    GtkTooltip             *tooltip,
				    gpointer                user_data)
{
	EmpathyContactListViewPriv *priv = GET_PRIV (view);
	EmpathyContact             *contact;
	GtkTreeModel               *model;
	GtkTreeIter                 iter;
	GtkTreePath                *path;
	static gint                 running = 0;
	gboolean                    ret = FALSE;

	/* Avoid an infinite loop. See GNOME bug #574377 */
	if (running > 0) {
		return FALSE;
	}
	running++;

	if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (view), &x, &y,
						keyboard_mode,
						&model, &path, &iter)) {
		goto OUT;
	}

	gtk_tree_view_set_tooltip_row (GTK_TREE_VIEW (view), tooltip, path);
	gtk_tree_path_free (path);

	gtk_tree_model_get (model, &iter,
			    EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact,
			    -1);
	if (!contact) {
		goto OUT;
	}

	if (!priv->tooltip_widget) {
		priv->tooltip_widget = empathy_contact_widget_new (contact,
			EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP |
			EMPATHY_CONTACT_WIDGET_SHOW_LOCATION);
		g_object_ref (priv->tooltip_widget);
		g_signal_connect (priv->tooltip_widget, "destroy",
				  G_CALLBACK (contact_list_view_tooltip_destroy_cb),
				  view);
		gtk_widget_show (priv->tooltip_widget);
	} else {
		empathy_contact_widget_set_contact (priv->tooltip_widget,
						    contact);
	}

	gtk_tooltip_set_custom (tooltip, priv->tooltip_widget);
	ret = TRUE;

	g_object_unref (contact);
OUT:
	running--;

	return ret;
}
static gboolean
query_tooltip_cb (EmpathyPersonaView *self,
    gint x,
    gint y,
    gboolean keyboard_mode,
    GtkTooltip *tooltip,
    gpointer user_data)
{
  EmpathyPersonaViewPriv *priv = GET_PRIV (self);
  FolksPersona *persona;
  TpContact *tp_contact;
  EmpathyContact *contact;
  GtkTreeModel *model;
  GtkTreeIter iter;
  GtkTreePath *path;
  static gint running = 0;
  gboolean ret = FALSE;

  /* Avoid an infinite loop. See GNOME bug #574377 */
  if (running > 0)
    return FALSE;
  running++;

  if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (self), &x, &y,
      keyboard_mode, &model, &path, &iter))
    {
      goto OUT;
    }

  gtk_tree_view_set_tooltip_row (GTK_TREE_VIEW (self), tooltip, path);
  gtk_tree_path_free (path);

  gtk_tree_model_get (model, &iter,
      EMPATHY_PERSONA_STORE_COL_PERSONA, &persona,
      -1);
  if (persona == NULL)
    goto OUT;

  tp_contact = tpf_persona_get_contact (TPF_PERSONA (persona));
  if (tp_contact == NULL)
    {
      g_clear_object (&persona);
      goto OUT;
    }

  contact = empathy_contact_dup_from_tp_contact (tp_contact);

  if (priv->tooltip_widget == NULL)
    {
      priv->tooltip_widget = empathy_contact_widget_new (contact,
          EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP |
          EMPATHY_CONTACT_WIDGET_SHOW_LOCATION);
      gtk_container_set_border_width (GTK_CONTAINER (priv->tooltip_widget), 8);
      g_object_ref (priv->tooltip_widget);
      g_signal_connect (priv->tooltip_widget, "destroy",
          (GCallback) tooltip_destroy_cb, self);
      gtk_widget_show (priv->tooltip_widget);
    }
  else
    {
      empathy_contact_widget_set_contact (priv->tooltip_widget, contact);
    }

  gtk_tooltip_set_custom (tooltip, priv->tooltip_widget);
  ret = TRUE;

  g_object_unref (contact);
  g_object_unref (persona);

OUT:
  running--;

  return ret;
}