changeset 5701:730bfc7c5e2d

[gaim-migrate @ 6122] Deleting accounts works. Ladies and gentlemen, we have a functioning account dialog once again. Unless I missed something. I probably did. Oh well, it works mostly at least! :) committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 03 Jun 2003 09:34:17 +0000
parents ad55a15c7b93
children 05858c215226
files src/gtkaccount.c
diffstat 1 files changed, 45 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkaccount.c	Tue Jun 03 09:24:46 2003 +0000
+++ b/src/gtkaccount.c	Tue Jun 03 09:34:17 2003 +0000
@@ -1236,9 +1236,52 @@
 }
 
 static void
-__delete_account_cb(GtkWidget *w, AccountsDialog *dialog)
+__delete_account_cb(GaimAccount *account)
+{
+	size_t index;
+	GtkTreeIter iter;
+
+	index = g_list_index(gaim_accounts_get_all(), account);
+
+	if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(accounts_dialog->model),
+									  &iter, NULL, index)) {
+
+		gtk_list_store_remove(accounts_dialog->model, &iter);
+	}
+
+	gaim_account_destroy(account);
+}
+
+static void
+__ask_delete_account_sel(GtkTreeModel *model, GtkTreePath *path,
+						 GtkTreeIter *iter, gpointer data)
 {
+	GaimAccount *account;
 
+	gtk_tree_model_get(model, iter, COLUMN_DATA, &account, -1);
+
+	if (account != NULL) {
+		char buf[8192];
+
+		g_snprintf(buf, sizeof(buf),
+				   _("Are you sure you want to delete %s?"),
+				   gaim_account_get_username(account));
+
+		gaim_request_action(NULL, NULL, buf, NULL, 1, account, 2,
+							_("Delete"), __delete_account_cb,
+							_("Cancel"), NULL);
+	}
+}
+
+static void
+__ask_delete_account_cb(GtkWidget *w, AccountsDialog *dialog)
+{
+	GtkTreeSelection *selection;
+
+	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
+
+	gtk_tree_selection_selected_foreach(selection, __ask_delete_account_sel,
+										dialog);
 }
 
 static void
@@ -1513,7 +1556,7 @@
 	gtk_widget_show(button);
 
 	g_signal_connect(G_OBJECT(button), "clicked",
-					 G_CALLBACK(__delete_account_cb), dialog);
+					 G_CALLBACK(__ask_delete_account_cb), dialog);
 
 	/* Close button */
 	button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);