changeset 1729:251c19bf5763

[gaim-migrate @ 1739] nsanch's rename patch. slightly modified. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 20 Apr 2001 07:39:09 +0000
parents 467a3b36623a
children 2d7601acacdd
files ChangeLog src/buddy.c src/dialogs.c src/gaim.h
diffstat 4 files changed, 397 insertions(+), 149 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Apr 19 03:55:12 2001 +0000
+++ b/ChangeLog	Fri Apr 20 07:39:09 2001 +0000
@@ -5,6 +5,8 @@
 	  messages
 	* Zephyr updates and additions, thanks Neil Sanchala (nsanch)
 	* Jabber can send/accept chat invites (due to mid)
+	* Can rename groups/buddies in the Edit Buddies pane
+	  (thanks Neil Sanchala)
 
 version 0.11.0-pre10 (04/13/2001):
 	* Many, many bug fixes
--- a/src/buddy.c	Thu Apr 19 03:55:12 2001 +0000
+++ b/src/buddy.c	Fri Apr 20 07:39:09 2001 +0000
@@ -93,6 +93,19 @@
 /* Predefine some functions */
 static void new_bp_callback(GtkWidget *w, char *name);
 
+struct buddy_show {
+	GtkWidget *item;
+	GtkWidget *pix;
+	GtkWidget *label;
+	GtkWidget *warn;
+	GtkWidget *idle;
+	char *name;
+	char *show;
+	GSList *connlist;
+	guint log_timer;
+	gint sound;
+};
+
 /* stuff for actual display of buddy list */
 struct group_show {
 	GtkWidget *item;
@@ -111,8 +124,167 @@
 static struct buddy_show *new_buddy_show(struct group_show *gs, struct buddy *buddy, char **xpm);
 static void remove_buddy_show(struct group_show *gs, struct buddy_show *bs);
 static struct group_show *find_gs_by_bs(struct buddy_show *b);
+static void update_num_group(struct group_show *gs);
 static void redo_buddy_list();
 
+void handle_group_rename(struct group *g, char* prevname) {
+	struct group_show *gs, *new_gs;
+	struct buddy_show *bs;
+	struct buddy *b;
+	GSList *m;
+	GtkCTreeNode *c;
+
+	c = gtk_ctree_find_by_row_data(GTK_CTREE(edittree), NULL, g);
+	gtk_ctree_node_set_text(GTK_CTREE(edittree), c, 0, g->name);
+
+	gs = find_group_show(prevname);
+	if (!gs) {
+		return;
+	}
+	new_gs = find_group_show(g->name);
+	if (new_gs) {
+		/* transfer everything that was in gs and is in the same gaim_conn as g
+		 * over to new_gs. */
+		m = gs->members;
+		while (m) {
+			bs = (struct buddy_show *)m->data;
+			if (g_slist_index(bs->connlist, g->gc) >= 0) {
+				b = find_buddy(g->gc, bs->name);
+				m = g_slist_next(m);
+				bs->connlist = g_slist_remove(bs->connlist, g->gc);
+				if (!bs->connlist) {
+					gs->members = g_slist_remove(gs->members, bs);
+					if (bs->log_timer > 0)
+						gtk_timeout_remove(bs->log_timer);
+					bs->log_timer = 0;
+					remove_buddy_show(gs, bs);
+					g_free(bs->show);
+					g_free(bs->name);
+					g_free(bs);
+				}
+				if ((bs = find_buddy_show(new_gs, b->name)) == NULL) {
+					if (*g->gc->prpl->list_icon) {
+						bs = new_buddy_show(new_gs, b,
+								(*g->gc->prpl->list_icon)(b->uc));
+					} else {
+						bs = new_buddy_show(new_gs, b, (char **)no_icon_xpm);
+					}
+				}
+				bs->connlist = g_slist_append(bs->connlist, g->gc);
+			} else {
+				m = g_slist_next(m);
+			}
+		}
+		if (!gs->members) {
+			/* we just transferred all of the members out of this group_show,
+			 * so this group_show serves no purpose now. */
+			shows = g_slist_remove(shows, gs);
+			gtk_tree_remove_item(GTK_TREE(buddies), gs->item);
+			g_free(gs->name);
+			g_free(gs);
+		} else {
+			update_num_group(gs);
+		}
+	} else {
+		/* two possible actions: if gs contains things that are only from g,
+		 * just rename gs and fix the label. otherwise, move everything in g
+		 * over to another group_show */
+		for (m = gs->members; m != NULL; m = g_slist_next(m)) {
+			bs = (struct buddy_show *)m->data;
+			if (g_slist_index(bs->connlist, g->gc) < 0 ||
+							g_slist_length(bs->connlist) > 1) {
+				break;
+			}
+		}
+		if (m) {
+			/* there's something from a different gaim_connection. */
+			new_gs = new_group_show(g->name);
+			m = gs->members;
+			while (m) {
+				bs = (struct buddy_show *)m->data;
+				if (g_slist_index(bs->connlist, g->gc) >= 0) {
+					b = find_buddy(g->gc, bs->name);
+					m = g_slist_next(m);
+					bs->connlist = g_slist_remove(bs->connlist, g->gc);
+					if (!bs->connlist) {
+						gs->members = g_slist_remove(gs->members, bs);
+						if (bs->log_timer > 0)
+							gtk_timeout_remove(bs->log_timer);
+						bs->log_timer = 0;
+						remove_buddy_show(gs, bs);
+						g_free(bs->show);
+						g_free(bs->name);
+						g_free(bs);
+					}
+					if (*g->gc->prpl->list_icon) {
+						bs = new_buddy_show(new_gs, b,
+								(*g->gc->prpl->list_icon)(b->uc));
+					} else {
+						bs = new_buddy_show(new_gs, b, (char **)no_icon_xpm);
+					}
+					bs->connlist = g_slist_append(NULL, g->gc);
+				} else {
+					m = g_slist_next(m);
+				}
+			}
+			update_num_group(gs);
+			update_num_group(new_gs);
+		} else {
+			g_free(gs->name);
+			gs->name = g_strdup(g->name);
+			update_num_group(gs);
+		}
+	}
+}
+
+void handle_buddy_rename(struct buddy *b, char *prevname) {
+	struct buddy_show *bs;
+	struct group_show *gs;
+	struct group *g;
+	GtkCTreeNode *c;
+	char buf[256];
+
+	c = gtk_ctree_find_by_row_data(GTK_CTREE(edittree), NULL, b);
+	if (strcmp(b->show, b->name))
+		g_snprintf(buf, sizeof(buf), "%s (%s)", b->name, b->show);
+	else
+		g_snprintf(buf, sizeof(buf), "%s", b->name);
+	gtk_ctree_node_set_text(GTK_CTREE(edittree), c, 0, buf);
+
+	gs = find_group_show(prevname);
+
+	g = find_group_by_buddy(b->gc, b->name);
+	if (!g) {
+		/* shouldn't happen */
+		return;
+	}
+	gs = find_group_show(g->name);
+	if (!gs) {
+		return;
+	}
+	bs = find_buddy_show(gs, prevname);
+	if (!bs) {
+		/* buddy's offline */
+		return;
+	}
+	
+	if (strcmp(b->name, prevname)) {
+		bs->connlist = g_slist_remove(bs->connlist, b->gc);
+		if (!bs->connlist) {
+			gs->members = g_slist_remove(gs->members, bs);
+			if (bs->log_timer > 0)
+				gtk_timeout_remove(bs->log_timer);
+			bs->log_timer = 0;
+			remove_buddy_show(gs, bs);
+			g_free(bs->show);
+			g_free(bs->name);
+			g_free(bs);
+		}
+	} else {
+		gtk_label_set_text(GTK_LABEL(bs->label), b->show);
+	}
+}
+
 void destroy_buddy()
 {
 	if (blist)
@@ -365,14 +537,14 @@
 		BuddyTickerSignoff();
 }
 
-void handle_click_group(GtkWidget *widget, GdkEventButton *event, gpointer func_data)
+void handle_click_group(GtkWidget *widget, GdkEventButton *event, struct group *g)
 {
 	if (event->type == GDK_2BUTTON_PRESS) {
 		if (GTK_TREE_ITEM(widget)->expanded)
 			gtk_tree_item_collapse(GTK_TREE_ITEM(widget));
 		else
 			gtk_tree_item_expand(GTK_TREE_ITEM(widget));
-	} else {
+	} else if ((event->type == GDK_BUTTON_PRESS) && (event->button == 3)) {
 	}
 }
 
@@ -419,9 +591,9 @@
 	}
 }
 
