Mercurial > pidgin.yaz
diff src/gtkimhtml.c @ 10145:4d484e455839
[gaim-migrate @ 11218]
This fixes the crash / hang / strangeness when dragging a buddy to a
conversation entry thing. Also fixes a minor memory leak with old plugins.
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Tue, 26 Oct 2004 01:00:35 +0000 |
parents | 4b276d2e5589 |
children | 5c3b27763126 |
line wrap: on
line diff
--- a/src/gtkimhtml.c Mon Oct 25 23:45:26 2004 +0000 +++ b/src/gtkimhtml.c Tue Oct 26 01:00:35 2004 +0000 @@ -106,15 +106,6 @@ }; enum { - DRAG_URL, - DRAG_HTML, - DRAG_UTF8_STRING, - DRAG_COMPOUND_TEXT, - DRAG_STRING, - DRAG_TEXT, -}; - -enum { URL_CLICKED, BUTTONS_UPDATE, TOGGLE_FORMAT, @@ -133,16 +124,8 @@ { "TEXT", 0, TARGET_TEXT}}; GtkTargetEntry link_drag_drop_targets[] = { - {"text/html", 0, DRAG_HTML }, - {"x-url/ftp", 0, DRAG_URL}, - {"x-url/http", 0, DRAG_URL}, - {"text/uri-list", 0, DRAG_URL}, - {"_NETSCAPE_URL", 0, DRAG_URL}, - { "UTF8_STRING", 0, DRAG_UTF8_STRING }, - { "COMPOUND_TEXT", 0, DRAG_COMPOUND_TEXT }, - { "STRING", 0, DRAG_STRING }, - { "TEXT", 0, DRAG_TEXT}}; - + GTK_IMHTML_DND_TARGETS +}; #ifdef _WIN32 /* Win32 clipboard format value, and functions to convert back and @@ -1298,8 +1281,7 @@ { GdkDragAction suggested_action = 0; - if (gtk_drag_dest_find_target (widget, context, - gtk_drag_dest_get_target_list (widget)) == GDK_NONE) { + if (gtk_drag_dest_find_target (widget, context, NULL) == GDK_NONE) { /* can't accept any of the offered targets */ } else { GtkWidget *source_widget; @@ -1314,11 +1296,7 @@ } } - if (suggested_action != 0) { - gdk_drag_status (context, suggested_action, time); - } else { - gdk_drag_status (context, 0, time); - } + gdk_drag_status (context, suggested_action, time); /* TRUE return means don't propagate the drag motion to parent * widgets that may also be drop sites. @@ -1354,7 +1332,7 @@ if(gtk_imhtml_get_editable(imhtml) && sd->data){ switch (info) { - case DRAG_URL: + case GTK_IMHTML_DRAG_URL: gaim_str_strip_cr(sd->data); links = g_strsplit(sd->data, "\n", 0); @@ -1370,7 +1348,7 @@ } } break; - case DRAG_HTML: + case GTK_IMHTML_DRAG_HTML: if (sd->length >= 2 && (*(guint16 *)text == 0xfeff || *(guint16 *)text == 0xfffe)) { /* This is UCS-2 */ @@ -1393,11 +1371,21 @@ } gtk_imhtml_insert_html_at_iter(imhtml, text, 0, &iter); 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); + gtk_imhtml_insert_html_at_iter(imhtml, tmp, 0, &iter); + g_free(tmp); + } + break; default: - break; + gtk_drag_finish(dc, FALSE, FALSE, t); + return; } - - gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); } else { gtk_drag_finish(dc, FALSE, FALSE, t);