]> git.0d.be Git - empathy.git/commitdiff
contact-list-store: don't put contacts in 'Ungrouped' when show-groups = False
authorDanielle Madeley <danielle.madeley@collabora.co.uk>
Thu, 1 Apr 2010 00:54:18 +0000 (11:54 +1100)
committerDanielle Madeley <danielle.madeley@collabora.co.uk>
Thu, 1 Apr 2010 00:54:18 +0000 (11:54 +1100)
Further, set show-groups = False for the contact list in EmpathyChat

libempathy-gtk/empathy-chat.c
libempathy-gtk/empathy-contact-list-store.c

index 36b4136ee40154d667c9c80c54c455b97c82fb79..90272007a2b6e4c586b15215ef95b589d2e98f9a 100644 (file)
@@ -2090,7 +2090,11 @@ chat_update_contacts_visibility (EmpathyChat *chat,
                                                priv->contacts_width);
                }
 
-               store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (priv->tp_chat));
+               store = empathy_contact_list_store_new (
+                               EMPATHY_CONTACT_LIST (priv->tp_chat));
+               empathy_contact_list_store_set_show_groups (
+                               EMPATHY_CONTACT_LIST_STORE (store), FALSE);
+
                priv->contact_list_view = GTK_WIDGET (empathy_contact_list_view_new (store,
                        EMPATHY_CONTACT_LIST_FEATURE_CONTACT_TOOLTIP,
                        EMPATHY_CONTACT_FEATURE_CHAT |
index dbcb9c81b85dc0756147d6a697a165c838790b07..16169347beb822707f0e0a08c9ac3e3f0bf23f54 100644 (file)
@@ -604,7 +604,6 @@ empathy_contact_list_store_set_show_groups (EmpathyContactListStore *store,
                                            gboolean                 show_groups)
 {
        EmpathyContactListStorePriv *priv;
-       GList                       *contacts, *l;
 
        g_return_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store));
 
@@ -616,19 +615,28 @@ empathy_contact_list_store_set_show_groups (EmpathyContactListStore *store,
 
        priv->show_groups = show_groups;
 
-       /* Remove all contacts and add them back, not optimized but that's the
-        * easy way :) */
-       gtk_tree_store_clear (GTK_TREE_STORE (store));
-       contacts = empathy_contact_list_get_members (priv->list);
-       for (l = contacts; l; l = l->next) {
-               contact_list_store_members_changed_cb (priv->list, l->data,
-                                                      NULL, 0, NULL,
-                                                      TRUE,
-                                                      store);
-
-               g_object_unref (l->data);
+       if (priv->setup_idle_id == 0) {
+               /* Remove all contacts and add them back, not optimized but
+                * that's the easy way :)
+                *
+                * This is only done if there's not a pending setup idle
+                * callback, otherwise it will race and the contacts will get
+                * added twice */
+               GList *contacts, *l;
+
+               gtk_tree_store_clear (GTK_TREE_STORE (store));
+               contacts = empathy_contact_list_get_members (priv->list);
+               for (l = contacts; l; l = l->next) {
+                       contact_list_store_members_changed_cb (priv->list,
+                                                              l->data,
+                                                              NULL, 0, NULL,
+                                                              TRUE,
+                                                              store);
+
+                       g_object_unref (l->data);
+               }
+               g_list_free (contacts);
        }
-       g_list_free (contacts);
 
        g_object_notify (G_OBJECT (store), "show-groups");
 }
@@ -1060,9 +1068,13 @@ contact_list_store_add_contact (EmpathyContactListStore *store,
        tp_connection_parse_object_path (connection, &protocol_name, NULL);
 
        if (!groups) {
-               GtkTreeIter iter_group;
+               GtkTreeIter iter_group, *parent;
 
-               if (!tp_strdiff (protocol_name, "local-xmpp")) {
+               parent = &iter_group;
+
+               if (!priv->show_groups) {
+                       parent = NULL;
+               } else if (!tp_strdiff (protocol_name, "local-xmpp")) {
                        /* these are People Nearby */
                        contact_list_store_get_group (store,
                                EMPATHY_CONTACT_LIST_STORE_PEOPLE_NEARBY,
@@ -1074,9 +1086,10 @@ contact_list_store_add_contact (EmpathyContactListStore *store,
                }
 
                gtk_tree_store_insert_after (GTK_TREE_STORE (store), &iter,
-                                            &iter_group, NULL);
+                                            parent, NULL);
 
-               add_contact_to_store (GTK_TREE_STORE (store), &iter, contact, flags);
+               add_contact_to_store (GTK_TREE_STORE (store), &iter,
+                                     contact, flags);
        }
 
        g_free (protocol_name);
@@ -1096,7 +1109,8 @@ contact_list_store_add_contact (EmpathyContactListStore *store,
        g_list_free (groups);
 
 #ifdef HAVE_FAVOURITE_CONTACTS
-       if (empathy_contact_list_is_favourite (priv->list, contact)) {
+       if (priv->show_groups &&
+           empathy_contact_list_is_favourite (priv->list, contact)) {
        /* Add contact to the fake 'Favorites' group */
                GtkTreeIter iter_group;