diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-06-04 20:57:03 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-06-14 15:21:49 +0800 |
commit | 32e517b2bc225ad56de043e79278374994c099ad (patch) | |
tree | 31bfddde30c6f6436404dd2971b50ef8ae1d7537 | |
parent | a96c2a5c0ac5133ab8b7a14fab0f2857cead162d (diff) | |
download | gsoc2013-empathy-32e517b2bc225ad56de043e79278374994c099ad.tar gsoc2013-empathy-32e517b2bc225ad56de043e79278374994c099ad.tar.gz gsoc2013-empathy-32e517b2bc225ad56de043e79278374994c099ad.tar.bz2 gsoc2013-empathy-32e517b2bc225ad56de043e79278374994c099ad.tar.lz gsoc2013-empathy-32e517b2bc225ad56de043e79278374994c099ad.tar.xz gsoc2013-empathy-32e517b2bc225ad56de043e79278374994c099ad.tar.zst gsoc2013-empathy-32e517b2bc225ad56de043e79278374994c099ad.zip |
add API for individual tooltips
-rw-r--r-- | libempathy-gtk/empathy-roster-view.c | 41 | ||||
-rw-r--r-- | libempathy-gtk/empathy-roster-view.h | 11 | ||||
-rw-r--r-- | tests/interactive/test-empathy-roster-view.c | 16 |
3 files changed, 68 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c index 28aac164c..3803c8b17 100644 --- a/libempathy-gtk/empathy-roster-view.c +++ b/libempathy-gtk/empathy-roster-view.c @@ -50,6 +50,9 @@ struct _EmpathyRosterViewPriv gboolean show_groups; EmpathyLiveSearch *search; + + EmpathyRosterViewIndividualTooltipCb individual_tooltip_cb; + gpointer individual_tooltip_data; }; static void @@ -876,6 +879,43 @@ empathy_roster_view_key_press_event (GtkWidget *widget, return chain_up (widget, event); } +static gboolean +empathy_roster_view_query_tooltip (GtkWidget *widget, + gint x, + gint y, + gboolean keyboard_mode, + GtkTooltip *tooltip) +{ + EmpathyRosterView *self = EMPATHY_ROSTER_VIEW (widget); + GtkWidget *child; + EmpathyRosterContact *contact; + FolksIndividual *individual; + + 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; + + contact = EMPATHY_ROSTER_CONTACT (child); + individual = empathy_roster_contact_get_individual (contact); + + return self->priv->individual_tooltip_cb (self, individual, keyboard_mode, + tooltip, self->priv->individual_tooltip_data); +} + +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_class_init ( EmpathyRosterViewClass *klass) @@ -893,6 +933,7 @@ empathy_roster_view_class_init ( widget_class->button_press_event = empathy_roster_view_button_press_event; widget_class->key_press_event = empathy_roster_view_key_press_event; + widget_class->query_tooltip = empathy_roster_view_query_tooltip; box_class->child_activated = empathy_roster_view_child_activated; diff --git a/libempathy-gtk/empathy-roster-view.h b/libempathy-gtk/empathy-roster-view.h index e5c3a6f40..e5160f6a3 100644 --- a/libempathy-gtk/empathy-roster-view.h +++ b/libempathy-gtk/empathy-roster-view.h @@ -64,6 +64,17 @@ 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); + G_END_DECLS #endif /* #ifndef __EMPATHY_ROSTER_VIEW_H__*/ diff --git a/tests/interactive/test-empathy-roster-view.c b/tests/interactive/test-empathy-roster-view.c index c76f670c8..f10aaf2d7 100644 --- a/tests/interactive/test-empathy-roster-view.c +++ b/tests/interactive/test-empathy-roster-view.c @@ -52,6 +52,19 @@ popup_individual_menu_cb (EmpathyRosterView *self, gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, button, time); } +static gboolean +individual_tooltip_cb (EmpathyRosterView *view, + FolksIndividual *individual, + gboolean keyboard_mode, + GtkTooltip *tooltip, + gpointer user_data) +{ + gtk_tooltip_set_text (tooltip, + folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual))); + + return TRUE; +} + int main (int argc, char **argv) @@ -91,6 +104,9 @@ main (int argc, empathy_roster_view_show_offline (EMPATHY_ROSTER_VIEW (view), show_offline); empathy_roster_view_show_groups (EMPATHY_ROSTER_VIEW (view), show_groups); + empathy_roster_view_set_individual_tooltip_cb (EMPATHY_ROSTER_VIEW (view), + individual_tooltip_cb, NULL); + g_object_unref (mgr); search = empathy_live_search_new (view); |