changeset 17851:452bd3baa9af

Do not update the blist TreeStore if a node is currently being edited. Then, when the node is finished editing, force a refresh. Fixes #397 in which aliasing gets rudely cut off anytime the buddy list changes
author Sean Egan <seanegan@gmail.com>
date Wed, 13 Jun 2007 02:28:38 +0000
parents 1f060ef64f77
children b0a1782b90d2 f10e6ba2a619
files pidgin/gtkblist.c
diffstat 1 files changed, 31 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkblist.c	Wed Jun 13 02:20:11 2007 +0000
+++ b/pidgin/gtkblist.c	Wed Jun 13 02:28:38 2007 +0000
@@ -108,6 +108,7 @@
 
 static guint visibility_manager_count = 0;
 static gboolean gtk_blist_obscured = FALSE;
+static gboolean editing_blist = FALSE;
 
 static GList *pidgin_blist_sort_methods = NULL;
 static struct pidgin_blist_sort_method *current_sort_method = NULL;
@@ -315,6 +316,12 @@
 	gtk_blist_join_chat(chat);
 }
 
+static void gtk_blist_renderer_editing_cancelled_cb(GtkCellRenderer *renderer, PurpleBuddyList *list)
+{
+	editing_blist = FALSE;
+	pidgin_blist_refresh(list);
+}
+
 static void gtk_blist_renderer_editing_started_cb(GtkCellRenderer *renderer,
 		GtkCellEditable *editable,
 		gchar *path_str,
@@ -351,10 +358,11 @@
 		GtkEntry *entry = GTK_ENTRY (editable);
 		gtk_entry_set_text(entry, text);
 	}
+	editing_blist = TRUE;
 }
 
 static void gtk_blist_renderer_edited_cb(GtkCellRendererText *text_rend, char *arg1,
-					 char *arg2, gpointer nada)
+					 char *arg2, PurpleBuddyList *list)
 {
 	GtkTreeIter iter;
 	GtkTreePath *path;
@@ -362,6 +370,7 @@
 	PurpleBlistNode *node;
 	PurpleGroup *dest;
 
+	editing_blist = FALSE;
 	path = gtk_tree_path_new_from_string (arg1);
 	gtk_tree_model_get_iter (GTK_TREE_MODEL(gtkblist->treemodel), &iter, path);
 	gtk_tree_path_free (path);
@@ -406,6 +415,7 @@
 		default:
 			break;
 	}
+	pidgin_blist_refresh(list);
 }
 
 static void gtk_blist_menu_alias_cb(GtkWidget *w, PurpleBlistNode *node)
@@ -4450,7 +4460,8 @@
 										"markup", NAME_COLUMN,
 										NULL);
 	g_signal_connect(G_OBJECT(rend), "editing-started", G_CALLBACK(gtk_blist_renderer_editing_started_cb), NULL);
-	g_signal_connect(G_OBJECT(rend), "edited", G_CALLBACK(gtk_blist_renderer_edited_cb), NULL);
+	g_signal_connect(G_OBJECT(rend), "editing-canceled", G_CALLBACK(gtk_blist_renderer_editing_cancelled_cb), list);
+	g_signal_connect(G_OBJECT(rend), "edited", G_CALLBACK(gtk_blist_renderer_edited_cb), list);
 	g_object_set(rend, "ypad", 0, "yalign", 0.5, NULL);
 #if GTK_CHECK_VERSION(2,6,0)
 	g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
@@ -4792,9 +4803,10 @@
 
 	gtk_tree_path_free(newpath);
 
-	gtk_tree_store_set(gtkblist->treemodel, iter,
-			NODE_COLUMN, node,
-			-1);
+	if (!editing_blist)
+		gtk_tree_store_set(gtkblist->treemodel, iter,
+				NODE_COLUMN, node,
+				-1);
 
 	if(node->parent) {
 		GtkTreePath *expand = NULL;
@@ -4827,6 +4839,9 @@
 
 	g_return_if_fail(node != NULL);
 
+	if (editing_blist)
+		return;
+	
 	if (PURPLE_BLIST_NODE_IS_GROUP(node))
 		gnode = node;
 	else if (PURPLE_BLIST_NODE_IS_BUDDY(node))
@@ -4878,7 +4893,7 @@
 				   GROUP_EXPANDER_VISIBLE_COLUMN, TRUE,
 				   CONTACT_EXPANDER_VISIBLE_COLUMN, FALSE,
 				   BUDDY_ICON_VISIBLE_COLUMN, FALSE,
-				   IDLE_VISIBLE_COLUMN, FALSE,
+			   	   IDLE_VISIBLE_COLUMN, FALSE,
 				   EMBLEM_VISIBLE_COLUMN, FALSE,
 				   -1);
 		g_free(title);
@@ -4928,6 +4943,9 @@
 	gboolean biglist = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons");
 	presence = purple_buddy_get_presence(buddy);
 
+	if (editing_blist)
+		return;
+	
 	status = pidgin_blist_get_status_icon((PurpleBlistNode*)buddy,
 						PIDGIN_STATUS_ICON_SMALL);
 
@@ -4973,7 +4991,6 @@
 			idle = i2;
 		}
 	}
-
 	gtk_tree_store_set(gtkblist->treemodel, iter,
 			   STATUS_ICON_COLUMN, status,
 			   STATUS_ICON_VISIBLE_COLUMN, TRUE,
@@ -4988,7 +5005,7 @@
 			   CONTACT_EXPANDER_COLUMN, NULL,
 			   CONTACT_EXPANDER_VISIBLE_COLUMN, expanded,
 			   GROUP_EXPANDER_VISIBLE_COLUMN, FALSE,
-			-1);
+   			   -1);
 
 	g_free(mark);
 	g_free(idle);
@@ -5007,6 +5024,9 @@
 	PurpleBuddy *buddy;
 	struct _pidgin_blist_node *gtknode;
 
+	if (editing_blist)
+		return;
+
 	if (PURPLE_BLIST_NODE_IS_BUDDY(node))
 		cnode = node->parent;
 	else
@@ -5103,6 +5123,9 @@
 
 	g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node));
 
+	if (editing_blist)
+		return;
+
 	/* First things first, update the group */
 	pidgin_blist_update_group(list, node->parent);