changeset 6058:d5f4ae4f9a02

[gaim-migrate @ 6508] This should fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=196664 I also removed the dialog for rename buddy. The UI doesn't use it anymore. We think renaming a buddy is silly. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 08 Jul 2003 02:33:17 +0000
parents dc2124210882
children d8cd876e613e
files src/blist.c src/blist.h src/dialogs.c src/server.c src/ui.h
diffstat 5 files changed, 31 insertions(+), 105 deletions(-) [+]
line wrap: on
line diff
--- a/src/blist.c	Tue Jul 08 02:08:55 2003 +0000
+++ b/src/blist.c	Tue Jul 08 02:33:17 2003 +0000
@@ -274,6 +274,27 @@
 		gaim_conversation_autoset_title(conv);
 }
 
+void  gaim_blist_server_alias_buddy (struct buddy *buddy, const char *alias)
+{
+	struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
+	GaimConversation *conv;
+
+	g_free(buddy->server_alias);
+
+	if(alias && strlen(alias) && g_utf8_validate(alias, -1, NULL))
+		buddy->server_alias = g_strdup(alias);
+	else
+		buddy->server_alias = NULL;
+
+	if (ops)
+		ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
+
+	conv = gaim_find_conversation_with_account(buddy->name, buddy->account);
+
+	if (conv)
+		gaim_conversation_autoset_title(conv);
+}
+
 void gaim_blist_rename_group(struct group *group, const char *name)
 {
 	struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
--- a/src/blist.h	Tue Jul 08 02:08:55 2003 +0000
+++ b/src/blist.h	Tue Jul 08 02:33:17 2003 +0000
@@ -265,6 +265,14 @@
 void gaim_blist_alias_buddy(struct buddy *buddy, const char *alias);
 
 /**
+ * Sets the server-sent aliase of a buddy in the buddy list.
+ *
+ * @param buddy  The buddy whose alias will be changed.
+ * @param alias  The buddy's "official" alias.
+ */
+void gaim_blist_server_alias_buddy(struct buddy *buddy, const char *alias);
+
+/**
  * Aliases a chat in the buddy list.
  *
  * @param chat  The chat whose alias will be changed.
--- a/src/dialogs.c	Tue Jul 08 02:08:55 2003 +0000
+++ b/src/dialogs.c	Tue Jul 08 02:33:17 2003 +0000
@@ -49,7 +49,6 @@
 static GtkWidget *icondlg;
 static GtkWidget *alias_dialog = NULL;
 static GtkWidget *rename_dialog = NULL;
-static GtkWidget *rename_bud_dialog = NULL;
 static GtkWidget *fontseld = NULL;
 
 
@@ -289,8 +288,6 @@
 		icondlg = NULL;
 	else if (dest == rename_dialog)
 		rename_dialog = NULL;
-	else if (dest == rename_bud_dialog)
-		rename_bud_dialog = NULL;
 
 	dialogwindows = g_list_remove(dialogwindows, dest);
 	gtk_widget_destroy(dest);
@@ -4330,98 +4327,6 @@
 }
 
 
-/*------------------------------------------------------------------------*/
-/*  The dialog for renaming buddies                                       */
-/*------------------------------------------------------------------------*/
-
-static void do_rename_buddy(GObject *obj, GtkWidget *entry)
-{
-	const char *new_name;
-	struct buddy *b;
-
-	new_name = gtk_entry_get_text(GTK_ENTRY(entry));
-	b = g_object_get_data(obj, "buddy");
-
-	if (!g_list_find(gaim_connections_get_all(), b->account->gc)) {
-		destroy_dialog(rename_bud_dialog, rename_bud_dialog);
-		return;
-	}
-
-	if (new_name && (strlen(new_name) != 0) && strcmp(new_name, b->name)) {
-		struct group *g = gaim_find_buddys_group(b);
-		char *prevname = b->name;
-		if (g)
-			serv_remove_buddy(b->account->gc, b->name, g->name);
-		b->name = g_strdup(new_name);
-		serv_add_buddy(b->account->gc, b->name);
-		gaim_blist_rename_buddy(b, prevname);
-		gaim_blist_save();
-		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) {
-		GAIM_DIALOG(rename_bud_dialog);
-		gtk_window_set_role(GTK_WINDOW(rename_bud_dialog), "rename_bud_dialog");
-		gtk_window_set_resizable(GTK_WINDOW(rename_bud_dialog), TRUE);
-		gtk_window_set_title(GTK_WINDOW(rename_bud_dialog), _("Rename Buddy"));
-		g_signal_connect(G_OBJECT(rename_bud_dialog), "destroy",
-				   G_CALLBACK(destroy_dialog), rename_bud_dialog);
-		gtk_widget_realize(rename_bud_dialog);
-
-		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);
-		g_object_set_data(G_OBJECT(name_entry), "buddy", b);
-		gtk_entry_set_text(GTK_ENTRY(name_entry), b->name);
-		g_signal_connect(G_OBJECT(name_entry), "activate",
-				   G_CALLBACK(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 = gaim_pixbuf_button_from_stock(_("OK"), GTK_STOCK_OK, GAIM_BUTTON_HORIZONTAL);
-		g_object_set_data(G_OBJECT(button), "buddy", b);
-		gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
-		g_signal_connect(G_OBJECT(button), "clicked",
-				   G_CALLBACK(do_rename_buddy), name_entry);
-
-		button = gaim_pixbuf_button_from_stock(_("Cancel"), GTK_STOCK_CANCEL, GAIM_BUTTON_HORIZONTAL);
-		gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
-		g_signal_connect(G_OBJECT(button), "clicked",
-				   G_CALLBACK(destroy_dialog), rename_bud_dialog);
-	}
-
-	gtk_widget_show_all(rename_bud_dialog);
-}
-
-
 GtkWidget *gaim_pixbuf_toolbar_button_from_stock(char *icon)
 {
 	GtkWidget *button, *image,  *bbox;
--- a/src/server.c	Tue Jul 08 02:08:55 2003 +0000
+++ b/src/server.c	Tue Jul 08 02:33:17 2003 +0000
@@ -453,18 +453,11 @@
 
 void serv_got_alias(GaimConnection *gc, const char *who, const char *alias) {
 	struct buddy *b = gaim_find_buddy(gc->account, who);
+
 	if(!b)
 		return;
 
-	if (b->server_alias)
-		g_free(b->server_alias);
-
-	if (alias && g_utf8_validate(alias, -1, NULL))
-		b->server_alias = g_strdup(alias);
-	else
-		b->server_alias = NULL;
-
-	gaim_blist_update_buddy_status(b, b->uc);
+	gaim_blist_server_alias_buddy(b, alias);
 }
 
 /*
--- a/src/ui.h	Tue Jul 08 02:08:55 2003 +0000
+++ b/src/ui.h	Tue Jul 08 02:33:17 2003 +0000
@@ -224,7 +224,6 @@
 extern void cancel_font(GtkWidget *widget, GaimConversation *c);
 extern void apply_font(GtkWidget *widget, GtkFontSelection *fontsel);
 extern void show_rename_group(GtkWidget *, struct group *);
-extern void show_rename_buddy(GtkWidget *, struct buddy *);
 extern GtkWidget *gaim_pixbuf_button(char *, char *, GaimButtonOrientation);
 extern GtkWidget *gaim_pixbuf_button_from_stock(const char *, const char *, GaimButtonOrientation);
 extern GtkWidget *gaim_pixbuf_toolbar_button_from_stock(char *);