diff options
author | Iain Holmes <iain@src.gnome.org> | 2001-01-07 08:31:04 +0800 |
---|---|---|
committer | Iain Holmes <iain@src.gnome.org> | 2001-01-07 08:31:04 +0800 |
commit | 4f3765c9613ec25423d9b7a4a1fc4901a857618a (patch) | |
tree | dd4d799839822722c9904623085896cdc49c998a /calendar | |
parent | 127f5e5a1fbf36eb9429a225e326a713bc624dfd (diff) | |
download | gsoc2013-evolution-4f3765c9613ec25423d9b7a4a1fc4901a857618a.tar gsoc2013-evolution-4f3765c9613ec25423d9b7a4a1fc4901a857618a.tar.gz gsoc2013-evolution-4f3765c9613ec25423d9b7a4a1fc4901a857618a.tar.bz2 gsoc2013-evolution-4f3765c9613ec25423d9b7a4a1fc4901a857618a.tar.lz gsoc2013-evolution-4f3765c9613ec25423d9b7a4a1fc4901a857618a.tar.xz gsoc2013-evolution-4f3765c9613ec25423d9b7a4a1fc4901a857618a.tar.zst gsoc2013-evolution-4f3765c9613ec25423d9b7a4a1fc4901a857618a.zip |
Neaten the HTML, add Tasks, and make the day change when the day changes :)
Calendar summary.
svn path=/trunk/; revision=7285
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 7 | ||||
-rw-r--r-- | calendar/gui/calendar-summary.c | 85 |
2 files changed, 86 insertions, 6 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index ae3f5afda9..e0485372c2 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,10 @@ +2001-01-06 Iain Holmes <iain@helixcode.com> + + * gui/calendar-summary.c (generate_html_summary): Neaten the HTML, + and fix the time printing stuff. Add stuff the get Tasks. + (alarm_fn): Set up an alarm for midnight everynight and regenerate + the HTML for the new day. + 2001-01-05 JP Rosevear <jpr@helixcode.com> * gui/event-editor.c (get_widgets): get categories button diff --git a/calendar/gui/calendar-summary.c b/calendar/gui/calendar-summary.c index 2def2f6fea..258e73e7d7 100644 --- a/calendar/gui/calendar-summary.c +++ b/calendar/gui/calendar-summary.c @@ -51,6 +51,8 @@ typedef struct { char *icon; guint32 idle; + + gpointer alarm; } CalSummary; enum { @@ -79,7 +81,8 @@ generate_html_summary (CalSummary *summary) datestr = g_new (char, 256); timeptr = localtime (&t); strftime (datestr, 255, _("%A, %e %B %Y"), timeptr); - ret_html = g_strdup_printf ("<b>%s</b><br> <ul>", datestr); + ret_html = g_strdup_printf ("<p align=\"center\">Appointments</p>" + "<hr><b>%s</b><br><ul>", datestr); g_free (datestr); uids = cal_client_get_objects_in_range (summary->client, @@ -90,7 +93,9 @@ generate_html_summary (CalSummary *summary) CalComponentText text; CalClientGetStatus status; CalComponentDateTime start, end; - struct icaltimetype *start_time, *end_time; + struct icaltimetype *end_time; + time_t start_t, end_t; + struct tm *start_tm, *end_tm; char *start_str, *end_str; char *uid; char *tmp2; @@ -105,14 +110,21 @@ generate_html_summary (CalSummary *summary) cal_component_get_dtend (comp, &end); g_print ("text.value: %s\n", text.value); - start_time = start.value; end_time = end.value; - start_str = g_strdup_printf ("%d.%d", start_time->hour, start_time->minute); + start_t = icaltime_as_timet (*start.value); + + start_str = g_new (char, 20); + start_tm = localtime (&start_t); + strftime (start_str, 19, _("%I:%M%p"), start_tm); + if (end_time) { - end_str = g_strdup_printf ("%d.%d", end_time->hour, end_time->minute); + end_str = g_new (char, 20); + end_t = icaltime_as_timet (*end_time); + end_tm = localtime (&end_t); + strftime (end_str, 19, _("%I:%M%p"), end_tm); } else { - end_str = g_strdup (" "); + end_str = g_strdup ("..."); } tmp2 = g_strdup_printf ("<li>%s:%s -> %s</li>", text.value, start_str, end_str); @@ -128,6 +140,45 @@ generate_html_summary (CalSummary *summary) cal_obj_uid_list_free (uids); tmp = ret_html; + ret_html = g_strconcat (ret_html, + "</ul><p align=\"center\">Tasks<hr><ul>", + NULL); + g_free (tmp); + + /* Generate a list of tasks */ + uids = cal_client_get_objects_in_range (summary->client, + CALOBJ_TYPE_TODO, day_begin, + day_end); + for (l = uids; l; l = l->next){ + CalComponent *comp; + CalComponentText text; + CalClientGetStatus status; + CalComponentDateTime start, end; + struct icaltimetype *start_time, *end_time; + char *start_str, *end_str; + char *uid; + char *tmp2; + + uid = l->data; + status = cal_client_get_object (summary->client, uid, &comp); + if (status != CAL_CLIENT_GET_SUCCESS) + continue; + + cal_component_get_summary (comp, &text); + + tmp2 = g_strdup_printf ("<li>%s</li>", text.value); + g_free (start_str); + g_free (end_str); + + tmp = ret_html; + ret_html = g_strconcat (ret_html, tmp2, NULL); + g_free (tmp); + g_free (tmp2); + } + + cal_obj_uid_list_free (uids); + + tmp = ret_html; ret_html = g_strconcat (ret_html, "</ul>", NULL); g_free (tmp); @@ -239,6 +290,23 @@ cal_loaded_cb (CalClient *client, break; } } +static void +alarm_fn (gpointer alarm_id, + time_t old_t, + CalSummary *summary) +{ + time_t t, day_end; + + /* Remove the old alarm, and start a new one for the next midnight */ + alarm_remove (alarm_id); + + t = time (NULL); + day_end = time_day_end (t); + summary->alarm = alarm_add (day_end, alarm_fn, summary, NULL); + + /* Now redraw the summary */ + generate_html_summary (summary); +} BonoboObject * create_summary_view (ExecutiveSummaryComponentFactory *_factory, @@ -250,6 +318,7 @@ create_summary_view (ExecutiveSummaryComponentFactory *_factory, BonoboEventSource *event_source; CalSummary *summary; char *html, *file; + time_t t, day_end; file = g_concat_dir_and_file (evolution_dir, "local/Calendar/calendar.ics"); @@ -264,6 +333,10 @@ create_summary_view (ExecutiveSummaryComponentFactory *_factory, summary->cal_loaded = FALSE; summary->idle = 0; + t = time (NULL); + day_end = time_day_end (t); + summary->alarm = alarm_add (day_end, alarm_fn, summary, NULL); + /* Check for calendar files */ if (!g_file_exists (file)) { cal_client_create_calendar (summary->client, file); |