X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-text-utils.c;h=f2ca84088c2f6d9eb20451cb4fee7cc67dfffc15;hp=561ca9f12ac48c54b38479aa1812d3a89617f49b;hb=d39a0b6738e86acb01327d641b6e78eb0afa8c63;hpb=d27a0a29347366d5421e7e796eca4655ef0d095a diff --git a/src/modest-text-utils.c b/src/modest-text-utils.c index 561ca9f..f2ca840 100644 --- a/src/modest-text-utils.c +++ b/src/modest-text-utils.c @@ -400,7 +400,7 @@ modest_text_utils_convert_buffer_to_html_start (GString *html, const gchar *data /* replace with special html chars where needed*/ for (i = 0; i != n; ++i) { - char kar = data[i]; + guchar kar = data[i]; if (space_seen && kar != ' ') { g_string_append_c (html, ' '); @@ -410,8 +410,10 @@ modest_text_utils_convert_buffer_to_html_start (GString *html, const gchar *data /* we artificially insert a breakpoint (newline) * after 256, to make sure our lines are not so long * they will DOS the regexping later + * Also, check that kar is ASCII to make sure that we + * don't break a UTF8 char in two */ - if (++break_dist == 256) { + if (++break_dist >= 256 && kar < 127) { g_string_append_c (html, '\n'); break_dist = 0; } @@ -1651,3 +1653,37 @@ modest_text_utils_label_get_selection (GtkLabel *label) return g_strdup (""); } } + +static gboolean +_forward_search_image_char (gunichar ch, + gpointer userdata) +{ + return (ch == 0xFFFC); +} + +gboolean +modest_text_utils_buffer_selection_is_valid (GtkTextBuffer *buffer) +{ + gboolean result; + GtkTextIter start, end; + + g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), FALSE); + + result = gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (buffer)); + + /* check there are no images in selection */ + if (result) { + gtk_text_buffer_get_selection_bounds (buffer, &start, &end); + if (gtk_text_iter_get_char (&start)== 0xFFFC) + result = FALSE; + else { + gtk_text_iter_backward_char (&end); + if (gtk_text_iter_forward_find_char (&start, _forward_search_image_char, + NULL, &end)) + result = FALSE; + } + + } + + return result; +}