diff options
author | Damon Chaplin <damon@ximian.com> | 2001-09-18 09:35:46 +0800 |
---|---|---|
committer | Damon Chaplin <damon@src.gnome.org> | 2001-09-18 09:35:46 +0800 |
commit | 999889586bbb251669c5a384f1b5d03bd72d0a6d (patch) | |
tree | 7041172cea75e0ee3556c3629425a8cda60bd58f /calendar/pcs | |
parent | 5772dcbe43079dd8cf59e5458cb44a7a749df66f (diff) | |
download | gsoc2013-evolution-999889586bbb251669c5a384f1b5d03bd72d0a6d.tar gsoc2013-evolution-999889586bbb251669c5a384f1b5d03bd72d0a6d.tar.gz gsoc2013-evolution-999889586bbb251669c5a384f1b5d03bd72d0a6d.tar.bz2 gsoc2013-evolution-999889586bbb251669c5a384f1b5d03bd72d0a6d.tar.lz gsoc2013-evolution-999889586bbb251669c5a384f1b5d03bd72d0a6d.tar.xz gsoc2013-evolution-999889586bbb251669c5a384f1b5d03bd72d0a6d.tar.zst gsoc2013-evolution-999889586bbb251669c5a384f1b5d03bd72d0a6d.zip |
added a timeout to refresh the list every 10 minutes. Not ideal, as the
2001-09-17 Damon Chaplin <damon@ximian.com>
* gui/calendar-model.c: added a timeout to refresh the list every
10 minutes. Not ideal, as the user may be editing a task when it gets
refreshed.
(adjust_query_sexp): use the 'completed-before?' operator to filter
out tasks according to the config settings.
* gui/dialogs/task-details-page.c (task_details_page_fill_widgets):
added support for the 'Completed' date. This code must have got lost
somewhere, as it used to work.
(date_changed_cb): set the priv->updating flag while updating the other
widgets.
* pcs/cal-backend-file.c (cal_backend_file_update_objects): made sure
we freed the components.
* pcs/query.c (func_completed_before): added 'completed-before?'
operator.
* gui/calendar-config.c (calendar_config_configure_e_cell_date_edit):
don't set the lower & upper hour. Use 0-24 like the EDateEdit does.
* gui/dialogs/cal-prefs-dialog.c (cal_prefs_dialog_show_config): set
the 12/24-hour time format options sensitive only if we support both.
* gui/calendar-config.c (config_read): if the locale doesn't define
'am' and 'pm' strings then we must use 24-hour format.
* gui/calendar-commands.c (calendar_set_folder_bar_label): don't
translate the '%d' as it doesn't make much sense. Resolves bug #8027.
svn path=/trunk/; revision=12925
Diffstat (limited to 'calendar/pcs')
-rw-r--r-- | calendar/pcs/cal-backend-file.c | 37 | ||||
-rw-r--r-- | calendar/pcs/query.c | 72 |
2 files changed, 88 insertions, 21 deletions
diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c index 1313b22f12..fd4e3a2cd0 100644 --- a/calendar/pcs/cal-backend-file.c +++ b/calendar/pcs/cal-backend-file.c @@ -1499,7 +1499,7 @@ cal_backend_file_update_objects (CalBackend *backend, const char *calobj) { CalBackendFile *cbfile; CalBackendFilePrivate *priv; - icalcomponent *icalcomp, *vcalendar_comp = NULL; + icalcomponent *toplevel_comp, *icalcomp = NULL; icalcomponent_kind kind; CalComponent *old_comp; CalComponent *comp; @@ -1515,29 +1515,22 @@ cal_backend_file_update_objects (CalBackend *backend, const char *calobj) /* Pull the component from the string and ensure that it is sane */ - fprintf (stderr, "cal_backend_file: Parsing string:\n%s\n", calobj); - icalcomp = icalparser_parse_string ((char *) calobj); + toplevel_comp = icalparser_parse_string ((char *) calobj); - if (!icalcomp) + if (!toplevel_comp) return FALSE; - fprintf (stderr, "cal_backend_file: Parsed OK.\n"); - - kind = icalcomponent_isa (icalcomp); + kind = icalcomponent_isa (toplevel_comp); if (kind == ICAL_VCALENDAR_COMPONENT) { int num_found = 0; icalcomponent_kind child_kind; icalcomponent *subcomp; - fprintf (stderr, "cal_backend_file: VCALENDAR found\n"); - /* We have a VCALENDAR containing the VEVENT/VTODO and the related timezone data, so we have to step through it to find the actual VEVENT/VTODO component. */ - vcalendar_comp = icalcomp; - - subcomp = icalcomponent_get_first_component (vcalendar_comp, + subcomp = icalcomponent_get_first_component (toplevel_comp, ICAL_ANY_COMPONENT); while (subcomp) { child_kind = icalcomponent_isa (subcomp); @@ -1547,28 +1540,30 @@ cal_backend_file_update_objects (CalBackend *backend, const char *calobj) icalcomp = subcomp; num_found++; } - subcomp = icalcomponent_get_next_component (vcalendar_comp, + subcomp = icalcomponent_get_next_component (toplevel_comp, ICAL_ANY_COMPONENT); } /* If we didn't find exactly 1 VEVENT/VTODO it is an error. */ if (num_found != 1) { - icalcomponent_free (icalcomp); + icalcomponent_free (toplevel_comp); return FALSE; } - } else if (!(kind == ICAL_VEVENT_COMPONENT - || kind == ICAL_VTODO_COMPONENT - || kind == ICAL_VJOURNAL_COMPONENT)) { + } else if (kind == ICAL_VEVENT_COMPONENT + || kind == ICAL_VTODO_COMPONENT + || kind == ICAL_VJOURNAL_COMPONENT) { + icalcomp = toplevel_comp; + } else { /* We don't support this type of component */ - icalcomponent_free (icalcomp); + icalcomponent_free (toplevel_comp); return FALSE; } comp = cal_component_new (); if (!cal_component_set_icalcomponent (comp, icalcomp)) { gtk_object_unref (GTK_OBJECT (comp)); - icalcomponent_free (icalcomp); + icalcomponent_free (toplevel_comp); return FALSE; } @@ -1578,6 +1573,8 @@ cal_backend_file_update_objects (CalBackend *backend, const char *calobj) if (!comp_uid || !comp_uid[0]) { gtk_object_unref (GTK_OBJECT (comp)); + if (kind == ICAL_VCALENDAR_COMPONENT) + icalcomponent_free (toplevel_comp); return FALSE; } @@ -1599,7 +1596,7 @@ cal_backend_file_update_objects (CalBackend *backend, const char *calobj) /* If we have a VCALENDAR component with child VTIMEZONEs and the VEVENT/VTODO, we have to merge it into the existing VCALENDAR, resolving any conflicting TZIDs. */ - icalcomponent_merge_component (priv->icalcomp, vcalendar_comp); + icalcomponent_merge_component (priv->icalcomp, toplevel_comp); /* Now we add the component to our local cache, but we pass FALSE as the last argument, since we have already added diff --git a/calendar/pcs/query.c b/calendar/pcs/query.c index 1b991a85ea..3efd2bde50 100644 --- a/calendar/pcs/query.c +++ b/calendar/pcs/query.c @@ -830,6 +830,75 @@ func_is_completed (ESExp *esexp, int argc, ESExpResult **argv, void *data) return result; } +/* (completed-before? TIME) + * + * TIME - time_t + * + * Returns a boolean indicating whether the component was completed on or + * before the given time (i.e. it checks the COMPLETED property). + * This is really only useful for TODO components. + */ +static ESExpResult * +func_completed_before (ESExp *esexp, int argc, ESExpResult **argv, void *data) +{ + Query *query; + QueryPrivate *priv; + CalComponent *comp; + ESExpResult *result; + struct icaltimetype *tt; + icaltimezone *zone; + gboolean retval = FALSE; + time_t before_time, completed_time; + + query = QUERY (data); + priv = query->priv; + + g_assert (priv->next_comp != NULL); + comp = priv->next_comp; + + /* Check argument types */ + + if (argc != 1) { + e_sexp_fatal_error (esexp, _("completed-before? expects 1 argument")); + return NULL; + } + + if (argv[0]->type != ESEXP_RES_TIME) { + e_sexp_fatal_error (esexp, _("completed-before? expects argument 1 " + "to be a time_t")); + return NULL; + } + before_time = argv[0]->value.time; + + cal_component_get_completed (comp, &tt); + if (tt) { + /* COMPLETED must be in UTC. */ + zone = icaltimezone_get_utc_timezone (); + completed_time = icaltime_as_timet_with_zone (*tt, zone); + +#if 0 + g_print ("Query Time : %s", ctime (&before_time)); + g_print ("Completed Time: %s", ctime (&completed_time)); +#endif + + /* We want to return TRUE if before_time is after + completed_time. */ + if (difftime (before_time, completed_time) > 0) { +#if 0 + g_print (" Returning TRUE\n"); +#endif + retval = TRUE; + } + + cal_component_free_icaltimetype (tt); + } + + result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); + result->value.bool = retval; + + return result; +} + /* Adds a component to our the UIDs hash table and notifies the client */ @@ -948,7 +1017,8 @@ static struct { { "occur-in-time-range?", func_occur_in_time_range }, { "contains?", func_contains }, { "has-categories?", func_has_categories }, - { "is-completed?", func_is_completed } + { "is-completed?", func_is_completed }, + { "completed-before?", func_completed_before } }; /* Initializes a sexp by interning our own symbols */ |