From 33b5d84fbaaf8dd4eafe4176dba08213c046463f Mon Sep 17 00:00:00 2001 From: Jose Dapena Paz Date: Fri, 14 Mar 2008 17:06:16 +0000 Subject: [PATCH] Fix for bug NB#81584. * src/modest-text-utils.[ch]: * Added a method to process a recipient list and make it have lines with length lower than 1000 characters. * src/widgets/modest-recpt-view.c: * Strip lines of recipients added, to have a length lower than 1000 characters. pmo-trunk-r4316 --- src/modest-text-utils.c | 24 ++++++++++++++++++++++++ src/modest-text-utils.h | 10 ++++++++++ src/widgets/modest-recpt-view.c | 10 +++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/modest-text-utils.c b/src/modest-text-utils.c index 01e70d3..5906bb7 100644 --- a/src/modest-text-utils.c +++ b/src/modest-text-utils.c @@ -653,6 +653,30 @@ modest_text_utils_address_range_at_position (const gchar *recipients_list, *end = range_end; } +gchar * +modest_text_utils_address_with_standard_length (const gchar *recipients_list) +{ + gchar ** splitted; + gchar ** current; + GString *buffer = g_string_new (""); + + splitted = g_strsplit (recipients_list, "\n", 0); + current = splitted; + while (*current) { + gchar *line; + if (current != splitted) + buffer = g_string_append_c (buffer, '\n'); + line = g_strndup (*splitted, 1000); + buffer = g_string_append (buffer, line); + g_free (line); + current++; + } + + g_strfreev (splitted); + + return g_string_free (buffer, FALSE); +} + /* ******************************************************************* */ /* ************************* UTILIY FUNCTIONS ************************ */ diff --git a/src/modest-text-utils.h b/src/modest-text-utils.h index 4443876..b2e56ea 100644 --- a/src/modest-text-utils.h +++ b/src/modest-text-utils.h @@ -386,6 +386,16 @@ GSList *modest_text_utils_split_addresses_list (const gchar *addresses); void modest_text_utils_get_addresses_indexes (const gchar *addresses, GSList **start_indexes, GSList **end_indexes); /** + * modest_text_utils_address_with_standard_length: + * @recipients_list: a string + * + * obtains the list of recipients, but making sure that lines are not longer than 1000 chars + * + * Returns: a newly allocated string + */ +gchar * modest_text_utils_address_with_standard_length (const gchar *recipients_list); + +/** * modest_text_utils_get_color_string: * @color: a #GdkColor * diff --git a/src/widgets/modest-recpt-view.c b/src/widgets/modest-recpt-view.c index 54e33c1..cb8511c 100644 --- a/src/widgets/modest-recpt-view.c +++ b/src/widgets/modest-recpt-view.c @@ -85,11 +85,19 @@ modest_recpt_view_set_recipients (ModestRecptView *recpt_view, const gchar *reci { const GtkWidget *text_view = NULL; GtkTextBuffer *buffer = NULL; + gchar *std_recipients; text_view = modest_scroll_text_get_text_view (MODEST_SCROLL_TEXT (recpt_view)); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)); - gtk_text_buffer_set_text (buffer, recipients, -1); + if (recipients == NULL) { + std_recipients = NULL; + } else { + std_recipients = modest_text_utils_address_with_standard_length (recipients); + } + + gtk_text_buffer_set_text (buffer, std_recipients, -1); + g_free (std_recipients); if (GTK_WIDGET_REALIZED (recpt_view)) gtk_widget_queue_resize (GTK_WIDGET (recpt_view)); -- 1.7.9.5