aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-roster-view.c
diff options
context:
space:
mode:
authorLaurent Contzen <lcontzen@gmail.com>2012-08-07 22:28:21 +0800
committerLaurent Contzen <lcontzen@gmail.com>2012-08-07 22:41:51 +0800
commit44472802c9c232f7ab6639af2e0a88b090016671 (patch)
tree445ce217b743f96d602ff20f87e9f58b4f7da42a /libempathy-gtk/empathy-roster-view.c
parent5ff0b2f71b6516b399deb732bfe0124e32a8a7bf (diff)
downloadgsoc2013-empathy-44472802c9c232f7ab6639af2e0a88b090016671.tar
gsoc2013-empathy-44472802c9c232f7ab6639af2e0a88b090016671.tar.gz
gsoc2013-empathy-44472802c9c232f7ab6639af2e0a88b090016671.tar.bz2
gsoc2013-empathy-44472802c9c232f7ab6639af2e0a88b090016671.tar.lz
gsoc2013-empathy-44472802c9c232f7ab6639af2e0a88b090016671.tar.xz
gsoc2013-empathy-44472802c9c232f7ab6639af2e0a88b090016671.tar.zst
gsoc2013-empathy-44472802c9c232f7ab6639af2e0a88b090016671.zip
Moved _contact_in_top from the model to the view
empathy-roster-model and empathy-roster-model-manager: removed _contact_in_top empathy-roster-view: added new function contact_in_top and modified functions to use it
Diffstat (limited to 'libempathy-gtk/empathy-roster-view.c')
-rw-r--r--libempathy-gtk/empathy-roster-view.c56
1 files changed, 38 insertions, 18 deletions
diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c
index de14b5d97..a820d2b62 100644
--- a/libempathy-gtk/empathy-roster-view.c
+++ b/libempathy-gtk/empathy-roster-view.c
@@ -484,6 +484,40 @@ individual_removed_cb (EmpathyRosterModel *model,
individual_removed (self, individual);
}
+static gboolean
+contact_in_top (EmpathyRosterView *self,
+ EmpathyRosterContact *contact)
+{
+ if (!self->priv->show_groups)
+ {
+ /* Always display top contacts in non-group mode. */
+ GList *groups;
+ FolksIndividual *individual;
+ gboolean result = FALSE;
+
+ individual = empathy_roster_contact_get_individual (contact);
+
+ groups = empathy_roster_model_get_groups_for_individual (
+ self->priv->model, individual);
+
+ if (g_list_find (groups, EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP) != NULL)
+ result = TRUE;
+
+ g_list_free (groups);
+
+ return result;
+ }
+
+ if (!tp_strdiff (empathy_roster_contact_get_group (contact),
+ EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP))
+ /* If we are displaying contacts, we only want to *always* display the
+ * RosterContact which is displayed at the top; not the ones displayed in
+ * the 'normal' group sections */
+ return TRUE;
+
+ return FALSE;
+}
+
static gint
compare_roster_contacts_by_alias (EmpathyRosterContact *a,
EmpathyRosterContact *b)
@@ -507,8 +541,8 @@ compare_roster_contacts_no_group (EmpathyRosterView *self,
{
gboolean top_a, top_b;
- top_a = empathy_roster_model_contact_in_top (self->priv->model, a);
- top_b = empathy_roster_model_contact_in_top (self->priv->model, b);
+ top_a = contact_in_top (self, a);
+ top_b = contact_in_top (self, b);
if (top_a == top_b)
/* Both contacts are in the top of the roster (or not). Sort them
@@ -731,22 +765,8 @@ contact_should_be_displayed (EmpathyRosterView *self,
if (self->priv->show_offline)
return TRUE;
- if (empathy_roster_model_contact_in_top (self->priv->model,
- contact))
- {
- const gchar *group_name;
-
- if (!self->priv->show_groups)
- /* Always display favourite contacts in non-group mode. */
- return TRUE;
-
- group_name = empathy_roster_contact_get_group (contact);
-
- if (!tp_strdiff (group_name, EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP))
- /* Always display favourite contact in group mode only in the
- * 'top group'*/
- return TRUE;
- }
+ if (contact_in_top (self, contact))
+ return TRUE;
return empathy_roster_contact_is_online (contact);
}