-void pressed_alias_bs(GtkWidget *widget, struct buddy_show *b)
+void pressed_alias_bs(GtkWidget *widget, struct buddy_show *bs)
 {
-	alias_dialog_bs(b);
+	alias_dialog_bud(find_buddy(bs->connlist->data, bs->name));
 }
 
 void pressed_alias_bud(GtkWidget *widget, struct buddy *b)
@@ -556,18 +728,17 @@
 	node = gtk_ctree_node_nth(GTK_CTREE(edittree), row);
 	type = gtk_ctree_node_get_row_data(GTK_CTREE(edittree), node);
 	if (*type == EDIT_GROUP) {
-		/*struct group *group = (struct group *)type;
+		struct group *group = (struct group *)type;
 		menu = gtk_menu_new();
 
 		button = gtk_menu_item_new_with_label(_("Rename"));
 		gtk_signal_connect(GTK_OBJECT(button), "activate",
-				   GTK_SIGNAL_FUNC(rename_group), node);
+				   GTK_SIGNAL_FUNC(show_rename_group), group);
 		gtk_menu_append(GTK_MENU(menu), button);
 		gtk_widget_show(button);
 
 		gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
 			       event->button, event->time);
-		*/
 	} else if (*type == EDIT_BUDDY) {
 		struct buddy *b = (struct buddy *)type;
 		menu = gtk_menu_new();
@@ -585,6 +756,12 @@
 			gtk_menu_append(GTK_MENU(menu), button);
 			gtk_widget_show(button);
 		}
