+
+ return EMPATHY_ROSTER_GROUP (roster_group);
+}
+
+static void
+update_empty (EmpathyRosterView *self,
+ gboolean empty)
+{
+ if (self->priv->empty == empty)
+ return;
+
+ self->priv->empty = empty;
+ g_object_notify (G_OBJECT (self), "empty");
+}
+
+static gboolean filter_group (EmpathyRosterView *self,
+ EmpathyRosterGroup *group);
+
+static gboolean
+at_least_one_group_displayed (EmpathyRosterView *self)
+{
+ GHashTableIter iter;
+ gpointer v;
+
+ g_hash_table_iter_init (&iter, self->priv->roster_groups);
+ while (g_hash_table_iter_next (&iter, NULL, &v))
+ {
+ EmpathyRosterGroup *group = EMPATHY_ROSTER_GROUP (v);
+
+ if (filter_group (self, group))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+check_if_empty (EmpathyRosterView *self)
+{
+ /* Roster is considered as empty if there is no contact *and* no group
+ * currently displayed. */
+ if (g_hash_table_size (self->priv->displayed_contacts) != 0 ||
+ at_least_one_group_displayed (self))
+ {
+ update_empty (self, FALSE);
+ return;
+ }
+
+ update_empty (self, TRUE);
+}
+
+static void
+update_group_widgets (EmpathyRosterView *self,
+ EmpathyRosterGroup *group,
+ EmpathyRosterContact *contact,
+ gboolean add)
+{
+ guint old_count, count;
+
+ old_count = empathy_roster_group_get_widgets_count (group);
+
+ if (add)
+ count = empathy_roster_group_add_widget (group, GTK_WIDGET (contact));
+ else
+ count = empathy_roster_group_remove_widget (group, GTK_WIDGET (contact));
+
+ if (count != old_count)
+ {
+ gtk_list_box_row_changed (GTK_LIST_BOX_ROW (group));
+
+ check_if_empty (self);
+ }