]> git.0d.be Git - empathy.git/commitdiff
Allow to unmark contacts as favorite using DnD
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 10 Mar 2010 13:19:58 +0000 (14:19 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 15 Mar 2010 08:28:43 +0000 (09:28 +0100)
libempathy-gtk/empathy-contact-list-view.c

index b7e73f21e0c7bbe3d9fed6fb5221f50adbe82298..58d4569fc04e89cf242a656b8fa69e204ce4c3d0 100644 (file)
@@ -245,6 +245,14 @@ contact_list_view_drag_got_contact (EmpathyTpContactFactory *factory,
                return;
        }
 
+       if (!tp_strdiff (data->old_group, EMPATHY_CONTACT_LIST_STORE_FAVORITE)) {
+               /* Remove contact as favourite */
+               empathy_contact_list_remove_from_favourites (list, contact);
+               /* Don't try to remove it */
+               g_free (data->old_group);
+               data->old_group = NULL;
+       }
+
        if (data->new_group) {
                empathy_contact_list_add_to_group (list, contact, data->new_group);
        }
@@ -294,7 +302,7 @@ contact_list_view_contact_drag_received (GtkWidget         *view,
        gchar         *new_group = NULL;
        gchar         *old_group = NULL;
        gboolean       success = TRUE;
-       gboolean       new_group_is_fake;
+       gboolean       new_group_is_fake, old_group_is_fake = TRUE;
 
        priv = GET_PRIV (view);
 
@@ -310,11 +318,14 @@ contact_list_view_contact_drag_received (GtkWidget         *view,
                source_path = gtk_tree_row_reference_get_path (priv->drag_row);
                if (source_path) {
                        old_group = empathy_contact_list_store_get_parent_group (
-                                                                                model, source_path, NULL, NULL);
+                                                                                model, source_path, NULL, &old_group_is_fake);
                        gtk_tree_path_free (source_path);
                }
        }
 
+       if (!group_can_be_modified (old_group, old_group_is_fake, FALSE))
+               return FALSE;
+
        if (!tp_strdiff (old_group, new_group)) {
                g_free (new_group);
                g_free (old_group);