comparison src/gtkconv.c @ 8962:4ff4c34b7500

[gaim-migrate @ 9736] IM Image, WYSIWYG. It's still somewhat buggy, although the worse problems are with oscar's direct connect. We could always yank oscar's im image flag if we think it will cause too many bug reports. I made the GaimImgstore struct opque. I modified oscar's sending function to parse im images better, and everything seems to work. I made it write some errors to the conversation if you try to send an image and you aren't direct connected. That's just a hack until you can set formatting flags on a per conversation bases. There's a scrolling bug I haven't tracked down. I think it may exist normally and this just causes it better. It's worth noting jabber also uses this for pics in profiles, although I never did find a test case. Hopefully some other stuff can use this soon too, maybe Yahoo! pics in profiles or something. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Mon, 17 May 2004 06:47:20 +0000
parents 80944edf8d80
children c2ad41f7c82b
comparison
equal deleted inserted replaced
8961:92e061a1db10 8962:4ff4c34b7500
332 332
333 if (!gaim_account_is_connected(account)) 333 if (!gaim_account_is_connected(account))
334 return; 334 return;
335 335
336 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); 336 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry));
337 clean = gaim_markup_strip_html(buf); 337 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL);
338 338
339 gtk_widget_grab_focus(gtkconv->entry); 339 gtk_widget_grab_focus(gtkconv->entry);
340 340
341 if (strlen(clean) == 0) { 341 if (strlen(clean) == 0) {
342 g_free(clean); 342 g_free(clean);
4530 { 4530 {
4531 GaimGtkConversation *gtkconv; 4531 GaimGtkConversation *gtkconv;
4532 GaimConvWindow *win; 4532 GaimConvWindow *win;
4533 GaimConnection *gc; 4533 GaimConnection *gc;
4534 int gtk_font_options = 0; 4534 int gtk_font_options = 0;
4535 GSList *images = NULL;
4536 char buf[BUF_LONG]; 4535 char buf[BUF_LONG];
4537 char buf2[BUF_LONG]; 4536 char buf2[BUF_LONG];
4538 char mdate[64]; 4537 char mdate[64];
4539 char color[10]; 4538 char color[10];
4540 char *str; 4539 char *str;
4554 gaim_prefs_get_bool("/gaim/gtk/conversations/im/raise_on_events")))) { 4553 gaim_prefs_get_bool("/gaim/gtk/conversations/im/raise_on_events")))) {
4555 4554
4556 gaim_conv_window_show(win); 4555 gaim_conv_window_show(win);
4557 } 4556 }
4558 4557
4559 if (flags & GAIM_MESSAGE_IMAGES)
4560 gaim_gtk_find_images(message, &images);
4561
4562 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) 4558 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml))))
4563 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0); 4559 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0);
4564 4560
4565 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ 4561 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */
4566 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); 4562 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime));
4593 4589
4594 g_snprintf(buf2, sizeof(buf2), 4590 g_snprintf(buf2, sizeof(buf2),
4595 "<FONT %s><FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B></FONT>", 4591 "<FONT %s><FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B></FONT>",
4596 sml_attrib, mdate, message); 4592 sml_attrib, mdate, message);
4597 4593
4598 gtk_imhtml_append_text_with_images(GTK_IMHTML(gtkconv->imhtml), 4594 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0);
4599 buf2, 0, images);
4600 4595
4601 /* Add the message to a conversations scrollback buffer */ 4596 /* Add the message to a conversations scrollback buffer */
4602 conv->history = g_string_append(conv->history, buf); 4597 conv->history = g_string_append(conv->history, buf);
4603 conv->history = g_string_append(conv->history, "<BR>\n"); 4598 conv->history = g_string_append(conv->history, "<BR>\n");
4604 4599
4611 4606
4612 g_snprintf(buf2, sizeof(buf2), 4607 g_snprintf(buf2, sizeof(buf2),
4613 "<FONT %s><FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B></FONT>", 4608 "<FONT %s><FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B></FONT>",
4614 sml_attrib, mdate, message); 4609 sml_attrib, mdate, message);
4615 4610
4616 gtk_imhtml_append_text_with_images(GTK_IMHTML(gtkconv->imhtml), 4611 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0);
4617 buf2, 0, images); 4612
4618
4619 /* Add the message to a conversations scrollback buffer */ 4613 /* Add the message to a conversations scrollback buffer */
4620 conv->history = g_string_append(conv->history, buf); 4614 conv->history = g_string_append(conv->history, buf);
4621 conv->history = g_string_append(conv->history, "<BR>\n"); 4615 conv->history = g_string_append(conv->history, "<BR>\n");
4622 } else if (flags & GAIM_MESSAGE_NO_LOG) { 4616 } else if (flags & GAIM_MESSAGE_NO_LOG) {
4623 g_snprintf(buf, BUF_LONG, 4617 g_snprintf(buf, BUF_LONG,
4624 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", 4618 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>",
4625 sml_attrib, message); 4619 sml_attrib, message);
4626 4620
4627 gtk_imhtml_append_text_with_images(GTK_IMHTML(gtkconv->imhtml), 4621 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf, 0);
4628 buf, 0, images);
4629 } 4622 }
4630 else { 4623 else {
4631 char *new_message = g_memdup(message, length); 4624 char *new_message = g_memdup(message, length);
4632 char *who_escaped = g_markup_escape_text(who, strlen(who)); 4625 char *who_escaped = g_markup_escape_text(who, strlen(who));
4633 4626
4704 "<B>%s</B></FONT> ", 4697 "<B>%s</B></FONT> ",
4705 color, sml_attrib ? sml_attrib : "", mdate, str); 4698 color, sml_attrib ? sml_attrib : "", mdate, str);
4706 4699
4707 g_free(str); 4700 g_free(str);
4708 4701
4709 gtk_imhtml_append_text_with_images(GTK_IMHTML(gtkconv->imhtml), 4702 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml),
4710 buf2, 0, images); 4703 buf2, 0);
4711 4704
4712 if(gc){ 4705 if(gc){
4713 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); 4706 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : "");
4714 char *post = "</font>"; 4707 char *post = "</font>";
4715 int pre_len = strlen(pre); 4708 int pre_len = strlen(pre);
4725 g_free(pre); 4718 g_free(pre);
4726 } 4719 }
4727 else 4720 else
4728 with_font_tag = g_memdup(new_message, length); 4721 with_font_tag = g_memdup(new_message, length);
4729 4722
4730 gtk_imhtml_append_text_with_images(GTK_IMHTML(gtkconv->imhtml), 4723 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml),
4731 with_font_tag, gtk_font_options, images); 4724 with_font_tag, gtk_font_options);
4732 4725
4733 conv->history = g_string_append(conv->history, buf); 4726 conv->history = g_string_append(conv->history, buf);
4734 conv->history = g_string_append(conv->history, new_message); 4727 conv->history = g_string_append(conv->history, new_message);
4735 conv->history = g_string_append(conv->history, "<BR>\n"); 4728 conv->history = g_string_append(conv->history, "<BR>\n");
4736 4729
4739 } 4732 }
4740 4733
4741 4734
4742 if(sml_attrib) 4735 if(sml_attrib)
4743 g_free(sml_attrib); 4736 g_free(sml_attrib);
4744
4745 if (images) {
4746 GSList *tmp;
4747
4748 for (tmp = images; tmp; tmp = tmp->next) {
4749 GdkPixbuf *pixbuf = tmp->data;
4750 if(pixbuf)
4751 g_object_unref(pixbuf);
4752 }
4753
4754 g_slist_free(images);
4755 }
4756 } 4737 }
4757 4738
4758 static void 4739 static void
4759 gaim_gtkconv_chat_add_user(GaimConversation *conv, const char *user) 4740 gaim_gtkconv_chat_add_user(GaimConversation *conv, const char *user)
4760 { 4741 {