gaim/gaim

2a1a0d0d673d
Parents b59671364e74
Children b4b2249bb76a
" Em was in #gaim with a crash on dnd urls, so I walked
'em through avoiding the crash. Then we discovered it
was adding it twice, and realized that the second part
was the data for the A tag. And then I found a memory
leak. So I tweaked the patch to use the label that
we're given.

In other words, crash fix, memory leak fix, use the
label for a url if we're given it.

Things to note, selecting a big block of text with
multiple links in it has issues as does selecting
multiple links. I'm not sure how to go about fixing
that, I leave that to someone who knows what the hell
they're doing with dnd, but i got the same results with
firefox and galeon. Selecting multiple links will use
everything that was selected as the label, and the url
for whatever part you grabbed. When selecing text with
multiple links in it, the output depends on how you
selected it and which part you grabbed to drag." --Gary (grim) Kramlich
--- a/src/gtkimhtml.c Sun Apr 03 22:44:03 2005 -0400
+++ b/src/gtkimhtml.c Mon Apr 04 07:20:18 2005 -0400
@@ -1351,6 +1351,7 @@
char *text = sd->data;
GtkTextMark *mark = gtk_text_buffer_get_insert(imhtml->text_buffer);
GtkTextIter iter;
+ gint i = 0;
gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark);
@@ -1360,21 +1361,32 @@
gaim_str_strip_cr(sd->data);
links = g_strsplit(sd->data, "\n", 0);
- while((link = *links++) != NULL){
+ while((link = links[i]) != NULL){
if(gaim_str_has_prefix(link, "http://") ||
gaim_str_has_prefix(link, "https://") ||
- gaim_str_has_prefix(link, "ftp://")){
- gtk_imhtml_insert_link(imhtml, mark, link, link);
+ gaim_str_has_prefix(link, "ftp://"))
+ {
+ gchar *label;
+
+ if(links[i + 1])
+ i++;
+
+ label = links[i];
+
+ gtk_imhtml_insert_link(imhtml, mark, link, label);
} else if (link=='\0') {
/* Ignore blank lines */
} else {
/* Special reasons, aka images being put in via other tag, etc. */
/* ... don't pretend we handled it if we didn't */
gtk_drag_finish(dc, FALSE, FALSE, t);
+ g_strfreev(links);
return;
}
+
+ i++;
}
- g_strfreev(links);
+ g_strfreev(links);
break;
case GTK_IMHTML_DRAG_HTML:
{