[empathy] roster-view: use a signal instead of a cb to handle individual tooltips
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] roster-view: use a signal instead of a cb to handle individual tooltips
- Date: Mon, 18 Jun 2012 11:21:01 +0000 (UTC)
commit c977e894c549b8bb146e23dd5ce88509a30c96cd
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Mon Jun 18 13:15:17 2012 +0200
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 ---------
src/empathy-roster-window.c | 9 +++----
tests/interactive/test-empathy-roster-view.c | 7 +++--
4 files changed, 18 insertions(+), 38 deletions(-)
---
diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c
index 7ae8052..a2033f2 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 c3d475b..a0ed775 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);
diff --git a/src/empathy-roster-window.c b/src/empathy-roster-window.c
index a1363fc..abff479 100644
--- a/src/empathy-roster-window.c
+++ b/src/empathy-roster-window.c
@@ -1925,10 +1925,8 @@ individual_tooltip_cb (EmpathyRosterView *view,
FolksIndividual *individual,
gboolean keyboard_mode,
GtkTooltip *tooltip,
- gpointer user_data)
+ EmpathyRosterWindow *self)
{
- EmpathyRosterWindow *self = user_data;
-
if (self->priv->tooltip_widget == NULL)
{
self->priv->tooltip_widget = empathy_individual_widget_new (individual,
@@ -2089,9 +2087,10 @@ empathy_roster_window_init (EmpathyRosterWindow *self)
G_CALLBACK (popup_individual_menu_cb), self);
g_signal_connect (self->priv->view, "notify::empty",
G_CALLBACK (view_empty_cb), self);
+ g_signal_connect (self->priv->view, "individual-tooltip",
+ G_CALLBACK (individual_tooltip_cb), self);
- empathy_roster_view_set_individual_tooltip_cb (self->priv->view,
- individual_tooltip_cb, self);
+ gtk_widget_set_has_tooltip (GTK_WIDGET (self->priv->view), TRUE);
/* Set up search bar */
self->priv->search_bar = empathy_live_search_new (
diff --git a/tests/interactive/test-empathy-roster-view.c b/tests/interactive/test-empathy-roster-view.c
index becb332..d0f739d 100644
--- a/tests/interactive/test-empathy-roster-view.c
+++ b/tests/interactive/test-empathy-roster-view.c
@@ -113,13 +113,14 @@ main (int argc,
G_CALLBACK (popup_individual_menu_cb), NULL);
g_signal_connect (view, "notify::empty",
G_CALLBACK (empty_cb), NULL);
+ g_signal_connect (view, "individual-tooltip",
+ G_CALLBACK (individual_tooltip_cb), NULL);
+
+ gtk_widget_set_has_tooltip (view, TRUE);
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]