[empathy] contact-list-store: remove 'fake group' code



commit 9357aef4b6cc3ee6c18f987dd439b11a7a21f20a
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Fri Oct 14 15:30:01 2011 -0400

    contact-list-store: remove 'fake group' code
    
    This store is only used for MUC members which doesn't use these fake groups.
    Actually we could drop all the group code but it would probably be easier to
    completely rewrite the way we display MUC members.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=661489

 libempathy-gtk/empathy-contact-list-store.c |   75 +--------------------------
 libempathy-gtk/empathy-contact-list-store.h |    4 --
 libempathy-gtk/empathy-contact-list-view.c  |   50 ------------------
 po/POTFILES.in                              |    1 -
 4 files changed, 1 insertions(+), 129 deletions(-)
---
diff --git a/libempathy-gtk/empathy-contact-list-store.c b/libempathy-gtk/empathy-contact-list-store.c
index 80fc572..6350a04 100644
--- a/libempathy-gtk/empathy-contact-list-store.c
+++ b/libempathy-gtk/empathy-contact-list-store.c
@@ -1071,15 +1071,6 @@ contact_list_store_add_contact (EmpathyContactListStore *store,
 
 		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,
-				&iter_group, NULL, NULL, TRUE);
-		} else {
-			contact_list_store_get_group (store,
-				EMPATHY_CONTACT_LIST_STORE_UNGROUPED,
-				&iter_group, NULL, NULL, TRUE);
 		}
 
 		add_contact_to_store (GTK_TREE_STORE (store), &iter, parent,
@@ -1099,17 +1090,6 @@ contact_list_store_add_contact (EmpathyContactListStore *store,
 	}
 	g_list_free (groups);
 
-	if (priv->show_groups &&
-	    empathy_contact_list_is_favourite (priv->list, contact)) {
-	/* Add contact to the fake 'Favorites' group */
-		GtkTreeIter iter_group;
-
-		contact_list_store_get_group (store, EMPATHY_CONTACT_LIST_STORE_FAVORITE,
-			&iter_group, NULL, NULL, TRUE);
-
-		add_contact_to_store (GTK_TREE_STORE (store), &iter, &iter_group, contact, flags);
-	}
-
 	contact_list_store_contact_update (store, contact);
 }
 
@@ -1487,20 +1467,6 @@ contact_list_store_get_group (EmpathyContactListStore *store,
 }
 
 static gint
