aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-06-14 21:42:53 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-06-15 19:07:18 +0800
commitbed1c1b27c5ccb6d35be8ef2b2bb6b4fa8f24f24 (patch)
treec8982ad38e77291410facf568de1dd7ad56a3164 /libempathy-gtk
parent7f8fe5091b7a980133c0c3d1285cb718f8772142 (diff)
downloadgsoc2013-empathy-bed1c1b27c5ccb6d35be8ef2b2bb6b4fa8f24f24.tar
gsoc2013-empathy-bed1c1b27c5ccb6d35be8ef2b2bb6b4fa8f24f24.tar.gz
gsoc2013-empathy-bed1c1b27c5ccb6d35be8ef2b2bb6b4fa8f24f24.tar.bz2
gsoc2013-empathy-bed1c1b27c5ccb6d35be8ef2b2bb6b4fa8f24f24.tar.lz
gsoc2013-empathy-bed1c1b27c5ccb6d35be8ef2b2bb6b4fa8f24f24.tar.xz
gsoc2013-empathy-bed1c1b27c5ccb6d35be8ef2b2bb6b4fa8f24f24.tar.zst
gsoc2013-empathy-bed1c1b27c5ccb6d35be8ef2b2bb6b4fa8f24f24.zip
roster-view: sort top contacts alphabetically
We just want them to be on top but they should be sorted alphabetically together, not by popularity. This makes the 'top' contacts more stable. https://bugzilla.gnome.org/show_bug.cgi?id=678091
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-roster-view.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c
index 97125c750..a035c897e 100644
--- a/libempathy-gtk/empathy-roster-view.c
+++ b/libempathy-gtk/empathy-roster-view.c
@@ -512,33 +512,21 @@ compare_roster_contacts_by_alias (EmpathyRosterContact *a,
return g_ascii_strcasecmp (alias_a, alias_b);
}
-static gint
-compare_individual_top_position (EmpathyRosterView *self,
- EmpathyRosterContact *a,
- EmpathyRosterContact *b)
+static gboolean
+contact_in_top (EmpathyRosterView *self,
+ EmpathyRosterContact *contact)
{
- FolksIndividual *ind_a, *ind_b;
+ FolksIndividual *individual;
GList *tops;
- gint index_a, index_b;
- ind_a = empathy_roster_contact_get_individual (a);
- ind_b = empathy_roster_contact_get_individual (b);
+ individual = empathy_roster_contact_get_individual (contact);
tops = empathy_individual_manager_get_top_individuals (self->priv->manager);
- index_a = g_list_index (tops, ind_a);
- index_b = g_list_index (tops, ind_b);
+ if (g_list_index (tops, individual) != -1)
+ return TRUE;
- if (index_a == index_b)
- return 0;
-
- if (index_a == -1)
- return 1;
-
- if (index_b == -1)
- return -1;
-
- return index_a - index_b;
+ return FALSE;
}
static gint
@@ -546,13 +534,19 @@ compare_roster_contacts_no_group (EmpathyRosterView *self,
EmpathyRosterContact *a,
EmpathyRosterContact *b)
{
- gint top;
+ gboolean top_a, top_b;
- top = compare_individual_top_position (self, a, b);
- if (top != 0)
- return top;
+ top_a = contact_in_top (self, a);
+ top_b = contact_in_top (self, b);
- return compare_roster_contacts_by_alias (a, b);
+ if (top_a == top_b)
+ /* Both contacts are in the top of the roster (or not). Sort them
+ * alphabetically */
+ return compare_roster_contacts_by_alias (a, b);
+ else if (top_a)
+ return -1;
+ else
+ return 1;
}
static gint