From 452dc1600d0a6ae63474220e3ce74664058ece5c Mon Sep 17 00:00:00 2001 From: Chenthill Palanisamy Date: Sat, 22 Jul 2006 10:17:18 +0000 Subject: Added support Gw notes. svn path=/trunk/; revision=32378 --- calendar/gui/e-cal-component-memo-preview.c | 57 +++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 3 deletions(-) (limited to 'calendar/gui/e-cal-component-memo-preview.c') diff --git a/calendar/gui/e-cal-component-memo-preview.c b/calendar/gui/e-cal-component-memo-preview.c index 7cb23740ce..1dd9dee782 100644 --- a/calendar/gui/e-cal-component-memo-preview.c +++ b/calendar/gui/e-cal-component-memo-preview.c @@ -100,18 +100,59 @@ url_requested_cb (GtkHTML *html, const char *url, GtkHTMLStream *stream, gpointe } } +/* Converts a time_t to a string, relative to the specified timezone */ +static char * +timet_to_str_with_zone (ECalComponentDateTime *dt, ECal *ecal, icaltimezone *default_zone) +{ + struct icaltimetype itt; + icaltimezone *zone; + struct tm tm; + char buf[256]; + + if (dt->tzid) { + /* If we can't find the zone, we'll guess its "local" */ + if (!e_cal_get_timezone (ecal, dt->tzid, &zone, NULL)) + zone = NULL; + } else if (dt->value->is_utc) { + zone = icaltimezone_get_utc_timezone (); + } else { + zone = NULL; + } + + + itt = *dt->value; + if (zone) + icaltimezone_convert_time (&itt, zone, default_zone); + tm = icaltimetype_to_tm (&itt); + + e_time_format_date_and_time (&tm, calendar_config_get_24_hour_format (), + FALSE, FALSE, buf, sizeof (buf)); + + return g_locale_to_utf8 (buf, -1, NULL, NULL, NULL); +} + static void write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone *default_zone) { ECalComponentText text; + ECalComponentDateTime dt; gchar *str; GSList *l; gboolean one_added = FALSE; g_return_if_fail (E_IS_CAL_COMPONENT (comp)); - gtk_html_stream_printf (stream, - ""); + /* write document header */ + e_cal_component_get_summary (comp, &text); + + if (text.value) + gtk_html_stream_printf (stream, + "

%s

", + text.value); + else + gtk_html_stream_printf (stream, + "

%s

", + _("Untitled")); /* write icons for the categories */ e_cal_component_get_categories_list (comp, &l); @@ -155,6 +196,16 @@ write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone gtk_html_stream_printf (stream, "" ""); + /* write start date */ + e_cal_component_get_dtstart (comp, &dt); + if (dt.value != NULL) { + str = timet_to_str_with_zone (&dt, ecal, default_zone); + gtk_html_stream_printf (stream, "", + _("Start Date:"), str); + + e_cal_component_free_datetime (&dt); + g_free (str); + } /* write description and URL */ gtk_html_stream_printf (stream, ""); @@ -163,7 +214,7 @@ write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone if (l) { GSList *node; - gtk_html_stream_printf (stream, "", _("Memo:")); + gtk_html_stream_printf (stream, "", _("Description:")); gtk_html_stream_printf (stream, "
%s%s

%s
%s"); -- cgit v1.2.3