From 5ff0b2f71b6516b399deb732bfe0124e32a8a7bf Mon Sep 17 00:00:00 2001 From: Laurent Contzen Date: Tue, 7 Aug 2012 11:01:13 +0200 Subject: Added top_group_members list in model, view relying on it empathy-roster-model: no longer emits top-individuals and favourites-changed signals empathy-roster-model-manager: new top_group_members GList with filling function. _contact_in_top uses top_group_members. top_group_members is modified when top-individuals and favourites-changed signals are caught. empathy-roster-view: no longer catches top-individuals or favourites-changed signals from the model --- libempathy-gtk/empathy-roster-view.c | 142 +---------------------------------- 1 file changed, 4 insertions(+), 138 deletions(-) (limited to 'libempathy-gtk/empathy-roster-view.c') diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c index e9b44af37..de14b5d97 100644 --- a/libempathy-gtk/empathy-roster-view.c +++ b/libempathy-gtk/empathy-roster-view.c @@ -304,16 +304,6 @@ individual_added (EmpathyRosterView *self, else { GList *groups, *l; - GList *tops; - - tops = empathy_roster_model_get_top_individuals (self->priv->model); - - if (folks_favourite_details_get_is_favourite ( - FOLKS_FAVOURITE_DETAILS (individual)) || - g_list_index (tops, individual) != -1) - { - add_to_group (self, individual, EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP); - } groups = empathy_roster_model_get_groups_for_individual (self->priv->model, individual); @@ -833,27 +823,6 @@ filter_list (GtkWidget *child, g_return_val_if_reached (FALSE); } -/* @list: GList of EmpathyRosterContact - * - * Returns: %TRUE if @list contains an EmpathyRosterContact associated with - * @individual */ -static gboolean -individual_in_list (FolksIndividual *individual, - GList *list) -{ - GList *l; - - for (l = list; l != NULL; l = g_list_next (l)) - { - EmpathyRosterContact *contact = l->data; - - if (empathy_roster_contact_get_individual (contact) == individual) - return TRUE; - } - - return FALSE; -} - static void populate_view (EmpathyRosterView *self) { @@ -905,69 +874,6 @@ remove_from_group (EmpathyRosterView *self, gtk_container_remove (GTK_CONTAINER (self), contact); } -static void -update_top_contacts (EmpathyRosterView *self) -{ - GList *tops, *l; - GList *to_add = NULL, *to_remove = NULL; - EmpathyRosterGroup *group; - - if (!self->priv->show_groups) - { - egg_list_box_resort (EGG_LIST_BOX (self)); - return; - } - - tops = empathy_roster_model_get_top_individuals (self->priv->model); - - group = g_hash_table_lookup (self->priv->roster_groups, - EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP); - if (group == NULL) - { - to_add = g_list_copy (tops); - } - else - { - GList *contacts; - - contacts = empathy_roster_group_get_widgets (group); - - /* Check which EmpathyRosterContact have to be removed */ - for (l = contacts; l != NULL; l = g_list_next (l)) - { - EmpathyRosterContact *contact = l->data; - FolksIndividual *individual; - - if (empathy_roster_model_contact_in_top (self->priv->model, - contact)) - continue; - - individual = empathy_roster_contact_get_individual (contact); - - if (g_list_find (tops, individual) == NULL) - to_remove = g_list_prepend (to_remove, individual); - } - - /* Check which EmpathyRosterContact have to be added */ - for (l = tops; l != NULL; l = g_list_next (l)) - { - FolksIndividual *individual = l->data; - - if (!individual_in_list (individual, contacts)) - to_add = g_list_prepend (to_add, individual); - } - } - - for (l = to_add; l != NULL; l = g_list_next (l)) - add_to_group (self, l->data, EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP); - - for (l = to_remove; l != NULL; l = g_list_next (l)) - remove_from_group (self, l->data, EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP); - - g_list_free (to_add); - g_list_free (to_remove); -} - static void groups_changed_cb (EmpathyRosterModel *model, FolksIndividual *individual, @@ -976,7 +882,10 @@ groups_changed_cb (EmpathyRosterModel *model, EmpathyRosterView *self) { if (!self->priv->show_groups) - return; + { + egg_list_box_resort (EGG_LIST_BOX (self)); + return; + } if (is_member) { @@ -988,45 +897,6 @@ groups_changed_cb (EmpathyRosterModel *model, } } -static void -top_individuals_changed_cb (EmpathyRosterModel *model, - EmpathyRosterView *self) -{ - update_top_contacts (self); -} - -static void -favourites_changed_cb (EmpathyRosterModel *model, - FolksIndividual *individual, - gboolean favourite, - EmpathyRosterView *self) -{ - GHashTable *contacts; - - contacts = g_hash_table_lookup (self->priv->roster_contacts, individual); - if (contacts == NULL) - return; - - if (self->priv->show_groups) - { - if (favourite) - add_to_group (self, individual, EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP); - else - remove_from_group (self, individual, - EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP); - } - else - { - GtkWidget *contact; - - contact = g_hash_table_lookup (contacts, NO_GROUP); - if (contact == NULL) - return; - - egg_list_box_child_changed (EGG_LIST_BOX (self), contact); - } -} - static void empathy_roster_view_constructed (GObject *object) { @@ -1047,10 +917,6 @@ empathy_roster_view_constructed (GObject *object) G_CALLBACK (individual_removed_cb), self, 0); tp_g_signal_connect_object (self->priv->model, "groups-changed", G_CALLBACK (groups_changed_cb), self, 0); - tp_g_signal_connect_object (self->priv->model, "top-individuals-changed", - G_CALLBACK (top_individuals_changed_cb), self, 0); - tp_g_signal_connect_object (self->priv->model, "favourites-changed", - G_CALLBACK (favourites_changed_cb), self, 0); egg_list_box_set_sort_func (EGG_LIST_BOX (self), roster_view_sort, self, NULL); -- cgit v1.2.3