+		
+		button = gtk_menu_item_new_with_label(_("Rename"));
+		gtk_signal_connect(GTK_OBJECT(button), "activate",
+				   GTK_SIGNAL_FUNC(show_rename_buddy), b);
+		gtk_menu_append(GTK_MENU(menu), button);
+		gtk_widget_show(button);
 
 		button = gtk_menu_item_new_with_label(_("Add Buddy Pounce"));
 		gtk_signal_connect(GTK_OBJECT(button), "activate",
@@ -1745,7 +1922,7 @@
 	g->item = gtk_tree_item_new();
 	gtk_tree_insert(GTK_TREE(buddies), g->item, pos);
 	gtk_signal_connect(GTK_OBJECT(g->item), "button_press_event",
-			   GTK_SIGNAL_FUNC(handle_click_group), NULL);
+			   GTK_SIGNAL_FUNC(handle_click_group), g);
 	gtk_widget_show(g->item);
 
 	g->label = gtk_label_new(group);
@@ -1787,7 +1964,7 @@
 	gtk_container_add(GTK_CONTAINER(b->item), box);
 	gtk_widget_show(box);
 
-	pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, NULL, xpm);
+	pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, NULL, xpm ? xpm : no_icon_xpm);
 	b->pix = gtk_pixmap_new(pm, bm);
 	gtk_box_pack_start(GTK_BOX(box), b->pix, FALSE, FALSE, 1);
 	gtk_widget_show(b->pix);
--- a/src/dialogs.c	Thu Apr 19 03:55:12 2001 +0000
+++ b/src/dialogs.c	Fri Apr 20 07:39:09 2001 +0000
@@ -90,6 +90,8 @@
 static GtkWidget *aliasdlg = NULL;
 static GtkWidget *aliasentry = NULL;
 static GtkWidget *aliasname = NULL;
+static GtkWidget *rename_dialog = NULL;
+static GtkWidget *rename_bud_dialog = NULL;
 
 struct create_away {
         GtkWidget *window;
@@ -284,6 +286,12 @@
 		aliasname = NULL;
 	}
 
+	if (dest == rename_dialog)
+		rename_dialog = NULL;
+	
+	if (dest == rename_bud_dialog)
+		rename_bud_dialog = NULL;
+
         dialogwindows = g_list_remove(dialogwindows, dest);
         gtk_widget_destroy(dest);
 
