comparison src/buddy_chat.c @ 1303:9c34f99af79e

[gaim-migrate @ 1313] if you ignore someone in chat, and they leave and return, they stay ignored. properly. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 19 Dec 2000 03:28:33 +0000
parents b5783215b245
children a0d89bdc733e
comparison
equal deleted inserted replaced
1302:4c5c2fcb83cd 1303:9c34f99af79e
421 { 421 {
422 char *name = g_strdup(buddy); 422 char *name = g_strdup(buddy);
423 char tmp[BUF_LONG]; 423 char tmp[BUF_LONG];
424 GtkWidget *list_item; 424 GtkWidget *list_item;
425 int pos; 425 int pos;
426 GList *ignored;
426 427
427 plugin_event(event_chat_buddy_join, b->gc, b->name, name, 0); 428 plugin_event(event_chat_buddy_join, b->gc, b->name, name, 0);
428 b->in_room = g_list_insert_sorted(b->in_room, name, insertname); 429 b->in_room = g_list_insert_sorted(b->in_room, name, insertname);
429 pos = g_list_index(b->in_room, name); 430 pos = g_list_index(b->in_room, name);
430 431
431 list_item = gtk_list_item_new_with_label(name); 432 ignored = b->ignored;
433 while (ignored) {
434 if (!strcasecmp(name, ignored->data))
435 break;
436 ignored = ignored->next;
437 }
438
439 if (ignored) {
440 g_snprintf(tmp, sizeof(tmp), "X %s", name);
441 list_item = gtk_list_item_new_with_label(tmp);
442 } else
443 list_item = gtk_list_item_new_with_label(name);
444
432 gtk_object_set_user_data(GTK_OBJECT(list_item), name); 445 gtk_object_set_user_data(GTK_OBJECT(list_item), name);
433 gtk_list_insert_items(GTK_LIST(b->list), g_list_append(NULL, list_item), pos); 446 gtk_list_insert_items(GTK_LIST(b->list), g_list_append(NULL, list_item), pos);
434 gtk_widget_show(list_item); 447 gtk_widget_show(list_item);
435 448
436 g_snprintf(tmp, sizeof(tmp), _("%d people in room"), g_list_length(b->in_room)); 449 g_snprintf(tmp, sizeof(tmp), _("%d people in room"), g_list_length(b->in_room));
512 } 525 }
513 526
514 void ignore_callback(GtkWidget *w, struct conversation *b) 527 void ignore_callback(GtkWidget *w, struct conversation *b)
515 { 528 {
516 char *name; 529 char *name;
517 GList *i; 530 GList *i, *ignored;
518 int pos; 531 int pos;
519 GtkWidget *list_item; 532 GtkWidget *list_item;
520 char tmp[80]; 533 char tmp[80];
521 534
522 i = GTK_LIST(b->list)->selection; 535 i = GTK_LIST(b->list)->selection;
525 else 538 else
526 return; 539 return;
527 540
528 pos = gtk_list_child_position(GTK_LIST(b->list), i->data); 541 pos = gtk_list_child_position(GTK_LIST(b->list), i->data);
529 542
530 if (g_list_index(b->ignored, (gpointer)name) == -1) { 543 ignored = b->ignored;
531 b->ignored = g_list_append(b->ignored, name); 544 while (ignored) {
545 if (!strcasecmp(name, ignored->data))
546 break;
547 ignored = ignored->next;
548 }
549
550 if (ignored) {
551 b->ignored = g_list_remove(b->ignored, ignored->data);
552 g_snprintf(tmp, sizeof tmp, "%s", name);
553 } else {
554 b->ignored = g_list_append(b->ignored, g_strdup(name));
532 g_snprintf(tmp, sizeof tmp, "X %s", name); 555 g_snprintf(tmp, sizeof tmp, "X %s", name);
533 } else {
534 b->ignored = g_list_remove(b->ignored, name);
535 g_snprintf(tmp, sizeof tmp, "%s", name);
536 } 556 }
537 557
538 list_item = gtk_list_item_new_with_label(tmp); 558 list_item = gtk_list_item_new_with_label(tmp);
539 gtk_object_set_user_data(GTK_OBJECT(list_item), name); 559 gtk_object_set_user_data(GTK_OBJECT(list_item), name);
540 gtk_list_insert_items(GTK_LIST(b->list), g_list_append(NULL, list_item), pos); 560 gtk_list_insert_items(GTK_LIST(b->list), g_list_append(NULL, list_item), pos);