comparison src/gtkconv.c @ 7440:8c0527c91a92

[gaim-migrate @ 8045] this is all more better, but i forget what it all is. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Wed, 05 Nov 2003 23:43:53 +0000
parents 643cbc9a6035
children 064c697cc223
comparison
equal deleted inserted replaced
7439:3a51b301a805 7440:8c0527c91a92
4504 GaimConvWindow *win; 4504 GaimConvWindow *win;
4505 GaimConnection *gc; 4505 GaimConnection *gc;
4506 int gtk_font_options = 0; 4506 int gtk_font_options = 0;
4507 GString *log_str; 4507 GString *log_str;
4508 GSList *images = NULL; 4508 GSList *images = NULL;
4509 char buf[BUF_LONG]; 4509 char buf[BUF_LONG];
4510 char buf2[BUF_LONG]; 4510 char buf2[BUF_LONG];
4511 char mdate[64]; 4511 char mdate[64];
4512 char color[10]; 4512 char color[10];
4513 char *str; 4513 char *str;
4514 char *with_font_tag; 4514 char *with_font_tag;
4538 else 4538 else
4539 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); 4539 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime));
4540 4540
4541 if(gc) 4541 if(gc)
4542 sml_attrib = g_strdup_printf("sml=\"%s\"", gc->prpl->info->name); 4542 sml_attrib = g_strdup_printf("sml=\"%s\"", gc->prpl->info->name);
4543 4543
4544 gtk_font_options ^= GTK_IMHTML_NO_COMMENTS; 4544 gtk_font_options ^= GTK_IMHTML_NO_COMMENTS;
4545 4545
4546 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_colors")) 4546 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_colors"))
4547 gtk_font_options ^= GTK_IMHTML_NO_COLOURS; 4547 gtk_font_options ^= GTK_IMHTML_NO_COLOURS;
4548 4548
4552 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_font_sizes")) 4552 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_font_sizes"))
4553 gtk_font_options ^= GTK_IMHTML_NO_SIZES; 4553 gtk_font_options ^= GTK_IMHTML_NO_SIZES;
4554 4554
4555 if (!gaim_prefs_get_bool("/gaim/gtk/logging/strip_html")) 4555 if (!gaim_prefs_get_bool("/gaim/gtk/logging/strip_html"))
4556 gtk_font_options ^= GTK_IMHTML_RETURN_LOG; 4556 gtk_font_options ^= GTK_IMHTML_RETURN_LOG;
4557 4557
4558 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol(conv->account)))->options & 4558 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol(conv->account)))->options &
4559 OPT_PROTO_USE_POINTSIZE) { 4559 OPT_PROTO_USE_POINTSIZE) {
4560
4561 gtk_font_options ^= GTK_IMHTML_USE_POINTSIZE; 4560 gtk_font_options ^= GTK_IMHTML_USE_POINTSIZE;
4562 } 4561 }
4563 4562
4564 if (flags & GAIM_MESSAGE_SYSTEM) { 4563 if (flags & GAIM_MESSAGE_SYSTEM) {
4565 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")) 4564 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps"))
4566 g_snprintf(buf, BUF_LONG, "(%s) <B>%s</B>", 4565 g_snprintf(buf, BUF_LONG, "(%s) <B>%s</B>",
4567 mdate, message); 4566 mdate, message);
4568 else 4567 else
4569 g_snprintf(buf, BUF_LONG, "<B>%s</B>", message); 4568 g_snprintf(buf, BUF_LONG, "<B>%s</B>", message);
4570 4569
4571 g_snprintf(buf2, sizeof(buf2), 4570 g_snprintf(buf2, sizeof(buf2),
4572 "<!--(%s) --><B>%s</B><BR>", 4571 "<!--(%s) --><B>%s</B><BR>",
4573 mdate, message); 4572 mdate, message);
4574 4573
4575 gtk_imhtml_append_text_with_images(GTK_IMHTML(gtkconv->imhtml), buf2, 0, images); 4574 gtk_imhtml_append_text_with_images(GTK_IMHTML(gtkconv->imhtml), buf2, 0, images);
4576 4575
4577 if (gaim_prefs_get_bool("/gaim/gtk/logging/strip_html")) { 4576 if (gaim_prefs_get_bool("/gaim/gtk/logging/strip_html")) {
4578 char *t1 = gaim_markup_strip_html(buf); 4577 char *t1 = gaim_markup_strip_html(buf);
4579 4578
4580 conv->history = g_string_append(conv->history, t1); 4579 conv->history = g_string_append(conv->history, t1);
4581 conv->history = g_string_append(conv->history, "\n"); 4580 conv->history = g_string_append(conv->history, "\n");
4582 4581
4583 g_free(t1); 4582 g_free(t1);
4584 } 4583 }
4585 else { 4584 else {
4586 conv->history = g_string_append(conv->history, buf); 4585 conv->history = g_string_append(conv->history, buf);
4587 conv->history = g_string_append(conv->history, "<BR>\n"); 4586 conv->history = g_string_append(conv->history, "<BR>\n");
4588 } 4587 }
4589 4588
4590 } else if (flags & GAIM_MESSAGE_NO_LOG) { 4589 } else if (flags & GAIM_MESSAGE_NO_LOG) {
4591 g_snprintf(buf, BUF_LONG, 4590 g_snprintf(buf, BUF_LONG,
4592 "<B><FONT COLOR=\"#777777\">%s</FONT></B><BR>", 4591 "<B><FONT COLOR=\"#777777\">%s</FONT></B><BR>",
4593 message); 4592 message);
4594 4593
4595 gtk_imhtml_append_text_with_images(GTK_IMHTML(gtkconv->imhtml), buf, 0, images); 4594 gtk_imhtml_append_text_with_images(GTK_IMHTML(gtkconv->imhtml), buf, 0, images);
4596 } 4595 }
4597 else { 4596 else {
4598 char *new_message = g_memdup(message, length); 4597 char *new_message = g_memdup(message, length);
4599 4598
4600 if (flags & GAIM_MESSAGE_WHISPER) { 4599 if (flags & GAIM_MESSAGE_WHISPER) {
4601 str = g_malloc(1024); 4600 str = g_malloc(1024);
4602 4601
4603 /* If we're whispering, it's not an autoresponse. */ 4602 /* If we're whispering, it's not an autoresponse. */
4604 if (meify(new_message, length)) { 4603 if (meify(new_message, length)) {
4605 g_snprintf(str, 1024, "***%s", who); 4604 g_snprintf(str, 1024, "***%s", who);
4606 strcpy(color, "#6C2585"); 4605 strcpy(color, "#6C2585");
4607 } 4606 }
4608 else { 4607 else {
4609 g_snprintf(str, 1024, "*%s*:", who); 4608 g_snprintf(str, 1024, "*%s*:", who);
4610 strcpy(color, "#00FF00"); 4609 strcpy(color, "#00FF00");
4611 } 4610 }
4612 } 4611 }
4613 else { 4612 else {
4614 if (meify(new_message, length)) { 4613 if (meify(new_message, length)) {
4615 str = g_malloc(1024); 4614 str = g_malloc(1024);
4616 4615
4617 if (flags & GAIM_MESSAGE_AUTO_RESP) 4616 if (flags & GAIM_MESSAGE_AUTO_RESP)
4618 g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, who); 4617 g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, who);
4619 else 4618 else
4620 g_snprintf(str, 1024, "***%s", who); 4619 g_snprintf(str, 1024, "***%s", who);
4621 4620
4622 if (flags & GAIM_MESSAGE_NICK) 4621 if (flags & GAIM_MESSAGE_NICK)
4623 strcpy(color, "#AF7F00"); 4622 strcpy(color, "#AF7F00");
4624 else 4623 else
4625 strcpy(color, "#062585"); 4624 strcpy(color, "#062585");
4626 } 4625 }
4634 strcpy(color, "#AF7F00"); 4633 strcpy(color, "#AF7F00");
4635 else if (flags & GAIM_MESSAGE_RECV) { 4634 else if (flags & GAIM_MESSAGE_RECV) {
4636 if (flags & GAIM_MESSAGE_COLORIZE) { 4635 if (flags & GAIM_MESSAGE_COLORIZE) {
4637 const char *u; 4636 const char *u;
4638 int m = 0; 4637 int m = 0;
4639 4638
4640 for (u = who; *u != '\0'; u++) 4639 for (u = who; *u != '\0'; u++)
4641 m += *u; 4640 m += *u;
4642 4641
4643 m = m % NUM_NICK_COLORS; 4642 m = m % NUM_NICK_COLORS;
4644 4643
4645 strcpy(color, nick_colors[m]); 4644 strcpy(color, nick_colors[m]);
4646 } 4645 }
4647 else 4646 else
4648 strcpy(color, "#A82F2F"); 4647 strcpy(color, "#A82F2F");
4649 } 4648 }
4650 else if (flags & GAIM_MESSAGE_SEND) 4649 else if (flags & GAIM_MESSAGE_SEND)
4651 strcpy(color, "#16569E"); 4650 strcpy(color, "#16569E");
4652 } 4651 }
4653 } 4652 }
4654 4653
4655 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")) 4654 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps"))
4656 g_snprintf(buf, BUF_LONG, 4655 g_snprintf(buf, BUF_LONG,
4657 "<FONT COLOR=\"%s\" %s>(%s) " 4656 "<FONT COLOR=\"%s\" %s>(%s) "
4658 "<B>%s</B></FONT> ", color, 4657 "<B>%s</B></FONT> ", color,
4659 sml_attrib ? sml_attrib : "", mdate, str); 4658 sml_attrib ? sml_attrib : "", mdate, str);
4660 else 4659 else
4661 g_snprintf(buf, BUF_LONG, 4660 g_snprintf(buf, BUF_LONG,
4662 "<FONT COLOR=\"%s\" %s><B>%s</B></FONT> ", color, 4661 "<FONT COLOR=\"%s\" %s><B>%s</B></FONT> ", color,
4663 sml_attrib ? sml_attrib : "", str); 4662 sml_attrib ? sml_attrib : "", str);
4664 4663
4665 g_snprintf(buf2, BUF_LONG, 4664 g_snprintf(buf2, BUF_LONG,
4666 "<FONT COLOR=\"%s\" %s><!--(%s) -->" 4665 "<FONT COLOR=\"%s\" %s><!--(%s) -->"
4667 "<B>%s</B></FONT> ", 4666 "<B>%s</B></FONT> ",
4668 color, sml_attrib ? sml_attrib : "", mdate, str); 4667 color, sml_attrib ? sml_attrib : "", mdate, str);
4669 4668
4670 g_free(str); 4669 g_free(str);
4671 4670
4672 gtk_imhtml_append_text_with_images(GTK_IMHTML(gtkconv->imhtml), buf2, 0, images); 4671 gtk_imhtml_append_text_with_images(GTK_IMHTML(gtkconv->imhtml), buf2, 0, images);
4673 4672
4674 if(gc){ 4673 if(gc){
4675 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); 4674 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : "");
4676 char *post = "</font>"; 4675 char *post = "</font>";
4677 int pre_len = strlen(pre); 4676 int pre_len = strlen(pre);
4678 int post_len = strlen(post); 4677 int post_len = strlen(post);
4679 4678
4680 with_font_tag = g_malloc(length + pre_len + post_len + 1); 4679 with_font_tag = g_malloc(length + pre_len + post_len + 1);
4681 4680
4682 strcpy(with_font_tag, pre); 4681 strcpy(with_font_tag, pre);
4683 memcpy(with_font_tag + pre_len, new_message, length); 4682 memcpy(with_font_tag + pre_len, new_message, length);
4684 strcpy(with_font_tag + pre_len + length, post); 4683 strcpy(with_font_tag + pre_len + length, post);
4685 4684
4686 length += pre_len + post_len; 4685 length += pre_len + post_len;
4687 g_free(pre); 4686 g_free(pre);
4688 } 4687 }
4689 else 4688 else
4690 with_font_tag = g_memdup(new_message, length); 4689 with_font_tag = g_memdup(new_message, length);
4691 4690
4692 log_str = gtk_imhtml_append_text_with_images(GTK_IMHTML(gtkconv->imhtml), 4691 log_str = gtk_imhtml_append_text_with_images(GTK_IMHTML(gtkconv->imhtml),
4693 with_font_tag, gtk_font_options, images); 4692 with_font_tag, gtk_font_options, images);
4694 4693
4695 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0); 4694 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0);
4696 4695
4697 /*conv->history = g_string_append(conv->history, t1); 4696 /*conv->history = g_string_append(conv->history, t1);
4698 conv->history = g_string_append(conv->history, t2); 4697 conv->history = g_string_append(conv->history, t2);
4699 conv->history = g_string_append(conv->history, "\n"); 4698 conv->history = g_string_append(conv->history, "\n");
4700 4699
4701 g_free(t1); 4700 g_free(t1);
4702 g_free(t2); */ 4701 g_free(t2); */
4703 } 4702
4704 4703 g_free(with_font_tag);
4705 g_free(with_font_tag); 4704 }
4705
4706 4706
4707 if(sml_attrib) 4707 if(sml_attrib)
4708 g_free(sml_attrib); 4708 g_free(sml_attrib);
4709 4709
4710 if (images) { 4710 if (images) {