Mercurial > pidgin.yaz
changeset 10243:e450f24d1fe1
[gaim-migrate @ 11383]
I used to think Mozilla was a good thing. Now I'm not so sure.
Who would think "text/html" is "for internal use only" - yup, mozilla.
Oh well.
"No operating systems or external applications understand this flavor" eh? we
know the taste now!
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Tue, 23 Nov 2004 02:22:24 +0000 |
parents | c66da6503db8 |
children | 13cb42ebb537 |
files | src/gtkimhtml.c src/gtkimhtml.h |
diffstat | 2 files changed, 29 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkimhtml.c Tue Nov 23 02:15:47 2004 +0000 +++ b/src/gtkimhtml.c Tue Nov 23 02:22:24 2004 +0000 @@ -1332,7 +1332,6 @@ gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); - if(gtk_imhtml_get_editable(imhtml) && sd->data){ switch (info) { case GTK_IMHTML_DRAG_URL: @@ -1352,32 +1351,44 @@ } break; case GTK_IMHTML_DRAG_HTML: - if (sd->length >= 2 && - (*(guint16 *)text == 0xfeff || *(guint16 *)text == 0xfffe)) { - /* This is UCS-2 */ - char *tmp; - char *utf8 = g_convert(text, sd->length, "UTF-8", "UCS-2", NULL, NULL, NULL); - g_free(text); - text = utf8; - if (!text) { + { + char *utf8 = NULL; + /* Ewww. This is all because mozilla thinks that text/html is 'for internal use only.' + * as explained by this comment in gtkhtml: + * + * FIXME This hack decides the charset of the selection. It seems that + * mozilla/netscape alway use ucs2 for text/html + * and openoffice.org seems to always use utf8 so we try to validate + * the string as utf8 and if that fails we assume it is ucs2 + * + * See also the comment on text/html here: + * http://mail.gnome.org/archives/gtk-devel-list/2001-September/msg00114.html + */ + if (sd->length >= 2 && !g_utf8_validate(text, sd->length - 1, NULL)) { + utf8 = g_convert(text, sd->length, "UTF-8", "UCS-2", NULL, NULL, NULL); + + if (!utf8) { gaim_debug_warning("gtkimhtml", "g_convert from UCS-2 failed in drag_rcv_cb\n"); return; } - tmp = g_utf8_next_char(text); - memmove(text, tmp, strlen(tmp) + 1); - } - - if (!(*text) || !g_utf8_validate(text, -1, NULL)) { + + if (*(guint16 *)text == 0xfeff || *(guint16 *)text == 0xfffe || TRUE) { + char *tmp; + tmp = g_utf8_next_char(utf8); + memmove(utf8, tmp, strlen(tmp) + 1); + } + } else if (!(*text) || !g_utf8_validate(text, -1, NULL)) { gaim_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in drag_rcv_cb\n"); - g_free(text); return; } - gtk_imhtml_insert_html_at_iter(imhtml, text, 0, &iter); + + gtk_imhtml_insert_html_at_iter(imhtml, utf8 ? utf8 : text, 0, &iter); + g_free(utf8); break; + } case GTK_IMHTML_DRAG_TEXT: if (!(*text) || !g_utf8_validate(text, -1, NULL)) { gaim_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in drag_rcv_cb\n"); - g_free(text); return; } else { char *tmp = gaim_escape_html(text);
--- a/src/gtkimhtml.h Tue Nov 23 02:15:47 2004 +0000 +++ b/src/gtkimhtml.h Tue Nov 23 02:22:24 2004 +0000 @@ -200,11 +200,11 @@ }; #define GTK_IMHTML_DND_TARGETS \ + { "_NETSCAPE_URL", 0, GTK_IMHTML_DRAG_URL }, \ { "text/html", 0, GTK_IMHTML_DRAG_HTML }, \ { "x-url/ftp", 0, GTK_IMHTML_DRAG_URL }, \ { "x-url/http", 0, GTK_IMHTML_DRAG_URL }, \ { "text/uri-list", 0, GTK_IMHTML_DRAG_URL }, \ - { "_NETSCAPE_URL", 0, GTK_IMHTML_DRAG_URL }, \ { "UTF8_STRING", 0, GTK_IMHTML_DRAG_UTF8_STRING }, \ { "COMPOUND_TEXT", 0, GTK_IMHTML_DRAG_COMPOUND_TEXT }, \ { "STRING", 0, GTK_IMHTML_DRAG_STRING }, \