[empathy] roster-window: display individual tooltips



commit aac60300edfcb929acca9e4fc59cdb5803eecc30
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Mon Jun 18 12:17:33 2012 +0200

    roster-window: display individual tooltips
    
    I re-used the same code as in EmpathyIndividualView.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=678294

 src/empathy-roster-window.c |   50 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/src/empathy-roster-window.c b/src/empathy-roster-window.c
index 6a791f4..a1363fc 100644
--- a/src/empathy-roster-window.c
+++ b/src/empathy-roster-window.c
@@ -124,6 +124,7 @@ struct _EmpathyRosterWindowPriv {
   GtkWidget *no_entry_label;
   GtkWidget *button_account_settings;
   GtkWidget *spinner_loading;
+  GtkWidget *tooltip_widget;
 
   GMenu *menumodel;
   GMenu *rooms_section;
@@ -999,6 +1000,8 @@ empathy_roster_window_finalize (GObject *window)
   g_object_unref (self->priv->menumodel);
   g_object_unref (self->priv->rooms_section);
 
+  g_clear_object (&self->priv->tooltip_widget);
+
   G_OBJECT_CLASS (empathy_roster_window_parent_class)->finalize (window);
 }
 
@@ -1911,6 +1914,50 @@ view_empty_cb (EmpathyRosterView *view,
 }
 
 static void
+tooltip_destroy_cb (GtkWidget *widget,
+    EmpathyRosterWindow *self)
+{
+  g_clear_object (&self->priv->tooltip_widget);
+}
+
+static gboolean
+individual_tooltip_cb (EmpathyRosterView *view,
+    FolksIndividual *individual,
+    gboolean keyboard_mode,
+    GtkTooltip *tooltip,
+    gpointer user_data)
+{
+  EmpathyRosterWindow *self = user_data;
+
+  if (self->priv->tooltip_widget == NULL)
+    {
+      self->priv->tooltip_widget = empathy_individual_widget_new (individual,
+          EMPATHY_INDIVIDUAL_WIDGET_FOR_TOOLTIP |
+          EMPATHY_INDIVIDUAL_WIDGET_SHOW_LOCATION |
+          EMPATHY_INDIVIDUAL_WIDGET_SHOW_CLIENT_TYPES);
+
+      gtk_container_set_border_width (
+          GTK_CONTAINER (self->priv->tooltip_widget), 8);
+
+      g_object_ref (self->priv->tooltip_widget);
+
+      tp_g_signal_connect_object (self->priv->tooltip_widget, "destroy",
+          G_CALLBACK (tooltip_destroy_cb), self, 0);
+
+      gtk_widget_show (self->priv->tooltip_widget);
+    }
+  else
+    {
+      empathy_individual_widget_set_individual (
+        EMPATHY_INDIVIDUAL_WIDGET (self->priv->tooltip_widget), individual);
+    }
+
+  gtk_tooltip_set_custom (tooltip, self->priv->tooltip_widget);
+
+  return TRUE;
+}
+
+static void
 empathy_roster_window_init (EmpathyRosterWindow *self)
 {
   GtkBuilder *gui;
@@ -2043,6 +2090,9 @@ empathy_roster_window_init (EmpathyRosterWindow *self)
   g_signal_connect (self->priv->view, "notify::empty",
       G_CALLBACK (view_empty_cb), self);
 
+  empathy_roster_view_set_individual_tooltip_cb (self->priv->view,
+      individual_tooltip_cb, self);
+
   /* Set up search bar */
   self->priv->search_bar = empathy_live_search_new (
       GTK_WIDGET (self->priv->view));



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