-get_position (const char **strv,
-	      const char *str)
-{
-	int i;
-
-	for (i = 0; strv[i] != NULL; i++) {
-		if (!tp_strdiff (strv[i], str))
-			return i;
-	}
-
-	return -1;
-}
-
-static gint
 compare_separator_and_groups (gboolean is_separator_a,
 			      gboolean is_separator_b,
 			      const gchar *name_a,
@@ -1510,18 +1476,6 @@ compare_separator_and_groups (gboolean is_separator_a,
 			      gboolean fake_group_a,
 			      gboolean fake_group_b)
 {
-	/* these two lists are the sorted list of fake groups to include at the
-	 * top and bottom of the roster */
-	const char *top_groups[] = {
-		EMPATHY_CONTACT_LIST_STORE_FAVORITE,
-		NULL
-	};
-
-	const char *bottom_groups[] = {
-		EMPATHY_CONTACT_LIST_STORE_UNGROUPED,
-		NULL
-	};
-
 	if (is_separator_a || is_separator_b) {
 		/* We have at least one separator */
 		if (is_separator_a) {
@@ -1537,34 +1491,7 @@ compare_separator_and_groups (gboolean is_separator_a,
 	} else if (contact_a && !contact_b) {
 		return -1;
 	} else if (!contact_a && !contact_b) {
-		gboolean a_in_top, b_in_top, a_in_bottom, b_in_bottom;
-
-		a_in_top = fake_group_a &&
-			tp_strv_contains (top_groups, name_a);
-		b_in_top = fake_group_b &&
-			tp_strv_contains (top_groups, name_b);
-		a_in_bottom = fake_group_a &&
-			tp_strv_contains (bottom_groups, name_a);
-		b_in_bottom = fake_group_b &&
-			tp_strv_contains (bottom_groups, name_b);
-
-		if (a_in_top && b_in_top) {
-			/* compare positions */
-			return CLAMP (get_position (top_groups, name_a) -
-				      get_position (top_groups, name_b),
-				      -1, 1);
-		} else if (a_in_bottom && b_in_bottom) {
-			/* compare positions */
-			return CLAMP (get_position (bottom_groups, name_a) -
-				      get_position (bottom_groups, name_b),
-				      -1, 1);
-		} else if (a_in_top || b_in_bottom) {
-			return -1;
-		} else if (b_in_top || a_in_bottom) {
-			return 1;
-		} else {
-			return g_utf8_collate (name_a, name_b);
-		}
+		return g_utf8_collate (name_a, name_b);
 	}
 
 	/* Two contacts, ordering depends of the sorting policy */
diff --git a/libempathy-gtk/empathy-contact-list-store.h b/libempathy-gtk/empathy-contact-list-store.h
index 1760a00..8e773e6 100644
--- a/libempathy-gtk/empathy-contact-list-store.h
+++ b/libempathy-gtk/empathy-contact-list-store.h
@@ -68,10 +68,6 @@ typedef enum {
 	EMPATHY_CONTACT_LIST_STORE_COL_COUNT,
 } EmpathyContactListStoreCol;
 
-#define EMPATHY_CONTACT_LIST_STORE_UNGROUPED _("Ungrouped")
-#define EMPATHY_CONTACT_LIST_STORE_FAVORITE  _("Favorite People")
-#define EMPATHY_CONTACT_LIST_STORE_PEOPLE_NEARBY _("People Nearby")
-
 struct _EmpathyContactListStore {
 	GtkTreeStore parent;
 	gpointer priv;
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index f8c055c..1d95baf 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -331,20 +331,6 @@ contact_list_view_drag_got_contact (TpConnection            *connection,
 
 	list = empathy_contact_list_store_get_list_iface (priv->store);
 
-	if (!tp_strdiff (data->new_group, EMPATHY_CONTACT_LIST_STORE_FAVORITE)) {
-		/* Mark contact as favourite */
-		empathy_contact_list_add_to_favourites (list, contact);
-		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);
 	}
@@ -354,27 +340,6 @@ contact_list_view_drag_got_contact (TpConnection            *connection,
 }
 
 static gboolean
-group_can_be_modified (const gchar *name,
-		       gboolean     is_fake_group,
-		       gboolean     adding)
-{
-	/* Real groups can always be modified */
-	if (!is_fake_group)
-		return TRUE;
-
-	/* The favorite fake group can be modified so users can
-	 * add/remove favorites using DnD */
-	if (!tp_strdiff (name, EMPATHY_CONTACT_LIST_STORE_FAVORITE))
-		return TRUE;
-
-	/* We can remove contacts from the 'ungrouped' fake group */
-	if (!adding && !tp_strdiff (name, EMPATHY_CONTACT_LIST_STORE_UNGROUPED))
-		return TRUE;
-
-	return FALSE;
-}
-
-static gboolean
 contact_list_view_contact_drag_received (GtkWidget         *view,
 					 GdkDragContext    *context,
 					 GtkTreeModel      *model,
@@ -401,9 +366,6 @@ contact_list_view_contact_drag_received (GtkWidget         *view,
 	new_group = empathy_contact_list_store_get_parent_group (model,
 								 path, NULL, &new_group_is_fake);
 
-	if (!group_can_be_modified (new_group, new_group_is_fake, TRUE))
-		return FALSE;
-
 	/* Get source group information. */
 	if (priv->drag_row) {
 		source_path = gtk_tree_row_reference_get_path (priv->drag_row);
@@ -414,9 +376,6 @@ contact_list_view_contact_drag_received (GtkWidget         *view,
 		}
 	}
 
-	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);
@@ -1036,15 +995,6 @@ contact_list_view_group_icon_cell_data_func (GtkTreeViewColumn     *tree_column,
 	if (!is_group)
 		goto out;
 
-	if (!tp_strdiff (name, EMPATHY_CONTACT_LIST_STORE_FAVORITE)) {
-		pixbuf = empathy_pixbuf_from_icon_name ("emblem-favorite",
-			GTK_ICON_SIZE_MENU);
-	}
-	else if (!tp_strdiff (name, EMPATHY_CONTACT_LIST_STORE_PEOPLE_NEARBY)) {
-		pixbuf = empathy_pixbuf_from_icon_name ("im-local-xmpp",
-			GTK_ICON_SIZE_MENU);
-	}
-
 out:
 	g_object_set (cell,
 		      "visible", pixbuf != NULL,
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 668d5f1..c17c179 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -36,7 +36,6 @@ libempathy-gtk/empathy-contact-blocking-dialog.c
 libempathy-gtk/empathy-chat-text-view.c
 libempathy-gtk/empathy-contact-dialogs.c
 [type: gettext/glade]libempathy-gtk/empathy-contact-dialogs.ui
-libempathy-gtk/empathy-contact-list-store.h
 libempathy-gtk/empathy-contact-list-view.c
 libempathy-gtk/empathy-contact-menu.c
 libempathy-gtk/empathy-contact-search-dialog.c



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]