From d3d7a1fe65c052e9187b4603171198aa373f4d0b Mon Sep 17 00:00:00 2001 From: Laurent Contzen Date: Tue, 19 Jun 2012 16:20:29 +0200 Subject: Create and use People Nearby group https://bugzilla.gnome.org/show_bug.cgi?id=678156 --- libempathy-gtk/empathy-roster-view.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c index 0decfd14f..111b643b6 100644 --- a/libempathy-gtk/empathy-roster-view.c +++ b/libempathy-gtk/empathy-roster-view.c @@ -8,6 +8,8 @@ #include #include +#include + G_DEFINE_TYPE (EmpathyRosterView, empathy_roster_view, EGG_TYPE_LIST_BOX) /* Flashing delay for icons (milliseconds). */ @@ -36,6 +38,7 @@ static guint signals[LAST_SIGNAL]; #define NO_GROUP "X-no-group" #define UNGROUPED _("Ungrouped") #define TOP_GROUP _("Top Contacts") +#define PEOPLE_NEARBY _("People Nearby") struct _EmpathyRosterViewPriv { @@ -163,6 +166,27 @@ roster_contact_changed_cb (GtkWidget *child, egg_list_box_child_changed (EGG_LIST_BOX (self), child); } +static gboolean +is_xmpp_local_contact (FolksIndividual *individual) +{ + EmpathyContact *contact; + TpConnection *connection; + const gchar *protocol_name = NULL; + gboolean result; + + contact = empathy_contact_dup_from_folks_individual (individual); + + if (contact == NULL) + return FALSE; + + connection = empathy_contact_get_connection (contact); + protocol_name = tp_connection_get_protocol_name (connection); + result = !tp_strdiff (protocol_name, "local-xmpp"); + g_object_unref (contact); + + return result; +} + static GtkWidget * add_roster_contact (EmpathyRosterView *self, FolksIndividual *individual, @@ -221,6 +245,8 @@ ensure_roster_group (EmpathyRosterView *self, if (!tp_strdiff (group, TOP_GROUP)) roster_group = empathy_roster_group_new (group, "emblem-favorite-symbolic"); + else if (!tp_strdiff (group, PEOPLE_NEARBY)) + roster_group = empathy_roster_group_new (group, "im-local-xmpp"); else roster_group = empathy_roster_group_new (group, NULL); @@ -299,6 +325,10 @@ individual_added (EmpathyRosterView *self, { add_to_group (self, individual, NO_GROUP); } + else if (is_xmpp_local_contact (individual)) + { + add_to_group (self, individual, PEOPLE_NEARBY); + } else { GeeSet *groups; -- cgit v1.2.3