@@ -552,38 +560,38 @@
 
 static void do_im(GtkWidget *widget, GtkWidget *imentry)
 {
-        char *who;
-        struct conversation *c;
+	char *who;
+	struct conversation *c;
 	
-        who = g_strdup(gtk_entry_get_text(GTK_ENTRY(imentry)));
+	who = g_strdup(gtk_entry_get_text(GTK_ENTRY(imentry)));
 	destroy_dialog(NULL, imdialog);
-        imdialog = NULL;
+	imdialog = NULL;
         
-        if (!strcasecmp(who, "")) {
-                g_free(who);
+	if (!strcasecmp(who, "")) {
+		g_free(who);
 		return;
 	}
 
-        c = find_conversation(who);
-
-        if (c == NULL) {
-                c = new_conversation(who);
-        } else {
-                gdk_window_raise(c->window->window);
+	c = find_conversation(who);
+
+	if (c == NULL) {
+		c = new_conversation(who);
+	} else {
+		gdk_window_raise(c->window->window);
 	}
-        g_free(who);
+	g_free(who);
 }
 
 static void do_info(GtkWidget *widget, GtkWidget *infoentry)
 {
 	char *who;
 	
-        who = g_strdup(normalize(gtk_entry_get_text(GTK_ENTRY(infoentry))));
+	who = g_strdup(normalize(gtk_entry_get_text(GTK_ENTRY(infoentry))));
 	destroy_dialog(NULL, infodialog);
-        infodialog = NULL;
+	infodialog = NULL;
         
-        if (!strcasecmp(who, "")) {
-                g_free(who);
+	if (!strcasecmp(who, "")) {
+		g_free(who);
 		return;
 	}
 	
@@ -602,8 +610,8 @@
 	GtkWidget *eedialog;
 
 	eedialog = gtk_window_new(GTK_WINDOW_DIALOG);
-        ok = gtk_button_new_with_label(_("OK"));
-        box = gtk_vbox_new(FALSE, 10);
+	ok = gtk_button_new_with_label(_("OK"));
+	box = gtk_vbox_new(FALSE, 10);
 
 
 	if (display_options & OPT_DISP_COOL_LOOK)
@@ -632,7 +640,7 @@
 	gtk_signal_connect(GTK_OBJECT(ok), "clicked",
 			   GTK_SIGNAL_FUNC(destroy_dialog), eedialog);
 	gtk_widget_realize(eedialog);
-        aol_icon(eedialog->window);
+	aol_icon(eedialog->window);
 
 	gtk_widget_show(eedialog);
 }
@@ -3382,115 +3390,13 @@
 	return;
 }
 
-static void do_alias_bs(GtkWidget *w, struct buddy_show *b)
+static void do_alias_bud(GtkWidget *w, struct buddy *b)
 {
-	GSList *c = b->connlist;
-	struct gaim_connection *g;
-	struct buddy *n;
-	g_free(b->show);
-	b->show = g_strdup(gtk_entry_get_text(GTK_ENTRY(aliasname)));
-	gtk_label_set(GTK_LABEL(b->label), b->show);
-	while (c) {
-		g = (struct gaim_connection *)c->data;
-		n = find_buddy(g, b->name);
-		if (n) g_snprintf(n->show, sizeof(n->show), "%s", b->show);
-		c = c->next;
-	}
+	char *al = gtk_entry_get_text(GTK_ENTRY(aliasname));
+	g_snprintf(b->show, sizeof(b->show), "%s", (al && strlen(al)) ? al : b->name);
+	handle_buddy_rename(b, b->name);
 	do_export(0, 0);
 	destroy_dialog(aliasdlg, aliasdlg);
-	build_edit_tree();
-}
-
-void alias_dialog_bs(struct buddy_show *b)
-{
-	GtkWidget *frame;
-	GtkWidget *vbox;
-	GtkWidget *bbox;
-	GtkWidget *cancel;
-	static GtkWidget *add = NULL;
-	GtkWidget *label;
-        GtkWidget *topbox;
-	static int a, c;
-
-	if (aliasdlg)
-		gtk_widget_destroy(aliasdlg);
-
-        aliasdlg = gtk_window_new(GTK_WINDOW_DIALOG);
-	gtk_window_set_policy(GTK_WINDOW(aliasdlg), FALSE, FALSE, TRUE);
-	gtk_window_set_wmclass(GTK_WINDOW(aliasdlg), "alias_dialog", "Gaim");
-	gtk_widget_realize(aliasdlg);
-	dialogwindows = g_list_prepend(dialogwindows, aliasdlg);
-
-	bbox = gtk_hbox_new(TRUE, 10);
-        topbox = gtk_hbox_new(FALSE, 5);
-        vbox = gtk_vbox_new(FALSE, 5);
-
-        aliasentry = gtk_entry_new();
-	aliasname = gtk_entry_new();
-        /* Put the buttons in the box */
-
-	add = picture_button(aliasdlg, _("Alias"), add_xpm);
-
-	cancel = picture_button(aliasdlg, _("Cancel"), cancel_xpm);
-
-        gtk_box_pack_start(GTK_BOX(bbox), add, FALSE, FALSE, 5);
-        gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 5);
-
-	frame = gtk_frame_new(NULL);
-	gtk_frame_set_label(GTK_FRAME(frame), _("Alias Buddy"));
-
-        label = gtk_label_new(_("Buddy"));
-        gtk_widget_show(label);
-        gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5);
-        gtk_box_pack_start(GTK_BOX(topbox), aliasentry, FALSE, FALSE, 5);
-	gtk_entry_set_editable(GTK_ENTRY(aliasentry), FALSE);
-	label = gtk_label_new(_("Alias"));
-	gtk_widget_show(label);
-        gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5);
-        gtk_box_pack_start(GTK_BOX(topbox), aliasname, FALSE, FALSE, 5);
-
-	gtk_entry_set_text(GTK_ENTRY(aliasentry), b->name);
-	gtk_entry_set_text(GTK_ENTRY(aliasname), b->show);
-
-        /* And the boxes in the box */
-        gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5);
-        gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 5);
-
-        /* Handle closes right */
-        gtk_signal_connect(GTK_OBJECT(aliasdlg), "destroy",
-                           GTK_SIGNAL_FUNC(destroy_dialog), aliasdlg);
-        gtk_signal_connect(GTK_OBJECT(cancel), "clicked",
-                           GTK_SIGNAL_FUNC(destroy_dialog), aliasdlg);
-        a = gtk_signal_connect(GTK_OBJECT(add), "clicked",
-                           GTK_SIGNAL_FUNC(do_alias_bs), b);
-	c = gtk_signal_connect(GTK_OBJECT(aliasname), "activate",
-			   GTK_SIGNAL_FUNC(do_alias_bs), b);
-        /* Finish up */
-        gtk_widget_show(add);
-        gtk_widget_show(cancel);
-        gtk_widget_show(aliasentry);
-        gtk_widget_show(aliasname);
-        gtk_widget_show(topbox);
-        gtk_widget_show(bbox);
-        gtk_widget_show(vbox);
-	gtk_widget_show(frame);
-        gtk_window_set_title(GTK_WINDOW(aliasdlg), _("Gaim - Alias Buddy"));
-        gtk_window_set_focus(GTK_WINDOW(aliasdlg), aliasentry);
-	gtk_container_add(GTK_CONTAINER(frame), vbox);
-        gtk_container_add(GTK_CONTAINER(aliasdlg), frame);
-	gtk_container_set_border_width(GTK_CONTAINER(aliasdlg), 5);
-        gtk_widget_realize(aliasdlg);
-        aol_icon(aliasdlg->window);
-
-	gtk_widget_show(aliasdlg);
-}
-
-static void do_alias_bud(GtkWidget *w, struct buddy *b)
-{
-	g_snprintf(b->show, sizeof(b->show), "%s", gtk_entry_get_text(GTK_ENTRY(aliasname)));
-	do_export(0, 0);
-	destroy_dialog(aliasdlg, aliasdlg);
-	build_edit_tree();
 }
 
 void alias_dialog_bud(struct buddy *b)
