From 9b57702d4d406955ce3ec2e841253ed3efe3bbb8 Mon Sep 17 00:00:00 2001 From: Damon Chaplin Date: Sat, 6 May 2000 16:47:27 +0000 Subject: finish editing event when user hits Return key. 2000-05-06 Damon Chaplin * gui/e-day-view.c: * gui/e-week-view.c: finish editing event when user hits Return key. (e_week_view_on_text_item_event): stop event signals after doing any other calls, since otherwise it will also stop any other resulting event signals. * gui/e-week-view-event-item.c (e_week_view_event_item_draw): don't draw the start/end times while editing. * gui/eventedit.c: changed the Summary field to a GtkEntry, since we now only want a single line of text. * cal-util/calobj.c (ical_object_normalize_summary): new function to convert the summary field to a single line of text, by converting any sequence of CR & LF characters to a single space. (ical_object_create_from_vobject): call the above function. I think all functions that load iCalObjects go through this. (ical_new): called it here as well just in case. svn path=/trunk/; revision=2827 --- calendar/cal-util/calobj.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'calendar/cal-util/calobj.c') diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c index 9691d31c11..4ea3b495b0 100644 --- a/calendar/cal-util/calobj.c +++ b/calendar/cal-util/calobj.c @@ -22,6 +22,7 @@ #define PRODID "-//Helix Code//NONSGML Evolution Calendar//EN" static gint compare_exdates (gconstpointer a, gconstpointer b); +static void ical_object_normalize_summary (iCalObject *ico); @@ -90,6 +91,8 @@ ical_new (char *comment, char *organizer, char *summary) ico->malarm.type = ALARM_MAIL; ico->aalarm.type = ALARM_AUDIO; + ical_object_normalize_summary (ico); + return ico; } @@ -680,7 +683,11 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) if (has (o, VCSummaryProp)){ ical->summary = g_strdup (str_val (vo)); free (the_str); - } else + + /* Convert any CR/LF/CRLF sequences in the summary field to + spaces so we just have a one-line field. */ + ical_object_normalize_summary (ical); + } else ical->summary = g_strdup (""); /* status */ @@ -1762,3 +1769,28 @@ compare_exdates (gconstpointer a, gconstpointer b) time_t diff = *ca - *cb; return (diff < 0) ? -1 : (diff > 0) ? 1 : 0; } + + +/* Converts any CR/LF sequences in the summary field to spaces so we just + have a one-line field. The iCalObjects summary field is changed. */ +static void +ical_object_normalize_summary (iCalObject *ico) +{ + gchar *src, *dest, ch; + gboolean just_output_space = FALSE; + + src = dest = ico->summary; + while ((ch = *src++)) { + if (ch == '\n' || ch == '\r') { + /* We only output 1 space for each sequence of CR & LF + characters. */ + if (!just_output_space) { + *dest++ = ' '; + just_output_space = TRUE; + } + } else { + *dest++ = ch; + just_output_space = FALSE; + } + } +} -- cgit v1.2.3