diff options
author | Iain Holmes <iain@src.gnome.org> | 2001-07-03 10:45:58 +0800 |
---|---|---|
committer | Iain Holmes <iain@src.gnome.org> | 2001-07-03 10:45:58 +0800 |
commit | 29700d38aeb9a90caaed499ac010f7632e9587dc (patch) | |
tree | 23c708ae35cd17f6021bd27b80e62a61ed7ed994 | |
parent | ed11afdec64d889fbb515ef11897fec3862fe31b (diff) | |
download | gsoc2013-evolution-29700d38aeb9a90caaed499ac010f7632e9587dc.tar.gz gsoc2013-evolution-29700d38aeb9a90caaed499ac010f7632e9587dc.tar.zst gsoc2013-evolution-29700d38aeb9a90caaed499ac010f7632e9587dc.zip |
New tasks stuff
svn path=/trunk/; revision=10715
-rw-r--r-- | my-evolution/ChangeLog | 6 | ||||
-rw-r--r-- | my-evolution/Makefile.am | 2 | ||||
-rw-r--r-- | my-evolution/e-summary-tasks.c | 289 | ||||
-rw-r--r-- | my-evolution/e-summary-tasks.h | 20 | ||||
-rw-r--r-- | my-evolution/e-summary.c | 3 | ||||
-rw-r--r-- | my-evolution/e-summary.h | 2 |
6 files changed, 322 insertions, 0 deletions
diff --git a/my-evolution/ChangeLog b/my-evolution/ChangeLog index c59eb8d5aa..4b3bd0c870 100644 --- a/my-evolution/ChangeLog +++ b/my-evolution/ChangeLog @@ -1,5 +1,11 @@ 2001-07-02 Iain Holmes <iain@ximian.com> + * e-summary-tasks.[ch]: New files for tasks. + + * e-summary.c: USe the tasks. + +2001-07-02 Iain Holmes <iain@ximian.com> + * Makefile.am: Add the glade files to the EXTRA_DIST 2001-07-02 Ettore Perazzoli <ettore@ximian.com> diff --git a/my-evolution/Makefile.am b/my-evolution/Makefile.am index c2db15a0e9..e713bcf202 100644 --- a/my-evolution/Makefile.am +++ b/my-evolution/Makefile.am @@ -46,6 +46,8 @@ evolution_executive_summary_SOURCES = \ e-summary-preferences.h \ e-summary-rdf.c \ e-summary-rdf.h \ + e-summary-tasks.c \ + e-summary-tasks.h \ e-summary-type.h \ e-summary-weather.c \ e-summary-weather.h \ diff --git a/my-evolution/e-summary-tasks.c b/my-evolution/e-summary-tasks.c new file mode 100644 index 0000000000..b6058b46e6 --- /dev/null +++ b/my-evolution/e-summary-tasks.c @@ -0,0 +1,289 @@ +/* + * e-summary-tasks.c: + * + * Copyright (C) 2001 Ximian, Inc. + * + * Authors: Iain Holmes <iain@ximian.com> + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <gnome.h> +#include <gal/widgets/e-unicode.h> + +#include "e-summary-tasks.h" +#include "e-summary.h" +#include <cal-client/cal-client.h> +#include <cal-util/timeutil.h> + +struct _ESummaryTasks { + CalClient *client; + + char *html; +}; + +const char * +e_summary_tasks_get_html (ESummary *summary) +{ + if (summary->tasks == NULL) { + return NULL; + } + + return summary->tasks->html; +} + +/* list_sort_merge, and list_sort are copied from GNOME-VFS. + Author: Sven Oliver <sven.over@ob.kamp.net> + Modified by Ettore Perazzoli <ettore@comm2000.it> to let the compare + functions get an additional gpointer parameter. + + Included here as using gnome-vfs for 1 20 line function + seems a bit of overkill. +*/ + +typedef gint (* CalSummaryListCompareFunc) (gconstpointer a, + gconstpointer b, + gpointer data); +static GList * +cal_list_sort_merge (GList *l1, + GList *l2, + CalSummaryListCompareFunc compare_func, + gpointer data) +{ + GList list, *l, *lprev; + + l = &list; + lprev = NULL; + + while (l1 && l2) { + if (compare_func (l1->data, l2->data, data) < 0) { + l->next = l1; + l = l->next; + l->prev = lprev; + lprev = l; + l1 = l1->next; + } else { + l->next = l2; + l = l->next; + l->prev = lprev; + lprev = l; + l2 = l2->next; + } + } + + l->next = l1 ? l1 : l2; + l->next->prev = l; + + return list.next; +} + +static GList * +cal_list_sort (GList *list, + CalSummaryListCompareFunc compare_func, + gpointer data) +{ + GList *l1, *l2; + + if (!list) + return NULL; + if (!list->next) + return list; + + l1 = list; + l2 = list->next; + + while ((l2 = l2->next) != NULL) { + if ((l2 = l2->next) == NULL) + break; + l1 = l1->next; + } + + l2 = l1->next; + l1->next = NULL; + + return cal_list_sort_merge (cal_list_sort (list, compare_func, data), + cal_list_sort (l2, compare_func, data), + compare_func, data); +} + +static int +sort_uids (gconstpointer a, + gconstpointer b, + gpointer user_data) +{ + CalComponent *comp_a, *comp_b; + ESummary *summary = user_data; + ESummaryTasks *tasks = summary->tasks; + CalClientGetStatus status; + CalComponentDateTime start_a, start_b; + + /* a after b then return > 0 */ + + status = cal_client_get_object (tasks->client, a, &comp_a); + if (status != CAL_CLIENT_GET_SUCCESS) + return -1; + + status = cal_client_get_object (tasks->client, b, &comp_b); + if (status != CAL_CLIENT_GET_SUCCESS) + return 1; + + cal_component_get_dtstart (comp_a, &start_a); + cal_component_get_dtstart (comp_b, &start_b); + + return icaltime_compare (*start_a.value, *start_b.value); +} + +static gboolean +generate_html (gpointer data) +{ + ESummary *summary = data; + ESummaryTasks *tasks = summary->tasks; + GList *uids, *l; + GString *string; + char *tmp; + time_t t, day_begin, day_end; + + t = time (NULL); + day_begin = time_day_begin (t); + day_end = time_day_end (t); + + uids = cal_client_get_uids (tasks->client, CALOBJ_TYPE_TODO); + if (uids == NULL) { + char *s1, *s2; + + s1 = e_utf8_from_locale_string (_("Tasks")); + s2 = e_utf8_from_locale_string (_("No tasks")); + g_free (tasks->html); + tasks->html = g_strconcat ("<dl><dt><img src=\"ico-tasks.png\" align=\"middle\" " + "alt=\"\" width=\"48\" height=\"48\"> <b><a href=\"evolution:/local/Tasks\">", + s1, "</a></b></dt><dd><b>", s2, "</b></dd></dl>", NULL); + g_free (s1); + g_free (s2); + + e_summary_draw (summary); + return FALSE; + } else { + char *s; + + string = g_string_new ("<dl><dt><img src=\"ico-calendar.png\" align=\"middle\" " + "alt=\"\" width=\"48\" height=\"48\"> <b><a href=\"evolution:/local/Tasks\">"); + s = e_utf8_from_locale_string (_("Tasks")); + g_string_append (string, s); + g_free (s); + g_string_append (string, "</a></b></dt><dd>"); + for (l = uids; l; l = l->next) { + char *uid; + CalComponent *comp; + CalComponentText text; + CalClientGetStatus status; + struct icaltimetype *completed; + + uid = l->data; + status = cal_client_get_object (tasks->client, uid, &comp); + if (status != CAL_CLIENT_GET_SUCCESS) { + continue; + } + + cal_component_get_summary (comp, &text); + cal_component_get_completed (comp, &completed); + + if (completed == NULL) { + tmp = g_strdup_printf ("<img align=\"middle\" src=\"es-appointments.png\" " + "alt=\"\" width=\"16\" height=\"16\">   " + "<font size=\"-1\"><a href=\"#\">%s</a></font><br>", + text.value); + } else { + tmp = g_strdup_printf ("<img align=\"middle\" src=\"es-appointments.png\" " + "alt=\"\" width=\"16\" height=\"16\">   " + "<font size=\"-1\"><strike><a href=\"#\">%s</a></strike></font><br>", + text.value); + } + + g_string_append (string, tmp); + g_free (tmp); + } + + cal_obj_uid_list_free (uids); + g_string_append (string, "</ul>"); + } + + if (tasks->html) { + g_free (tasks->html); + } + tasks->html = string->str; + g_string_free (string, FALSE); + + e_summary_draw (summary); + return FALSE; +} + +static void +cal_opened_cb (CalClient *client, + CalClientOpenStatus status, + ESummary *summary) +{ + if (status == CAL_CLIENT_OPEN_SUCCESS) { + g_idle_add (generate_html, summary); + } else { + /* Need to work out what to do if there's an error */ + } +} +static void +obj_changed_cb (CalClient *client, + const char *uid, + gpointer data) +{ + g_idle_add (generate_html, data); +} + +static void +e_summary_tasks_protocol (ESummary *summary, + const char *uri, + void *closure) +{ + +} + +void +e_summary_tasks_init (ESummary *summary) +{ + ESummaryTasks *tasks; + gboolean result; + char *uri; + + g_return_if_fail (summary != NULL); + + tasks = g_new (ESummaryTasks, 1); + summary->tasks = tasks; + tasks->html = NULL; + + tasks->client = cal_client_new (); + if (tasks->client == NULL) { + g_warning ("Error making the client"); + return; + } + + gtk_signal_connect (GTK_OBJECT (tasks->client), "cal-opened", + GTK_SIGNAL_FUNC (cal_opened_cb), summary); + gtk_signal_connect (GTK_OBJECT (tasks->client), "obj-updated", + GTK_SIGNAL_FUNC (obj_changed_cb), summary); + gtk_signal_connect (GTK_OBJECT (tasks->client), "obj-removed", + GTK_SIGNAL_FUNC (obj_changed_cb), summary); + + uri = gnome_util_prepend_user_home ("evolution/local/Tasks/tasks.ics"); + result = cal_client_open_calendar (tasks->client, uri, FALSE); + g_free (uri); + if (result == FALSE) { + g_message ("Open tasks failed"); + } + + e_summary_add_protocol_listener (summary, "tasks", e_summary_tasks_protocol, tasks); +} + +void +e_summary_tasks_reconfigure (ESummary *summary) +{ + +} diff --git a/my-evolution/e-summary-tasks.h b/my-evolution/e-summary-tasks.h new file mode 100644 index 0000000000..aec1b39424 --- /dev/null +++ b/my-evolution/e-summary-tasks.h @@ -0,0 +1,20 @@ +/* + * e-summary-tasks.h + * + * Copyright (C) 2001 Ximian, Inc. + * + * Authors: Iain Holmes <iain@ximian.com> + */ + +#ifndef __E_SUMMARY_TASKS_H__ +#define __E_SUMMARY_TASKS_H__ + +#include "e-summary-type.h" + +typedef struct _ESummaryTasks ESummaryTasks; + +const char *e_summary_tasks_get_html (ESummary *summary); +void e_summary_tasks_init (ESummary *summary); +void e_summary_tasks_reconfigure (ESummary *summary); + +#endif diff --git a/my-evolution/e-summary.c b/my-evolution/e-summary.c index 830cad4220..1af0b1edac 100644 --- a/my-evolution/e-summary.c +++ b/my-evolution/e-summary.c @@ -137,6 +137,8 @@ e_summary_draw (ESummary *summary) html = (char *) e_summary_calendar_get_html (summary); g_string_append (string, html); + html = (char *) e_summary_tasks_get_html (summary); + g_string_append (string, html); g_string_append (string, HTML_5); @@ -387,6 +389,7 @@ e_summary_new (const GNOME_Evolution_Shell shell) e_summary_mail_init (summary, shell); e_summary_calendar_init (summary); + e_summary_tasks_init (summary); e_summary_rdf_init (summary); e_summary_weather_init (summary); diff --git a/my-evolution/e-summary.h b/my-evolution/e-summary.h index 1ba2ee18b7..24e643b787 100644 --- a/my-evolution/e-summary.h +++ b/my-evolution/e-summary.h @@ -15,6 +15,7 @@ #include "e-summary-calendar.h" #include "e-summary-rdf.h" #include "e-summary-weather.h" +#include "e-summary-tasks.h" #include <Evolution.h> @@ -90,6 +91,7 @@ struct _ESummary { ESummaryCalendar *calendar; ESummaryRDF *rdf; ESummaryWeather *weather; + ESummaryTasks *tasks; ESummaryPrivate *priv; |