aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-05-30 19:58:02 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-05-30 19:58:02 +0800
commit00160ff5ab516aa40789b2087a9bac20c55dff50 (patch)
treeedffec46ec3d01b514073ff0d9db5591c701bf23
parentad0ec31156a8484e9bf97559c02b16ce69a0c7e2 (diff)
downloadgsoc2013-empathy-00160ff5ab516aa40789b2087a9bac20c55dff50.tar
gsoc2013-empathy-00160ff5ab516aa40789b2087a9bac20c55dff50.tar.gz
gsoc2013-empathy-00160ff5ab516aa40789b2087a9bac20c55dff50.tar.bz2
gsoc2013-empathy-00160ff5ab516aa40789b2087a9bac20c55dff50.tar.lz
gsoc2013-empathy-00160ff5ab516aa40789b2087a9bac20c55dff50.tar.xz
gsoc2013-empathy-00160ff5ab516aa40789b2087a9bac20c55dff50.tar.zst
gsoc2013-empathy-00160ff5ab516aa40789b2087a9bac20c55dff50.zip
Set a tooltip on contact list view showing EmpathyContactWidget information
svn path=/trunk/; revision=1131
-rw-r--r--libempathy-gtk/empathy-contact-list-view.c88
-rw-r--r--libempathy-gtk/empathy-contact-list-view.h3
2 files changed, 80 insertions, 11 deletions
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index 58ae7711f..3443950de 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -66,6 +66,7 @@ typedef struct {
GtkTreeRowReference *drag_row;
EmpathyContactListFeatureFlags list_features;
EmpathyContactFeatureFlags contact_features;
+ GtkWidget *tooltip_widget;
} EmpathyContactListViewPriv;
typedef struct {
@@ -117,6 +118,67 @@ static guint signals[LAST_SIGNAL];
G_DEFINE_TYPE (EmpathyContactListView, empathy_contact_list_view, GTK_TYPE_TREE_VIEW);
static void
+contact_list_view_tooltip_destroy_cb (GtkWidget *widget,
+ EmpathyContactListView *view)
+{
+ EmpathyContactListViewPriv *priv = GET_PRIV (view);
+
+ DEBUG ("Tooltip destroyed");
+ if (priv->tooltip_widget) {
+ g_object_unref (priv->tooltip_widget);
+ priv->tooltip_widget = NULL;
+ }
+}
+
+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;
+
+ 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_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 void
contact_list_view_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
@@ -900,6 +962,10 @@ contact_list_view_set_list_features (EmpathyContactListView *view,
/* FIXME: URI could still be droped depending on FT feature */
gtk_drag_dest_unset (GTK_WIDGET (view));
}
+
+ /* Update has-tooltip */
+ gtk_widget_set_has_tooltip (GTK_WIDGET (view),
+ features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_TOOLTIP);
}
static void
@@ -913,6 +979,10 @@ contact_list_view_finalize (GObject *object)
g_object_unref (priv->store);
}
+ if (priv->tooltip_widget) {
+ g_object_unref (priv->tooltip_widget);
+ }
+
G_OBJECT_CLASS (empathy_contact_list_view_parent_class)->finalize (object);
}
@@ -1041,26 +1111,24 @@ empathy_contact_list_view_init (EmpathyContactListView *view)
NULL, NULL);
/* Connect to tree view signals rather than override. */
- g_signal_connect (view,
- "button-press-event",
+ g_signal_connect (view, "button-press-event",
G_CALLBACK (contact_list_view_button_press_event_cb),
NULL);
- g_signal_connect (view,
- "key-press-event",
+ g_signal_connect (view, "key-press-event",
G_CALLBACK (contact_list_view_key_press_event_cb),
NULL);
- g_signal_connect (view,
- "row-activated",
+ g_signal_connect (view, "row-activated",
G_CALLBACK (contact_list_view_row_activated_cb),
NULL);
- g_signal_connect (view,
- "row-expanded",
+ g_signal_connect (view, "row-expanded",
G_CALLBACK (contact_list_view_row_expand_or_collapse_cb),
GINT_TO_POINTER (TRUE));
- g_signal_connect (view,
- "row-collapsed",
+ g_signal_connect (view, "row-collapsed",
G_CALLBACK (contact_list_view_row_expand_or_collapse_cb),
GINT_TO_POINTER (FALSE));
+ g_signal_connect (view, "query-tooltip",
+ G_CALLBACK (contact_list_view_query_tooltip_cb),
+ NULL);
}
EmpathyContactListView *
diff --git a/libempathy-gtk/empathy-contact-list-view.h b/libempathy-gtk/empathy-contact-list-view.h
index 39dc5966b..82990d64f 100644
--- a/libempathy-gtk/empathy-contact-list-view.h
+++ b/libempathy-gtk/empathy-contact-list-view.h
@@ -53,7 +53,8 @@ typedef enum {
EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE = 1 << 3,
EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DROP = 1 << 4,
EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DRAG = 1 << 5,
- EMPATHY_CONTACT_LIST_FEATURE_ALL = (1 << 6) - 1,
+ EMPATHY_CONTACT_LIST_FEATURE_CONTACT_TOOLTIP = 1 << 6,
+ EMPATHY_CONTACT_LIST_FEATURE_ALL = (1 << 7) - 1,
} EmpathyContactListFeatureFlags;
struct _EmpathyContactListView {