[empathy] roster-view: don't display offline not favorite top contacts
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] roster-view: don't display offline not favorite top contacts
- Date: Tue, 4 Sep 2012 08:09:05 +0000 (UTC)
commit 6d5797f1c816826e4d1e398f7cc0503db1e993fb
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Thu Aug 30 10:10:38 2012 +0200
roster-view: don't display offline not favorite top contacts
We just want to always display the favorites offline contacts in the top
contact section.
One may say that we are kinda breaking the model group abstraction, which is
probably true. Ideally we may want to have a roster view subclass implementing
the top contact logic but life is too short.
https://bugzilla.gnome.org/show_bug.cgi?id=683022
libempathy-gtk/empathy-roster-view.c | 44 +++++++++++++++++++++++++++++++++-
1 files changed, 43 insertions(+), 1 deletions(-)
---
diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c
index 5577285..bd62aad 100644
--- a/libempathy-gtk/empathy-roster-view.c
+++ b/libempathy-gtk/empathy-roster-view.c
@@ -346,6 +346,32 @@ add_to_group (EmpathyRosterView *self,
}
static void
+individual_favourite_change_cb (FolksIndividual *individual,
+ GParamSpec *spec,
+ EmpathyRosterView *self)
+{
+ /* We may have to refilter the contact as only favorite contacts are always
+ * displayed regardless of their presence. */
+ GHashTable *contacts;
+ GtkWidget *contact;
+
+ contacts = g_hash_table_lookup (self->priv->roster_contacts, individual);
+ if (contacts == NULL)
+ return;
+
+ if (self->priv->show_groups)
+ contact = g_hash_table_lookup (contacts,
+ EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP);
+ else
+ contact = g_hash_table_lookup (contacts, NO_GROUP);
+
+ if (contact == NULL)
+ return;
+
+ egg_list_box_child_changed (EGG_LIST_BOX (self), contact);
+}
+
+static void
individual_added (EmpathyRosterView *self,
FolksIndividual *individual)
{
@@ -385,6 +411,9 @@ individual_added (EmpathyRosterView *self,
g_list_free (groups);
}
+
+ tp_g_signal_connect_object (individual, "notify::is-favourite",
+ G_CALLBACK (individual_favourite_change_cb), self, 0);
}
static void
@@ -793,6 +822,17 @@ remove_from_displayed (EmpathyRosterView *self,
check_if_empty (self);
}
+static gboolean
+contact_is_favorite (EmpathyRosterContact *contact)
+{
+ FolksIndividual *individual;
+
+ individual = empathy_roster_contact_get_individual (contact);
+
+ return folks_favourite_details_get_is_favourite (
+ FOLKS_FAVOURITE_DETAILS (individual));
+}
+
/**
* check if @contact should be displayed according to @self's current status
* and without consideration for the state of @contact's groups.
@@ -815,7 +855,9 @@ contact_should_be_displayed (EmpathyRosterView *self,
if (self->priv->show_offline)
return TRUE;
- if (contact_in_top (self, contact))
+ if (contact_in_top (self, contact) &&
+ contact_is_favorite (contact))
+ /* Favorite top contacts are always displayed */
return TRUE;
return empathy_roster_contact_is_online (contact);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]