aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-08-30 16:10:38 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-09-04 16:08:53 +0800
commit6d5797f1c816826e4d1e398f7cc0503db1e993fb (patch)
tree5a5891945bee2e255cffb4619c134ff88e147928
parent53c73e017555fc7bd64359d794817502ef774f87 (diff)
downloadgsoc2013-empathy-6d5797f1c816826e4d1e398f7cc0503db1e993fb.tar
gsoc2013-empathy-6d5797f1c816826e4d1e398f7cc0503db1e993fb.tar.gz
gsoc2013-empathy-6d5797f1c816826e4d1e398f7cc0503db1e993fb.tar.bz2
gsoc2013-empathy-6d5797f1c816826e4d1e398f7cc0503db1e993fb.tar.lz
gsoc2013-empathy-6d5797f1c816826e4d1e398f7cc0503db1e993fb.tar.xz
gsoc2013-empathy-6d5797f1c816826e4d1e398f7cc0503db1e993fb.tar.zst
gsoc2013-empathy-6d5797f1c816826e4d1e398f7cc0503db1e993fb.zip
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
-rw-r--r--libempathy-gtk/empathy-roster-view.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c
index 557728527..bd62aadf6 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);