Mercurial > pidgin.yaz
changeset 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 | 757a7c088801 |
children | ffab99688e5f |
files | src/gtkconv.c src/gtkimhtml.c src/gtkimhtml.h src/plugin.c |
diffstat | 4 files changed, 49 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkconv.c Mon Oct 25 23:45:26 2004 +0000 +++ b/src/gtkconv.c Tue Oct 26 01:00:35 2004 +0000 @@ -4505,8 +4505,10 @@ /* XXX - Attempt to load this file into gdk_pixbuf, or otherwise determine if it is an image. If it is, offer * the choice of a) sending this file b) inserting this file as an IM image or c) setting this file as a custom * buddy icon for this buddy */ + gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); } - gtk_drag_finish(dc, FALSE, FALSE, t); + else + gtk_drag_finish(dc, FALSE, FALSE, t); } /************************************************************************** @@ -4637,11 +4639,9 @@ static const GtkTargetEntry te[] = { - {"text/uri-list", 0, 0}, - {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 1}, - {"text/plain", 0, 2}, - {"STRING", 0, 3}, - {"application/x-im-contact", 0, 4} + GTK_IMHTML_DND_TARGETS, + {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, + {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} }; static void
--- 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);
--- a/src/gtkimhtml.h Mon Oct 25 23:45:26 2004 +0000 +++ b/src/gtkimhtml.h Tue Oct 26 01:00:35 2004 +0000 @@ -192,6 +192,28 @@ GTK_IMHTML_USE_POINTSIZE = 1 << 8 } GtkIMHtmlOptions; +enum { + GTK_IMHTML_DRAG_URL = 0, + GTK_IMHTML_DRAG_HTML, + GTK_IMHTML_DRAG_UTF8_STRING, + GTK_IMHTML_DRAG_COMPOUND_TEXT, + GTK_IMHTML_DRAG_STRING, + GTK_IMHTML_DRAG_TEXT, + GTK_IMHTML_DRAG_NUM +}; + +#define GTK_IMHTML_DND_TARGETS \ + { "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 }, \ + { "text/plain", 0, GTK_IMHTML_DRAG_TEXT }, \ + { "TEXT", 0, GTK_IMHTML_DRAG_TEXT } + typedef gpointer (*GtkIMHtmlGetImageFunc) (int id); typedef gpointer (*GtkIMHtmlGetImageDataFunc) (gpointer i); typedef size_t (*GtkIMHtmlGetImageSizeFunc) (gpointer i);
--- a/src/plugin.c Mon Oct 25 23:45:26 2004 +0000 +++ b/src/plugin.c Tue Oct 26 01:00:35 2004 +0000 @@ -493,6 +493,8 @@ plugin->info->major_version != GAIM_MAJOR_VERSION) { if(plugin->handle) g_module_close(plugin->handle); + if(plugin->path != NULL) + g_free(plugin->path); g_free(plugin); return; }