| 198 |
193 |
| 199 static void |
194 static void |
| 200 do_remove_chat(GaimChat *chat) |
195 do_remove_chat(GaimChat *chat) |
| 201 { |
196 { |
| 202 gaim_blist_remove_chat(chat); |
197 gaim_blist_remove_chat(chat); |
| 203 gaim_blist_save(); |
|
| 204 } |
198 } |
| 205 |
199 |
| 206 static void |
200 static void |
| 207 do_remove_buddy(GaimBuddy *b) |
201 do_remove_buddy(GaimBuddy *buddy) |
| 208 { |
202 { |
| 209 GaimGroup *g; |
203 GaimGroup *group; |
| 210 GaimConversation *c; |
204 GaimConversation *conv; |
| 211 gchar *name; |
205 gchar *name; |
| 212 GaimAccount *account; |
206 GaimAccount *account; |
| 213 |
207 |
| 214 if (!b) |
208 if (!buddy) |
| 215 return; |
209 return; |
| 216 |
210 |
| 217 g = gaim_find_buddys_group(b); |
211 group = gaim_find_buddys_group(buddy); |
| 218 name = g_strdup(b->name); /* b->name is a crasher after remove_buddy */ |
212 name = g_strdup(buddy->name); /* b->name is a crasher after remove_buddy */ |
| 219 account = b->account; |
213 account = buddy->account; |
| 220 |
214 |
| 221 gaim_debug(GAIM_DEBUG_INFO, "blist", |
215 gaim_debug(GAIM_DEBUG_INFO, "blist", |
| 222 "Removing '%s' from buddy list.\n", b->name); |
216 "Removing '%s' from buddy list.\n", buddy->name); |
| 223 serv_remove_buddy(b->account->gc, name, g->name); |
217 /* XXX - Should remove from blist first... then call serv_remove_buddy()? */ |
| 224 gaim_blist_remove_buddy(b); |
218 serv_remove_buddy(buddy->account->gc, buddy, group); |
| 225 gaim_blist_save(); |
219 gaim_blist_remove_buddy(buddy); |
| 226 |
220 |
| 227 c = gaim_find_conversation_with_account(name, account); |
221 conv = gaim_find_conversation_with_account(name, account); |
| 228 |
222 |
| 229 if (c != NULL) |
223 if (conv != NULL) |
| 230 gaim_conversation_update(c, GAIM_CONV_UPDATE_REMOVE); |
224 gaim_conversation_update(conv, GAIM_CONV_UPDATE_REMOVE); |
| 231 |
225 |
| 232 g_free(name); |
226 g_free(name); |
| 233 } |
227 } |
| 234 |
228 |
| 235 static void do_remove_contact(GaimContact *c) |
229 static void do_remove_contact(GaimContact *contact) |
| 236 { |
230 { |
| 237 GaimBlistNode *bnode, *cnode; |
231 GaimBlistNode *bnode, *cnode; |
| 238 GaimGroup *g; |
232 GaimGroup *group; |
| 239 |
233 |
| 240 if(!c) |
234 if (!contact) |
| 241 return; |
235 return; |
| 242 |
236 |
| 243 cnode = (GaimBlistNode *)c; |
237 cnode = (GaimBlistNode *)contact; |
| 244 g = (GaimGroup*)cnode->parent; |
238 group = (GaimGroup*)cnode->parent; |
| 245 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
239 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
| 246 GaimBuddy *b = (GaimBuddy*)bnode; |
240 GaimBuddy *buddy = (GaimBuddy*)bnode; |
| 247 if(b->account->gc) |
241 if (gaim_account_is_connected(buddy->account)) |
| 248 serv_remove_buddy(b->account->gc, b->name, g->name); |
242 serv_remove_buddy(buddy->account->gc, buddy, group); |
| 249 } |
243 } |
| 250 gaim_blist_remove_contact(c); |
244 gaim_blist_remove_contact(contact); |
| 251 } |
245 } |
| 252 |
246 |
| 253 void do_remove_group(GaimGroup *g) |
247 void do_remove_group(GaimGroup *group) |
| 254 { |
248 { |
| 255 GaimBlistNode *cnode, *bnode; |
249 GaimBlistNode *cnode, *bnode; |
| 256 |
250 |
| 257 cnode = ((GaimBlistNode*)g)->child; |
251 cnode = ((GaimBlistNode*)group)->child; |
| 258 |
252 |
| 259 while(cnode) { |
253 while (cnode) { |
| 260 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { |
254 if (GAIM_BLIST_NODE_IS_CONTACT(cnode)) { |
| 261 bnode = cnode->child; |
255 bnode = cnode->child; |
| 262 cnode = cnode->next; |
256 cnode = cnode->next; |
| 263 while(bnode) { |
257 while (bnode) { |
| 264 GaimBuddy *b; |
258 GaimBuddy *buddy; |
| 265 if(GAIM_BLIST_NODE_IS_BUDDY(bnode)) { |
259 if (GAIM_BLIST_NODE_IS_BUDDY(bnode)) { |
| 266 GaimConversation *c; |
260 GaimConversation *conv; |
| 267 b = (GaimBuddy*)bnode; |
261 buddy = (GaimBuddy*)bnode; |
| 268 bnode = bnode->next; |
262 bnode = bnode->next; |
| 269 c = gaim_find_conversation_with_account(b->name, b->account); |
263 conv = gaim_find_conversation_with_account(buddy->name, buddy->account); |
| 270 if(gaim_account_is_connected(b->account)) { |
264 if (gaim_account_is_connected(buddy->account)) { |
| 271 serv_remove_buddy(b->account->gc, b->name, g->name); |
265 serv_remove_buddy(buddy->account->gc, buddy, group); |
| 272 gaim_blist_remove_buddy(b); |
266 gaim_blist_remove_buddy(buddy); |
| 273 if(c) |
267 if (conv) |
| 274 gaim_conversation_update(c, |
268 gaim_conversation_update(conv, |
| 275 GAIM_CONV_UPDATE_REMOVE); |
269 GAIM_CONV_UPDATE_REMOVE); |
| 276 } |
270 } |
| 277 } else { |
271 } else { |
| 278 bnode = bnode->next; |
272 bnode = bnode->next; |
| 279 } |
273 } |
| 280 } |
274 } |
| 281 } else if(GAIM_BLIST_NODE_IS_CHAT(cnode)) { |
275 } else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { |
| 282 GaimChat *chat = (GaimChat *)cnode; |
276 GaimChat *chat = (GaimChat *)cnode; |
| 283 cnode = cnode->next; |
277 cnode = cnode->next; |
| 284 if(gaim_account_is_connected(chat->account)) |
278 if (gaim_account_is_connected(chat->account)) |
| 285 gaim_blist_remove_chat(chat); |
279 gaim_blist_remove_chat(chat); |
| 286 } else { |
280 } else { |
| 287 cnode = cnode->next; |
281 cnode = cnode->next; |
| 288 } |
282 } |
| 289 } |
283 } |
| 290 |
284 |
| 291 gaim_blist_remove_group(g); |
285 gaim_blist_remove_group(group); |
| 292 gaim_blist_save(); |
286 } |
| 293 } |
287 |
| 294 |
288 void show_confirm_del(GaimBuddy *buddy) |
| 295 void show_confirm_del(GaimBuddy *b) |
|
| 296 { |
289 { |
| 297 char *text; |
290 char *text; |
| 298 if (!b) |
291 |
| |
292 if (!buddy) |
| 299 return; |
293 return; |
| 300 |
294 |
| 301 text = g_strdup_printf(_("You are about to remove %s from your buddy list. Do you want to continue?"), b->name); |
295 text = g_strdup_printf(_("You are about to remove %s from your buddy list. Do you want to continue?"), buddy->name); |
| 302 |
296 |
| 303 gaim_request_action(NULL, NULL, _("Remove Buddy"), text, -1, b, 2, |
297 gaim_request_action(NULL, NULL, _("Remove Buddy"), text, -1, buddy, 2, |
| 304 _("Remove Buddy"), G_CALLBACK(do_remove_buddy), |
298 _("Remove Buddy"), G_CALLBACK(do_remove_buddy), |
| 305 _("Cancel"), NULL); |
299 _("Cancel"), NULL); |
| 306 |
300 |
| 307 g_free(text); |
301 g_free(text); |
| 308 } |
302 } |
| 318 |
312 |
| 319 g_free(name); |
313 g_free(name); |
| 320 g_free(text); |
314 g_free(text); |
| 321 } |
315 } |
| 322 |
316 |
| 323 void show_confirm_del_group(GaimGroup *g) |
317 void show_confirm_del_group(GaimGroup *group) |
| 324 { |
318 { |
| 325 char *text = g_strdup_printf(_("You are about to remove the group %s and all its members from your buddy list. Do you want to continue?"), |
319 char *text = g_strdup_printf(_("You are about to remove the group %s and all its members from your buddy list. Do you want to continue?"), |
| 326 g->name); |
320 group->name); |
| 327 |
321 |
| 328 gaim_request_action(NULL, NULL, _("Remove Group"), text, -1, g, 2, |
322 gaim_request_action(NULL, NULL, _("Remove Group"), text, -1, group, 2, |
| 329 _("Remove Group"), G_CALLBACK(do_remove_group), |
323 _("Remove Group"), G_CALLBACK(do_remove_group), |
| 330 _("Cancel"), NULL); |
324 _("Cancel"), NULL); |
| 331 |
325 |
| 332 g_free(text); |
326 g_free(text); |
| 333 } |
327 } |
| 334 |
328 |
| 335 void show_confirm_del_contact(GaimContact *c) |
329 void show_confirm_del_contact(GaimContact *contact) |
| 336 { |
330 { |
| 337 GaimBuddy *b = gaim_contact_get_priority_buddy(c); |
331 GaimBuddy *buddy = gaim_contact_get_priority_buddy(contact); |
| 338 |
332 |
| 339 if(!b) |
333 if (!buddy) |
| 340 return; |
334 return; |
| 341 |
335 |
| 342 if(((GaimBlistNode*)c)->child == (GaimBlistNode*)b && |
336 if (((GaimBlistNode*)contact)->child == (GaimBlistNode*)buddy && |
| 343 !((GaimBlistNode*)b)->next) { |
337 !((GaimBlistNode*)buddy)->next) { |
| 344 show_confirm_del(b); |
338 show_confirm_del(buddy); |
| 345 } else { |
339 } else { |
| 346 char *text = g_strdup_printf(_("You are about to remove the contact containing %s and %d other buddies from your buddy list. Do you want to continue?"), |
340 char *text = g_strdup_printf(_("You are about to remove the contact containing %s and %d other buddies from your buddy list. Do you want to continue?"), |
| 347 b->name, c->totalsize - 1); |
341 buddy->name, contact->totalsize - 1); |
| 348 |
342 |
| 349 gaim_request_action(NULL, NULL, _("Remove Contact"), text, -1, c, 2, |
343 gaim_request_action(NULL, NULL, _("Remove Contact"), text, -1, contact, 2, |
| 350 _("Remove Contact"), G_CALLBACK(do_remove_contact), |
344 _("Remove Contact"), G_CALLBACK(do_remove_contact), |
| 351 _("Cancel"), NULL); |
345 _("Cancel"), NULL); |
| 352 |
346 |
| 353 g_free(text); |
347 g_free(text); |
| 354 } |
348 } |
| 396 g_free(norm); |
387 g_free(norm); |
| 397 |
388 |
| 398 if (strlen(gtk_label_get_label(GTK_LABEL(label))) <= 0) |
389 if (strlen(gtk_label_get_label(GTK_LABEL(label))) <= 0) |
| 399 return FALSE; |
390 return FALSE; |
| 400 |
391 |
| 401 window = gtk_dialog_new_with_buttons(GAIM_ALERT_TITLE, GTK_WINDOW(gtkblist->window), 0, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); |
392 window = gtk_dialog_new_with_buttons(GAIM_ALERT_TITLE, NULL, 0, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); |
| 402 gtk_dialog_set_default_response (GTK_DIALOG(window), GTK_RESPONSE_OK); |
393 gtk_dialog_set_default_response (GTK_DIALOG(window), GTK_RESPONSE_OK); |
| 403 g_signal_connect(G_OBJECT(window), "response", G_CALLBACK(gtk_widget_destroy), NULL); |
394 g_signal_connect(G_OBJECT(window), "response", G_CALLBACK(gtk_widget_destroy), NULL); |
| 404 |
395 |
| 405 gtk_container_set_border_width (GTK_CONTAINER(window), 6); |
396 gtk_container_set_border_width (GTK_CONTAINER(window), 6); |
| 406 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); |
397 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); |