Mercurial > pidgin
changeset 8719:513b8bbcc104
[gaim-migrate @ 9474]
" This fixes a bug where pasting a link, or in general
clicking in the middle of it and then sending would get
the link tag stuck on, and everything you typed after
that would be a link, unless you pasted some nonlink
rich text. This also makes it so you can't append to a
link when it's the last character of the buffer, like
you can every other tag.
Also, I made some slight improvements to copy/pasting.
Seems the length parameter (in pasted_received_cb) is
the total bytes, not the number of x bit (where x often
= 16) units. So that (length * (bits/8)) thing that I
think Sean was doing was causing problems." --Tim Ringenbach - marv_sf
oh and i have apparently attributed much of datallah's work today to other people
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Tue, 20 Apr 2004 04:08:24 +0000 |
parents | 6ab61697426e |
children | 5c1c9ec3856a |
files | src/gtkimhtml.c |
diffstat | 1 files changed, 31 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkimhtml.c Tue Apr 20 04:04:41 2004 +0000 +++ b/src/gtkimhtml.c Tue Apr 20 04:08:24 2004 +0000 @@ -557,7 +557,7 @@ str = g_string_append(str, text); str = g_string_append_unichar(str, 0x0000); selection = g_convert(str->str, str->len, "UCS-2", "UTF-8", NULL, &len, NULL); - gtk_selection_data_set (selection_data, gdk_atom_intern("text/html", FALSE), 16, selection, len); + gtk_selection_data_set(selection_data, gdk_atom_intern("text/html", FALSE), 16, selection, len); g_string_free(str, TRUE); g_free(selection); } else { @@ -729,14 +729,33 @@ g_free(text); text = tmp; } else { - text = g_malloc((selection_data->format / 8) * selection_data->length); - memcpy(text, selection_data->data, selection_data->length * (selection_data->format / 8)); +#if 0 + /* Here's some debug code, for figuring out what sent to us over the clipboard. */ + { + int i; + + gaim_debug_misc("gtkimhtml", "In paste_received_cb():\n\tformat = %d, length = %d\n\t", + selection_data->format, selection_data->length); + + for (i = 0; i < (/*(selection_data->format / 8) **/ selection_data->length); i++) { + if ((i % 70) == 0) + printf("\n\t"); + if (selection_data->data[i] == '\0') + printf("."); + else + printf("%c", selection_data->data[i]); + } + printf("\n"); + } +#endif + text = g_malloc(selection_data->length); + memcpy(text, selection_data->data, selection_data->length); } memcpy (&c, text, 2); if (c == 0xfeff) { /* This is UCS2 */ - char *utf8 = g_convert(text+2, (selection_data->length * (selection_data->format / 8)) - 2, "UTF-8", "UCS-2", NULL, NULL, NULL); + char *utf8 = g_convert(text+2, selection_data->length - 2, "UTF-8", "UCS-2", NULL, NULL, NULL); g_free(text); text = utf8; if (!text) { @@ -2451,23 +2470,7 @@ g_list_free(imhtml->scalables); imhtml->scalables = NULL; - imhtml->edit.bold = FALSE; - imhtml->edit.italic = FALSE; - imhtml->edit.underline = FALSE; - - if (imhtml->edit.fontface) - g_free(imhtml->edit.fontface); - imhtml->edit.fontface = NULL; - - if (imhtml->edit.forecolor) - g_free(imhtml->edit.forecolor); - imhtml->edit.forecolor = NULL; - - if (imhtml->edit.backcolor) - g_free(imhtml->edit.backcolor); - imhtml->edit.backcolor = NULL; - - imhtml->edit.fontsize = 0; + gtk_imhtml_close_tags(imhtml, &start); g_signal_emit(object, signals[CLEAR_FORMAT], 0); g_object_unref(object); @@ -3049,10 +3052,10 @@ * * Just in case I do do this, I asked about what to set the secondary text cursor to. * - (12:45:27) ?? ???: secondary_cursor_color = (rgb(background) + rgb(primary_cursor_color) ) / 2 * -(12:45:55) ?? ???: understand? * + * (12:45:27) ?? ???: secondary_cursor_color = (rgb(background) + rgb(primary_cursor_color) ) / 2 + * (12:45:55) ?? ???: understand? * (12:46:14) Tim: yeah. i didn't know there was an exact formula -(12:46:56) ?? ???: u might need to exactract separate each color from RGB * + * (12:46:56) ?? ???: u might need to exactract separate each color from RGB */ static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, @@ -3106,7 +3109,7 @@ imhtml->edit.fontface = g_strdup(&(tag->name)[10]); if (strncmp(tag->name, "FONT SIZE ", 10) == 0) imhtml->edit.fontsize = strtol(&(tag->name)[10], NULL, 10); - if (strncmp(tag->name, "LINK ", 5) == 0) + if ((strncmp(tag->name, "LINK ", 5) == 0) && !gtk_text_iter_is_end(&iter)) imhtml->edit.link = tag; } } @@ -3632,6 +3635,9 @@ imhtml->edit.fontsize = 0; + if (imhtml->edit.link) + gtk_imhtml_toggle_link(imhtml, NULL); + gtk_text_buffer_remove_all_tags(imhtml->text_buffer, iter, iter); }