@@ -3867,3 +3773,176 @@
 
 	return;
 }
+
+/*------------------------------------------------------------------------*/
+/*  The dialog for renaming groups                                        */
+/*------------------------------------------------------------------------*/
+
+static void do_rename_group(GtkObject *obj, GtkWidget *entry)
+{
+	char *new_name;
+	struct group *g;
+
+	new_name = gtk_entry_get_text(GTK_ENTRY(entry));
+	g = gtk_object_get_user_data(obj);
+
+	if (new_name && (strlen(new_name) != 0) && strcmp(new_name, g->name)) {
+		char *prevname = g_strdup(g->name);
+		g_snprintf(g->name, sizeof(g->name), "%s", new_name);
+		handle_group_rename(g, prevname);
+		g_free(prevname);
+		do_export(0, 0);
+	}
+
+	destroy_dialog(rename_dialog, rename_dialog);
+}
+
+void show_rename_group(GtkWidget *unused, struct group *g)
+{
+	GtkWidget *mainbox;
+	GtkWidget *frame;
+	GtkWidget *fbox;
+	GtkWidget *bbox;
+	GtkWidget *button;
+	GtkWidget *name_entry;
+	GtkWidget *label;
+
+	if (!rename_dialog) {
+		rename_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
+		gtk_window_set_wmclass(GTK_WINDOW(rename_dialog), "rename_dialog",
+				       "Gaim");
+		gtk_window_set_policy(GTK_WINDOW(rename_dialog), FALSE, TRUE, TRUE);
+		gtk_window_set_title(GTK_WINDOW(rename_dialog),
+						_("Gaim - Rename Group"));
+		gtk_signal_connect(GTK_OBJECT(rename_dialog), "destroy",
+				   GTK_SIGNAL_FUNC(destroy_dialog), rename_dialog);
+		gtk_widget_realize(rename_dialog);
+		aol_icon(rename_dialog->window);
+
+		mainbox = gtk_vbox_new(FALSE, 5);
+		gtk_container_set_border_width(GTK_CONTAINER(mainbox), 5);
+		gtk_container_add(GTK_CONTAINER(rename_dialog), mainbox);
+
+		frame = gtk_frame_new(_("Rename Group"));
+		gtk_box_pack_start(GTK_BOX(mainbox), frame, TRUE, TRUE, 0);
+
+		fbox = gtk_hbox_new(FALSE, 5);
+		gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
+		gtk_container_add(GTK_CONTAINER(frame), fbox);
+
+		label = gtk_label_new(_("New name:"));
+		gtk_box_pack_start(GTK_BOX(fbox), label, FALSE, FALSE, 0);
+
+		name_entry = gtk_entry_new();
+		gtk_box_pack_start(GTK_BOX(fbox), name_entry, TRUE, TRUE, 0);
+		gtk_object_set_user_data(GTK_OBJECT(name_entry), g);
+		gtk_entry_set_text(GTK_ENTRY(name_entry), g->name);
+		gtk_signal_connect(GTK_OBJECT(name_entry), "activate",
+				   GTK_SIGNAL_FUNC(do_rename_group), name_entry);
+		gtk_widget_grab_focus(name_entry);
+
+		bbox = gtk_hbox_new(FALSE, 5);
+		gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0);
+
+		button = picture_button(rename_dialog, _("Cancel"), cancel_xpm);
+		gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
+		gtk_signal_connect(GTK_OBJECT(button), "clicked",
+				   GTK_SIGNAL_FUNC(destroy_dialog), rename_dialog);
+
+		button = picture_button(rename_dialog, _("OK"), ok_xpm);
+		gtk_object_set_user_data(GTK_OBJECT(button), g);
+		gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
+		gtk_signal_connect(GTK_OBJECT(button), "clicked",
+				   GTK_SIGNAL_FUNC(do_rename_group), name_entry);
+	}
+
+	gtk_widget_show_all(rename_dialog);
+}
+
+/*------------------------------------------------------------------------*/
+/*  The dialog for renaming buddies                                       */
+/*------------------------------------------------------------------------*/
+
+static void do_rename_buddy(GtkObject *obj, GtkWidget *entry)
+{
+	char *new_name;
+	struct buddy *b;
+
+	new_name = gtk_entry_get_text(GTK_ENTRY(entry));
+	b = gtk_object_get_user_data(obj);
+
+	if (new_name && (strlen(new_name) != 0) && strcmp(new_name, b->name)) {
+		char *prevname = g_strdup(b->name);
+		serv_remove_buddy(b->gc, b->name);
+		if (!strcmp(b->name, b->show))
+			g_snprintf(b->show, sizeof(b->show), "%s", new_name);
+		g_snprintf(b->name, sizeof(b->name), "%s", new_name);
+		serv_add_buddy(b->gc, b->name);
+		handle_buddy_rename(b, prevname);
+		g_free(prevname);
+	}
+
+	destroy_dialog(rename_bud_dialog, rename_bud_dialog);
+}
+
+void show_rename_buddy(GtkWidget *unused, struct buddy *b)
+{
+	GtkWidget *mainbox;
+	GtkWidget *frame;
+	GtkWidget *fbox;
+	GtkWidget *bbox;
+	GtkWidget *button;
+	GtkWidget *name_entry;
+	GtkWidget *label;
+
+	if (!rename_bud_dialog) {
+		rename_bud_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
+		gtk_window_set_wmclass(GTK_WINDOW(rename_bud_dialog), "rename_bud_dialog",
+				       "Gaim");
+		gtk_window_set_policy(GTK_WINDOW(rename_bud_dialog), FALSE, TRUE, TRUE);
+		gtk_window_set_title(GTK_WINDOW(rename_bud_dialog),
+						_("Gaim - Rename Buddy"));
+		gtk_signal_connect(GTK_OBJECT(rename_bud_dialog), "destroy",
+				   GTK_SIGNAL_FUNC(destroy_dialog), rename_bud_dialog);
+		gtk_widget_realize(rename_bud_dialog);
+		aol_icon(rename_bud_dialog->window);
+
+		mainbox = gtk_vbox_new(FALSE, 5);
+		gtk_container_set_border_width(GTK_CONTAINER(mainbox), 5);
+		gtk_container_add(GTK_CONTAINER(rename_bud_dialog), mainbox);
+
+		frame = gtk_frame_new(_("Rename Buddy"));
+		gtk_box_pack_start(GTK_BOX(mainbox), frame, TRUE, TRUE, 0);
+
+		fbox = gtk_hbox_new(FALSE, 5);
+		gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
+		gtk_container_add(GTK_CONTAINER(frame), fbox);
+
+		label = gtk_label_new(_("New name:"));
+		gtk_box_pack_start(GTK_BOX(fbox), label, FALSE, FALSE, 0);
+
+		name_entry = gtk_entry_new();
+		gtk_box_pack_start(GTK_BOX(fbox), name_entry, TRUE, TRUE, 0);
+		gtk_object_set_user_data(GTK_OBJECT(name_entry), b);
+		gtk_entry_set_text(GTK_ENTRY(name_entry), b->name);
+		gtk_signal_connect(GTK_OBJECT(name_entry), "activate",
+				   GTK_SIGNAL_FUNC(do_rename_buddy), name_entry);
+		gtk_widget_grab_focus(name_entry);
+
+		bbox = gtk_hbox_new(FALSE, 5);
+		gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0);
+
+		button = picture_button(rename_bud_dialog, _("Cancel"), cancel_xpm);
+		gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
+		gtk_signal_connect(GTK_OBJECT(button), "clicked",
+				   GTK_SIGNAL_FUNC(destroy_dialog), rename_bud_dialog);
+
+		button = picture_button(rename_bud_dialog, _("OK"), ok_xpm);
+		gtk_object_set_user_data(GTK_OBJECT(button), b);
+		gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
+		gtk_signal_connect(GTK_OBJECT(button), "clicked",
+				   GTK_SIGNAL_FUNC(do_rename_buddy), name_entry);
+	}
+
+	gtk_widget_show_all(rename_bud_dialog);
+}
--- a/src/gaim.h	Thu Apr 19 03:55:12 2001 +0000
+++ b/src/gaim.h	Fri Apr 20 07:39:09 2001 +0000
@@ -241,19 +241,6 @@
 	struct gaim_connection *gc; /* the connection it belongs to */
 };
 
