[empathy] factor out group_can_be_modified



commit 71ad0f9d2f6a6c35719fbd4d5315ef1104299e7e
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Wed Mar 10 13:49:42 2010 +0100

    factor out group_can_be_modified

 libempathy-gtk/empathy-contact-list-view.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index 9412079..b11a20e 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -254,6 +254,22 @@ contact_list_view_drag_got_contact (EmpathyTpContactFactory *factory,
 }
 
 static gboolean
+group_can_be_modified (const gchar *name,
+		       gboolean is_fake_group)
+{
+	/* Real groups can always be modified */
+	if (!is_fake_group)
+		return TRUE;
+
+	/* Only 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;
+
+	return FALSE;
+}
+
+static gboolean
 contact_list_view_contact_drag_received (GtkWidget         *view,
 					 GdkDragContext    *context,
 					 GtkTreeModel      *model,
@@ -273,18 +289,15 @@ contact_list_view_contact_drag_received (GtkWidget         *view,
 	gchar         *new_group = NULL;
 	gchar         *old_group = NULL;
 	gboolean       success = TRUE;
-	gboolean       is_fake_group;
+	gboolean       new_group_is_fake;
 
 	priv = GET_PRIV (view);
 
 	sel_data = (const gchar *) gtk_selection_data_get_data (selection);
 	new_group = empathy_contact_list_store_get_parent_group (model,
-								 path, NULL, &is_fake_group);
+								 path, NULL, &new_group_is_fake);
 
-	if (is_fake_group &&
-			tp_strdiff (new_group, EMPATHY_CONTACT_LIST_STORE_FAVORITE))
-		/* Fake groups can't be modified. We allow to drag to the favorite fake
-		 * group tough so user can mark contact as favorite using DnD */
+	if (!group_can_be_modified (new_group, new_group_is_fake))
 		return FALSE;
 
 	/* Get source group information. */



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