diff options
author | Federico Mena Quintero <federico@ximian.com> | 2001-04-13 00:29:56 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2001-04-13 00:29:56 +0800 |
commit | 3b562b0b9f81cdd6cedea7c7c53272a98568e63a (patch) | |
tree | 16f563e4357fa6268bbd5930e29f5f17a258e81f /calendar/pcs | |
parent | b1c4145cd9bde65773aa668939e8557986c205c5 (diff) | |
download | gsoc2013-evolution-3b562b0b9f81cdd6cedea7c7c53272a98568e63a.tar.gz gsoc2013-evolution-3b562b0b9f81cdd6cedea7c7c53272a98568e63a.tar.zst gsoc2013-evolution-3b562b0b9f81cdd6cedea7c7c53272a98568e63a.zip |
New function to restart a query for the day view. (query_obj_updated_cb):
2001-04-12 Federico Mena Quintero <federico@ximian.com>
* gui/e-day-view.c (update_query): New function to restart a query
for the day view.
(query_obj_updated_cb): Renamed from obj_updated_cb(); updated for
queries instead of calendar clients.
(query_obj_removed_cb): Likewise.
(cal_opened_cb): Just update_query() instead of queueing reloading
all the events.
(e_day_view_set_cal_client): Likewise.
(e_day_view_set_query): Likewise.
(e_day_view_set_selected_time_range): Likewise.
(e_day_view_set_days_shown): Likewise.
(e_day_view_recalc_work_week): Likewise.
(e_day_view_queue_reload_events): Removed function now that events
are updated entirely by the query.
(e_day_view_reload_events_idle_cb): Likewise.
(e_day_view_reload_events): Likewise.
(e_day_view_init): Use a pretty arrow instead of GDK_TOP_LEFT_ARROW.
* gui/e-week-view.c: Analogous changes to the ones in e-day-view.c.
(e_week_view_init): Use a pretty arrow instead of GDK_TOP_LEFT_ARROW.
* cal-util/timeutil.c (isodate_from_time_t): Return a g_strdup()ed
version of the string instead of a pointer to a static buffer.
(time_from_isodate): Resurrected function. Polished up to our
current standards of paranoia.
* pcs/query.c (func_time_now): New function (time-now).
(func_make_time): New function (make-time ISODATE).
(func_time_add_day): New function (time-add-day TIME N).
(func_time_day_begin): New function (time-day-begin TIME).
(func_time_day_end): New function (time-day-end TIME).
(func_occur_in_time_range): Use time_t values instead of ints.
(match_component): Free the stringized component. Free the ESexp
result value.
* gui/e-day-view.h: Removed a couple of unused prototypes.
* pcs/query.c (query_destroy): Oops, disconnect from the backend.
* pcs/cal.c (Cal_get_query): Duplicate the query reference before
we return it.
* gui/calendar-commands.c (pixmaps): Fixed paths to image files.
svn path=/trunk/; revision=9266
Diffstat (limited to 'calendar/pcs')
-rw-r--r-- | calendar/pcs/cal.c | 17 | ||||
-rw-r--r-- | calendar/pcs/query.c | 194 |
2 files changed, 198 insertions, 13 deletions
diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c index 3129665466..e723c077cb 100644 --- a/calendar/pcs/cal.c +++ b/calendar/pcs/cal.c @@ -456,6 +456,8 @@ Cal_get_query (PortableServer_Servant servant, Cal *cal; CalPrivate *priv; Query *query; + CORBA_Environment ev2; + GNOME_Evolution_Calendar_Query query_copy; cal = CAL (bonobo_object_from_servant (servant)); priv = cal->priv; @@ -468,7 +470,20 @@ Cal_get_query (PortableServer_Servant servant, return CORBA_OBJECT_NIL; } - return BONOBO_OBJREF (query); + CORBA_exception_init (&ev2); + query_copy = CORBA_Object_duplicate (BONOBO_OBJREF (query), &ev2); + if (ev2._major != CORBA_NO_EXCEPTION) { + CORBA_exception_free (&ev2); + g_message ("Cal_get_query(): Could not duplicate the query reference"); + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_GNOME_Evolution_Calendar_Cal_CouldNotCreate, + NULL); + return CORBA_OBJECT_NIL; + } + + CORBA_exception_free (&ev2); + + return query_copy; } /** diff --git a/calendar/pcs/query.c b/calendar/pcs/query.c index 708a160794..474a2eb971 100644 --- a/calendar/pcs/query.c +++ b/calendar/pcs/query.c @@ -30,6 +30,7 @@ #include <gtk/gtksignal.h> #include <e-util/e-sexp.h> #include <cal-util/cal-recur.h> +#include <cal-util/timeutil.h> #include "query.h" @@ -138,6 +139,7 @@ query_destroy (GtkObject *object) priv = query->priv; if (priv->backend) { + gtk_signal_disconnect_by_data (GTK_OBJECT (priv->backend), query); gtk_object_unref (GTK_OBJECT (priv->backend)); priv->backend = NULL; } @@ -200,7 +202,164 @@ query_destroy (GtkObject *object) -/* Search engine functions */ +/* E-Sexp functions */ + +/* (time-now) + * + * Returns a time_t of time (NULL). + */ +static ESExpResult * +func_time_now (ESExp *esexp, int argc, ESExpResult **argv, void *data) +{ + ESExpResult *result; + + if (argc != 0) { + e_sexp_fatal_error (esexp, _("time-now expects 0 arguments")); + return NULL; + } + + result = e_sexp_result_new (esexp, ESEXP_RES_TIME); + result->value.time = time (NULL); + + return result; +} + +/* (make-time ISODATE) + * + * ISODATE - string, ISO 8601 date/time representation + * + * Constructs a time_t value for the specified date. + */ +static ESExpResult * +func_make_time (ESExp *esexp, int argc, ESExpResult **argv, void *data) +{ + const char *str; + time_t t; + ESExpResult *result; + + if (argc != 1) { + e_sexp_fatal_error (esexp, _("make-time expects 1 argument")); + return NULL; + } + + if (argv[0]->type != ESEXP_RES_STRING) { + e_sexp_fatal_error (esexp, _("make-time expects argument 1 " + "to be a string")); + return NULL; + } + str = argv[0]->value.string; + + t = time_from_isodate (str); + if (t == -1) { + e_sexp_fatal_error (esexp, _("make-time argument 1 must be an " + "ISO 8601 date/time string")); + return NULL; + } + + result = e_sexp_result_new (esexp, ESEXP_RES_TIME); + result->value.time = t; + + return result; +} + +/* (time-add-day TIME N) + * + * TIME - time_t, base time + * N - int, number of days to add + * + * Adds the specified number of days to a time value. + */ +static ESExpResult * +func_time_add_day (ESExp *esexp, int argc, ESExpResult **argv, void *data) +{ + ESExpResult *result; + time_t t; + int n; + + if (argc != 2) { + e_sexp_fatal_error (esexp, _("time-add-day expects 2 arguments")); + return NULL; + } + + if (argv[0]->type != ESEXP_RES_TIME) { + e_sexp_fatal_error (esexp, _("time-add-day expects argument 1 " + "to be a time_t")); + return NULL; + } + t = argv[0]->value.time; + + if (argv[1]->type != ESEXP_RES_INT) { + e_sexp_fatal_error (esexp, _("time-add-day expects argument 2 " + "to be an integer")); + return NULL; + } + n = argv[1]->value.number; + + result = e_sexp_result_new (esexp, ESEXP_RES_TIME); + result->value.time = time_add_day (t, n); + + return result; +} + +/* (time-day-begin TIME) + * + * TIME - time_t, base time + * + * Returns the start of the day, according to the local time. + */ +static ESExpResult * +func_time_day_begin (ESExp *esexp, int argc, ESExpResult **argv, void *data) +{ + time_t t; + ESExpResult *result; + + if (argc != 1) { + e_sexp_fatal_error (esexp, _("time-day-begin expects 1 argument")); + return NULL; + } + + if (argv[0]->type != ESEXP_RES_TIME) { + e_sexp_fatal_error (esexp, _("time-day-begin expects argument 1 " + "to be a time_t")); + return NULL; + } + t = argv[0]->value.time; + + result = e_sexp_result_new (esexp, ESEXP_RES_TIME); + result->value.time = time_day_begin (t); + + return result; +} + +/* (time-day-end TIME) + * + * TIME - time_t, base time + * + * Returns the end of the day, according to the local time. + */ +static ESExpResult * +func_time_day_end (ESExp *esexp, int argc, ESExpResult **argv, void *data) +{ + time_t t; + ESExpResult *result; + + if (argc != 1) { + e_sexp_fatal_error (esexp, _("time-day-end expects 1 argument")); + return NULL; + } + + if (argv[0]->type != ESEXP_RES_TIME) { + e_sexp_fatal_error (esexp, _("time-day-end expects argument 1 " + "to be a time_t")); + return NULL; + } + t = argv[0]->value.time; + + result = e_sexp_result_new (esexp, ESEXP_RES_TIME); + result->value.time = time_day_end (t); + + return result; +} /* (get-vtype) * @@ -284,14 +443,12 @@ instance_occur_cb (CalComponent *comp, time_t start, time_t end, gpointer data) /* (occur-in-time-range? START END) * - * START - int, time_t start of the time range - * END - int, time_t end of the time range + * START - time_t, start of the time range + * END - time_t, end of the time range * * Returns a boolean indicating whether the component has any occurrences in the * specified time range. - * - * We may prefer to switch this to a string representation of times (ISO 8601, - * perhaps). */ + */ static ESExpResult * func_occur_in_time_range (ESExp *esexp, int argc, ESExpResult **argv, void *data) { @@ -315,19 +472,19 @@ func_occur_in_time_range (ESExp *esexp, int argc, ESExpResult **argv, void *data return NULL; } - if (argv[0]->type != ESEXP_RES_INT) { + if (argv[0]->type != ESEXP_RES_TIME) { e_sexp_fatal_error (esexp, _("occur-in-time-range? expects argument 1 " - "to be an integer")); + "to be a time_t")); return NULL; } - start = argv[0]->value.number; + start = argv[0]->value.time; - if (argv[1]->type != ESEXP_RES_INT) { + if (argv[1]->type != ESEXP_RES_TIME) { e_sexp_fatal_error (esexp, _("occur-in-time-range? expects argument 2 " - "to be an integer")); + "to be a time_t")); return NULL; } - end = argv[1]->value.number; + end = argv[1]->value.time; /* See if there is at least one instance in that range */ @@ -446,6 +603,14 @@ static struct { char *name; ESExpFunc *func; } functions[] = { + /* Time-related functions */ + { "time-now", func_time_now }, + { "make-time", func_make_time }, + { "time-add-day", func_time_add_day }, + { "time-day-begin", func_time_day_begin }, + { "time-day-end", func_time_day_end }, + + /* Component-related functions */ { "get-vtype", func_get_vtype }, { "occur-in-time-range?", func_occur_in_time_range } }; @@ -487,6 +652,8 @@ match_component (Query *query, const char *uid, icalcomp = icalparser_parse_string (comp_str); g_assert (icalcomp != NULL); + g_free (comp_str); + comp = cal_component_new (); set_succeeded = cal_component_set_icalcomponent (comp, icalcomp); g_assert (set_succeeded); @@ -518,6 +685,7 @@ match_component (Query *query, const char *uid, "an evaluation error"); CORBA_exception_free (&ev); + return; } else if (result->type != ESEXP_RES_BOOL) { CORBA_Environment ev; @@ -541,6 +709,8 @@ match_component (Query *query, const char *uid, else remove_component (query, uid); } + + e_sexp_result_free (priv->esexp, result); } /* Processes a single component that is queued in the list */ |