[empathy] Don't allow moving contacts to fake groups using DnD



commit 8ae91c9509dde4dea0bc735dd24c7e3a690b4c9a
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Wed Mar 10 10:21:32 2010 +0100

    Don't allow moving contacts to fake groups using DnD
    
    Fake groups can't be modified.

 libempathy-gtk/empathy-contact-list-store.c |    8 +++++++-
 libempathy-gtk/empathy-contact-list-store.h |    3 ++-
 libempathy-gtk/empathy-contact-list-view.c  |    9 +++++++--
 3 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/libempathy-gtk/empathy-contact-list-store.c b/libempathy-gtk/empathy-contact-list-store.c
index 3ebeacb..9feb446 100644
--- a/libempathy-gtk/empathy-contact-list-store.c
+++ b/libempathy-gtk/empathy-contact-list-store.c
@@ -728,11 +728,13 @@ empathy_contact_list_store_row_separator_func (GtkTreeModel *model,
 gchar *
 empathy_contact_list_store_get_parent_group (GtkTreeModel *model,
 					    GtkTreePath  *path,
-					    gboolean     *path_is_group)
+					    gboolean     *path_is_group,
+					    gboolean     *is_fake_group)
 {
 	GtkTreeIter  parent_iter, iter;
 	gchar       *name = NULL;
 	gboolean     is_group;
+	gboolean     fake;
 
 	g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL);
 
@@ -762,6 +764,7 @@ empathy_contact_list_store_get_parent_group (GtkTreeModel *model,
 		gtk_tree_model_get (model, &iter,
 				    EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
 				    EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name,
+				    EMPATHY_CONTACT_LIST_STORE_COL_IS_FAKE_GROUP, &fake,
 				    -1);
 		if (!is_group) {
 			g_free (name);
@@ -773,6 +776,9 @@ empathy_contact_list_store_get_parent_group (GtkTreeModel *model,
 		*path_is_group = TRUE;
 	}
 
+	if (is_fake_group != NULL)
+		*is_fake_group = fake;
+
 	return name;
 }
 
diff --git a/libempathy-gtk/empathy-contact-list-store.h b/libempathy-gtk/empathy-contact-list-store.h
index db8f40c..1b36ea6 100644
--- a/libempathy-gtk/empathy-contact-list-store.h
+++ b/libempathy-gtk/empathy-contact-list-store.h
@@ -105,7 +105,8 @@ gboolean                   empathy_contact_list_store_row_separator_func (GtkTre
 									 gpointer                    data);
 gchar *                    empathy_contact_list_store_get_parent_group   (GtkTreeModel               *model,
 									 GtkTreePath                *path,
-									 gboolean                   *path_is_group);
+									 gboolean                   *path_is_group,
+									 gboolean                   *is_fake_group);
 gboolean                   empathy_contact_list_store_search_equal_func  (GtkTreeModel               *model,
 									 gint                        column,
 									 const gchar                *key,
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index 2a3fb77..e563895 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -266,19 +266,24 @@ contact_list_view_contact_drag_received (GtkWidget         *view,
 	gchar         *new_group = NULL;
 	gchar         *old_group = NULL;
 	gboolean       success = TRUE;
+	gboolean       is_fake_group;
 
 	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);
+								 path, NULL, &is_fake_group);
+
+	if (is_fake_group)
+		/* Fake groups can't be modified */
+		return FALSE;
 
 	/* Get source group information. */
 	if (priv->drag_row) {
 		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);
+										 model, source_path, NULL, NULL);
 			gtk_tree_path_free (source_path);
 		}
 	}



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