-struct buddy_show {
-	GtkWidget *item;
-	GtkWidget *pix;
-	GtkWidget *label;
-	GtkWidget *warn;
-	GtkWidget *idle;
-	char *name;
-	char *show;
-	GSList *connlist;
-	guint log_timer;
-	gint sound;
-};
-
 struct log_conversation {
 	char name[80];
 	char filename[512];
@@ -686,6 +673,8 @@
 extern void parse_toc_buddy_list(struct gaim_connection *, char *, int);
 
 /* Functions in buddy.c */
+extern void handle_group_rename(struct group *, char *);
+extern void handle_buddy_rename(struct buddy *, char *);
 extern void destroy_buddy();
 extern void update_button_pix();
 extern void toggle_show_empty_groups();
@@ -783,7 +772,6 @@
 gint sort_awaymsg_list(gconstpointer, gconstpointer);
 
 /* Functions in dialogs.c */
-extern void alias_dialog_bs(struct buddy_show *);
 extern void alias_dialog_bud(struct buddy *);
 extern void do_export(GtkWidget *, void *);
 extern void show_warn_dialog(struct gaim_connection *, char *);
@@ -825,6 +813,8 @@
 extern void cancel_font(GtkWidget *widget, struct conversation *c);
 extern void apply_font(GtkWidget *widget, GtkFontSelection *fontsel);
 extern void set_color_selection(GtkWidget *selection, GdkColor color);
+extern void show_rename_group(GtkWidget *, struct group *);
+extern void show_rename_buddy(GtkWidget *, struct buddy *);
 
 /* Functions in browser.c */
 extern void open_url(GtkWidget *, char *);