changeset 2743:9f71beb77c60

[gaim-migrate @ 2756] I didnt test this but it should work committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Sun, 18 Nov 2001 04:19:49 +0000
parents 6f527cbd899d
children 62df9fbd201a
files src/conversation.c src/dialogs.c src/gaim.h src/prefs.c
diffstat 4 files changed, 121 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/conversation.c	Sun Nov 18 00:21:49 2001 +0000
+++ b/src/conversation.c	Sun Nov 18 04:19:49 2001 +0000
@@ -540,13 +540,10 @@
 {
 	struct buddy *b = find_buddy(c->gc, c->name);
 	if (b) {
-		struct group *g = find_group_by_buddy(c->gc, c->name);
-		debug_printf(_("Removing '%s' from buddylist.\n"), c->name);
-		serv_remove_buddy(c->gc, c->name, g->name);
-		remove_buddy(c->gc, g, b);
-		do_export(c->gc);
-		build_edit_tree();
-		update_convo_add_button(c);
+		if (im_options & OPT_IM_DONT_CONFIRM_DEL)
+			show_confirm_del(c->gc, c->name);
+		else
+			do_remove_buddy(NULL, b);
 	} else if (c->gc)
 		show_add_buddy(c->gc, c->name, NULL, NULL);
 
--- a/src/dialogs.c	Sun Nov 18 00:21:49 2001 +0000
+++ b/src/dialogs.c	Sun Nov 18 04:19:49 2001 +0000
@@ -96,6 +96,16 @@
 static GtkWidget *rename_dialog = NULL;
 static GtkWidget *rename_bud_dialog = NULL;
 
+struct confirm_del {
+	GtkWidget *window;
+	GtkWidget *label;
+	GtkWidget *ok;
+	GtkWidget *cancel;
+	GtkWidget *checkbox;	
+	char name[1024];
+	struct gaim_connection *gc;
+};
+
 struct create_away {
 	GtkWidget *window;
 	GtkWidget *entry;
@@ -103,7 +113,6 @@
 	struct away_message *mess;
 };
 
-
 struct warning {
 	GtkWidget *window;
 	GtkWidget *anon;
@@ -413,17 +422,116 @@
 	gtk_box_pack_start(GTK_BOX(fbox), bbox, FALSE, FALSE, 5);
 	gtk_widget_show(bbox);
 
-	warn = picture_button(w->window, _("Warn"), warn_xpm);
-	gtk_box_pack_start(GTK_BOX(bbox), warn, FALSE, FALSE, 5);
-	gtk_signal_connect(GTK_OBJECT(warn), "clicked", GTK_SIGNAL_FUNC(do_warn), w);
-
 	cancel = picture_button(w->window, _("Cancel"), cancel_xpm);
 	gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 5);
 	gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), w->window);
 
+	warn = picture_button(w->window, _("Warn"), warn_xpm);
+	gtk_box_pack_end(GTK_BOX(bbox), warn, FALSE, FALSE, 5);
+	gtk_signal_connect(GTK_OBJECT(warn), "clicked", GTK_SIGNAL_FUNC(do_warn), w);
+
 	gtk_widget_show(w->window);
 }
 
