comparison src/gtkaccount.c @ 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
comparison
equal deleted inserted replaced
5700:ad55a15c7b93 5701:730bfc7c5e2d
1234 gtk_tree_selection_selected_foreach(selection, __modify_account_sel, 1234 gtk_tree_selection_selected_foreach(selection, __modify_account_sel,
1235 dialog); 1235 dialog);
1236 } 1236 }
1237 1237
1238 static void 1238 static void
1239 __delete_account_cb(GtkWidget *w, AccountsDialog *dialog) 1239 __delete_account_cb(GaimAccount *account)
1240 { 1240 {
1241 1241 size_t index;
1242 GtkTreeIter iter;
1243
1244 index = g_list_index(gaim_accounts_get_all(), account);
1245
1246 if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(accounts_dialog->model),
1247 &iter, NULL, index)) {
1248
1249 gtk_list_store_remove(accounts_dialog->model, &iter);
1250 }
1251
1252 gaim_account_destroy(account);
1253 }
1254
1255 static void
1256 __ask_delete_account_sel(GtkTreeModel *model, GtkTreePath *path,
1257 GtkTreeIter *iter, gpointer data)
1258 {
1259 GaimAccount *account;
1260
1261 gtk_tree_model_get(model, iter, COLUMN_DATA, &account, -1);
1262
1263 if (account != NULL) {
1264 char buf[8192];
1265
1266 g_snprintf(buf, sizeof(buf),
1267 _("Are you sure you want to delete %s?"),
1268 gaim_account_get_username(account));
1269
1270 gaim_request_action(NULL, NULL, buf, NULL, 1, account, 2,
1271 _("Delete"), __delete_account_cb,
1272 _("Cancel"), NULL);
1273 }
1274 }
1275
1276 static void
1277 __ask_delete_account_cb(GtkWidget *w, AccountsDialog *dialog)
1278 {
1279 GtkTreeSelection *selection;
1280
1281 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
1282
1283 gtk_tree_selection_selected_foreach(selection, __ask_delete_account_sel,
1284 dialog);
1242 } 1285 }
1243 1286
1244 static void 1287 static void
1245 __close_accounts_cb(GtkWidget *w, AccountsDialog *dialog) 1288 __close_accounts_cb(GtkWidget *w, AccountsDialog *dialog)
1246 { 1289 {
1511 button = gtk_button_new_from_stock(GTK_STOCK_DELETE); 1554 button = gtk_button_new_from_stock(GTK_STOCK_DELETE);
1512 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); 1555 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
1513 gtk_widget_show(button); 1556 gtk_widget_show(button);
1514 1557
1515 g_signal_connect(G_OBJECT(button), "clicked", 1558 g_signal_connect(G_OBJECT(button), "clicked",
1516 G_CALLBACK(__delete_account_cb), dialog); 1559 G_CALLBACK(__ask_delete_account_cb), dialog);
1517 1560
1518 /* Close button */ 1561 /* Close button */
1519 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); 1562 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
1520 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); 1563 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
1521 gtk_widget_show(button); 1564 gtk_widget_show(button);