| 396 |
396 |
| 397 } |
397 } |
| 398 |
398 |
| 399 |
399 |
| 400 |
400 |
| 401 void update_chat_list(struct conversation *b) |
|
| 402 { |
|
| 403 GtkWidget *list_item; |
|
| 404 char name[80]; |
|
| 405 char *tmp; |
|
| 406 GList *names = b->in_room; |
|
| 407 |
|
| 408 if (!b->is_chat) { |
|
| 409 debug_print("update_chat_list: expecting chat, got IM\n"); |
|
| 410 return; |
|
| 411 } |
|
| 412 |
|
| 413 gtk_list_clear_items(GTK_LIST(b->list), 0, -1); |
|
| 414 |
|
| 415 |
|
| 416 while(names) { |
|
| 417 tmp = (char *)names->data; |
|
| 418 if (g_list_index(b->ignored, names->data) != -1) |
|
| 419 g_snprintf(name, sizeof(name), "X %s", tmp); |
|
| 420 else |
|
| 421 g_snprintf(name, sizeof(name), "%s", tmp); |
|
| 422 |
|
| 423 list_item = gtk_list_item_new_with_label(name); |
|
| 424 gtk_widget_show(list_item); |
|
| 425 gtk_object_set_user_data(GTK_OBJECT(list_item), tmp); |
|
| 426 |
|
| 427 gtk_list_append_items(GTK_LIST(b->list), g_list_append(NULL, list_item)); |
|
| 428 |
|
| 429 names = names->next; |
|
| 430 } |
|
| 431 |
|
| 432 } |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 void add_chat_buddy(struct conversation *b, char *buddy) |
401 void add_chat_buddy(struct conversation *b, char *buddy) |
| 437 { |
402 { |
| 438 char *name = g_strdup(buddy); |
403 char *name = g_strdup(buddy); |
| 439 char tmp[BUF_LONG]; |
404 char tmp[BUF_LONG]; |
| |
405 GtkWidget *list_item; |
| 440 |
406 |
| 441 plugin_event(event_chat_buddy_join, b->gc, b->name, name, 0); |
407 plugin_event(event_chat_buddy_join, b->gc, b->name, name, 0); |
| 442 b->in_room = g_list_append(b->in_room, name); |
408 b->in_room = g_list_append(b->in_room, name); |
| 443 |
409 |
| 444 update_chat_list(b); |
410 list_item = gtk_list_item_new_with_label(name); |
| |
411 gtk_object_set_user_data(GTK_OBJECT(list_item), name); |
| |
412 gtk_list_append_items(GTK_LIST(b->list), g_list_append(NULL, list_item)); |
| |
413 gtk_widget_show(list_item); |
| 445 |
414 |
| 446 if (b->makesound && (sound_options & OPT_SOUND_CHAT_JOIN)) |
415 if (b->makesound && (sound_options & OPT_SOUND_CHAT_JOIN)) |
| 447 play_sound(CHAT_JOIN); |
416 play_sound(CHAT_JOIN); |
| 448 |
417 |
| 449 if (display_options & OPT_DISP_CHAT_LOGON) { |
418 if (display_options & OPT_DISP_CHAT_LOGON) { |
| 456 |
425 |
| 457 |
426 |
| 458 void remove_chat_buddy(struct conversation *b, char *buddy) |
427 void remove_chat_buddy(struct conversation *b, char *buddy) |
| 459 { |
428 { |
| 460 GList *names = b->in_room; |
429 GList *names = b->in_room; |
| |
430 GList *items = GTK_LIST(b->list)->children; |
| |
431 |
| 461 char tmp[BUF_LONG]; |
432 char tmp[BUF_LONG]; |
| 462 |
433 |
| 463 plugin_event(event_chat_buddy_leave, b->gc, b->name, buddy, 0); |
434 plugin_event(event_chat_buddy_leave, b->gc, b->name, buddy, 0); |
| 464 |
435 |
| 465 while(names) { |
436 while(names) { |
| 466 if (!strcasecmp((char *)names->data, buddy)) { |
437 if (!strcasecmp((char *)names->data, buddy)) { |
| |
438 char *tmp = names->data; |
| 467 b->in_room = g_list_remove(b->in_room, names->data); |
439 b->in_room = g_list_remove(b->in_room, names->data); |
| 468 update_chat_list(b); |
440 while (items) { |
| |
441 if (tmp == gtk_object_get_user_data(items->data)) { |
| |
442 gtk_list_remove_items(GTK_LIST(b->list), |
| |
443 g_list_append(NULL, items->data)); |
| |
444 break; |
| |
445 } |
| |
446 items = items->next; |
| |
447 } |
| |
448 g_free(tmp); |
| 469 break; |
449 break; |
| 470 } |
450 } |
| 471 names = names->next; |
451 names = names->next; |
| 472 } |
452 } |
| 473 |
453 |
| 506 |
486 |
| 507 void ignore_callback(GtkWidget *w, struct conversation *b) |
487 void ignore_callback(GtkWidget *w, struct conversation *b) |
| 508 { |
488 { |
| 509 char *name; |
489 char *name; |
| 510 GList *i; |
490 GList *i; |
| |
491 int pos; |
| |
492 GtkWidget *list_item; |
| |
493 char tmp[80]; |
| 511 |
494 |
| 512 i = GTK_LIST(b->list)->selection; |
495 i = GTK_LIST(b->list)->selection; |
| 513 if (i) |
496 if (i) |
| 514 name = (char *)gtk_object_get_user_data(GTK_OBJECT(i->data)); |
497 name = (char *)gtk_object_get_user_data(GTK_OBJECT(i->data)); |
| 515 else |
498 else |
| 516 return; |
499 return; |
| 517 |
500 |
| 518 if (g_list_index(b->ignored, (gpointer)name) == -1) |
501 pos = gtk_list_child_position(GTK_LIST(b->list), i->data); |
| |
502 |
| |
503 if (g_list_index(b->ignored, (gpointer)name) == -1) { |
| 519 b->ignored = g_list_append(b->ignored, name); |
504 b->ignored = g_list_append(b->ignored, name); |
| 520 else |
505 g_snprintf(tmp, sizeof tmp, "X %s", name); |
| |
506 } else { |
| 521 b->ignored = g_list_remove(b->ignored, name); |
507 b->ignored = g_list_remove(b->ignored, name); |
| 522 |
508 g_snprintf(tmp, sizeof tmp, "%s", name); |
| 523 update_chat_list(b); |
509 } |
| |
510 |
| |
511 list_item = gtk_list_item_new_with_label(tmp); |
| |
512 gtk_object_set_user_data(GTK_OBJECT(list_item), name); |
| |
513 gtk_list_insert_items(GTK_LIST(b->list), g_list_append(NULL, list_item), pos); |
| |
514 gtk_widget_destroy(i->data); |
| |
515 gtk_widget_show(list_item); |
| 524 } |
516 } |
| 525 |
517 |
| 526 |
518 |
| 527 |
519 |
| 528 void show_new_buddy_chat(struct conversation *b) |
520 void show_new_buddy_chat(struct conversation *b) |