+void do_remove_buddy(GtkWidget *w, struct buddy *b)
+{
+	struct group *g = find_group_by_buddy(b->gc, b->name);
+	struct gaim_connection *gc = b->gc;
+	struct conversation *cv;
+
+	if (!b)
+		return;
+
+	debug_printf(_("Removing '%s' from buddylist.\n"), b->name);
+	serv_remove_buddy(b->gc, b->name, g->name);
+	remove_buddy(gc, g, b);
+	do_export(gc);
+	build_edit_tree();
+
+	cv = find_conversation(b->name);
+
+	if (cv)
+		update_convo_add_button(cv);
+
+}
+
+void toggle_confirm_del_cb(GtkWidget *w, int opt)
+{
+	im_options = im_options ^ opt;
+}
+
+void show_confirm_del(struct gaim_connection *gc, gchar *name)
+{
+	struct confirm_del *b = g_new0(struct confirm_del, 1);
+	struct buddy *bd;
+	GtkWidget *hbox;
+	GtkWidget *vbox;
+	GtkWidget *fbox;
+	GtkWidget *frame;
+	gchar tmp[2048];
+
+	GAIM_DIALOG(b->window);
+	dialogwindows = g_list_prepend(dialogwindows, b->window);
+
+	g_snprintf(tmp, sizeof(tmp), _("Gaim - Remove %s?"), name);
+	gtk_window_set_title(GTK_WINDOW(b->window), tmp);
+	gtk_window_set_wmclass(GTK_WINDOW(b->window), "confirm_del", "Gaim");
+	gtk_window_set_policy(GTK_WINDOW(b->window), FALSE, FALSE, TRUE);
+	gtk_signal_connect(GTK_OBJECT(b->window), "delete_event",
+			   GTK_SIGNAL_FUNC(destroy_dialog), b->window);
+
+	gtk_widget_realize(b->window);
+
+	vbox = gtk_vbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(b->window), vbox);
+	gtk_widget_show(vbox);
+
+	frame = gtk_frame_new(_("Remove Buddy"));
+	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
+	gtk_container_set_border_width(GTK_CONTAINER(frame), 5);
+	gtk_widget_show(frame);	
+
+	fbox = gtk_vbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(frame), fbox);
+	gtk_container_set_border_width(GTK_CONTAINER(fbox), 5);
+	gtk_widget_show(fbox);
+
+	g_snprintf(tmp, sizeof(tmp), _("You are about to remove '%s' from\nyour buddylist. Do you want to continue?"), name);
+	b->label = gtk_label_new(tmp);
+	gtk_misc_set_alignment(GTK_MISC(b->label), 0, 0.5);
+	gtk_label_set_justify(GTK_LABEL(b->label), GTK_JUSTIFY_LEFT);
+	gtk_box_pack_start(GTK_BOX(fbox), b->label, FALSE, FALSE, 0);
+	gtk_widget_show(b->label);
+
+	b->checkbox = gtk_check_button_new_with_label(_("Do not ask me this question again"));
+	gtk_signal_connect(GTK_OBJECT(b->checkbox), "clicked",
+			   GTK_SIGNAL_FUNC(toggle_confirm_del_cb), (int *)OPT_IM_DONT_CONFIRM_DEL);
+	gtk_box_pack_start(GTK_BOX(fbox), b->checkbox, FALSE, FALSE, 0);
+	gtk_widget_show(b->checkbox);
+
+	hbox = gtk_hbox_new(FALSE, 5);
+	gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
+	gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, FALSE, 0);
+	gtk_widget_show(hbox);
+
+	b->ok = picture_button(b->window, _("Accept"), ok_xpm);
+	gtk_box_pack_start(GTK_BOX(hbox), b->ok, FALSE, FALSE, 5);
+
+	bd = find_buddy(gc, name);
+
+	if (bd)
+		gtk_signal_connect(GTK_OBJECT(b->ok), "clicked", GTK_SIGNAL_FUNC(do_remove_buddy), bd);
+	
+	gtk_signal_connect(GTK_OBJECT(b->ok), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
+
+	b->cancel = picture_button(b->window, _("Cancel"), cancel_xpm);
+	gtk_box_pack_start(GTK_BOX(hbox), b->cancel, FALSE, FALSE, 5);
+	gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), b->window);
+	
+	gtk_widget_show(b->window);	
+}
+
+
 
 /*------------------------------------------------------------------------*/
 /*  The dialog for getting an error                                       */
@@ -3759,6 +3867,7 @@
 	gtk_widget_show_all(rename_dialog);
 }
 
+
 /*------------------------------------------------------------------------*/
 /*  The dialog for renaming buddies                                       */
 /*------------------------------------------------------------------------*/
--- a/src/gaim.h	Sun Nov 18 00:21:49 2001 +0000
+++ b/src/gaim.h	Sun Nov 18 04:19:49 2001 +0000
@@ -242,6 +242,7 @@
 #define OPT_IM_SIDE_TAB			0x00000020
 #define OPT_IM_BR_TAB			0x00000040
 #define OPT_IM_HIDE_ICONS		0x00000080
+#define OPT_IM_DONT_CONFIRM_DEL		0x00000100
 
 extern guint chat_options;
 #define OPT_CHAT_ONE_WINDOW		0x00000001
@@ -338,6 +339,7 @@
 extern void show_find_email(struct gaim_connection *);
 extern void show_find_info(struct gaim_connection *);
 extern void show_set_info(struct gaim_connection *);
+extern void show_confirm_del(struct gaim_connection *, gchar *);
 
 /* Functions in gaimrc.c */
 extern gint sort_awaymsg_list(gconstpointer, gconstpointer);
--- a/src/prefs.c	Sun Nov 18 00:21:49 2001 +0000
+++ b/src/prefs.c	Sun Nov 18 04:19:49 2001 +0000
@@ -906,6 +906,7 @@
 			vbox2);
 	gaim_button(_("Raise windows on events"), &im_options, OPT_IM_POPUP, vbox2);
 	gaim_button(_("Show logins in window"), &im_options, OPT_IM_LOGON, vbox2);
+	gaim_button(_("Do not confirm removing of buddies"), &im_options, OPT_IM_DONT_CONFIRM_DEL, vbox2);
 
 	frame = gtk_frame_new(_("Window Sizes"));
 	gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 5);